Skip to content

fix(security): prevent unsafe approval patterns from hanging command authorization - #82950

Closed
SebTardif wants to merge 25 commits into
openclaw:mainfrom
SebTardif:fix/exec-approval-redos-guard
Closed

SebTardif wants to merge 25 commits into
openclaw:mainfrom
SebTardif:fix/exec-approval-redos-guard

Conversation

@SebTardif

@SebTardif SebTardif commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

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]a beside [A]A still folds to one string under i and stays refused.

A longer alternative that begins with the shorter one is overlap. Let unit be [a] plus ba seventeen 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 c3bb06c1a1e merges main 0452534c2d4. That merge takes main's Bash 3.2 update-argument array and does not change the analyzer. The analyzer commit remains 255982a2a3b. Isolated worktree /tmp/oc-82950 on fix/exec-approval-redos-guard. Live node transcript, re-run on the merge, from production compileSafeRegexDetailed, compileSafeRegexForExec, compileSafeRegex, compileConfigRegex, redactSensitiveText, analyzeArgvCommand, evaluateExecAllowlist, updateExecApprovalsForMaintenance, collectRejectedExecArgPatterns, and repairRejectedExecArgPatterns. State directory /var/folders/7_/3g02szlx2h3_4pdqp0knlw740000gn/T/oc-82950-proof-DEDjy6/.openclaw (not ~/.openclaw).

compileExecArgPattern takes only the source text. On the ignore-case rows below, execArg is that unflagged compile. The flagged result is the shared and exec fields.

$ cd /tmp/oc-82950 && corepack pnpm exec tsx /tmp/proof-82950.mts
host node v26.11.0
stateDir .../oc-82950-proof-DEDjy6/.openclaw
compileMs 8
safe-overflow shared=accepted exec=accepted direct=accepted conservative=false execArg=accepted
safe-overflow-ignore-case shared=accepted exec=accepted direct=accepted conservative=false execArg-unflagged=accepted
case-collision shared=accepted exec=accepted direct=accepted execArg=accepted
case-collision-ignore-case shared=refused exec=refused direct=refused reason=unsafe-nested-repetition execArg-unflagged=accepted
non-ascii-overflow shared=accepted exec=accepted direct=accepted execArg=accepted
non-ascii-overflow-ignore-case shared=refused exec=refused direct=refused reason=unsafe-nested-repetition execArg-unflagged=accepted
corp-overflow shared=accepted exec=accepted compileConfigRegex(gi)=accepted ignoreCaseMatchesSecret=true
class-overflow shared=accepted exec=accepted direct=accepted conservative=false execArg=accepted
class-overflow-ignore-case shared=accepted exec=accepted direct=accepted conservative=false execArg-unflagged=accepted
truncated-overlap-34-68 shared=refused exec=refused reason=unsafe-nested-repetition
mixed-tail shared=refused exec=refused direct=refused reason=unsafe-nested-repetition execArg=refused
truncated-disjoint-b-c shared=accepted exec=refused direct=accepted conservative=true execArg=refused
samples aazz=true qqzz=true az=false zz=true aa=true
redact before=seen corp-aaaaaaaaaaaaaaaazz end
redact after=seen corp-aaaaaaaaaaaaaaaa*** end
secretStillPresent=false
class redact before=seen corp-aazz end
class redact after=seen corp-aa*** end
class secretStillPresent=false
mixed-tail redact left the raw text in place
overlap redact left the raw 34-versus-68 unit in the text
allowlist safe+aazz satisfied=true resolved=/bin/echo
allowlist safe+az satisfied=false resolved=/bin/echo
allowlist overlap-34 satisfied=false resolved=/bin/echo
allowlist nested-aaa satisfied=false resolved=/bin/echo
allowlist truncated-33b satisfied=false resolved=/bin/echo
allowlist class+aazz satisfied=true resolved=/bin/echo
allowlist mixed-tail satisfied=false resolved=/bin/echo
doctor findings=4 preserve-only=/bin/truncated-disjoint-32 reason=unsafe-nested-repetition
doctor removed=/bin/mixed-tail,/bin/unsafe,/bin/overlap
doctor remaining=/bin/echo,/bin/class-overflow,/bin/truncated-disjoint-32,/bin/safe

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]z stays 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-82950 at c3bb06c1a1ef623bd4aa842853ef537e4c9b44ae. Isolated OPENCLAW_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 HOME and OPENCLAW_STATE_DIR to a fresh temp directory before importing production modules. It called compileSafeRegexDetailed, compileSafeRegexForExec, compileSafeRegex, and compileExecArgPattern on the safe overflow (plain and flag i), the aa/AA collision (plain and flag i), the éé overflow (plain and flag i), the corp overflow, the class overflow (plain and flag i), the 34-versus-68 [a] overlap, the repeated [a]ba... tail, the [a] plus 32 a then b versus c suffix, the unequal (ax|...|qx)|axax overflow, and (a+)+. It called compileConfigRegex on the corp pattern with gi, then redactSensitiveText for the corp pattern, the class pattern, the repeated tail, and the 34-versus-68 overlap. It called analyzeArgvCommand for /bin/echo plus each sample argument, then evaluateExecAllowlist. It seeded seven persisted entries with updateExecApprovalsForMaintenance, then ran collectRejectedExecArgPatterns and repairRejectedExecArgPatterns. Command: cd /tmp/oc-82950 && corepack pnpm exec tsx /tmp/proof-82950.mts.

  • Evidence after fix: terminal output from that isolated production node run:

    safe-overflow shared=accepted exec=accepted
    safe-overflow-ignore-case shared=accepted exec=accepted
    case-collision shared=accepted
    case-collision-ignore-case shared=refused exec=refused reason=unsafe-nested-repetition
    non-ascii-overflow shared=accepted
    non-ascii-overflow-ignore-case shared=refused exec=refused reason=unsafe-nested-repetition
    class-overflow shared=accepted exec=accepted
    class-overflow-ignore-case shared=accepted exec=accepted
    mixed-tail shared=refused exec=refused reason=unsafe-nested-repetition
    corp gi compiled=true secretStillPresent=false
    redact after=seen corp-aaaaaaaaaaaaaaaa*** end
    class redact after=seen corp-aa*** end
    class secretStillPresent=false
    mixed-tail raw text still present
    overlap raw unit still present
    allowlist aazz=true az=false overlap=false nested=false truncated=false class-aazz=true mixed-tail=false resolved=/bin/echo
    doctor removed /bin/mixed-tail, /bin/unsafe, and /bin/overlap
    doctor kept /bin/echo, /bin/class-overflow, /bin/truncated-disjoint-32, /bin/safe
    truncated-disjoint-32 preserve=true
  • Observed result after fix: aazz, qqzz, zz, and aa match the safe overflow; az does not. The same source with flag i still compiles, and compileConfigRegex(corp, "gi") matches the secret. redactSensitiveText changed seen corp-aaaaaaaaaaaaaaaazz end to seen corp-aaaaaaaaaaaaaaaa*** end (the last capture zz masks to ***). The class form ([a]a|...|[q]q)|[z]z compiles with and without flag i. Redaction changed seen corp-aazz end to seen corp-aa*** end, and corp-aazz is gone. aa beside AA compiles without i and refuses with i. [a]a beside [A]A does the same. éé in the same overflow shape compiles without i and refuses with i. 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, and compileExecArgPattern. Redaction left that raw text in place. [a] plus 32 a then b versus c is accepted by the shared compiler, refused by exec, and preserved by Doctor. Unequal overflow and (a+)+ refuse. The allowlist satisfied both aazz rows and rejected az, 34 as, aaa, 33 as plus b, and the repeated-tail sample. Command resolution reported /bin/echo on 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 i after ASCII case-folding, so custom redaction keeps (aa|bb|...|qq)|zz. A one-character class uses that check, so ([a]a|...|[q]q)|[z]z stays 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 on updateExecApprovalsForMaintenance.

Ref #90014

@openclaw-barnacle openclaw-barnacle Bot added size: XS proof: supplied External PR includes structured after-fix real behavior proof. labels May 17, 2026
@clawsweeper

clawsweeper Bot commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This 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 (a+)+$ and receives a long argument ending in !.

  • Before: Authorization evaluates the backtracking regex and can hang.
  • After: The matcher rejects the pattern before testing the argument.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful production-function evidence supports the direction, but two P1 analyzer defects and incomplete upgrade and execution-boundary proof prevent readiness.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A stored manual approval regex can freeze command authorization.
Reason: The defect remains in current source, and vincentkoc recorded approval for denying and removing unsafe or invalid rules; that approval does not cover deleting valid rules.

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
Reviewed head: 255982a2a3b53327d7eb0de6dce55de1ad6314a6

Before merge

  • Add real behavior proof - Authority-chain proof required: the supplied current-head macOS Node transcript exercises production compilers, allowlist evaluation, redaction, and seeded SQLite repair through direct imports, but stops before shipped command launch and Doctor entry points. Provide redacted Node and native traces showing an allowed command launching, mismatching arguments rejected before launch, and revoked approval rejected at the final launch boundary; redact credentials, IPs, phone numbers, and non-public endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Reject equivalent grouped repetitions after truncation (P1) - The previous truncated-tail finding remains when equivalent copies use grouping. Let unit = '[a]' + 'ba'.repeat(17), then compile ^(${unit}|(${unit})(${unit}))+$. Both alternatives retain matching 32-atom prefixes and nonhomogeneous unknown tails, but their raw sources are not prefixes because the longer branch starts with (. The new check therefore misses the overlap and the shared fallback returns false, allowing a regex equivalent to (unit|unitunit)+$. Testing ('a' + 'ba'.repeat(17)).repeat(40) + '!' can then backtrack exponentially in shared consumers such as custom redaction; the base rejected these unequal-length repeated alternatives. Compare the represented languages rather than relying on source spelling, while retaining disjoint-tail behavior.
  • Respect character classes when splitting overflow alternatives (P1) - The previous safe-class finding remains for classes containing regex delimiters. ^((aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq)|[|]z)+$ is a disjoint two-character code accepted by the base, including the input aa|z. Expansion of the inner union overflows, but splitTopLevelPlain splits the literal pipe inside [|], so fixedWidthLiteralAlternativesAreDisjoint fails before the new class reader can recognize it. Both compilers classify the valid rule as unsafe, custom redaction drops its equivalent mask, and Doctor deletes the stored approval. Make splitting and group unwrapping respect class boundaries.
  • Resolve security concern: Shared safety errors affect synchronous redaction - Configured patterns are operator-supplied, but their subjects can contain external text; affected shared consumers can stall or leave custom-sensitive values unmasked.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P1] Reject equivalent grouped repetitions after truncation — src/security/safe-regex.ts:306-307
  • [P1] Respect character classes when splitting overflow alternatives — src/security/safe-regex-sequences.ts:237-240
  • [medium] Shared safety errors affect synchronous redaction — src/security/safe-regex.ts:323

Tests

  • Low-value test src/security/safe-regex.test.ts: Remove token-array assertions that pin internal parser representation; retain the compilation and matching cases that establish the escaping contracts.
  • Missing end-to-end proof: The supplied evidence does not establish shipped Node/native launch rejection, a stable-release Doctor upgrade, or base-fail/head-pass regression results for the remaining cases.
Agent review details

How this fits together

Persisted 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]
Loading

Technical review

Best 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:

  • [P1] Reject equivalent grouped repetitions after truncation — src/security/safe-regex.ts:306-307
    The previous truncated-tail finding remains when equivalent copies use grouping. Let unit = '[a]' + 'ba'.repeat(17), then compile ^(${unit}|(${unit})(${unit}))+$. Both alternatives retain matching 32-atom prefixes and nonhomogeneous unknown tails, but their raw sources are not prefixes because the longer branch starts with (. The new check therefore misses the overlap and the shared fallback returns false, allowing a regex equivalent to (unit|unitunit)+$. Testing ('a' + 'ba'.repeat(17)).repeat(40) + '!' can then backtrack exponentially in shared consumers such as custom redaction; the base rejected these unequal-length repeated alternatives. Compare the represented languages rather than relying on source spelling, while retaining disjoint-tail behavior.
    Confidence: 0.98
  • [P1] Respect character classes when splitting overflow alternatives — src/security/safe-regex-sequences.ts:237-240
    The previous safe-class finding remains for classes containing regex delimiters. ^((aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq)|[|]z)+$ is a disjoint two-character code accepted by the base, including the input aa|z. Expansion of the inner union overflows, but splitTopLevelPlain splits the literal pipe inside [|], so fixedWidthLiteralAlternativesAreDisjoint fails before the new class reader can recognize it. Both compilers classify the valid rule as unsafe, custom redaction drops its equivalent mask, and Doctor deletes the stored approval. Make splitting and group unwrapping respect class boundaries.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 919fcc263201.

Provenance checked

Testing

Proof path: in-process harness.

Security

Needs attention: The shared analyzer still admits a backtracking expression and can discard a valid custom redaction rule.

Evidence

Security concerns:

  • [medium] Shared safety errors affect synchronous redaction — src/security/safe-regex.ts:323
    Configured patterns are operator-supplied, but their subjects can contain external text; affected shared consumers can stall or leave custom-sensitive values unmasked.
    Confidence: 0.98

What I checked:

  • Current main retains the original failure path: Non-hashed argPattern values still reach new RegExp(argPattern) and synchronous regex testing without the proposed safety guard. (src/infra/exec-command-resolution.ts:262, 919fcc263201)
  • Remaining truncated-language bypass: Grouped copies of a long mixed-atom unit have identical truncated languages but different source prefixes; the shared compiler consequently accepts an overlapping repetition through its unproven fallback. (src/security/safe-regex.ts:323, 255982a2a3b5)
  • Remaining safe-class rejection: The overflow literal reader splits an unescaped pipe inside [|] as alternation, so a safe fixed-width rule is classified unsafe and becomes removable by Doctor. (src/security/safe-regex-sequences.ts:237, 255982a2a3b5)
  • Recorded compatibility approval: Repository member vincentkoc explicitly accepted denying and removing unsafe or invalid persisted approvals, followed by normal re-approval: fix(security): prevent unsafe approval patterns from hanging command authorization #82950 (comment).
  • Supplied behavior evidence: The full current body supplies terminal output from production compiler, allowlist, redaction, and seeded SQLite repair calls; it explicitly excludes current-head JavaScriptCore matching and release-to-candidate installation. (255982a2a3b5)
  • Previous findings checked against the new head: The latest commit adds class-literal handling, source-prefix overlap detection, regression cases, and corresponding generated native code; both preceding findings have narrower remaining cases described in this review. (src/security/safe-regex-sequences.ts:338, 255982a2a3b5)

Likely related people:

  • Peter Steinberger: Raw commit 031bf0c adds src/security/safe-regex.ts:296 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 031bf0c6c026; files: src/security/safe-regex.ts)
  • Vincent Koc: Raw commit adad27d adds src/commands/doctor-security.ts:17 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: adad27d7448e; files: src/commands/doctor-security.ts)
  • Josh Avant: Raw commit 1c37c8c adds src/infra/exec-command-resolution.ts:290 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 1c37c8cdc71b; files: src/infra/exec-command-resolution.ts)

PR surface

Source +2289, Tests +1752, Config +2, Generated +1870, Other +88. Total +6001 across 31 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 12 2417 128 +2289
Tests 9 1752 0 +1752
Docs 0 0 0 0
Config 1 2 0 +2
Generated 1 1870 0 +1870
Other 8 91 3 +88
Total 31 6132 131 +6001

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The original approval-path hang remains on main, and the proposed shared analyzer still has consequential availability and stored-rule defects.
  • merge-risk: 🚨 compatibility: The remaining safe-class rejection can disable and delete an existing valid manual approval; the recorded approval covers unsafe or invalid rules.
  • merge-risk: 🚨 security-boundary: Incorrect shared safety classifications affect custom redaction and persisted command approval rules.
  • merge-risk: 🚨 availability: Equivalent grouped truncated repetitions can reach synchronous shared regex matching with exponential backtracking.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (91 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-20T15:10:14.019Z sha b8d332b :: needs real behavior proof before merge. :: [P1] Keep unknown truncated tails from authorizing overlapping repetitions | [P1] Separate expansion exhaustion from proven unsafe patterns | [P1] Handle property escapes inside mixed character classes
  • reviewed 2026-09-20T15:43:23.044Z sha de03bda :: needs real behavior proof before merge. :: [P1] Preserve uncertainty when comparing truncated alternatives | [P1] Preserve stored rules when sequence expansion is inconclusive | [P1] Keep disjoint mixed-property redaction patterns usable | [P1] Regenerate the macOS policy after changing its TypeScript source
  • reviewed 2026-09-21T00:30:38.881Z sha 01fb611 :: needs real behavior proof before merge. :: [P1] Keep inconclusive expansion from enabling unsafe shared regexes | [P1] Require both omitted languages to support an overlap conclusion | [P2] Reconcile native parity expectations with the new refusal result
  • reviewed 2026-09-21T16:42:04.158Z sha b4ebf36 :: needs real behavior proof before merge. :: [P1] Preserve safe overflow rules without treating exhaustion as overlap | [P1] Reject overlapping truncated alternatives in the shared compiler | [P2] Update Doctor coverage for the newly conservative refusal
  • reviewed 2026-10-14T12:37:04.380Z sha b4ebf36 :: needs real behavior proof before merge. :: [P1] Preserve safe overflow rules without treating exhaustion as overlap | [P1] Reject overlapping truncated alternatives in the shared compiler | [P2] Update Doctor coverage for the newly conservative refusal
  • reviewed 2026-10-14T13:04:54.906Z sha 811f6db :: needs real behavior proof before merge. :: [P1] Preserve safe class-based rules when expansion overflows | [P1] Regenerate the macOS bundle after the latest analyzer changes
  • reviewed 2026-10-14T14:25:38.441Z sha 809d1d6 :: needs real behavior proof before merge. :: [P1] Preserve safe class-based rules when expansion overflows | [P1] Reject overlapping truncated tails in the shared compiler
  • reviewed 2026-10-14T14:56:40.186Z sha ecd6de5 :: needs real behavior proof before merge. :: [P1] Preserve safe class-based rules when expansion overflows | [P1] Reject overlapping truncated tails in the shared compiler

Reviewed October 14, 2026, 11:45 AM ET / 15:45 UTC (Revision 92).

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:security Security boundary, credential, authz, sandbox, or sensitive-data risk. impact:crash-loop Crash, hang, restart loop, or process-level availability failure. labels May 17, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed impact:security Security boundary, credential, authz, sandbox, or sensitive-data risk. impact:crash-loop Crash, hang, restart loop, or process-level availability failure. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🥚 common Frosted Branchling

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🥚 common.
Trait: sparkles near resolved comments.
Image traits: location merge queue dock; accessory proof snapshot camera; palette amber, ink, and glacier blue; mood curious; pose standing beside its cracked shell; shell soft velvet shell; lighting cool dashboard glow; background little resolved-comment flags.
Share on X: post this hatch
Copy: My PR egg hatched a 🥚 common Frosted Branchling in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. proof: supplied External PR includes structured after-fix real behavior proof. and removed proof: supplied External PR includes structured after-fix real behavior proof. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 20, 2026
@SebTardif
SebTardif force-pushed the fix/exec-approval-redos-guard branch from 9083898 to 8802261 Compare May 21, 2026 15:14
@SebTardif

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels May 21, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

9 similar comments
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

5 similar comments
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

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]>
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Maintainer security review required

This external contributor PR changes sensitive security components. A maintainer must review these changes before merging.

Current SHA: c3bb06c1a1ef623bd4aa842853ef537e4c9b44ae

These sensitive security changes were made:

  • src/security/safe-regex-adjacent.ts: Controls product security checks or trust decisions. Check whether the change weakens detection, protection, or remediation.
  • src/security/safe-regex-sequences.ts: Controls product security checks or trust decisions. Check whether the change weakens detection, protection, or remediation.
  • src/security/safe-regex-tokens.ts: Controls product security checks or trust decisions. Check whether the change weakens detection, protection, or remediation.
  • src/security/safe-regex.ts: Controls product security checks or trust decisions. Check whether the change weakens detection, protection, or remediation.

After reviewing the changes, post a new PR comment containing only approval commands, each on its own line:

/allow-security-sensitive-change

A later push requires a fresh approval comment.

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]>
@steipete

Copy link
Copy Markdown
Contributor

Thanks for the PR. We're closing older pull requests that have gone stale against current main.

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 main and we'll review it there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos commands Command implementations merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts security-review-required security-sensitive-changed size: XL stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants