Repository navigation
feat: add G708 rule for server-side template injection via text/template - #1597
Merged
Merged
Conversation
Add taint analysis rule G708 to detect SSTI vulnerabilities when using Go text/template package. Covers two attack vectors: - User input flowing into Template.Parse() (SSTI/RCE) - Tainted data passed to Execute/ExecuteTemplate with http.ResponseWriter (XSS) CWE-94. Includes 6 test samples (3 positive, 3 negative).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1597 +/- ##
==========================================
+ Coverage 80.90% 81.00% +0.09%
==========================================
Files 104 105 +1
Lines 9947 9997 +50
==========================================
+ Hits 8048 8098 +50
Misses 1408 1408
Partials 491 491 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
feat: add G708 rule for server-side template injection via text/template
Summary
Add taint analysis rule G708 to detect Server-Side Template Injection (SSTI) vulnerabilities when using Go's
text/templatepackage.The
text/templatepackage performs no auto-escaping and allows calling any exported method on the data object passed toExecute. This enables:Detection
Covers two attack vectors via taint analysis:
Template.Parse()(SSTI/RCE, critical)Execute/ExecuteTemplatewriting tohttp.ResponseWriter(XSS, high)CWE-94: Improper Control of Generation of Code (Code Injection)
Sanitizers
html.EscapeString,html/templateescape functionsurl.QueryEscape,url.PathEscapestrconvnumeric conversionsTests
6 test samples (3 positive, 3 negative) covering:
html/templatesafe usage, non-HTTP writer, sanitized inputFiles Changed
analyzers/ssti.go(new) — taint configanalyzers/analyzerslist.go— registrationcwe/data.go— CWE-94 entryissue/issue.go— G708→CWE-94 mappingtestutils/g708_samples.go(new) — test samplesanalyzers/analyzerslist_test.go,analyzers/analyzers_test.go— testsRULES.md,README.md— docs