Skip to content

Commit bf80284

Browse files
committed
python-webrepl-empty-password-python
1 parent 7c1442d commit bf80284

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
id: python-webrepl-empty-password-python
2+
language: python
3+
severity: warning
4+
message: >-
5+
The application creates a database connection with an empty password.
6+
This can lead to unauthorized access by either an internal or external
7+
malicious actor. To prevent this vulnerability, enforce authentication
8+
when connecting to a database by using environment variables to securely
9+
provide credentials or retrieving them from a secure vault or HSM
10+
(Hardware Security Module).
11+
note: >-
12+
[CWE-287]: Improper Authentication
13+
[OWASP A07:2021]: Identification and Authentication Failures
14+
[REFERENCES]
15+
https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
16+
17+
ast-grep-essentials: true
18+
19+
utils:
20+
webrepl.start(..., password="",...):
21+
kind: call
22+
all:
23+
- has:
24+
stopBy: neighbor
25+
kind: attribute
26+
regex: ^webrepl.start$
27+
- has:
28+
stopBy: neighbor
29+
kind: argument_list
30+
has:
31+
stopBy: neighbor
32+
kind: keyword_argument
33+
all:
34+
- has:
35+
stopBy: neighbor
36+
kind: identifier
37+
regex: ^password$
38+
- has:
39+
stopBy: neighbor
40+
kind: string
41+
not:
42+
has:
43+
stopBy: end
44+
kind: string_content
45+
rule:
46+
kind: call
47+
matches: webrepl.start(..., password="",...)
48+
not:
49+
all:
50+
- has:
51+
stopBy: end
52+
kind: ERROR
53+
- inside:
54+
stopBy: end
55+
kind: ERROR
56+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
id: python-webrepl-empty-password-python
2+
snapshots:
3+
? |
4+
webrepl.start(password="")
5+
: labels:
6+
- source: webrepl.start(password="")
7+
style: primary
8+
start: 0
9+
end: 26
10+
- source: webrepl.start
11+
style: secondary
12+
start: 0
13+
end: 13
14+
- source: password
15+
style: secondary
16+
start: 14
17+
end: 22
18+
- source: '""'
19+
style: secondary
20+
start: 23
21+
end: 25
22+
- source: password=""
23+
style: secondary
24+
start: 14
25+
end: 25
26+
- source: (password="")
27+
style: secondary
28+
start: 13
29+
end: 26
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
id: python-webrepl-empty-password-python
2+
valid:
3+
- |
4+
webrepl.start(password=SECURE_PASSWORD_CONFIG["password"])
5+
invalid:
6+
- |
7+
webrepl.start(password="")

0 commit comments

Comments
 (0)