-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathowasp-top10.html
More file actions
749 lines (706 loc) · 33 KB
/
owasp-top10.html
File metadata and controls
749 lines (706 loc) · 33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="images/logo.png">
<link rel="apple-touch-icon" href="images/logo.png">
<title>OWASP Top 10 - DevDunia</title>
<meta name="description" content="Learn about OWASP Top 10 security vulnerabilities with examples, prevention methods, and interactive demonstrations.">
<meta name="keywords" content="OWASP, security vulnerabilities, web security, penetration testing, vulnerability assessment">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://devdunia.com/owasp-top10.html">
<meta property="og:title" content="OWASP Top 10 - DevDunia">
<meta property="og:description" content="Learn about OWASP Top 10 security vulnerabilities with examples, prevention methods, and interactive demonstrations.">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://devdunia.com/owasp-top10.html">
<meta property="twitter:title" content="OWASP Top 10 - DevDunia">
<meta property="twitter:description" content="Learn about OWASP Top 10 security vulnerabilities with examples, prevention methods, and interactive demonstrations.">
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<style>
.glass {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.vulnerability-card {
transition: all 0.3s ease;
cursor: pointer;
}
.vulnerability-card:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}
.vulnerability-card.active {
border-color: #3b82f6;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.example-code {
background: #1e293b;
color: #e2e8f0;
font-family: 'Courier New', monospace;
border-radius: 8px;
padding: 1rem;
overflow-x: auto;
}
.severity-critical { border-left: 4px solid #dc2626; }
.severity-high { border-left: 4px solid #ea580c; }
.severity-medium { border-left: 4px solid #d97706; }
.severity-low { border-left: 4px solid #16a34a; }
</style>
</head>
<body class="min-h-screen bg-gradient-to-br from-slate-900 via-purple-900 to-slate-900">
<!-- Navbar -->
<div id="navbar-container"></div>
<!-- Sidebar -->
<div id="sidebar-container"></div>
<!-- Main Content -->
<main class="h-screen lg:ml-72 flex flex-col">
<!-- Header -->
<header class="bg-gradient-to-r from-blue-600 to-indigo-500 text-white p-6">
<div class="container mx-auto">
<h1 class="text-3xl font-bold mb-2">
<i class="fas fa-shield-alt mr-3"></i>
OWASP Top 10 Security Vulnerabilities
</h1>
<p class="text-lg opacity-90">
Learn about the most critical web application security risks with examples and prevention methods
</p>
</div>
</header>
<!-- Content -->
<div class="flex-1 p-6 overflow-y-auto">
<div class="container mx-auto">
<!-- Introduction -->
<div class="glass rounded-lg p-6 mb-6">
<h2 class="text-2xl font-bold text-white mb-4">
<i class="fas fa-info-circle mr-2 text-blue-400"></i>
What is OWASP Top 10?
</h2>
<p class="text-gray-300 mb-4">
The OWASP Top 10 is a standard awareness document for developers and web application security.
It represents a broad consensus about the most critical security risks to web applications.
</p>
<div class="bg-blue-900/30 border border-blue-500/30 rounded-lg p-4">
<p class="text-blue-200">
<strong>Note:</strong> This tool is for educational purposes only. Always ensure you have proper authorization before testing security vulnerabilities.
</p>
</div>
</div>
<!-- OWASP Top 10 List -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6">
<!-- A01: Broken Access Control -->
<div class="vulnerability-card glass rounded-lg p-6 severity-critical" data-vuln="a01">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-white">A01: Broken Access Control</h3>
<span class="bg-red-600 text-white px-3 py-1 rounded-full text-sm font-semibold">Critical</span>
</div>
<p class="text-gray-300 mb-4">
Restrictions on what authenticated users are allowed to do are not properly enforced.
</p>
<div class="flex items-center text-sm text-gray-400">
<i class="fas fa-chart-line mr-2"></i>
<span>94% of applications tested</span>
</div>
</div>
<!-- A02: Cryptographic Failures -->
<div class="vulnerability-card glass rounded-lg p-6 severity-critical" data-vuln="a02">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-white">A02: Cryptographic Failures</h3>
<span class="bg-red-600 text-white px-3 py-1 rounded-full text-sm font-semibold">Critical</span>
</div>
<p class="text-gray-300 mb-4">
Failures related to cryptography which often lead to sensitive data exposure.
</p>
<div class="flex items-center text-sm text-gray-400">
<i class="fas fa-lock mr-2"></i>
<span>Previously "Sensitive Data Exposure"</span>
</div>
</div>
<!-- A03: Injection -->
<div class="vulnerability-card glass rounded-lg p-6 severity-critical" data-vuln="a03">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-white">A03: Injection</h3>
<span class="bg-red-600 text-white px-3 py-1 rounded-full text-sm font-semibold">Critical</span>
</div>
<p class="text-gray-300 mb-4">
SQL, NoSQL, OS, and LDAP injection flaws occur when untrusted data is sent to an interpreter.
</p>
<div class="flex items-center text-sm text-gray-400">
<i class="fas fa-database mr-2"></i>
<span>SQL, NoSQL, OS, LDAP</span>
</div>
</div>
<!-- A04: Insecure Design -->
<div class="vulnerability-card glass rounded-lg p-6 severity-high" data-vuln="a04">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-white">A04: Insecure Design</h3>
<span class="bg-orange-600 text-white px-3 py-1 rounded-full text-sm font-semibold">High</span>
</div>
<p class="text-gray-300 mb-4">
Risks related to design and architectural flaws, with a focus on secure design patterns.
</p>
<div class="flex items-center text-sm text-gray-400">
<i class="fas fa-architecture mr-2"></i>
<span>New in 2021</span>
</div>
</div>
<!-- A05: Security Misconfiguration -->
<div class="vulnerability-card glass rounded-lg p-6 severity-high" data-vuln="a05">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-white">A05: Security Misconfiguration</h3>
<span class="bg-orange-600 text-white px-3 py-1 rounded-full text-sm font-semibold">High</span>
</div>
<p class="text-gray-300 mb-4">
Security misconfiguration is the most commonly seen issue, often due to insecure default configurations.
</p>
<div class="flex items-center text-sm text-gray-400">
<i class="fas fa-cog mr-2"></i>
<span>90% of applications</span>
</div>
</div>
<!-- A06: Vulnerable Components -->
<div class="vulnerability-card glass rounded-lg p-6 severity-high" data-vuln="a06">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-white">A06: Vulnerable Components</h3>
<span class="bg-orange-600 text-white px-3 py-1 rounded-full text-sm font-semibold">High</span>
</div>
<p class="text-gray-300 mb-4">
Using components with known vulnerabilities, including libraries, frameworks, and other software modules.
</p>
<div class="flex items-center text-sm text-gray-400">
<i class="fas fa-puzzle-piece mr-2"></i>
<span>Previously "Using Components"</span>
</div>
</div>
<!-- A07: Authentication Failures -->
<div class="vulnerability-card glass rounded-lg p-6 severity-high" data-vuln="a07">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-white">A07: Authentication Failures</h3>
<span class="bg-orange-600 text-white px-3 py-1 rounded-full text-sm font-semibold">High</span>
</div>
<p class="text-gray-300 mb-4">
Confirmation of the user's identity, authentication, and session management is critical.
</p>
<div class="flex items-center text-sm text-gray-400">
<i class="fas fa-user-shield mr-2"></i>
<span>Previously "Broken Authentication"</span>
</div>
</div>
<!-- A08: Software and Data Integrity Failures -->
<div class="vulnerability-card glass rounded-lg p-6 severity-medium" data-vuln="a08">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-white">A08: Software and Data Integrity Failures</h3>
<span class="bg-yellow-600 text-white px-3 py-1 rounded-full text-sm font-semibold">Medium</span>
</div>
<p class="text-gray-300 mb-4">
Software and data integrity failures relate to code and infrastructure that does not protect against integrity violations.
</p>
<div class="flex items-center text-sm text-gray-400">
<i class="fas fa-check-double mr-2"></i>
<span>New in 2021</span>
</div>
</div>
<!-- A09: Security Logging Failures -->
<div class="vulnerability-card glass rounded-lg p-6 severity-medium" data-vuln="a09">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-white">A09: Security Logging Failures</h3>
<span class="bg-yellow-600 text-white px-3 py-1 rounded-full text-sm font-semibold">Medium</span>
</div>
<p class="text-gray-300 mb-4">
Insufficient logging and monitoring, coupled with ineffective or non-existent incident response.
</p>
<div class="flex items-center text-sm text-gray-400">
<i class="fas fa-clipboard-list mr-2"></i>
<span>Previously "Insufficient Logging"</span>
</div>
</div>
<!-- A10: Server-Side Request Forgery -->
<div class="vulnerability-card glass rounded-lg p-6 severity-medium" data-vuln="a10">
<div class="flex items-center justify-between mb-4">
<h3 class="text-xl font-bold text-white">A10: Server-Side Request Forgery</h3>
<span class="bg-yellow-600 text-white px-3 py-1 rounded-full text-sm font-semibold">Medium</span>
</div>
<p class="text-gray-300 mb-4">
SSRF flaws occur whenever a web application is fetching a remote resource without validating the user-supplied URL.
</p>
<div class="flex items-center text-sm text-gray-400">
<i class="fas fa-external-link-alt mr-2"></i>
<span>New in 2021</span>
</div>
</div>
</div>
<!-- Detailed Information Panel -->
<div id="vulnerability-details" class="glass rounded-lg p-6 hidden">
<div id="vulnerability-content"></div>
</div>
<!-- Prevention Guidelines -->
<div class="glass rounded-lg p-6">
<h2 class="text-2xl font-bold text-white mb-4">
<i class="fas fa-shield-alt mr-2 text-green-400"></i>
General Prevention Guidelines
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<div class="bg-green-900/30 border border-green-500/30 rounded-lg p-4">
<h3 class="font-bold text-green-300 mb-2">Input Validation</h3>
<p class="text-green-200 text-sm">Validate and sanitize all user inputs</p>
</div>
<div class="bg-blue-900/30 border border-blue-500/30 rounded-lg p-4">
<h3 class="font-bold text-blue-300 mb-2">Authentication</h3>
<p class="text-blue-200 text-sm">Implement strong authentication mechanisms</p>
</div>
<div class="bg-purple-900/30 border border-purple-500/30 rounded-lg p-4">
<h3 class="font-bold text-purple-300 mb-2">Authorization</h3>
<p class="text-purple-200 text-sm">Enforce proper access controls</p>
</div>
<div class="bg-yellow-900/30 border border-yellow-500/30 rounded-lg p-4">
<h3 class="font-bold text-yellow-300 mb-2">Encryption</h3>
<p class="text-yellow-200 text-sm">Encrypt sensitive data in transit and at rest</p>
</div>
<div class="bg-red-900/30 border border-red-500/30 rounded-lg p-4">
<h3 class="font-bold text-red-300 mb-2">Logging</h3>
<p class="text-red-200 text-sm">Implement comprehensive logging and monitoring</p>
</div>
<div class="bg-indigo-900/30 border border-indigo-500/30 rounded-lg p-4">
<h3 class="font-bold text-indigo-300 mb-2">Updates</h3>
<p class="text-indigo-200 text-sm">Keep all components updated</p>
</div>
</div>
</div>
</div>
</div>
</main>
<script>
// Load navbar and sidebar
document.addEventListener('DOMContentLoaded', function() {
// Load navbar
fetch('navbar.html')
.then(response => response.text())
.then(data => {
document.getElementById('navbar-container').innerHTML = data;
})
.catch(error => console.error('Error loading navbar:', error));
// Load sidebar
fetch('final_sidebar.html')
.then(response => response.text())
.then(data => {
document.getElementById('sidebar-container').innerHTML = data;
})
.catch(error => console.error('Error loading sidebar:', error));
});
// Vulnerability data
const vulnerabilities = {
a01: {
title: "A01: Broken Access Control",
description: "Restrictions on what authenticated users are allowed to do are not properly enforced.",
examples: [
{
type: "Directory Traversal",
code: `// Vulnerable code
app.get('/files/:filename', (req, res) => {
const filename = req.params.filename;
res.sendFile(filename); // No validation!
});
// Secure code
app.get('/files/:filename', (req, res) => {
const filename = path.basename(req.params.filename);
const filepath = path.join('/safe/directory/', filename);
if (filepath.startsWith('/safe/directory/')) {
res.sendFile(filepath);
} else {
res.status(403).send('Access denied');
}
});`
},
{
type: "IDOR (Insecure Direct Object Reference)",
code: `// Vulnerable code
app.get('/user/:id', (req, res) => {
const user = getUserById(req.params.id);
res.json(user); // No authorization check!
// Secure code
app.get('/user/:id', authenticateToken, (req, res) => {
if (req.user.id !== parseInt(req.params.id)) {
return res.status(403).send('Access denied');
}
const user = getUserById(req.params.id);
res.json(user);
});`
}
],
prevention: [
"Implement proper access controls",
"Use principle of least privilege",
"Validate user permissions for each request",
"Use indirect object references",
"Implement proper session management"
]
},
a02: {
title: "A02: Cryptographic Failures",
description: "Failures related to cryptography which often lead to sensitive data exposure.",
examples: [
{
type: "Weak Encryption",
code: `// Vulnerable code
const crypto = require('crypto');
const password = 'user123';
const hash = crypto.createHash('md5').update(password).digest('hex');
// Secure code
const bcrypt = require('bcrypt');
const saltRounds = 12;
const hash = await bcrypt.hash(password, saltRounds);`
},
{
type: "Plain Text Storage",
code: `// Vulnerable code
const user = {
username: 'john',
password: 'plaintext123' // Never store plain text!
};
// Secure code
const user = {
username: 'john',
password: await bcrypt.hash('plaintext123', 12),
salt: generateRandomSalt()
};`
}
],
prevention: [
"Use strong encryption algorithms (AES-256, RSA-2048+)",
"Hash passwords with bcrypt, scrypt, or Argon2",
"Use HTTPS for all communications",
"Implement proper key management",
"Never store sensitive data in plain text"
]
},
a03: {
title: "A03: Injection",
description: "SQL, NoSQL, OS, and LDAP injection flaws occur when untrusted data is sent to an interpreter.",
examples: [
{
type: "SQL Injection",
code: `// Vulnerable code
const query = "SELECT * FROM users WHERE username = '" + username + "'";
db.query(query, (err, result) => {
// Direct string concatenation - vulnerable!
});
// Secure code
const query = "SELECT * FROM users WHERE username = ?";
db.query(query, [username], (err, result) => {
// Parameterized queries - secure!
});`
},
{
type: "NoSQL Injection",
code: `// Vulnerable code
const user = await User.findOne({
username: req.body.username,
password: req.body.password
});
// Secure code
const user = await User.findOne({
username: { $eq: req.body.username },
password: { $eq: await bcrypt.hash(req.body.password, 12) }
});`
}
],
prevention: [
"Use parameterized queries",
"Implement input validation and sanitization",
"Use ORM/ODM frameworks",
"Apply principle of least privilege to database accounts",
"Implement proper error handling"
]
},
a04: {
title: "A04: Insecure Design",
description: "Risks related to design and architectural flaws, with a focus on secure design patterns.",
examples: [
{
type: "Missing Security Controls",
code: `// Insecure design
class UserController {
updateProfile(userId, data) {
// No authorization check
return this.userService.update(userId, data);
}
}
// Secure design
class UserController {
updateProfile(userId, data, currentUser) {
// Check authorization
if (currentUser.id !== userId && !currentUser.isAdmin) {
throw new UnauthorizedError();
}
return this.userService.update(userId, data);
}
}`
}
],
prevention: [
"Implement threat modeling",
"Use secure design patterns",
"Apply security by design principles",
"Conduct security architecture reviews",
"Implement proper access controls from the start"
]
},
a05: {
title: "A05: Security Misconfiguration",
description: "Security misconfiguration is the most commonly seen issue, often due to insecure default configurations.",
examples: [
{
type: "Default Credentials",
code: `# Vulnerable configuration
# Default admin credentials
admin:admin123
# Secure configuration
# Use strong, unique credentials
admin:ComplexP@ssw0rd!2024`
},
{
type: "Debug Mode in Production",
code: `# Vulnerable configuration
DEBUG=True
SECRET_KEY=dev-key-123
# Secure configuration
DEBUG=False
SECRET_KEY=your-super-secret-production-key-here`
}
],
prevention: [
"Remove default accounts and passwords",
"Disable unnecessary features and services",
"Implement proper error handling",
"Use security headers",
"Regular security configuration reviews"
]
},
a06: {
title: "A06: Vulnerable Components",
description: "Using components with known vulnerabilities, including libraries, frameworks, and other software modules.",
examples: [
{
type: "Outdated Dependencies",
code: `# Vulnerable package.json
{
"dependencies": {
"express": "4.16.0", # Known vulnerabilities
"lodash": "4.17.10" # Outdated version
}
}
# Secure package.json
{
"dependencies": {
"express": "^4.18.2", # Latest secure version
"lodash": "^4.17.21" # Updated version
}
}`
}
],
prevention: [
"Keep all components updated",
"Use dependency scanning tools",
"Remove unused dependencies",
"Implement security monitoring",
"Use trusted sources for components"
]
},
a07: {
title: "A07: Authentication Failures",
description: "Confirmation of the user's identity, authentication, and session management is critical.",
examples: [
{
type: "Weak Session Management",
code: `// Vulnerable code
app.use(session({
secret: 'weak-secret',
cookie: { secure: false, httpOnly: false }
}));
// Secure code
app.use(session({
secret: process.env.SESSION_SECRET,
cookie: {
secure: true,
httpOnly: true,
maxAge: 3600000,
sameSite: 'strict'
}
}));`
}
],
prevention: [
"Implement strong authentication mechanisms",
"Use secure session management",
"Implement multi-factor authentication",
"Use secure password policies",
"Implement proper logout functionality"
]
},
a08: {
title: "A08: Software and Data Integrity Failures",
description: "Software and data integrity failures relate to code and infrastructure that does not protect against integrity violations.",
examples: [
{
type: "Insecure CI/CD Pipeline",
code: `# Vulnerable pipeline
# No integrity checks
deploy:
script:
- docker build -t app .
- docker push registry/app:latest
# Secure pipeline
deploy:
script:
- docker build -t app .
- docker scan app # Security scanning
- docker push registry/app:latest
- verify_signature app:latest`
}
],
prevention: [
"Implement code signing",
"Use secure CI/CD pipelines",
"Implement integrity checks",
"Use secure update mechanisms",
"Implement proper access controls"
]
},
a09: {
title: "A09: Security Logging Failures",
description: "Insufficient logging and monitoring, coupled with ineffective or non-existent incident response.",
examples: [
{
type: "Insufficient Logging",
code: `// Vulnerable code
app.post('/login', (req, res) => {
const user = authenticate(req.body);
if (user) {
res.json({ success: true });
// No logging of login attempts
}
});
// Secure code
app.post('/login', (req, res) => {
const user = authenticate(req.body);
if (user) {
logger.info('Successful login', {
userId: user.id,
ip: req.ip,
userAgent: req.get('User-Agent')
});
res.json({ success: true });
} else {
logger.warn('Failed login attempt', {
ip: req.ip,
userAgent: req.get('User-Agent')
});
res.status(401).json({ error: 'Invalid credentials' });
}
});`
}
],
prevention: [
"Implement comprehensive logging",
"Use centralized logging systems",
"Implement real-time monitoring",
"Create incident response plans",
"Regular log analysis and review"
]
},
a10: {
title: "A10: Server-Side Request Forgery",
description: "SSRF flaws occur whenever a web application is fetching a remote resource without validating the user-supplied URL.",
examples: [
{
type: "Unvalidated URL Fetching",
code: `// Vulnerable code
app.get('/fetch', (req, res) => {
const url = req.query.url;
fetch(url).then(response => {
res.json(response);
}); // No URL validation!
});
// Secure code
app.get('/fetch', (req, res) => {
const url = req.query.url;
const allowedHosts = ['api.example.com', 'cdn.example.com'];
try {
const urlObj = new URL(url);
if (!allowedHosts.includes(urlObj.hostname)) {
return res.status(400).json({ error: 'Invalid URL' });
}
fetch(url).then(response => {
res.json(response);
});
} catch (error) {
res.status(400).json({ error: 'Invalid URL format' });
}
});`
}
],
prevention: [
"Validate and sanitize URLs",
"Use allowlists for allowed hosts",
"Implement network segmentation",
"Use outbound proxies",
"Implement proper error handling"
]
}
};
// Add click handlers to vulnerability cards
document.addEventListener('DOMContentLoaded', function() {
const cards = document.querySelectorAll('.vulnerability-card');
const detailsPanel = document.getElementById('vulnerability-details');
const contentDiv = document.getElementById('vulnerability-content');
cards.forEach(card => {
card.addEventListener('click', function() {
// Remove active class from all cards
cards.forEach(c => c.classList.remove('active'));
// Add active class to clicked card
this.classList.add('active');
const vulnId = this.getAttribute('data-vuln');
const vuln = vulnerabilities[vulnId];
if (vuln) {
contentDiv.innerHTML = `
<div class="mb-6">
<h3 class="text-2xl font-bold text-white mb-4">${vuln.title}</h3>
<p class="text-gray-300 mb-6">${vuln.description}</p>
</div>
<div class="mb-6">
<h4 class="text-xl font-bold text-white mb-4">
<i class="fas fa-code mr-2 text-yellow-400"></i>
Examples
</h4>
${vuln.examples.map(example => `
<div class="mb-4">
<h5 class="font-bold text-yellow-300 mb-2">${example.type}</h5>
<div class="example-code">
<pre>${example.code}</pre>
</div>
</div>
`).join('')}
</div>
<div>
<h4 class="text-xl font-bold text-white mb-4">
<i class="fas fa-shield-alt mr-2 text-green-400"></i>
Prevention Methods
</h4>
<ul class="list-disc list-inside text-gray-300 space-y-2">
${vuln.prevention.map(method => `<li>${method}</li>`).join('')}
</ul>
</div>
`;
detailsPanel.classList.remove('hidden');
detailsPanel.scrollIntoView({ behavior: 'smooth' });
}
});
});
});
</script>
</body>
</html>