fix: auth+safety hardening (#70 #72 #76)#77
Open
keylimesoda wants to merge 1 commit intoMartian-Engineering:mainfrom
Open
fix: auth+safety hardening (#70 #72 #76)#77keylimesoda wants to merge 1 commit intoMartian-Engineering:mainfrom
keylimesoda wants to merge 1 commit intoMartian-Engineering:mainfrom
Conversation
…ring#72 Martian-Engineering#76 Martian-Engineering#70 (Critical) — Cross-session data leakage - Grant-aware conversation scoping in resolveLcmConversationScope() - lcm_grep, lcm_describe, lcm_expand_query now enforce grant boundaries - Sub-agents without grants restricted to own conversation - Uniform 'Not found' errors prevent cross-conversation existence leaks Martian-Engineering#72 (High) — maxDepth enforcement in validateExpansion() - Rejects requests exceeding grant maxDepth - tokenCap enforcement unchanged (clamped by wrapWithAuth, not rejected) Martian-Engineering#76 (Medium) — ReDoS mitigation in regex grep - Nested quantifier detection + pattern length cap + compile validation - Typed UnsafeRegexError surfaces to tool layer instead of silent empty results - MAX_REGEX_SCAN_ROWS (10,000) caps candidate query in both stores - Note: bounded mitigation, not complete ReDoS fix 60 tests pass (4 new in regex-safety, 3 new in lcm-tools, 1 updated in expansion-auth)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three security fixes from adversarial code review: cross-session data leakage (Critical), grant depth enforcement (High), and ReDoS mitigation (Medium).
#70 (Critical) — Cross-session data leakage via lcm_grep/describe/expand_query
Sub-agents could bypass conversation scope by passing
allConversations=trueor arbitraryconversationIdto tools that didn't consult the grant system.Fix:
resolveLcmConversationScope()now accepts optional grant context. When a sub-agent has a delegated grant, scope is restricted toallowedConversationIds. Sub-agents without grants are restricted to their own conversation. Uniform "Not found" errors prevent cross-conversation existence leaks.Files: lcm-conversation-scope.ts, lcm-grep-tool.ts, lcm-describe-tool.ts, lcm-expand-query-tool.ts
#72 (High) — Grant maxDepth not enforced
validateExpansion()checked grant existence and scope but never compared request depth againstgrant.maxDepth.Fix: Added depth check after existing scope checks. Token cap enforcement intentionally left as clamp (existing
wrapWithAuth()behavior is correct).File: expansion-auth.ts
#76 (Medium) — ReDoS in regex grep
Both store
searchRegex()methods compiled user-provided patterns vianew RegExp()with no validation.Fix: New
regex-safety.tswith nested quantifier detection, pattern length cap, and compile validation. TypedUnsafeRegexErrorsurfaces to tool layer. SQL candidate queries capped at 10K rows. Note: this is a bounded mitigation, not a complete ReDoS fix.Files: regex-safety.ts (new), conversation-store.ts, summary-store.ts
Test Results
60 tests pass (4 new in regex-safety, 3 new in lcm-tools, 1 updated in expansion-auth).
Changes
12 files changed, 536 insertions(+), 69 deletions(-)