fix(analyzers): rely on runner for example filtering in E5 and TM4 (close executable bypass)#237
Open
CharmingGroot wants to merge 1 commit into
Open
Conversation
E5 (NVIDIA#218) and TM4 (NVIDIA#220) called is_code_example() with an unconditional continue, letting a nearby example marker (e.g. "# for example") suppress findings in executable files. The shared runner already filters examples in non-executable docs and only downweights executables, so the analyzer-level call was redundant and created an attacker-controlled bypass — the same issue fixed for SC7 in NVIDIA#224. Remove it from both analyzers; replace TM4's analyze-level doc-exclusion test with an executable-evasion test and add the equivalent E5 regression. Signed-off-by: CharmingGroot <ohyes9711@gmail.com>
b1c3657 to
308da53
Compare
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
The SC7 review (#224) established that calling
is_code_example()inside an analyzer with an unconditionalcontinuelets a nearby example marker suppress findings in executable files — the shared runner already filters examples in non-executable docs and only downweights executables, so the analyzer-level call is redundant and opens an attacker-controlled bypass. E5 (#218) and TM4 (#220), both merged, use the same pattern. This applies the same fix.Changes
static_patterns_data_exfiltration.py(E5): drop theis_code_examplecall and import; rely on the runner's file-type-aware handling.static_patterns_tool_misuse.py(TM4): same.# for examplenext toprivileged: truestill fires); an equivalent E5 regression is added.Why this is safe
Detection is unchanged — the runner still suppresses non-executable docs and downweights executables. Only the bypass is closed: a
# for examplenears3.put_object(...)orprivileged: truein a.sh/.pyno longer evades E5/TM4.anti_refusalalready uses a confidence penalty (not a skip), so it is intentionally left as-is.Testing
make formatandmake lintpass; the full suite reports 1256 passed, 0 failed. A re-scan confirms detection is preserved (E5 ×2, TM4 ×6 still fire on the same fixtures).Follows up on the review in #224.