fix(path): keep sanitizers responsive on adversarial input - #75
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 28, 2026, 2:45 AM ET / 06:45 UTC. ClawSweeper reviewWhat this changesThis PR replaces backtracking-prone cleanup regexes in path-segment, temporary-name, and Windows device-path sanitizers with bounded character scans, adds long hostile-input regression tests, and records the security hardening in the changelog. Merge readinessKeep this PR open for explicit maintainer review: it is a member-authored, security-sensitive change to public path-sanitization behavior. The proposed bounded scans and focused adversarial-input coverage are directionally appropriate, and no concrete patch defect is established from the available review evidence. Priority: P2 Review scores
Verification
How this fits together
flowchart LR
A[Caller-controlled path input] --> B[Path segment sanitizer]
A --> C[Temporary name builder]
A --> D[Windows device-path check]
B --> E[Validated safe name]
C --> E
D --> F[Allow or reject device target]
E --> G[Guarded filesystem operation]
F --> G
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the linear scans only after maintainer review confirms equivalence with the existing sanitizer contract across ordinary inputs and adversarial boundary cases, retaining the new regression coverage as protection against excessive CPU use. Do we have a high-confidence way to reproduce the issue? Yes, at source level: the PR supplies focused long-input cases for each claimed regex hotspot, but this read-only review did not independently execute the timing tests against a pre-fix revision. Is this the best way to solve the issue? Yes in principle: replacing vulnerable edge/suffix matching with bounded scans is the narrowest maintainable ReDoS-hardening approach, provided maintainers confirm the scans preserve the existing public normalization contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0206c4b567b4. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Maintainer review completed against the prior regex semantics. I ran a deterministic differential check over 50,000 randomized inputs for each changed boundary: path-segment sanitization (both dot-prefix modes), temporary prefix/extension output, and Windows device classification, plus a curated reserved-device corpus. Old and new outputs matched in every case. Existing CI is green across Node 22/24, macOS/Linux/Windows, native, package smoke, coverage, clippy/audit, and workflow lint. |
What Problem This Solves
Fixes an issue where consumers passing long attacker-controlled path segments, temp-name inputs, or Windows device paths could trigger excessive CPU use in sanitizer regexes.
Why This Change Was Made
Backtracking-prone edge and suffix regexes are replaced with bounded character scans while preserving existing path validation, fallback behavior, and Windows device detection. A dedicated regression suite covers the flagged input shapes.
User Impact
Path and temp-name sanitization remains responsive for very long hostile inputs without changing the public API or accepted output shapes.
Evidence
focused test run: 61 tests passed
pnpm buildfile-size lint
git diff --checkautoreview: clean, no accepted/actionable findings
Tests added or updated when behavior changed
Security and compatibility impact considered
CHANGELOG.mdupdated when release-relevantNo credentials, private paths, private hosts, or sensitive contents included