@intentsolutionsio/penetration-tester 2.0.0 → 3.0.4

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.
Files changed (112) hide show
  1. package/.claude-plugin/plugin.json +8 -3
  2. package/README.md +8 -0
  3. package/commands/pentest.md +5 -0
  4. package/package.json +8 -3
  5. package/skills/analyzing-tls-config/SKILL.md +221 -0
  6. package/skills/analyzing-tls-config/references/AUTHORIZATION.md +133 -0
  7. package/skills/analyzing-tls-config/references/PLAYBOOK.md +267 -0
  8. package/skills/analyzing-tls-config/references/THEORY.md +128 -0
  9. package/skills/analyzing-tls-config/scripts/analyze_tls.py +415 -0
  10. package/skills/auditing-cors-policy/SKILL.md +186 -0
  11. package/skills/auditing-cors-policy/references/PLAYBOOK.md +220 -0
  12. package/skills/auditing-cors-policy/references/THEORY.md +142 -0
  13. package/skills/auditing-cors-policy/scripts/audit_cors.py +350 -0
  14. package/skills/auditing-npm-dependencies/SKILL.md +254 -0
  15. package/skills/auditing-npm-dependencies/references/PLAYBOOK.md +175 -0
  16. package/skills/auditing-npm-dependencies/references/THEORY.md +122 -0
  17. package/skills/auditing-npm-dependencies/scripts/audit_npm.py +408 -0
  18. package/skills/auditing-python-dependencies/SKILL.md +251 -0
  19. package/skills/auditing-python-dependencies/references/PLAYBOOK.md +193 -0
  20. package/skills/auditing-python-dependencies/references/THEORY.md +122 -0
  21. package/skills/auditing-python-dependencies/scripts/audit_python.py +459 -0
  22. package/skills/checking-http-security-headers/SKILL.md +176 -0
  23. package/skills/checking-http-security-headers/references/PLAYBOOK.md +212 -0
  24. package/skills/checking-http-security-headers/references/THEORY.md +137 -0
  25. package/skills/checking-http-security-headers/scripts/check_headers.py +362 -0
  26. package/skills/checking-license-compliance/SKILL.md +225 -0
  27. package/skills/checking-license-compliance/references/PLAYBOOK.md +161 -0
  28. package/skills/checking-license-compliance/references/THEORY.md +152 -0
  29. package/skills/checking-license-compliance/scripts/check_licenses.py +461 -0
  30. package/skills/composing-vulnerability-report/SKILL.md +212 -0
  31. package/skills/composing-vulnerability-report/references/PLAYBOOK.md +180 -0
  32. package/skills/composing-vulnerability-report/references/THEORY.md +178 -0
  33. package/skills/composing-vulnerability-report/scripts/compose_report.py +396 -0
  34. package/skills/confirming-pentest-authorization/SKILL.md +247 -0
  35. package/skills/confirming-pentest-authorization/references/PLAYBOOK.md +189 -0
  36. package/skills/confirming-pentest-authorization/references/THEORY.md +167 -0
  37. package/skills/confirming-pentest-authorization/scripts/check_authorization.py +457 -0
  38. package/skills/defining-pentest-scope/SKILL.md +227 -0
  39. package/skills/defining-pentest-scope/references/PLAYBOOK.md +238 -0
  40. package/skills/defining-pentest-scope/references/THEORY.md +170 -0
  41. package/skills/defining-pentest-scope/scripts/define_scope.py +472 -0
  42. package/skills/detecting-command-injection-patterns/SKILL.md +144 -0
  43. package/skills/detecting-command-injection-patterns/references/PLAYBOOK.md +302 -0
  44. package/skills/detecting-command-injection-patterns/references/THEORY.md +206 -0
  45. package/skills/detecting-command-injection-patterns/scripts/scan_cmdi.py +290 -0
  46. package/skills/detecting-debug-endpoints/SKILL.md +207 -0
  47. package/skills/detecting-debug-endpoints/references/PLAYBOOK.md +402 -0
  48. package/skills/detecting-debug-endpoints/references/THEORY.md +218 -0
  49. package/skills/detecting-debug-endpoints/scripts/probe_debug.py +518 -0
  50. package/skills/detecting-directory-listing/SKILL.md +206 -0
  51. package/skills/detecting-directory-listing/references/PLAYBOOK.md +277 -0
  52. package/skills/detecting-directory-listing/references/THEORY.md +203 -0
  53. package/skills/detecting-directory-listing/scripts/probe_directory_listing.py +180 -0
  54. package/skills/detecting-eval-exec-usage/SKILL.md +128 -0
  55. package/skills/detecting-eval-exec-usage/references/PLAYBOOK.md +306 -0
  56. package/skills/detecting-eval-exec-usage/references/THEORY.md +159 -0
  57. package/skills/detecting-eval-exec-usage/scripts/scan_eval.py +223 -0
  58. package/skills/detecting-exposed-secrets-files/SKILL.md +179 -0
  59. package/skills/detecting-exposed-secrets-files/references/PLAYBOOK.md +274 -0
  60. package/skills/detecting-exposed-secrets-files/references/THEORY.md +174 -0
  61. package/skills/detecting-exposed-secrets-files/scripts/probe_secrets.py +207 -0
  62. package/skills/detecting-insecure-deserialization/SKILL.md +148 -0
  63. package/skills/detecting-insecure-deserialization/references/PLAYBOOK.md +333 -0
  64. package/skills/detecting-insecure-deserialization/references/THEORY.md +199 -0
  65. package/skills/detecting-insecure-deserialization/scripts/scan_deserialization.py +250 -0
  66. package/skills/detecting-sql-injection-patterns/SKILL.md +161 -0
  67. package/skills/detecting-sql-injection-patterns/references/PLAYBOOK.md +317 -0
  68. package/skills/detecting-sql-injection-patterns/references/THEORY.md +261 -0
  69. package/skills/detecting-sql-injection-patterns/scripts/scan_sqli.py +354 -0
  70. package/skills/detecting-ssl-cert-issues/SKILL.md +182 -0
  71. package/skills/detecting-ssl-cert-issues/references/PLAYBOOK.md +203 -0
  72. package/skills/detecting-ssl-cert-issues/references/THEORY.md +133 -0
  73. package/skills/detecting-ssl-cert-issues/scripts/check_cert_chain.py +481 -0
  74. package/skills/detecting-weak-cryptography/SKILL.md +147 -0
  75. package/skills/detecting-weak-cryptography/references/PLAYBOOK.md +466 -0
  76. package/skills/detecting-weak-cryptography/references/THEORY.md +194 -0
  77. package/skills/detecting-weak-cryptography/scripts/scan_weak_crypto.py +417 -0
  78. package/skills/fingerprinting-server-software/SKILL.md +191 -0
  79. package/skills/fingerprinting-server-software/references/PLAYBOOK.md +337 -0
  80. package/skills/fingerprinting-server-software/references/THEORY.md +183 -0
  81. package/skills/fingerprinting-server-software/scripts/fingerprint_server.py +347 -0
  82. package/skills/generating-executive-summary/SKILL.md +261 -0
  83. package/skills/generating-executive-summary/references/PLAYBOOK.md +201 -0
  84. package/skills/generating-executive-summary/references/THEORY.md +195 -0
  85. package/skills/generating-executive-summary/scripts/exec_summary.py +538 -0
  86. package/skills/mapping-findings-to-owasp-top10/SKILL.md +235 -0
  87. package/skills/mapping-findings-to-owasp-top10/references/PLAYBOOK.md +193 -0
  88. package/skills/mapping-findings-to-owasp-top10/references/THEORY.md +160 -0
  89. package/skills/mapping-findings-to-owasp-top10/scripts/map_owasp.py +540 -0
  90. package/skills/performing-penetration-testing/SKILL.md +282 -190
  91. package/skills/performing-penetration-testing/references/OWASP_TOP_10.md +22 -0
  92. package/skills/performing-penetration-testing/references/REMEDIATION_PLAYBOOK.md +46 -0
  93. package/skills/performing-penetration-testing/references/SECURITY_HEADERS.md +41 -0
  94. package/skills/performing-penetration-testing/scripts/code_security_scanner.py +144 -79
  95. package/skills/performing-penetration-testing/scripts/dependency_auditor.py +116 -93
  96. package/skills/performing-penetration-testing/scripts/security_scanner.py +574 -446
  97. package/skills/probing-dangerous-http-methods/SKILL.md +182 -0
  98. package/skills/probing-dangerous-http-methods/references/PLAYBOOK.md +234 -0
  99. package/skills/probing-dangerous-http-methods/references/THEORY.md +145 -0
  100. package/skills/probing-dangerous-http-methods/scripts/probe_methods.py +263 -0
  101. package/skills/recording-pentest-engagement/SKILL.md +253 -0
  102. package/skills/recording-pentest-engagement/references/PLAYBOOK.md +203 -0
  103. package/skills/recording-pentest-engagement/references/THEORY.md +195 -0
  104. package/skills/recording-pentest-engagement/scripts/record_engagement.py +461 -0
  105. package/skills/scanning-for-hardcoded-secrets/SKILL.md +215 -0
  106. package/skills/scanning-for-hardcoded-secrets/references/PLAYBOOK.md +325 -0
  107. package/skills/scanning-for-hardcoded-secrets/references/THEORY.md +175 -0
  108. package/skills/scanning-for-hardcoded-secrets/scripts/scan_secrets.py +395 -0
  109. package/skills/tracing-transitive-vulnerabilities/SKILL.md +235 -0
  110. package/skills/tracing-transitive-vulnerabilities/references/PLAYBOOK.md +233 -0
  111. package/skills/tracing-transitive-vulnerabilities/references/THEORY.md +138 -0
  112. package/skills/tracing-transitive-vulnerabilities/scripts/trace_vulns.py +484 -0
@@ -12,11 +12,13 @@ missing function-level access control, CORS misconfiguration, and privilege
12
12
  escalation.
13
13
 
14
14
  **Scanner detection:**
15
+
15
16
  - `security_scanner.py` -- checks CORS policy for wildcard origins, reflected
16
17
  origins, and credentials with wildcard
17
18
  - `code_security_scanner.py` -- flags missing authorization decorators (regex)
18
19
 
19
20
  **Remediation (Python/Flask):**
21
+
20
22
  ```python
21
23
  # BAD: No authorization check
22
24
  @app.route("/api/users/<user_id>")
@@ -33,6 +35,7 @@ def get_user(user_id):
33
35
  ```
34
36
 
35
37
  **Remediation (Node.js/Express):**
38
+
36
39
  ```javascript
37
40
  // Middleware: verify resource ownership
38
41
  function authorizeUser(req, res, next) {
@@ -51,11 +54,13 @@ function authorizeUser(req, res, next) {
51
54
  plaintext transmission, weak hashing algorithms, and improper key management.
52
55
 
53
56
  **Scanner detection:**
57
+
54
58
  - `security_scanner.py` -- checks SSL/TLS certificate validity, protocol version,
55
59
  HSTS header presence and max-age
56
60
  - `code_security_scanner.py` -- flags MD5/SHA1 usage, insecure URLs (http://)
57
61
 
58
62
  **Remediation:**
63
+
59
64
  ```python
60
65
  # BAD: Weak hashing
61
66
  import hashlib
@@ -75,11 +80,13 @@ hashed = ph.hash(password)
75
80
  Includes SQL injection, NoSQL injection, OS command injection, and LDAP injection.
76
81
 
77
82
  **Scanner detection:**
83
+
78
84
  - `code_security_scanner.py` -- bandit flags (B608 SQL injection, B602 subprocess
79
85
  shell=True, B307 eval); regex patterns for string concatenation in queries,
80
86
  os.system calls, eval/exec usage
81
87
 
82
88
  **Remediation (SQL - Python):**
89
+
83
90
  ```python
84
91
  # BAD: String concatenation
85
92
  cursor.execute("SELECT * FROM users WHERE name = '" + name + "'")
@@ -89,6 +96,7 @@ cursor.execute("SELECT * FROM users WHERE name = %s", (name,))
89
96
  ```
90
97
 
91
98
  **Remediation (Command - Python):**
99
+
92
100
  ```python
93
101
  # BAD: Shell injection
94
102
  os.system("ping " + user_input)
@@ -105,11 +113,13 @@ subprocess.run(["ping", "-c", "1", validated_host], shell=False)
105
113
  implementation bugs. Missing threat modeling, insecure business logic.
106
114
 
107
115
  **Scanner detection:**
116
+
108
117
  - Not directly detectable by automated tools
109
118
  - `code_security_scanner.py` can flag patterns that suggest design issues (e.g.,
110
119
  no rate limiting, missing input validation at boundaries)
111
120
 
112
121
  **Mitigation:**
122
+
113
123
  - Use threat modeling (STRIDE, DREAD) during design
114
124
  - Implement defense in depth
115
125
  - Apply principle of least privilege
@@ -123,11 +133,13 @@ implementation bugs. Missing threat modeling, insecure business logic.
123
133
  features enabled, verbose error messages, misconfigured permissions.
124
134
 
125
135
  **Scanner detection:**
136
+
126
137
  - `security_scanner.py` -- checks all security headers, server version disclosure,
127
138
  exposed admin endpoints, directory listing, dangerous HTTP methods enabled
128
139
  - `dependency_auditor.py` -- flags outdated packages with known vulnerabilities
129
140
 
130
141
  **Remediation:**
142
+
131
143
  - Remove default accounts and passwords
132
144
  - Disable directory listing
133
145
  - Remove server version headers
@@ -143,10 +155,12 @@ features enabled, verbose error messages, misconfigured permissions.
143
155
  known vulnerabilities.
144
156
 
145
157
  **Scanner detection:**
158
+
146
159
  - `dependency_auditor.py` -- runs npm audit and pip-audit to find CVEs in
147
160
  installed packages, reports severity and available fix versions
148
161
 
149
162
  **Remediation:**
163
+
150
164
  ```bash
151
165
  # Check npm vulnerabilities
152
166
  npm audit
@@ -169,11 +183,13 @@ pip install --upgrade package-name
169
183
  session fixation, missing MFA.
170
184
 
171
185
  **Scanner detection:**
186
+
172
187
  - `security_scanner.py` -- checks for session cookie security attributes
173
188
  (Secure, HttpOnly, SameSite)
174
189
  - `code_security_scanner.py` -- flags hardcoded passwords and tokens
175
190
 
176
191
  **Remediation:**
192
+
177
193
  - Implement MFA
178
194
  - Never ship default credentials
179
195
  - Implement account lockout / rate limiting
@@ -189,10 +205,12 @@ violations. Includes insecure deserialization, unsigned updates, untrusted CI/CD
189
205
  pipelines.
190
206
 
191
207
  **Scanner detection:**
208
+
192
209
  - `code_security_scanner.py` -- bandit flags B301 (pickle), B506 (yaml.load
193
210
  without SafeLoader); regex patterns for marshal.loads, insecure deserialization
194
211
 
195
212
  **Remediation (Python):**
213
+
196
214
  ```python
197
215
  # BAD: Insecure deserialization
198
216
  import pickle
@@ -218,11 +236,13 @@ data = yaml.safe_load(content)
218
236
  inability to detect active breaches.
219
237
 
220
238
  **Scanner detection:**
239
+
221
240
  - Not directly detectable by automated scanning
222
241
  - Code review can identify missing logging in authentication and authorization
223
242
  paths
224
243
 
225
244
  **Mitigation:**
245
+
226
246
  - Log all authentication events (success and failure)
227
247
  - Log access control failures
228
248
  - Log input validation failures
@@ -238,10 +258,12 @@ inability to detect active breaches.
238
258
  without validating the destination, allowing attackers to reach internal services.
239
259
 
240
260
  **Scanner detection:**
261
+
241
262
  - `code_security_scanner.py` -- regex patterns for URL fetching with user input
242
263
  (requests.get with unvalidated variables)
243
264
 
244
265
  **Remediation (Python):**
266
+
245
267
  ```python
246
268
  # BAD: Fetch user-supplied URL directly
247
269
  response = requests.get(user_url)
@@ -8,17 +8,20 @@ the vulnerable pattern, the fix, and a verification command.
8
8
  ## SQL Injection
9
9
 
10
10
  **Vulnerable pattern (Python):**
11
+
11
12
  ```python
12
13
  query = "SELECT * FROM users WHERE username = '" + username + "'"
13
14
  cursor.execute(query)
14
15
  ```
15
16
 
16
17
  **Fix (Python - parameterized query):**
18
+
17
19
  ```python
18
20
  cursor.execute("SELECT * FROM users WHERE username = %s", (username,))
19
21
  ```
20
22
 
21
23
  **Fix (Python - SQLAlchemy):**
24
+
22
25
  ```python
23
26
  from sqlalchemy import text
24
27
  result = session.execute(text("SELECT * FROM users WHERE username = :name"),
@@ -26,22 +29,26 @@ result = session.execute(text("SELECT * FROM users WHERE username = :name"),
26
29
  ```
27
30
 
28
31
  **Vulnerable pattern (Node.js):**
32
+
29
33
  ```javascript
30
34
  const query = `SELECT * FROM users WHERE username = '${username}'`;
31
35
  db.query(query);
32
36
  ```
33
37
 
34
38
  **Fix (Node.js - parameterized):**
39
+
35
40
  ```javascript
36
41
  db.query("SELECT * FROM users WHERE username = $1", [username]);
37
42
  ```
38
43
 
39
44
  **Fix (Node.js - Knex.js):**
45
+
40
46
  ```javascript
41
47
  knex("users").where("username", username).first();
42
48
  ```
43
49
 
44
50
  **Verification:**
51
+
45
52
  ```bash
46
53
  python3 code_security_scanner.py /path/to/code --tools regex
47
54
  # Check that no SQL string concatenation findings remain
@@ -52,37 +59,44 @@ python3 code_security_scanner.py /path/to/code --tools regex
52
59
  ## Cross-Site Scripting (XSS)
53
60
 
54
61
  **Vulnerable pattern (Python/Jinja2):**
62
+
55
63
  ```python
56
64
  # Marking user input as safe bypasses auto-escaping
57
65
  return Markup(f"<p>Hello {user_input}</p>")
58
66
  ```
59
67
 
60
68
  **Fix (Python/Jinja2):**
69
+
61
70
  ```python
62
71
  # Let the template engine auto-escape (default in Jinja2)
63
72
  return render_template("greeting.html", name=user_input)
64
73
  ```
74
+
65
75
  ```html
66
76
  <!-- greeting.html - auto-escaped by default -->
67
77
  <p>Hello {{ name }}</p>
68
78
  ```
69
79
 
70
80
  **Vulnerable pattern (Node.js/Express):**
81
+
71
82
  ```javascript
72
83
  res.send(`<p>Search results for: ${req.query.q}</p>`);
73
84
  ```
74
85
 
75
86
  **Fix (Node.js - use template engine with auto-escaping):**
87
+
76
88
  ```javascript
77
89
  // With EJS (auto-escapes by default with <%= %>)
78
90
  res.render("search", { query: req.query.q });
79
91
  ```
92
+
80
93
  ```html
81
94
  <!-- search.ejs -->
82
95
  <p>Search results for: <%= query %></p>
83
96
  ```
84
97
 
85
98
  **Fix (React - auto-escapes by default):**
99
+
86
100
  ```jsx
87
101
  // React auto-escapes variables in JSX
88
102
  return <p>Search results for: {query}</p>;
@@ -90,11 +104,13 @@ return <p>Search results for: {query}</p>;
90
104
  ```
91
105
 
92
106
  **Additional protection - CSP header:**
107
+
93
108
  ```
94
109
  Content-Security-Policy: default-src 'self'; script-src 'self'
95
110
  ```
96
111
 
97
112
  **Verification:**
113
+
98
114
  ```bash
99
115
  python3 security_scanner.py https://your-site.com --checks headers
100
116
  # Verify CSP header is present and configured
@@ -105,6 +121,7 @@ python3 security_scanner.py https://your-site.com --checks headers
105
121
  ## Hardcoded Secrets
106
122
 
107
123
  **Vulnerable pattern:**
124
+
108
125
  ```python
109
126
  API_KEY = "sk-abc123def456ghi789"
110
127
  DATABASE_URL = "postgresql://admin:password123@db.example.com/prod"
@@ -112,6 +129,7 @@ AWS_SECRET_KEY = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
112
129
  ```
113
130
 
114
131
  **Fix (Python - environment variables):**
132
+
115
133
  ```python
116
134
  import os
117
135
 
@@ -121,6 +139,7 @@ AWS_SECRET_KEY = os.environ["AWS_SECRET_ACCESS_KEY"]
121
139
  ```
122
140
 
123
141
  **Fix (Python - dotenv for development):**
142
+
124
143
  ```python
125
144
  from dotenv import load_dotenv
126
145
  import os
@@ -130,6 +149,7 @@ API_KEY = os.environ["API_KEY"]
130
149
  ```
131
150
 
132
151
  **Fix (Node.js):**
152
+
133
153
  ```javascript
134
154
  // npm install dotenv
135
155
  require("dotenv").config();
@@ -139,6 +159,7 @@ const dbUrl = process.env.DATABASE_URL;
139
159
  ```
140
160
 
141
161
  **Prevention - .gitignore:**
162
+
142
163
  ```gitignore
143
164
  .env
144
165
  .env.local
@@ -149,6 +170,7 @@ credentials.json
149
170
  ```
150
171
 
151
172
  **Verification:**
173
+
152
174
  ```bash
153
175
  python3 code_security_scanner.py /path/to/code --tools regex
154
176
  # Check for hardcoded-secret findings
@@ -163,12 +185,14 @@ grep -q '.env' .gitignore && echo "OK" || echo "MISSING"
163
185
  **Vulnerable:** No security headers configured (defaults to none).
164
186
 
165
187
  **Fix (Express.js - Helmet):**
188
+
166
189
  ```javascript
167
190
  const helmet = require("helmet");
168
191
  app.use(helmet());
169
192
  ```
170
193
 
171
194
  **Fix (Django):**
195
+
172
196
  ```python
173
197
  # settings.py
174
198
  MIDDLEWARE = [
@@ -184,6 +208,7 @@ SECURE_REFERRER_POLICY = "strict-origin-when-cross-origin"
184
208
  ```
185
209
 
186
210
  **Fix (Flask):**
211
+
187
212
  ```python
188
213
  from flask_talisman import Talisman
189
214
 
@@ -195,6 +220,7 @@ Talisman(app, content_security_policy={
195
220
  ```
196
221
 
197
222
  **Verification:**
223
+
198
224
  ```bash
199
225
  python3 security_scanner.py https://your-site.com --checks headers
200
226
  # All headers should show as present
@@ -207,6 +233,7 @@ python3 security_scanner.py https://your-site.com --checks headers
207
233
  **Vulnerable:** TLS 1.0/1.1 enabled, weak cipher suites, expired certificates.
208
234
 
209
235
  **Fix (Nginx):**
236
+
210
237
  ```nginx
211
238
  ssl_protocols TLSv1.2 TLSv1.3;
212
239
  ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
@@ -217,6 +244,7 @@ ssl_session_tickets off;
217
244
  ```
218
245
 
219
246
  **Fix (Apache):**
247
+
220
248
  ```apache
221
249
  SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
222
250
  SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384
@@ -224,6 +252,7 @@ SSLHonorCipherOrder off
224
252
  ```
225
253
 
226
254
  **Certificate renewal (Let's Encrypt):**
255
+
227
256
  ```bash
228
257
  # Install certbot
229
258
  sudo certbot renew --dry-run
@@ -233,6 +262,7 @@ sudo certbot renew --dry-run
233
262
  ```
234
263
 
235
264
  **Verification:**
265
+
236
266
  ```bash
237
267
  python3 security_scanner.py https://your-site.com --checks ssl
238
268
  # Check certificate expiry and protocol version
@@ -245,6 +275,7 @@ python3 security_scanner.py https://your-site.com --checks ssl
245
275
  **Vulnerable:** Outdated packages with known CVEs.
246
276
 
247
277
  **Fix (npm):**
278
+
248
279
  ```bash
249
280
  # View vulnerabilities
250
281
  npm audit
@@ -260,6 +291,7 @@ npm install package-name@latest
260
291
  ```
261
292
 
262
293
  **Fix (Python/pip):**
294
+
263
295
  ```bash
264
296
  # Audit installed packages
265
297
  pip-audit
@@ -276,6 +308,7 @@ for pkg in json.load(sys.stdin):
276
308
  ```
277
309
 
278
310
  **Fix (Lock file hygiene):**
311
+
279
312
  ```bash
280
313
  # npm - regenerate lock file
281
314
  rm package-lock.json && npm install
@@ -285,6 +318,7 @@ pip freeze > requirements.txt
285
318
  ```
286
319
 
287
320
  **Verification:**
321
+
288
322
  ```bash
289
323
  python3 dependency_auditor.py /path/to/project
290
324
  # Should show no critical/high vulnerabilities
@@ -295,6 +329,7 @@ python3 dependency_auditor.py /path/to/project
295
329
  ## Command Injection
296
330
 
297
331
  **Vulnerable pattern (Python):**
332
+
298
333
  ```python
299
334
  import os
300
335
  os.system("ping " + user_host)
@@ -304,6 +339,7 @@ subprocess.run(f"grep {pattern} {filename}", shell=True)
304
339
  ```
305
340
 
306
341
  **Fix (Python):**
342
+
307
343
  ```python
308
344
  import subprocess
309
345
  import shlex
@@ -317,12 +353,14 @@ subprocess.run(f"grep {shlex.quote(pattern)} {shlex.quote(filename)}",
317
353
  ```
318
354
 
319
355
  **Vulnerable pattern (Node.js):**
356
+
320
357
  ```javascript
321
358
  const { exec } = require("child_process");
322
359
  exec(`ls ${userInput}`);
323
360
  ```
324
361
 
325
362
  **Fix (Node.js):**
363
+
326
364
  ```javascript
327
365
  const { execFile } = require("child_process");
328
366
  // execFile does not invoke a shell
@@ -332,6 +370,7 @@ execFile("ls", [validatedPath], (error, stdout) => {
332
370
  ```
333
371
 
334
372
  **Verification:**
373
+
335
374
  ```bash
336
375
  python3 code_security_scanner.py /path/to/code --tools bandit,regex
337
376
  # Check for command-injection category findings
@@ -342,6 +381,7 @@ python3 code_security_scanner.py /path/to/code --tools bandit,regex
342
381
  ## Insecure Deserialization
343
382
 
344
383
  **Vulnerable pattern (Python):**
384
+
345
385
  ```python
346
386
  import pickle
347
387
  data = pickle.loads(request.data) # Arbitrary code execution
@@ -351,6 +391,7 @@ config = yaml.load(user_input) # Arbitrary code execution
351
391
  ```
352
392
 
353
393
  **Fix (Python):**
394
+
354
395
  ```python
355
396
  # Use safe data formats
356
397
  import json
@@ -372,6 +413,7 @@ def verify_and_load(data, signature, secret_key):
372
413
  ```
373
414
 
374
415
  **Verification:**
416
+
375
417
  ```bash
376
418
  python3 code_security_scanner.py /path/to/code --tools bandit,regex
377
419
  # Check for insecure-deserialization category findings
@@ -382,6 +424,7 @@ python3 code_security_scanner.py /path/to/code --tools bandit,regex
382
424
  ## CORS Misconfiguration
383
425
 
384
426
  **Vulnerable:**
427
+
385
428
  ```javascript
386
429
  app.use(cors({ origin: "*", credentials: true }));
387
430
  // Or reflecting any origin:
@@ -389,6 +432,7 @@ res.setHeader("Access-Control-Allow-Origin", req.headers.origin);
389
432
  ```
390
433
 
391
434
  **Fix (Express.js):**
435
+
392
436
  ```javascript
393
437
  const allowedOrigins = ["https://app.example.com", "https://admin.example.com"];
394
438
 
@@ -407,6 +451,7 @@ app.use(cors({
407
451
  ```
408
452
 
409
453
  **Fix (Django):**
454
+
410
455
  ```python
411
456
  # pip install django-cors-headers
412
457
  CORS_ALLOWED_ORIGINS = [
@@ -417,6 +462,7 @@ CORS_ALLOW_CREDENTIALS = True
417
462
  ```
418
463
 
419
464
  **Verification:**
465
+
420
466
  ```bash
421
467
  python3 security_scanner.py https://your-api.com --checks cors
422
468
  # Should not show wildcard or reflected origin with credentials