feat(context): gate local-only suppression on trust_boundaries, not just app type#118
Open
gadievron wants to merge 1 commit into
Open
feat(context): gate local-only suppression on trust_boundaries, not just app type#118gadievron wants to merge 1 commit into
gadievron wants to merge 1 commit into
Conversation
…ust app type A data-processing library (parser, deserializer, codec) takes untrusted INPUT DATA — that data crossing into the code is the attack surface even with no network listener. The generator sets requires_remote_trigger=False for every library, so the Stage 1/2 prompts emitted 'only flag REMOTE attacker, not local users' and discarded exactly those bugs (tree-sitter: all parser memory-safety findings suppressed until requires_remote_trigger was hand-set). Add ApplicationContext.suppress_local_only(): suppress ONLY when no trust boundary is 'untrusted'. Reuses the already-captured trust_boundaries — no new field. Gate all 7 sites (6 live in prompts/, 1 display in context/). A genuine no-attack-surface library (all-trusted) is unchanged; an untrusted-input library is now analysed. Generator instruction reworded to set the flag from untrusted input, not blanket-false per type. Tests: 8 new (suppress_local_only unit + Stage 1 + Stage 2 present/absent).
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.
fix(context): gate the local-only suppression on trust_boundaries, not app-type alone
Problem
The context generator sets
requires_remote_trigger: Falsefor everylibrary/cli_tool. The Stage 1 and Stage 2 prompts (prompts/vulnerability_analysis.py,prompts/verification_prompts.py) then emit "This is a CLI tool/library… only flag vulnerabilities exploitable by a REMOTE attacker, not local users." That framing is correct for a library whose inputs are all operator-controlled — but wrong for a data-processing library (parser, deserializer, codec) whose untrusted input data is the attack surface even with no network listener. It tells the analyzer to discard exactly that bug class.Observed on tree-sitter (a C parsing library): every parser memory-safety finding was suppressed by this clause until
requires_remote_triggerwas hand-set.Fix
Add
ApplicationContext.suppress_local_only()— keep the suppression only when no trust boundary isuntrusted. This reuses the already-capturedtrust_boundaries(values:trusted/semi_trusted/untrusted); no new schema field. Gate all 7 emission sites (6 live inprompts/, 1 display incontext/). Generator instruction reworded to setrequires_remote_triggerfrom whether untrusted input is processed, not blanket-false per type (defense-in-depth; the gate holds even if the model keeps the old behavior).trustedboundaries → unchanged (still suppressed; genuine no-attack-surface libraries are not affected).untrustedboundary (e.g. tree-sitter'ssource_code_being_parsed: untrusted) → now analyzed.Scope note
This fixes the
requires_remote_triggersuppression mechanism only. A separate over-suppression — the generator sometimes emits over-broadnot_a_vulnerabilityentries (e.g. "memory operations in C are fine") — is not addressed here and is worth a follow-up.Not a security fix
This is an analyzer-targeting/coverage change (it changes which findings the LLM is told to consider), not a code-vulnerability patch.
Tests
9 in
tests/test_threat_model_untrusted_input_gate.py:suppress_local_only()unit cases (incl. case-insensitiveuntrustedmatch, since the values are LLM-generated) + Stage 1 and Stage 2 formatter present/absent for all-trusted vs untrusted-input contexts. No existing test pinned the prior behavior (verified:grep -rn suppress_local_only tests/= 1 file).Depends-on
None (standalone; the suppression clause is pre-existing on master). Co-exists with #94's
application_context.pychanges (different region; no conflict).