feat: add G709 rule for unsafe deserialization of untrusted data#1598
Merged
ccojocar merged 1 commit intosecurego:masterfrom Mar 11, 2026
Merged
Conversation
Add taint analysis rule G709 to detect unsafe deserialization when untrusted input flows into encoding/gob, encoding/xml, or gopkg.in/yaml.v2 deserialization functions. CWE-502. Includes 5 test samples (3 positive, 2 negative).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1598 +/- ##
==========================================
+ Coverage 81.00% 81.06% +0.06%
==========================================
Files 105 106 +1
Lines 9997 10030 +33
==========================================
+ Hits 8098 8131 +33
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.
Summary
Add taint analysis rule G709 to detect unsafe deserialization of untrusted data (CWE-502).
When user-controlled input flows into deserialization functions like
gob.NewDecoder,xml.Unmarshal, oryaml.v2.Unmarshal, attackers can exploit type instantiation mechanisms to achieve denial-of-service or remote code execution (e.g. CVE-2024-34156 for gob).Sinks
encoding/gobNewDecoderencoding/xmlNewDecoder,Unmarshalgopkg.in/yaml.v2NewDecoder,Unmarshalencoding/jsonis intentionally excluded (low risk, extremely common usage).Tests
5 test samples: 3 positive (gob, xml.NewDecoder, xml.Unmarshal), 2 negative (local file gob, json).
Files Changed
analyzers/unsafe_deserialization.go(new) — taint configtestutils/g709_samples.go(new) — test samplesanalyzers/analyzerslist.go— registrationcwe/data.go— CWE-502 entryissue/issue.go— G709->CWE-502 mappinganalyzers/analyzerslist_test.go,analyzers/analyzers_test.go— testsRULES.md,README.md— docs