forked from trailofbits/semgrep-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservercodec-readrequestbody-unhandled-nil.yaml
36 lines (35 loc) · 1.16 KB
/
servercodec-readrequestbody-unhandled-nil.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
rules:
- id: servercodec-readrequestbody-unhandled-nil
message: >-
The `func ($O *$CODEC) ReadRequestBody($ARG $TYPE) error` function does not handle `nil` argument, as the `ServerCodec` interface requires.
An incorrect implementation could lead to denial of service
languages: [go]
severity: WARNING
metadata:
category: security
cwe: "CWE-476: NULL Pointer Dereference"
subcategory: [vuln]
confidence: HIGH
likelihood: MEDIUM
impact: LOW
technology: [--no-technology--]
description: "Possible incorrect `ServerCodec` interface implementation"
references:
- https://github.com/golang/go/blob/go1.15.2/src/net/rpc/server.go#L643-L658
patterns:
- pattern: |
func ($O *$CODEC) ReadRequestBody($ARG $TYPE) error {
...
}
- pattern-not: |
func ($O *$CODEC) ReadRequestBody($ARG $TYPE) error {
...
if $ARG == nil { ... }
...
}
- pattern-not: |
func ($O *$CODEC) ReadRequestBody($ARG $TYPE) error {
...
if $ARG != nil { ... }
...
}