fix(security): anchor rm-deletion regex with \b to stop false positives#1374
Open
IanGordonOne wants to merge 2 commits into
Open
fix(security): anchor rm-deletion regex with \b to stop false positives#1374IanGordonOne wants to merge 2 commits into
IanGordonOne wants to merge 2 commits into
Conversation
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.
Problem
The
bash.blockedrm-protection rules in the SecurityPipeline use an unanchoredrm\s..., e.g.:Because
rmhas no word boundary and the.*wildcards span the whole command, this matches therminside ordinary words like confirm, then any hyphenated word (matching-\w*r), then a spaced/in prose — silently blocking entirely benign commands.Reproduction (both blocked by the current pattern)
Real-world: routine note/issue text that mentions "confirm", a hyphenated term, and a "/" path trips it. (Hit this repeatedly running
bd/git commands with descriptive text.)Fix
Add a
\bword boundary beforerm. In "confirm" theris preceded by a word char (no boundary) so it no longer matches; a realrm(start of command / after a space /;) still does. Real-threat coverage is unchanged.Verified in Node:
rm -rf /,rm -fr /,sudo rm -rf /, andrm -r --no-preserve-root /all still block.Scope
Anchors the six
-\w*rpatterns inReleases/v5.0.0/.claude/PAI/USER/SECURITY/PATTERNS.yamland the two (root + home) inReleases/v5.0.0/.claude/PAI/DOCUMENTATION/Security/Patterns.example.yaml.The four path-specific
rm\s.*/<file>patterns (PATTERNS.yaml ~lines 54-60) share the same unanchored-rmweakness but require a specific path token, so they false-positive far less — left out to keep this focused; happy to add\bthere too if you'd like.Applied and live-verified on my own PAI instance before submitting.