Repository navigation
security: flag credential paths only when the text asks for them - #169
Open
abu-tahir-0 wants to merge 1 commit into
Open
abu-tahir-0 wants to merge 1 commit into
abu-tahir-0 wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Closes #160.
Problem
tool-description-injectionflagged any mention of.env,.awsor~/.ssh, so it reported two of the six hard negatives inbenchmarks/poisoning_corpus.json: a tool that reads.envvariable names only and one that deletes an SSH key after the user confirms. Both descriptions are honest; the rule was matching the noun, not the request.Solution
A credential path now needs context before it is a finding. The window around it (120 characters each side) must contain either
include,send,upload,pass its contents,as the,in this field, ...), orthen read,before using this tool, read,copy the .env file, ...).An explicit safety cue (
NAMES only,never the values,without values) suppresses the finding, so a tool that says what it does not return stays clean. A sentence that warns against reading the path ("Never read the .env file") is not an imperative and is not flagged.Measurement
Poisoning corpus, before → after:
hard_benignflagged: 2 → 0 (reads-env-file,deletes-ssh-keyclear).poisonedmissed: unchanged apart fromevasive-base64, which is the subject of a separate PR (security: decode long base64 runs before scanning tool text #168) and remains missed here. Both credential-path injections (imp-block-read-ssh,param-description-injection) are still caught, now via the contextual rule.Testing
pytest tests/harness/test_new_rules.py -q— 15 passed (new cases: imperative read, include-into-field, copy, the two hard-negative descriptions, and a "never read" warning)pytest tests -m unit -q -n auto -p no:randomly— 395 passed, 2 failed onmain: the gray-box flake (test: test_a_correct_server_passes_every_rule_and_names_the_evidence is flaky under pytest-xdist #159, fixed by fixtures: raise the test server's accept backlog #167) andtest_fleet_service.py::test_the_dashboard_serves_html_behind_the_read_token(expects a published scan the fixture does not create here)ruff check,ruff format --check,mypy— clean