Repository navigation
Conversation
|
Codex review: needs real behavior proof before merge. What this changesThis PR guards exec approval regex matching in Node and macOS and adds Doctor diagnosis and repair of rejected stored rules. Example: An approval contains argPattern
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 5 items remain Keep open: current main still needs this protection, but two remaining analyzer defects block this PR. Priority: P1 Before merge
Findings
Tests
Agent review detailsHow this fits togetherPersisted executable and argument rules enter the approval matcher; its decisions feed command authorization, while Doctor inspects and repairs the same store and shared regex analysis also serves redaction. flowchart TD
A[Stored approval rules] --> B[Exec pattern compiler]
B --> C[Node allowlist matcher]
B --> D[macOS JavaScriptCore matcher]
C --> E[Command authorization and launch]
D --> E
A --> F[Doctor diagnosis and repair]
B --> G[Shared regex analysis]
G --> H[Custom redaction]
Technical reviewBest possible solution: Keep the shared compiler safe across equivalent regex spellings while preserving valid rules and using the existing transactional Doctor repair owner. Do we have a high-confidence way to reproduce the issue? Current-main source directly exposes the reported nested-repetition path; the two patch defects are also traceable through the analyzer without executing contributor code. Is this the best way to solve the issue? Reusing one compiler across Node and native matching is sound, but raw source-prefix checks and a second delimiter parser do not reliably preserve regex language semantics. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 919fcc263201. Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: The shared analyzer still admits a backtracking expression and can discard a valid custom redaction rule. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource +2289, Tests +1752, Config +2, Generated +1870, Other +88. Total +6001 across 31 files. Added test files: 3. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (91 earlier review cycles; latest 8 shown)
Reviewed October 14, 2026, 11:45 AM ET / 15:45 UTC (Revision 92). |
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Frosted Branchling Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
9083898 to
8802261
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
9 similar comments
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
5 similar comments
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
Same-width unique literals stay accepted when expansion overflows, including the i flag after ASCII case-folding, so custom redaction keeps (aa|bb|...|qq)|zz. A fold collision or a non-ASCII literal stays refused. Homogeneous truncated tails of one atom still reject, and Doctor still preserves a disjoint truncated suffix. Signed-off-by: Sebastien Tardif <[email protected]>
Merge current main and keep the proven-disjoint overflow policy. The exec-approval health check uses main's positional doctor API and the synchronous maintenance writer updateExecApprovalsForMaintenance. Signed-off-by: Sebastien Tardif <[email protected]>
Bring in the six commits that landed on main after c7dd7b9. None of them change the exec-approval pattern analyzer. Signed-off-by: Sebastien Tardif <[email protected]>
|
Regenerate the macOS JS bundle after the analyzer change. Skip generated Swift when collecting native UI copy, list the analyzer modules in the PR wrapper, mark the doctor note mock as isolation, and read octal token text only from simple tokens. Signed-off-by: Sebastien Tardif <[email protected]>
The post-swap restart check evaluates safe-regex as production code. Redaction calls tokenizePattern, so the token, sequence, and adjacent modules have to be real files. Stubbing them throws on the first call. Signed-off-by: Sebastien Tardif <[email protected]>
Product CI merges main before it runs. Current main adds mapfile to the upgrade-survivor helper, and the Bash 3.2 scan fails on that merge. This brings the branch onto d7c245e. Signed-off-by: Sebastien Tardif <[email protected]>
macOS system Bash is 3.2. The extended-stable helper's mapfile call fails the sourced-library scan. A read loop keeps the optional --channel stable argument. Signed-off-by: Sebastien Tardif <[email protected]>
A single-character class is the same letter as a plain literal. Expansion overflow used to reject ([a]a|[b]b|...|[q]q)|[z]z, so Doctor deleted a safe approval and redaction dropped the mask. A longer alternative that repeats the shorter one was accepted on the shared compiler after atom truncation. Same-width unique classes stay accepted, including ASCII case-fold, and a strict source prefix is proven overlap. Signed-off-by: Sebastien Tardif <[email protected]>
Main already reads the optional channel argument without mapfile and stores --yes in that same array. Keep that version. The local read loop did the same job with a separate channel_args array. Signed-off-by: Sebastien Tardif <[email protected]>
|
Thanks for the PR. We're closing older pull requests that have gone stale against current Approval argPatterns are written by the operator, and a 6,000-line change across Node, macOS, and Doctor is too large for that risk; CI is failing and real behavior proof is missing. A much smaller guard at the regex-compile boundary would be easier to review. If this change is still needed, please open a fresh PR against current |
What Problem This Solves
Exec approval, cron, and plugin model argPattern values can use nested alternation or adjacent overlapping repeats such as aa...b or (a|b)(b|c)z. Those patterns hang the JavaScript regex engine (catastrophic backtracking) and can freeze command authorization. A zero-minimum separator (?, {0,n}, or ) can be omitted, so ax?a and axa are still adjacent on that path. The shared safe-regex compiler must reject those shapes, including complete branch unions, without banning required separators (axa), disjoint optionals (ax?b), JWT-style {10,}.{10,} redact patterns, or safe Unicode class pairs used by group mentions.
Non-alternating grouped sequences such as (ab)(cb) must keep their complete languages. Reducing a group to its last token made (ab)* and (cb)* look like b vs b, so a safe pattern that should match abcb was rejected. Wrapping groups still flatten inner unions so ((a|b))((b|c)) stays rejected.
Equal character-class twins such as corp-[A-Z]+[A-Z]+ are valid custom redaction patterns. Tightening adjacent-repeat checks on the shared compiler would drop those patterns from redactSensitiveText. Shared compileSafeRegex keeps those twins. Exec stays fail-closed so they cannot hang command authorization.
Braced Unicode \u{hex} is a code point only when flags include u or v. Without those flags, \u{2} is identity u plus {2}, so ^(\u{2}|u)+$ is overlapping (uu|u)+ and must be rejected.
Disjoint mixed alternatives of equal consumed length such as ab|[c]d must stay accepted. An unconditional mixed-structure fallback treated corp-(ab|[c]d)+ as overlapping even though both branches consume two characters and are disjoint. That dropped custom redaction and let Doctor delete ^(ab|[c]d)+$. Shared analysis now compares equal-length atom sequences. Exec stays fail-closed on unsafe overlap such as (aa|a.)+ and (a+)+.
The mixed extractor must not treat every simple token as one consumed character. No-flag \141 is octal a and \x61 is hex a, so ^(\141\x61|aaaa)+$ is overlapping (aa|aaaa)+. Splitting \141 into \1, 4, 1 made 4 versus a look disjoint and let that ReDoS reach native matching. Decode complete escapes, or mark unknown-width atoms unproven, before positional disjointness.
Safe capturing wrappers such as ((ab)|(cd))+ must stay accepted. Both branches are fixed-width and disjoint. Treating group tokens as unknown overlap dropped corp-((ab)|(cd))+ from custom redaction and let Doctor delete ^((ab)|(cd))+$. Unwrap those groups. Conservative uncertainty is not grounds for deletion.
Decoded scalars must keep literal identity when overlap probing re-parses them as regex source. \x24 is
$, not an end-anchor, so ^(\x24a|[$]a)+$ must reject.\.is a literal dot, not a wildcard, so corp-(.a|[b]a)+ must stay accepted and still mask. Legacy octal first digit 4-7 consumes at most two digits, so \400 is \40 plus literal 0 and ^(\400| 0)+$ must reject.Two-digit and three-digit numeric escapes are backreferences when that capture exists. The two-digit high-octal rule treated \40 as space even with 40 capturing groups, so ^ + 39 empty groups + (a)(\40b|abab)+$ compared space-plus-b with abab and accepted. Native JavaScript repeats overlapping ab|abab. Count captures before decoding decimal escapes, or keep potentially valid backreferences unproven. Same for three-digit \141 when capture 141 exists.
Escaped dollars in alternatives are literals. corp-(a$|b[!])+ is a safe disjoint two-char pair. Stripping the final
$from a$ left a dangling escape, so atom extraction failed and the fallback rejected. Redaction then stopped masking corp-a$b!, and Doctor deleted the equivalent approval. Strip only actual anchor tokens.Safe nested alternatives such as corp-((ab|cd)e|(fg|hi)j)+ have disjoint fixed-width languages (abe, cde, fgj, hij). Atom extraction used to return null at the inner
|and the overlap fallback marked the outer+unsafe. Custom redaction then dropped the pattern, and Doctor deleted the equivalent anchored approval. Expand inner group alternatives into finite sequences so those languages stay accepted.Unequal-length alternatives are not ReDoS by length alone. ^(a|[b]c)+$ safely matches abc because the first characters are disjoint, so repetition is unambiguous. An unconditional unequal-length return labeled that rule unsafe, so exec denied it and Doctor deleted it. Check prefix disjointness first. Prefix overlap such as (a|aa)+ still rejects.
Property escapes are flag-dependent. Without u or v, \p{L} is identity p plus {L}, so ^(\p{L}a|p{L}ap{L}a)+$ is overlapping (p{L}a|p{L}ap{L}a)+. Tokenizing \p{L} as one Unicode atom and probing it with u compared a versus { and accepted that hang. Decode property escapes with the actual flags before positional comparison.
Analysis budget exhaustion is not the same as an unsafe pattern. The 32-atom cap used to abort extraction for ^([a] + 32 b's | [c] + 32 d's)+$ even though the first characters are disjoint. Keep truncated prefixes so proven-disjoint languages stay accepted. Equal-length truncated prefixes that already overlap, such as 33 versus 66 copies of [a]a{32}, are proven overlap and must reject.
Decoded non-ASCII scalars must keep that identity in the selected probe mode. Flag selection removes u, so emitting \u{e9} made ^(\u00E9a|[é]a)+$ look disjoint. Emit \xNN or \uXXXX instead.
The 16-sequence expansion cap is unproven, not overlap. ^((a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q)x|zx)+$ is disjoint fixed-width. Returning unsafe at that cap dropped custom redaction and let Doctor delete the stored rule. Returning no-overlap at that cap is also wrong: ^((a|...|q)x|axax)+$ never compared ax with axax, so repeating ax plus a failing suffix reached native matching. Collapse single-atom unions so the 17-way |x versus zx rule stays accepted and the axax prefix language still rejects. Leftover overflow is not permission to execute, except a same-width set of plain literals that stay unique after ASCII case-folding.
That exception is ^((aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq)|zz)+$. Expansion still overflows, but every alternative is a two-character literal and the set stays unique when ASCII letters fold, which is the i flag custom redaction adds. aa beside AA folds to one string and stays refused. A non-ASCII literal such as éé stays unproven under i and stays refused. Dual truncated tails that are more copies of one atom, 34 versus 68 of [a], stay refused on the shared compiler. A later distinct suffix, [a] plus 32 a's then b versus c, stays accepted on the shared compiler, refused by exec, and kept by Doctor. Uncertainty still must not authorize an expensive match and must not justify deleting a stored rule.
A one-character class is that letter. ^(([a]a|[b]b|[c]c|[d]d|[e]e|[f]f|[g]g|[h]h|[i]i|[j]j|[k]k|[l]l|[m]m|[n]n|[o]o|[p]p|[q]q)|[z]z)+$ is the same unique two-character set. The literal reader stopped at
[, so the overflow path refused it, Doctor deleted the approval, and redaction dropped the mask.[a]abeside[A]Astill folds to one string under i and stays refused.A longer alternative that begins with the shorter one is overlap. Let unit be
[a]plusbaseventeen times. The group(unit|unit concatenated with unit)keeps a matching 32-atom prefix and a nonhomogeneous omitted tail, so the shared compiler used to accept it. The longer source starts with the shorter source, so both compilers refuse, redaction leaves the raw text, and Doctor removes the stored rule.Incomplete equal prefixes are not proven overlap. p=[a] plus 31 a's, then p+b versus p+c, is fixed-width disjoint. Both truncated to the same 32 atoms. Unconditional true deleted that stored rule and dropped custom redaction. Keep a stored continuation atom so b versus c stays disjoint, while 33 versus 66 overlapping [a]a{32} prefixes still reject.
Shared Unicode atoms must be compared as languages. A class containing U+0100 versus a U+0100 literal (each followed by ASCII a, then repeated) share that code point, but the finite probe set never visits it, so first positions looked disjoint and redaction compiled it. Probe characters named by each atom. Disjoint [猫]|[犬] stays accepted on the shared compiler. Exec's stricter unprobed fallback does not protect redaction.
Overlap probes must inherit the s flag. ^(.a|\na\na)+$ with s lets dot consume newline, so the branches overlap. Comparing them without s declared them disjoint.
Exec approvals keep a stricter unprobed-Unicode fail-closed helper that is not part of the public plugin SDK. Runtime still refuses those conservative patterns. Doctor --fix must not delete a stored manual rule that the shared compiler accepts. Only unsafe or invalid entries are removed. Detect must not create or migrate shared approval state.
The same persisted allowlist is also evaluated by the native macOS app. Node and JavaScriptCore share compileExecArgPattern.
Ref #90014
Evidence
Latest head
c3bb06c1a1emerges main0452534c2d4. That merge takes main's Bash 3.2 update-argument array and does not change the analyzer. The analyzer commit remains255982a2a3b. Isolated worktree/tmp/oc-82950onfix/exec-approval-redos-guard. Live node transcript, re-run on the merge, from productioncompileSafeRegexDetailed,compileSafeRegexForExec,compileSafeRegex,compileConfigRegex,redactSensitiveText,analyzeArgvCommand,evaluateExecAllowlist,updateExecApprovalsForMaintenance,collectRejectedExecArgPatterns, andrepairRejectedExecArgPatterns. State directory/var/folders/7_/3g02szlx2h3_4pdqp0knlw740000gn/T/oc-82950-proof-DEDjy6/.openclaw(not~/.openclaw).compileExecArgPatterntakes only the source text. On the ignore-case rows below,execArgis that unflagged compile. The flagged result is thesharedandexecfields.Real behavior proof
Behavior or issue addressed: Budget exhaustion on a same-width set of unique literals is proven disjoint, including under ASCII case-folding, so custom redaction keeps
(aa|bb|...|qq)|zz. A one-character class uses that same check, so([a]a|[b]b|...|[q]q)|[z]zstays accepted and keeps its mask. A fold collision, a non-ASCII literal, an unequal-width overflow, and homogeneous truncated tails of one atom stay refused. A longer alternative that repeats the shorter one is proven overlap and stays refused on the shared compiler. A disjoint truncated suffix stays on the shared compiler, stays refused for exec, and stays stored.Real environment tested: macOS 27.0.1 arm64, Node v26.11.0, OpenClaw worktree
/tmp/oc-82950atc3bb06c1a1ef623bd4aa842853ef537e4c9b44ae. IsolatedOPENCLAW_STATE_DIR/var/folders/7_/3g02szlx2h3_4pdqp0knlw740000gn/T/oc-82950-proof-DEDjy6/.openclaw(not~/.openclaw).Exact steps or command run after this patch: The script set
HOMEandOPENCLAW_STATE_DIRto a fresh temp directory before importing production modules. It calledcompileSafeRegexDetailed,compileSafeRegexForExec,compileSafeRegex, andcompileExecArgPatternon the safe overflow (plain and flagi), theaa/AAcollision (plain and flagi), theééoverflow (plain and flagi), the corp overflow, the class overflow (plain and flagi), the 34-versus-68[a]overlap, the repeated[a]ba...tail, the[a]plus 32athenbversuscsuffix, the unequal(ax|...|qx)|axaxoverflow, and(a+)+. It calledcompileConfigRegexon the corp pattern withgi, thenredactSensitiveTextfor the corp pattern, the class pattern, the repeated tail, and the 34-versus-68 overlap. It calledanalyzeArgvCommandfor/bin/echoplus each sample argument, thenevaluateExecAllowlist. It seeded seven persisted entries withupdateExecApprovalsForMaintenance, then rancollectRejectedExecArgPatternsandrepairRejectedExecArgPatterns. Command:cd /tmp/oc-82950 && corepack pnpm exec tsx /tmp/proof-82950.mts.Evidence after fix: terminal output from that isolated production node run:
Observed result after fix:
aazz,qqzz,zz, andaamatch the safe overflow;azdoes not. The same source with flagistill compiles, andcompileConfigRegex(corp, "gi")matches the secret.redactSensitiveTextchangedseen corp-aaaaaaaaaaaaaaaazz endtoseen corp-aaaaaaaaaaaaaaaa*** end(the last capturezzmasks to***). The class form([a]a|...|[q]q)|[z]zcompiles with and without flagi. Redaction changedseen corp-aazz endtoseen corp-aa*** end, andcorp-aazzis gone.aabesideAAcompiles withoutiand refuses withi.[a]abeside[A]Adoes the same.ééin the same overflow shape compiles withoutiand refuses withi. The 34-versus-68[a]language refuses on the shared compiler, and redaction left that raw unit in the text. The repeated[a]ba...tail refuses on the shared compiler, exec, andcompileExecArgPattern. Redaction left that raw text in place.[a]plus 32athenbversuscis accepted by the shared compiler, refused by exec, and preserved by Doctor. Unequal overflow and(a+)+refuse. The allowlist satisfied bothaazzrows and rejectedaz, 34as,aaa, 33as plusb, and the repeated-tail sample. Command resolution reported/bin/echoon each of those rows. Doctor removed/bin/mixed-tail,/bin/unsafe, and/bin/overlap, and kept/bin/echo,/bin/class-overflow,/bin/truncated-disjoint-32, and/bin/safe.What was not tested: JavaScriptCore matching of this head. A published updater installing this candidate over a release build.
Summary
Same-width unique literals stay accepted when expansion overflows, including flag
iafter ASCII case-folding, so custom redaction keeps(aa|bb|...|qq)|zz. A one-character class uses that check, so([a]a|...|[q]q)|[z]zstays accepted and keeps its mask. A fold collision or a non-ASCII literal stays refused. A longer alternative that repeats the shorter one stays refused on the shared compiler, and Doctor removes it. Homogeneous truncated tails of one atom still reject. A disjoint truncated suffix stays shared-accepted, exec-refused, and stored. Unequal overflow and nested plus still refuse. Detect stays read-only. Repair stays onupdateExecApprovalsForMaintenance.Ref #90014