Skip to content

Add G120 SSA analyzer for unbounded form parsing in HTTP handlers#1520

Merged
ccojocar merged 1 commit intomasterfrom
new_analyzer
Feb 16, 2026
Merged

Add G120 SSA analyzer for unbounded form parsing in HTTP handlers#1520
ccojocar merged 1 commit intomasterfrom
new_analyzer

Conversation

@ccojocar
Copy link
Copy Markdown
Member

@ccojocar ccojocar commented Feb 16, 2026

  • Introduces new G120 to detect potential memory-exhaustion paths caused by unbounded form parsing in HTTP handlers.
  • Uses a pure SSA implementation (no AST fallback), checking ParseForm, ParseMultipartForm, FormValue, and PostFormValue on *http.Request.Suppresses findings when request bodies are explicitly bounded with http.MaxBytesReader.
  • Wires G120 into analyzer registration, README rule catalog, and CWE mapping (CWE-400).
  • Adds focused vulnerable/safe samples and analyzer test coverage; analyzer tests and lint pass.

Introduces new G120 to detect potential memory-exhaustion paths caused
by unbounded form parsing in HTTP handlers.
Uses a pure SSA implementation (no AST fallback), checking ParseForm,
ParseMultipartForm, FormValue, and PostFormValue on *http.Request.
Suppresses findings when request bodies are explicitly bounded with
http.MaxBytesReader.
Wires G120 into analyzer registration, README rule catalog, and CWE
mapping (CWE-400).
Adds focused vulnerable/safe samples and analyzer test coverage;
analyzer tests and lint pass.

Signed-off-by: Cosmin Cojocar <cosmin@cojocar.ch>
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 16, 2026

Codecov Report

❌ Patch coverage is 56.03448% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.23%. Comparing base (89cde27) to head (e45d6c2).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
analyzers/form_parsing_limits.go 56.03% 31 Missing and 20 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1520      +/-   ##
==========================================
- Coverage   76.50%   76.23%   -0.28%     
==========================================
  Files          98       99       +1     
  Lines        8395     8511     +116     
==========================================
+ Hits         6423     6488      +65     
- Misses       1624     1655      +31     
- Partials      348      368      +20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ccojocar ccojocar merged commit 238f982 into master Feb 16, 2026
7 of 9 checks passed
@ccojocar ccojocar deleted the new_analyzer branch February 16, 2026 14:06
@SuperSandro2000
Copy link
Copy Markdown

The upstream go doc mentions that ParseForm is capped at 10 MB already 🤔

https://pkg.go.dev/net/http#Request.ParseForm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants