fix: metadata-first watch triage to prevent prompt injection#5
Merged
Conversation
Remove raw file content reading from watch triage pipeline. Claude now triages exclusively from sread metadata: MIME type, size, entropy, PDF keywords, archive listings, ELF headers, VBA macro presence, shebang. Changes: - fileinfo module: replace text content preview with line count + shebang - fileinfo module: replace strings preview on unknown types with no-op - fileinfo module: replace office strings with targeted VBA macro check - watch.sh: remove Read from allowed tools during triage - watch.sh: update prompt to forbid content reading - WATCH.md: rule 1 now explicitly prohibits raw content reading with rationale Closes #3
- Strip all tools except Write from watch triage — Claude receives pre-extracted metadata in the prompt, needs no read/execute access - Shebang extraction now uses regex to capture interpreter path only, rejecting anything outside [a-zA-Z0-9/_.-] - Closes the Bash/Grep content-reading bypass from review feedback
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
Changes
sread fileinfo: text content preview replaced with line count + shebang only; office docs use targeted VBA macro check instead of strings dump; unknown types no longer extract stringsagent/watch.sh:Readremoved fromALLOWED_TOOLSduring triage invocations; prompt updated to forbid content readingagent/WATCH.md: rule 1 now explicitly prohibits raw content reading with rationale (untrusted files could contain text designed to manipulate analysis)Test plan
sread fileinfoagainst a text file — confirm no content preview, only line count + shebangsread fileinfoagainst a PDF — confirm PDF metadata + risk indicators shown, no text extractionsread fileinfoagainst an office doc — confirm VBA macro check only, no strings dumpdocker compose --profile test run --rm secy-testCloses #3