fix(taint): prioritize call-graph over type-based source matching#1628
fix(taint): prioritize call-graph over type-based source matching#1628costela wants to merge 1 commit intosecurego:masterfrom
Conversation
…reduce false positives Refactor isParameterTainted to check call-graph edges first and only fall back to type-based source matching (e.g. *http.Request) when the call graph cannot give a definitive answer (no callers visible or edge cap hit). This eliminates false positives for wrapper methods whose callers only pass safe values, while preserving detection for framework-registered handlers with no visible callers. Also fixes invoke-mode index adjustment for interface method calls and adds G704 test cases for wrapper methods with hardcoded vs tainted URLs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1628 +/- ##
==========================================
+ Coverage 81.09% 81.12% +0.02%
==========================================
Files 108 108
Lines 10093 10098 +5
==========================================
+ Hits 8185 8192 +7
- Misses 1423 1424 +1
+ Partials 485 482 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@ravisastryk AFAICT you're the main author for the taint engine, right? In that case, I'd really appreciate your take on this PR 🙏 |
|
Thank you @costela for the report and the quick PR! I have put up #1630 which takes a slightly different approach with a bit more test coverage - feel free to close this one in favour of that if it looks good to you. |
|
@ravisastryk thanks for the quick feedback! Your PR seems less invasive 👍 |
Summary
isParameterTaintedto check call-graph edges first and only fall back to type-based source matching (e.g.*http.Request) when the call graph cannot give a definitive answer (no visible callers or edge cap hit).IsInvoke), where the receiver is inCall.Valuerather thanArgs.Motivation
Previously, type-based source matching ran before the call-graph check, causing false positives for wrapper methods that receive a source type (e.g.
*http.Request) but whose callers only pass safe, hardcoded values.Test plan
go test ./taint/...— taint analyzer tests passgo test ./...— full test suite passes, including new G704 wrapper casesFixes #1629