Skip to content

fix(go): treat integer conversion as a taint sanitizer (fewer FPs) - #250

Merged
jaurakunal merged 1 commit into
mainfrom
fix/go-integer-conversion-sanitizer
Sep 23, 2026
Merged

jaurakunal merged 1 commit into
mainfrom
fix/go-integer-conversion-sanitizer

Conversation

@jaurakunal

Copy link
Copy Markdown
Owner

What

Second precision pass over AWS deception-bench. A user parameter converted to a number via strconv (Atoi/ParseInt/ParseUint/ParseFloat/ParseBool) can't carry ../, a shell metachar, or a URL host — so a path/URL/command built from it is safe. The Go taint rules now sanitize on those conversions.

  • Added strconv.* as pattern-sanitizers to the request-source Go taint rules (command-injection, ssrf, path-traversal, open-redirect). Sound and language-level, not app-specific — no overfitting.
  • A string parameter straight into a sink still flags (true positives kept).

Deliberately NOT changed (the "do not overfit" call)

The remaining ~24 deception-bench Go candidates are "safe" only via app-specific validators (validateRedirectHost, sanitizeFilename, validateUpstreamHost, confinement checks), and the benchmark pairs each with a vulnerable variant where that validation is subtly broken (e.g. validate the normalized URL, redirect the original). Recognizing those by name would overfit and suppress the genuinely-vulnerable variants, so they're left to flag-with-review.

Verified — no regression on any language

Per-language fixture-gate recall / FPs: TS/JS 12/12, Python 15/15, Java 10/10, Kotlin 9/9, Go 7/7 — all 0 FP (total 53/53, 0 FP). Only injection-go.yaml (every rule languages: [go]) + one Go fixture changed; other packs untouched. int-converted param no longer flagged, string param still flagged. govwa go-sast still 4/4. Full suite 2621 passed. Regression-guard fixture added.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EZ4QoTqRoYWE25CNoV2Wfy

Second precision pass over AWS deception-bench. A user parameter converted to a
number via strconv (Atoi/ParseInt/ParseUint/ParseFloat/ParseBool) can no longer
carry a `../`, a shell metacharacter, or a URL host — so a path/URL/command
built from it is safe. The Go taint rules now sanitize on those conversions.

- Added strconv.* as pattern-sanitizers to the request-source Go taint rules
  (command-injection, ssrf, path-traversal, open-redirect). Sound and
  language-level, NOT app-specific — so no overfitting to the benchmark.
- A string parameter straight into a sink still flags (true positives kept).

Deliberately NOT changed: the remaining ~24 deception-bench Go candidates
(open-redirect/path/ssrf) are "safe" only via app-specific validators
(validateRedirectHost, sanitizeFilename, validateUpstreamHost, confinement
checks), and the benchmark pairs each with a vulnerable variant where that
validation is subtly broken (e.g. validate the normalized URL, redirect the
original). Recognizing those validators by name would overfit AND suppress the
genuinely-vulnerable variants — so they are left to flag-with-review, the
defensible SAST behavior.

Verified — no regression on any language:
- SAST-injection fixture gate per language: TS/JS 12/12, Python 15/15, Java
  10/10, Kotlin 9/9, Go 7/7 — all 0 FP (total 53/53, 0 FP). Only injection-go.yaml
  (all rules `languages: [go]`) + a Go fixture changed; other packs untouched.
- int-converted param no longer flagged; string param still flagged.
- govwa go-sast still 4/4. Full suite: 2621 passed.
- Mined the int-conversion case into safe/ as a permanent regression guard.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ4QoTqRoYWE25CNoV2Wfy
@jaurakunal
jaurakunal merged commit 49454ff into main Sep 23, 2026
8 checks passed
@jaurakunal
jaurakunal deleted the fix/go-integer-conversion-sanitizer branch September 23, 2026 03:40
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.

1 participant