Skip to content

Commit 6e710c5

Browse files
committed
node-sequelize-empty-password-argument-typescript
1 parent f83aec6 commit 6e710c5

File tree

3 files changed

+157
-0
lines changed

3 files changed

+157
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
id: node-sequelize-empty-password-argument-typescript
2+
language: typescript
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+
[REFERENCES]
14+
- https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html
15+
utils:
16+
MATCH_BLANK_PASSWORD:
17+
kind: string
18+
pattern: $Q
19+
inside:
20+
stopBy: end
21+
kind: lexical_declaration
22+
all:
23+
- has:
24+
stopBy: end
25+
kind: new_expression
26+
all:
27+
- has:
28+
stopBy: end
29+
kind: identifier
30+
pattern: $E
31+
- has:
32+
stopBy: end
33+
kind: arguments
34+
nthChild: 2
35+
has:
36+
stopBy: end
37+
kind: string
38+
nthChild: 3
39+
pattern: $Q
40+
not:
41+
has:
42+
stopBy: end
43+
kind: string_fragment
44+
- any:
45+
- follows:
46+
stopBy: end
47+
kind: lexical_declaration
48+
has:
49+
stopBy: end
50+
kind: variable_declarator
51+
has:
52+
stopBy: end
53+
kind: identifier
54+
pattern: $E
55+
- follows:
56+
stopBy: end
57+
kind: import_statement
58+
has:
59+
stopBy: end
60+
kind: import_clause
61+
has:
62+
stopBy: end
63+
kind: identifier
64+
pattern: $E
65+
- follows:
66+
stopBy: end
67+
kind: import_statement
68+
has:
69+
stopBy: end
70+
kind: import_clause
71+
has:
72+
stopBy: end
73+
kind: identifier
74+
pattern: $E
75+
76+
rule:
77+
kind: string
78+
matches: MATCH_BLANK_PASSWORD
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
id: node-sequelize-empty-password-argument-typescript
2+
snapshots:
3+
? |
4+
const Sequelize = require('sequelize');
5+
const sequelize1 = new Sequelize('database', 'username', '', {
6+
host: 'localhost',
7+
port: '5433',
8+
dialect: 'postgres'
9+
})
10+
: labels:
11+
- source: ''''''
12+
style: primary
13+
start: 97
14+
end: 99
15+
- source: Sequelize
16+
style: secondary
17+
start: 63
18+
end: 72
19+
- source: ''''''
20+
style: secondary
21+
start: 97
22+
end: 99
23+
- source: |-
24+
('database', 'username', '', {
25+
host: 'localhost',
26+
port: '5433',
27+
dialect: 'postgres'
28+
})
29+
style: secondary
30+
start: 72
31+
end: 158
32+
- source: |-
33+
new Sequelize('database', 'username', '', {
34+
host: 'localhost',
35+
port: '5433',
36+
dialect: 'postgres'
37+
})
38+
style: secondary
39+
start: 59
40+
end: 158
41+
- source: Sequelize
42+
style: secondary
43+
start: 6
44+
end: 15
45+
- source: Sequelize = require('sequelize')
46+
style: secondary
47+
start: 6
48+
end: 38
49+
- source: const Sequelize = require('sequelize');
50+
style: secondary
51+
start: 0
52+
end: 39
53+
- source: |-
54+
const sequelize1 = new Sequelize('database', 'username', '', {
55+
host: 'localhost',
56+
port: '5433',
57+
dialect: 'postgres'
58+
})
59+
style: secondary
60+
start: 40
61+
end: 158
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
id: node-sequelize-empty-password-argument-typescript
2+
valid:
3+
- |
4+
const Sequelize = require('sequelize');
5+
const sequelize = new Sequelize({
6+
database: 'pinche',
7+
username: 'root',
8+
password: '123456789',
9+
dialect: 'mysql'
10+
});
11+
invalid:
12+
- |
13+
const Sequelize = require('sequelize');
14+
const sequelize1 = new Sequelize('database', 'username', '', {
15+
host: 'localhost',
16+
port: '5433',
17+
dialect: 'postgres'
18+
})

0 commit comments

Comments
 (0)