Skip to content

Commit 1336dc6

Browse files
niijccoVeille
andauthoredApr 3, 2025··
remove G113. It only affects old/unsupported versions of Go (#1328)
* don't warn on G113 (big.Rat SetString) if on an unaffected version of Go Newer versions of go (>=1.16.14, >=1.17.7, 1.18+) are not affected by this. Don't warn at all on those newer versions. See https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-23772 * alert on all known versions Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com> * remove G113 CVE-2022-23772 which only affects old/unsupport Go versions * Retire rule * gofmt --------- Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
1 parent 5fd2a37 commit 1336dc6

File tree

7 files changed

+35
-79
lines changed

7 files changed

+35
-79
lines changed
 

Diff for: ‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ directory you can supply `./...` as the input argument.
138138
- G110: Potential DoS vulnerability via decompression bomb
139139
- G111: Potential directory traversal
140140
- G112: Potential slowloris attack
141-
- G113: Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772)
142141
- G114: Use of net/http serve function that has no support for setting timeouts
143142
- G115: Potential integer overflow when converting between integer types
144143
- G201: SQL query construction using format string
@@ -172,6 +171,7 @@ directory you can supply `./...` as the input argument.
172171
### Retired rules
173172

174173
- G105: Audit the use of math/big.Int.Exp - [CVE is fixed](https://github.com/golang/go/issues/15184)
174+
- G113: Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772). This affected Go <1.16.14 and Go <1.17.7, which are no longer supported by gosec.
175175
- G307: Deferring a method which returns an error - causing more inconvenience than fixing a security issue, despite the details from this [blog post](https://www.joeshaw.org/dont-defer-close-on-writable-files/)
176176

177177
### Selecting rules

Diff for: ‎issue/issue.go

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ var ruleToCWE = map[string]string{
6565
"G110": "409",
6666
"G111": "22",
6767
"G112": "400",
68-
"G113": "190",
6968
"G114": "676",
7069
"G115": "190",
7170
"G201": "89",

Diff for: ‎report/formatter_test.go

+34-5
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,40 @@ var _ = Describe("Formatter", func() {
278278
})
279279
Context("When using different report formats", func() {
280280
grules := []string{
281-
"G101", "G102", "G103", "G104", "G106", "G107", "G109",
282-
"G110", "G111", "G112", "G113", "G201", "G202", "G203",
283-
"G204", "G301", "G302", "G303", "G304", "G305", "G401",
284-
"G402", "G403", "G404", "G405", "G406", "G407", "G501",
285-
"G502", "G503", "G504", "G505", "G506", "G507", "G601",
281+
"G101",
282+
"G102",
283+
"G103",
284+
"G104",
285+
"G106",
286+
"G107",
287+
"G109",
288+
"G110",
289+
"G111",
290+
"G112",
291+
"G201",
292+
"G202",
293+
"G203",
294+
"G204",
295+
"G301",
296+
"G302",
297+
"G303",
298+
"G304",
299+
"G305",
300+
"G401",
301+
"G402",
302+
"G403",
303+
"G404",
304+
"G405",
305+
"G406",
306+
"G407",
307+
"G501",
308+
"G502",
309+
"G503",
310+
"G504",
311+
"G505",
312+
"G506",
313+
"G507",
314+
"G601",
286315
}
287316

288317
It("csv formatted report should contain the CWE mapping", func() {

Diff for: ‎rules/math_big_rat.go

-45
This file was deleted.

Diff for: ‎rules/rulelist.go

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ func Generate(trackSuppressions bool, filters ...RuleFilter) RuleList {
7575
{"G110", "Detect io.Copy instead of io.CopyN when decompression", NewDecompressionBombCheck},
7676
{"G111", "Detect http.Dir('/') as a potential risk", NewDirectoryTraversal},
7777
{"G112", "Detect ReadHeaderTimeout not configured as a potential risk", NewSlowloris},
78-
{"G113", "Usage of Rat.SetString in math/big with an overflow", NewUsingOldMathBig},
7978
{"G114", "Use of net/http serve function that has no support for setting timeouts", NewHTTPServeWithoutTimeouts},
8079

8180
// injection

Diff for: ‎rules/rules_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ var _ = Describe("gosec rules", func() {
103103
runner("G112", testutils.SampleCodeG112)
104104
})
105105

106-
It("should detect potential uncontrolled memory consumption in Rat.SetString", func() {
107-
runner("G113", testutils.SampleCodeG113)
108-
})
109-
110106
It("should detect uses of net/http serve functions that have no support for setting timeouts", func() {
111107
runner("G114", testutils.SampleCodeG114)
112108
})

Diff for: ‎testutils/g113_samples.go

-22
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.