Skip to content

Commit daa5339

Browse files
committed
missing-ssl-minversion-go
1 parent 915adae commit daa5339

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
id: missing-ssl-minversion-go
2+
language: go
3+
severity: warning
4+
message: >-
5+
MinVersion` is missing from this TLS configuration. By default, TLS
6+
1.2 is currently used as the minimum when acting as a client, and TLS 1.0
7+
when acting as a server. General purpose web applications should default
8+
to TLS 1.3 with all other protocols disabled. Only where it is known that
9+
a web server must support legacy clients with unsupported an insecure
10+
browsers (such as Internet Explorer 10), it may be necessary to enable TLS
11+
1.0 to provide support. Add `MinVersion: tls.VersionTLS13' to the TLS
12+
configuration to bump the minimum version to TLS 1.3.
13+
note: >-
14+
[CWE-327]: Use of a Broken or Risky Cryptographic Algorithm
15+
[OWASP A03:2017]: Sensitive Data Exposure
16+
[OWASP A02:2021]: Cryptographic Failures
17+
[REFERENCES]
18+
https://owasp.org/Top10/A02_2021-Cryptographic_Failures
19+
20+
ast-grep-essentials: true
21+
22+
utils:
23+
match_tls_without_minversion:
24+
kind: composite_literal
25+
all:
26+
- has:
27+
kind: qualified_type
28+
all:
29+
- has:
30+
kind: package_identifier
31+
regex: "^tls$"
32+
- has:
33+
kind: type_identifier
34+
field: name
35+
regex: "^Config$"
36+
- has:
37+
kind: literal_value
38+
not:
39+
has:
40+
kind: keyed_element
41+
all:
42+
- has:
43+
kind: literal_element
44+
regex: ^MinVersion$
45+
- has:
46+
pattern: $A
47+
rule:
48+
any:
49+
- matches: match_tls_without_minversion
50+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
id: missing-ssl-minversion-go
2+
snapshots:
3+
? |
4+
server.TLS = &tls.Config{ Rand: zeroSource{}, }
5+
: labels:
6+
- source: 'tls.Config{ Rand: zeroSource{}, }'
7+
style: primary
8+
start: 14
9+
end: 47
10+
- source: tls
11+
style: secondary
12+
start: 14
13+
end: 17
14+
- source: Config
15+
style: secondary
16+
start: 18
17+
end: 24
18+
- source: tls.Config
19+
style: secondary
20+
start: 14
21+
end: 24
22+
- source: '{ Rand: zeroSource{}, }'
23+
style: secondary
24+
start: 24
25+
end: 47
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
id: missing-ssl-minversion-go
2+
valid:
3+
- |
4+
TLSClientConfig: &tls.Config{
5+
KeyLogWriter: w,
6+
MinVersion: tls.VersionSSL30,
7+
Rand: zeroSource{},
8+
InsecureSkipVerify: true,
9+
},
10+
11+
invalid:
12+
- |
13+
server.TLS = &tls.Config{ Rand: zeroSource{}, }
14+
15+

0 commit comments

Comments
 (0)