@intentsolutionsio/penetration-tester 2.0.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/.claude-plugin/plugin.json +19 -0
- package/LICENSE +21 -0
- package/README.md +160 -0
- package/commands/pentest.md +84 -0
- package/commands/scan-headers.md +43 -0
- package/package.json +40 -0
- package/skills/performing-penetration-testing/SKILL.md +266 -0
- package/skills/performing-penetration-testing/references/OWASP_TOP_10.md +284 -0
- package/skills/performing-penetration-testing/references/REMEDIATION_PLAYBOOK.md +452 -0
- package/skills/performing-penetration-testing/references/SECURITY_HEADERS.md +365 -0
- package/skills/performing-penetration-testing/scripts/code_security_scanner.py +780 -0
- package/skills/performing-penetration-testing/scripts/dependency_auditor.py +777 -0
- package/skills/performing-penetration-testing/scripts/requirements.txt +4 -0
- package/skills/performing-penetration-testing/scripts/security_scanner.py +1166 -0
- package/skills/performing-penetration-testing/scripts/setup_pentest_env.sh +199 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# OWASP Top 10 (2021) Reference
|
|
2
|
+
|
|
3
|
+
Quick reference for the OWASP Top 10 web application security risks, with scanner
|
|
4
|
+
mapping and remediation guidance.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## A01:2021 - Broken Access Control
|
|
9
|
+
|
|
10
|
+
**What it is:** Users can act outside their intended permissions. Includes IDOR,
|
|
11
|
+
missing function-level access control, CORS misconfiguration, and privilege
|
|
12
|
+
escalation.
|
|
13
|
+
|
|
14
|
+
**Scanner detection:**
|
|
15
|
+
- `security_scanner.py` -- checks CORS policy for wildcard origins, reflected
|
|
16
|
+
origins, and credentials with wildcard
|
|
17
|
+
- `code_security_scanner.py` -- flags missing authorization decorators (regex)
|
|
18
|
+
|
|
19
|
+
**Remediation (Python/Flask):**
|
|
20
|
+
```python
|
|
21
|
+
# BAD: No authorization check
|
|
22
|
+
@app.route("/api/users/<user_id>")
|
|
23
|
+
def get_user(user_id):
|
|
24
|
+
return db.get_user(user_id)
|
|
25
|
+
|
|
26
|
+
# GOOD: Verify the requesting user has access
|
|
27
|
+
@app.route("/api/users/<user_id>")
|
|
28
|
+
@login_required
|
|
29
|
+
def get_user(user_id):
|
|
30
|
+
if current_user.id != user_id and not current_user.is_admin:
|
|
31
|
+
abort(403)
|
|
32
|
+
return db.get_user(user_id)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Remediation (Node.js/Express):**
|
|
36
|
+
```javascript
|
|
37
|
+
// Middleware: verify resource ownership
|
|
38
|
+
function authorizeUser(req, res, next) {
|
|
39
|
+
if (req.user.id !== req.params.userId && !req.user.isAdmin) {
|
|
40
|
+
return res.status(403).json({ error: "Forbidden" });
|
|
41
|
+
}
|
|
42
|
+
next();
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## A02:2021 - Cryptographic Failures
|
|
49
|
+
|
|
50
|
+
**What it is:** Sensitive data exposed due to weak or missing encryption. Includes
|
|
51
|
+
plaintext transmission, weak hashing algorithms, and improper key management.
|
|
52
|
+
|
|
53
|
+
**Scanner detection:**
|
|
54
|
+
- `security_scanner.py` -- checks SSL/TLS certificate validity, protocol version,
|
|
55
|
+
HSTS header presence and max-age
|
|
56
|
+
- `code_security_scanner.py` -- flags MD5/SHA1 usage, insecure URLs (http://)
|
|
57
|
+
|
|
58
|
+
**Remediation:**
|
|
59
|
+
```python
|
|
60
|
+
# BAD: Weak hashing
|
|
61
|
+
import hashlib
|
|
62
|
+
hashed = hashlib.md5(password.encode()).hexdigest()
|
|
63
|
+
|
|
64
|
+
# GOOD: Use bcrypt or argon2
|
|
65
|
+
from argon2 import PasswordHasher
|
|
66
|
+
ph = PasswordHasher()
|
|
67
|
+
hashed = ph.hash(password)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## A03:2021 - Injection
|
|
73
|
+
|
|
74
|
+
**What it is:** Untrusted data sent to an interpreter as part of a command or query.
|
|
75
|
+
Includes SQL injection, NoSQL injection, OS command injection, and LDAP injection.
|
|
76
|
+
|
|
77
|
+
**Scanner detection:**
|
|
78
|
+
- `code_security_scanner.py` -- bandit flags (B608 SQL injection, B602 subprocess
|
|
79
|
+
shell=True, B307 eval); regex patterns for string concatenation in queries,
|
|
80
|
+
os.system calls, eval/exec usage
|
|
81
|
+
|
|
82
|
+
**Remediation (SQL - Python):**
|
|
83
|
+
```python
|
|
84
|
+
# BAD: String concatenation
|
|
85
|
+
cursor.execute("SELECT * FROM users WHERE name = '" + name + "'")
|
|
86
|
+
|
|
87
|
+
# GOOD: Parameterized query
|
|
88
|
+
cursor.execute("SELECT * FROM users WHERE name = %s", (name,))
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Remediation (Command - Python):**
|
|
92
|
+
```python
|
|
93
|
+
# BAD: Shell injection
|
|
94
|
+
os.system("ping " + user_input)
|
|
95
|
+
|
|
96
|
+
# GOOD: Use subprocess with list args
|
|
97
|
+
subprocess.run(["ping", "-c", "1", validated_host], shell=False)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## A04:2021 - Insecure Design
|
|
103
|
+
|
|
104
|
+
**What it is:** Flaws in the design and architecture of the application rather than
|
|
105
|
+
implementation bugs. Missing threat modeling, insecure business logic.
|
|
106
|
+
|
|
107
|
+
**Scanner detection:**
|
|
108
|
+
- Not directly detectable by automated tools
|
|
109
|
+
- `code_security_scanner.py` can flag patterns that suggest design issues (e.g.,
|
|
110
|
+
no rate limiting, missing input validation at boundaries)
|
|
111
|
+
|
|
112
|
+
**Mitigation:**
|
|
113
|
+
- Use threat modeling (STRIDE, DREAD) during design
|
|
114
|
+
- Implement defense in depth
|
|
115
|
+
- Apply principle of least privilege
|
|
116
|
+
- Use secure design patterns (input validation, output encoding)
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## A05:2021 - Security Misconfiguration
|
|
121
|
+
|
|
122
|
+
**What it is:** Missing security hardening, default credentials, unnecessary
|
|
123
|
+
features enabled, verbose error messages, misconfigured permissions.
|
|
124
|
+
|
|
125
|
+
**Scanner detection:**
|
|
126
|
+
- `security_scanner.py` -- checks all security headers, server version disclosure,
|
|
127
|
+
exposed admin endpoints, directory listing, dangerous HTTP methods enabled
|
|
128
|
+
- `dependency_auditor.py` -- flags outdated packages with known vulnerabilities
|
|
129
|
+
|
|
130
|
+
**Remediation:**
|
|
131
|
+
- Remove default accounts and passwords
|
|
132
|
+
- Disable directory listing
|
|
133
|
+
- Remove server version headers
|
|
134
|
+
- Configure security headers (see SECURITY_HEADERS.md)
|
|
135
|
+
- Disable unnecessary HTTP methods
|
|
136
|
+
- Review and minimize exposed endpoints
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## A06:2021 - Vulnerable and Outdated Components
|
|
141
|
+
|
|
142
|
+
**What it is:** Using libraries, frameworks, or other software components with
|
|
143
|
+
known vulnerabilities.
|
|
144
|
+
|
|
145
|
+
**Scanner detection:**
|
|
146
|
+
- `dependency_auditor.py` -- runs npm audit and pip-audit to find CVEs in
|
|
147
|
+
installed packages, reports severity and available fix versions
|
|
148
|
+
|
|
149
|
+
**Remediation:**
|
|
150
|
+
```bash
|
|
151
|
+
# Check npm vulnerabilities
|
|
152
|
+
npm audit
|
|
153
|
+
|
|
154
|
+
# Auto-fix where possible
|
|
155
|
+
npm audit fix
|
|
156
|
+
|
|
157
|
+
# Check Python dependencies
|
|
158
|
+
pip-audit
|
|
159
|
+
|
|
160
|
+
# Update specific package
|
|
161
|
+
pip install --upgrade package-name
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## A07:2021 - Identification and Authentication Failures
|
|
167
|
+
|
|
168
|
+
**What it is:** Weak authentication mechanisms, credential stuffing, brute force,
|
|
169
|
+
session fixation, missing MFA.
|
|
170
|
+
|
|
171
|
+
**Scanner detection:**
|
|
172
|
+
- `security_scanner.py` -- checks for session cookie security attributes
|
|
173
|
+
(Secure, HttpOnly, SameSite)
|
|
174
|
+
- `code_security_scanner.py` -- flags hardcoded passwords and tokens
|
|
175
|
+
|
|
176
|
+
**Remediation:**
|
|
177
|
+
- Implement MFA
|
|
178
|
+
- Never ship default credentials
|
|
179
|
+
- Implement account lockout / rate limiting
|
|
180
|
+
- Use strong password hashing (bcrypt, argon2)
|
|
181
|
+
- Rotate session IDs after authentication
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## A08:2021 - Software and Data Integrity Failures
|
|
186
|
+
|
|
187
|
+
**What it is:** Code and infrastructure that does not protect against integrity
|
|
188
|
+
violations. Includes insecure deserialization, unsigned updates, untrusted CI/CD
|
|
189
|
+
pipelines.
|
|
190
|
+
|
|
191
|
+
**Scanner detection:**
|
|
192
|
+
- `code_security_scanner.py` -- bandit flags B301 (pickle), B506 (yaml.load
|
|
193
|
+
without SafeLoader); regex patterns for marshal.loads, insecure deserialization
|
|
194
|
+
|
|
195
|
+
**Remediation (Python):**
|
|
196
|
+
```python
|
|
197
|
+
# BAD: Insecure deserialization
|
|
198
|
+
import pickle
|
|
199
|
+
data = pickle.loads(user_input)
|
|
200
|
+
|
|
201
|
+
# GOOD: Use safe formats
|
|
202
|
+
import json
|
|
203
|
+
data = json.loads(user_input)
|
|
204
|
+
|
|
205
|
+
# BAD: Unsafe YAML loading
|
|
206
|
+
import yaml
|
|
207
|
+
data = yaml.load(content)
|
|
208
|
+
|
|
209
|
+
# GOOD: Use SafeLoader
|
|
210
|
+
data = yaml.safe_load(content)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## A09:2021 - Security Logging and Monitoring Failures
|
|
216
|
+
|
|
217
|
+
**What it is:** Insufficient logging of security events, missing alerting, and
|
|
218
|
+
inability to detect active breaches.
|
|
219
|
+
|
|
220
|
+
**Scanner detection:**
|
|
221
|
+
- Not directly detectable by automated scanning
|
|
222
|
+
- Code review can identify missing logging in authentication and authorization
|
|
223
|
+
paths
|
|
224
|
+
|
|
225
|
+
**Mitigation:**
|
|
226
|
+
- Log all authentication events (success and failure)
|
|
227
|
+
- Log access control failures
|
|
228
|
+
- Log input validation failures
|
|
229
|
+
- Ensure logs are tamper-proof
|
|
230
|
+
- Implement alerting for anomalous patterns
|
|
231
|
+
- Test that logging and alerting work
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## A10:2021 - Server-Side Request Forgery (SSRF)
|
|
236
|
+
|
|
237
|
+
**What it is:** Application fetches remote resources based on user-supplied URLs
|
|
238
|
+
without validating the destination, allowing attackers to reach internal services.
|
|
239
|
+
|
|
240
|
+
**Scanner detection:**
|
|
241
|
+
- `code_security_scanner.py` -- regex patterns for URL fetching with user input
|
|
242
|
+
(requests.get with unvalidated variables)
|
|
243
|
+
|
|
244
|
+
**Remediation (Python):**
|
|
245
|
+
```python
|
|
246
|
+
# BAD: Fetch user-supplied URL directly
|
|
247
|
+
response = requests.get(user_url)
|
|
248
|
+
|
|
249
|
+
# GOOD: Validate against allowlist
|
|
250
|
+
from urllib.parse import urlparse
|
|
251
|
+
ALLOWED_HOSTS = {"api.example.com", "cdn.example.com"}
|
|
252
|
+
|
|
253
|
+
parsed = urlparse(user_url)
|
|
254
|
+
if parsed.hostname not in ALLOWED_HOSTS:
|
|
255
|
+
raise ValueError("URL not in allowlist")
|
|
256
|
+
if parsed.scheme not in ("http", "https"):
|
|
257
|
+
raise ValueError("Invalid scheme")
|
|
258
|
+
response = requests.get(user_url, allow_redirects=False)
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Scanner Quick Reference
|
|
264
|
+
|
|
265
|
+
| OWASP Risk | security_scanner.py | dependency_auditor.py | code_security_scanner.py |
|
|
266
|
+
|------------|--------------------|-----------------------|--------------------------|
|
|
267
|
+
| A01 Access Control | CORS checks | -- | Auth pattern checks |
|
|
268
|
+
| A02 Crypto Failures | SSL/TLS, HSTS | -- | MD5/SHA1, http:// |
|
|
269
|
+
| A03 Injection | -- | -- | SQLi, CMDi, eval |
|
|
270
|
+
| A04 Insecure Design | -- | -- | -- (manual review) |
|
|
271
|
+
| A05 Misconfiguration | Headers, endpoints | Outdated packages | -- |
|
|
272
|
+
| A06 Vulnerable Components | -- | npm/pip audit | -- |
|
|
273
|
+
| A07 Auth Failures | Cookie attributes | -- | Hardcoded secrets |
|
|
274
|
+
| A08 Integrity Failures | -- | -- | pickle, yaml.load |
|
|
275
|
+
| A09 Logging Failures | -- | -- | -- (manual review) |
|
|
276
|
+
| A10 SSRF | -- | -- | URL fetch patterns |
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Further Reading
|
|
281
|
+
|
|
282
|
+
- [OWASP Top 10 Official](https://owasp.org/www-project-top-ten/)
|
|
283
|
+
- [OWASP Cheat Sheet Series](https://cheatsheetseries.owasp.org/)
|
|
284
|
+
- [CWE Top 25](https://cwe.mitre.org/top25/archive/2023/2023_top25_list.html)
|