mirror of
https://github.com/hanzoai/skills.git
synced 2026-11-19 00:47:36 +00:00
hanzoskills.com/llms.txt now opens with the install line, the API reference index and the company index, so an agent that lands on any one of the three can find the rest. robots.txt claimed 537 documents while llms.txt counts 920. The number is gone from robots.txt; llms.txt derives it. public/ is regenerated from scripts/site.py, which it had fallen behind: the copy-prompt menu and agent bar were in the generator and not in the committed pages. tests/site.mjs passes against the result. Co-authored-by: Hanzo Dev <[email protected]>
836 lines
38 KiB
HTML
836 lines
38 KiB
HTML
<!doctype html>
|
|
<html lang="en"><head>
|
|
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>security-vulnerability-assessment</title>
|
|
<meta name="color-scheme" content="dark">
|
|
<style>
|
|
/* Committed to one visual world: a dark instrument panel. No light variant โ
|
|
the dot field and the hairline rules only read on black, and a naive
|
|
inversion would wash both out. Every colour is painted explicitly so the page
|
|
never borrows a host background. */
|
|
@font-face{font-family:'Zen';src:url('/fonts/Zen-Variable.woff2') format('woff2');font-weight:100 900;font-style:normal;font-display:swap}
|
|
@font-face{font-family:'Zen';src:url('/fonts/Zen-Italic-Variable.woff2') format('woff2');font-weight:100 900;font-style:italic;font-display:swap}
|
|
@font-face{font-family:'Zen Mono';src:url('/fonts/ZenMono-Variable.woff2') format('woff2');font-weight:100 900;font-style:normal;font-display:swap}
|
|
@font-face{font-family:'Zen Mono';src:url('/fonts/ZenMono-Italic-Variable.woff2') format('woff2');font-weight:100 900;font-style:italic;font-display:swap}
|
|
@font-face{font-family:'Zen Pixel Square';src:url('/fonts/ZenPixel-Square.woff2') format('woff2');font-style:normal;font-display:swap}
|
|
|
|
:root{
|
|
--ink:#f4f4f2; --soft:#9c9c98; --faint:#6a6a66; --ground:#000; --panel:#0a0a0a;
|
|
--line:#232323; --line-hi:#3a3a3a; --accent:#f4f4f2;
|
|
--font-zen-sans:'Zen',-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;
|
|
--font-zen-mono:'Zen Mono',ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
|
|
--font-zen-pixel-square:'Zen Pixel Square',monospace;
|
|
--mono:var(--font-zen-mono);
|
|
--sans:var(--font-zen-sans);
|
|
/* Controls are pills and surfaces are soft, as on hanzo.ai. */
|
|
--r:999px; --r-soft:14px;
|
|
}
|
|
*{box-sizing:border-box}
|
|
html{-webkit-text-size-adjust:100%}
|
|
body{margin:0;background:var(--ground);color:var(--ink);font-family:var(--sans);
|
|
font-size:16px;line-height:1.65;-webkit-font-smoothing:antialiased}
|
|
.wrap{max-width:60rem;margin:0 auto;padding:0 1.75rem}
|
|
|
|
/* The dot field. A halftone made of one repeating radial-gradient, faded out
|
|
along the diagonal by a mask so it reads as a wave rather than wallpaper. */
|
|
/* No overflow clip here: the dot field is inset to the box already, and a clip
|
|
would cut off the copy-prompt menu. */
|
|
.hero{position:relative;border-bottom:1px solid var(--line)}
|
|
.hero::before{content:"";position:absolute;inset:0;
|
|
background-image:radial-gradient(var(--line-hi) 1px, transparent 1px);
|
|
background-size:7px 7px;
|
|
-webkit-mask-image:linear-gradient(115deg,#000 0%,rgba(0,0,0,.55) 38%,transparent 72%);
|
|
mask-image:linear-gradient(115deg,#000 0%,rgba(0,0,0,.55) 38%,transparent 72%);
|
|
pointer-events:none}
|
|
.hero .wrap{position:relative;padding-top:5.5rem;padding-bottom:4rem}
|
|
|
|
nav{border-bottom:1px solid var(--line)}
|
|
nav .in{max-width:60rem;margin:0 auto;padding:1.1rem 1.75rem;display:flex;
|
|
justify-content:space-between;align-items:center;gap:1rem}
|
|
.brand{font-family:var(--mono);font-size:.85rem;letter-spacing:.14em;
|
|
text-transform:uppercase;color:var(--ink);text-decoration:none;
|
|
display:inline-flex;align-items:center;gap:.6rem}
|
|
.brand i{font-style:normal;color:var(--faint)}
|
|
.mark{width:1.15em;height:1.15em;display:block;flex:0 0 auto}
|
|
nav a.up{font-family:var(--mono);font-size:.72rem;letter-spacing:.14em;
|
|
text-transform:uppercase;color:var(--soft);text-decoration:none}
|
|
nav a.up:hover{color:var(--ink)}
|
|
|
|
h1{font-family:var(--mono);font-size:clamp(2rem,5.4vw,3.4rem);line-height:1.12;
|
|
letter-spacing:-.02em;margin:0 0 1.1rem;font-weight:500;text-wrap:balance}
|
|
h1 em{font-style:normal;color:var(--faint)}
|
|
.lede{color:var(--soft);font-size:1.05rem;max-width:52ch;margin:0 0 2.25rem}
|
|
|
|
.btns{display:flex;flex-wrap:wrap;gap:.7rem;margin:0 0 .5rem;align-items:center}
|
|
.btn{display:inline-flex;align-items:center;gap:.5rem;font-family:var(--mono);
|
|
font-size:.72rem;letter-spacing:.14em;text-transform:uppercase;
|
|
padding:.8rem 1.4rem;border:1px solid var(--line-hi);border-radius:var(--r);
|
|
color:var(--ink);text-decoration:none;background:transparent;cursor:pointer;
|
|
line-height:1.2;font-weight:400}
|
|
.btn:hover{background:#141414;text-decoration:none;border-color:var(--soft)}
|
|
.btn.solid{background:var(--ink);color:#000;border-color:var(--ink)}
|
|
.btn.solid:hover{background:#d8d8d4}
|
|
.btn .chev{width:.7em;height:.7em;flex:0 0 auto;transition:transform .15s ease}
|
|
.btn[aria-expanded="true"] .chev{transform:rotate(180deg)}
|
|
|
|
/* Copy-prompt selector. Each row copies the prompt for its own target. */
|
|
.copy{position:relative;display:inline-flex}
|
|
.menu{position:absolute;top:calc(100% + .5rem);left:0;z-index:20;min-width:21rem;
|
|
background:var(--panel);border:1px solid var(--line-hi);border-radius:var(--r-soft);
|
|
padding:.4rem;display:flex;flex-direction:column;
|
|
box-shadow:0 12px 32px rgba(0,0,0,.75)}
|
|
.menu[hidden]{display:none}
|
|
.mi{display:flex;align-items:center;gap:.7rem;width:100%;text-align:left;
|
|
padding:.62rem .8rem;border:0;border-radius:calc(var(--r-soft) - .35rem);
|
|
background:transparent;color:var(--ink);font-family:var(--mono);font-size:.76rem;
|
|
letter-spacing:.04em;text-decoration:none;cursor:pointer;line-height:1.3;
|
|
white-space:nowrap}
|
|
.mi:hover,.mi:focus-visible{background:#181818;outline:none}
|
|
.mi .mark{width:1.05rem;height:1.05rem;color:var(--soft)}
|
|
.mi:hover .mark{color:var(--ink)}
|
|
.mi u{margin-left:auto;color:var(--faint);text-decoration:none;font-size:.68rem;
|
|
letter-spacing:.1em;text-transform:uppercase}
|
|
|
|
/* Works-with bar: one scrolling row, name and mark per agent. */
|
|
.strip{border-bottom:1px solid var(--line);background:var(--panel)}
|
|
.strip .in{max-width:60rem;margin:0 auto;padding:.9rem 1.75rem;display:flex;
|
|
align-items:center;gap:1.25rem;font-family:var(--mono);font-size:.72rem;
|
|
letter-spacing:.1em;text-transform:uppercase;color:var(--faint)}
|
|
.strip b{color:var(--soft);font-weight:400;flex:0 0 auto;
|
|
border-right:1px solid var(--line);padding-right:1.25rem;align-self:stretch;
|
|
display:flex;align-items:center}
|
|
.bar{display:flex;align-items:center;gap:.5rem;flex:1 1 auto;min-width:0;
|
|
overflow-x:auto;scrollbar-width:none;scroll-snap-type:x proximity;
|
|
-webkit-overflow-scrolling:touch;
|
|
-webkit-mask-image:linear-gradient(90deg,#000 calc(100% - 3rem),transparent);
|
|
mask-image:linear-gradient(90deg,#000 calc(100% - 3rem),transparent)}
|
|
.bar::-webkit-scrollbar{display:none}
|
|
.agent{display:inline-flex;align-items:center;gap:.45rem;flex:0 0 auto;
|
|
padding:.4rem .85rem;border:1px solid var(--line);border-radius:var(--r);
|
|
color:var(--soft);white-space:nowrap;scroll-snap-align:start;
|
|
text-decoration:none;background:var(--ground)}
|
|
.agent:hover{color:var(--ink);border-color:var(--line-hi);text-decoration:none}
|
|
.agent .mark{width:.95rem;height:.95rem}
|
|
|
|
h2{font-family:var(--mono);font-size:1.1rem;letter-spacing:-.01em;margin:2.75rem 0 .75rem;font-weight:500}
|
|
h3{font-size:1rem;margin:2rem 0 .5rem;font-weight:600}
|
|
h4,h5,h6{font-size:.94rem;margin:1.5rem 0 .5rem;font-weight:600}
|
|
p{margin:0 0 1rem;max-width:70ch}
|
|
ul,ol{margin:0 0 1rem;padding-left:1.35rem;max-width:70ch}
|
|
li{margin:.22rem 0}
|
|
a{color:var(--ink);text-decoration:underline;text-underline-offset:3px;
|
|
text-decoration-color:var(--line-hi)}
|
|
a:hover{text-decoration-color:var(--ink)}
|
|
a:focus-visible{outline:1px solid var(--ink);outline-offset:3px}
|
|
code{font-family:var(--mono);font-size:.85em;background:var(--panel);
|
|
border:1px solid var(--line);border-radius:5px;padding:.1em .36em}
|
|
pre{background:var(--panel);border:1px solid var(--line);padding:1rem 1.1rem;
|
|
border-radius:var(--r-soft);overflow-x:auto;margin:0 0 1.25rem}
|
|
pre code{background:none;border:0;padding:0;font-size:.82rem;line-height:1.7}
|
|
blockquote{margin:0 0 1rem;padding-left:1rem;border-left:1px solid var(--line-hi);color:var(--soft)}
|
|
hr{border:0;border-top:1px solid var(--line);margin:2.5rem 0}
|
|
table{border-collapse:collapse;width:100%;margin:0 0 1.25rem;font-size:.92rem;
|
|
display:block;overflow-x:auto}
|
|
th,td{border:1px solid var(--line);padding:.5rem .7rem;text-align:left}
|
|
|
|
.curl{display:block;background:var(--panel);border:1px solid var(--line);
|
|
border-radius:var(--r-soft);padding:.95rem 1.1rem;font-family:var(--mono);
|
|
font-size:.8rem;color:var(--soft);overflow-x:auto;margin:0 0 2.5rem;
|
|
white-space:pre;line-height:1.9}
|
|
.curl b{color:var(--ink);font-weight:400}
|
|
.curl i{font-style:normal;color:var(--faint)}
|
|
|
|
/* index */
|
|
#q{width:100%;padding:.85rem 1.2rem;font-family:var(--mono);font-size:.85rem;color:var(--ink);
|
|
background:var(--panel);border:1px solid var(--line);border-radius:var(--r);margin:0 0 .6rem}
|
|
#q::placeholder{color:var(--faint);text-transform:uppercase;letter-spacing:.1em;font-size:.72rem}
|
|
#q:focus{outline:none;border-color:var(--soft)}
|
|
#count{color:var(--faint);font-family:var(--mono);font-size:.72rem;letter-spacing:.1em;
|
|
text-transform:uppercase;margin:0 0 2rem}
|
|
.cat{margin:2.5rem 0 .5rem;font-family:var(--mono);font-size:.7rem;letter-spacing:.16em;
|
|
text-transform:uppercase;color:var(--faint);border-bottom:1px solid var(--line);
|
|
padding-bottom:.45rem}
|
|
.row{display:block;padding:.6rem .9rem;margin:0 -.9rem;border-bottom:1px solid var(--line);
|
|
border-radius:var(--r-soft);text-decoration:none}
|
|
.row:hover{background:#0a0a0a}
|
|
.nm{font-family:var(--mono);font-size:.84rem;color:var(--ink);display:block}
|
|
.ds{color:var(--soft);font-size:.9rem;display:block;margin-top:.12rem}
|
|
footer{margin-top:4rem;padding:2rem 0 4rem;border-top:1px solid var(--line);
|
|
color:var(--faint);font-size:.85rem}
|
|
footer a{color:var(--soft)}
|
|
.fmap{display:grid;gap:1.75rem;grid-template-columns:repeat(auto-fit,minmax(11rem,1fr));
|
|
margin:0 0 2rem;font-size:.85rem}
|
|
.fmap b{display:block;font-family:var(--mono);font-size:.68rem;letter-spacing:.16em;
|
|
text-transform:uppercase;color:var(--faint);font-weight:400;margin:0 0 .6rem;
|
|
border-bottom:1px solid var(--line);padding-bottom:.4rem}
|
|
.fmap a{display:inline-block;color:var(--ink);text-decoration:none;margin:.3rem .35rem 0 0}
|
|
.fmap a:hover{text-decoration:underline}
|
|
.fmap div{color:var(--faint);line-height:1.5}
|
|
.fend{border-top:1px solid var(--line);padding-top:1.25rem;font-size:.82rem}
|
|
|
|
@media (max-width:640px){
|
|
.hero .wrap{padding-top:3.25rem;padding-bottom:2.75rem}
|
|
.btns{gap:.5rem}
|
|
.btn{padding:.75rem 1.15rem;font-size:.68rem}
|
|
.copy,.copy .btn{width:100%;justify-content:center}
|
|
.menu{left:0;right:0;min-width:0}
|
|
.strip .in{flex-direction:column;align-items:flex-start;gap:.6rem;padding:.9rem 1.75rem}
|
|
.strip b{border-right:0;padding-right:0}
|
|
.bar{width:100%}
|
|
}
|
|
</style>
|
|
<link rel="alternate" type="text/markdown" href="/security-vulnerability-assessment.md">
|
|
|
|
<link rel="icon" href="/favicon.svg">
|
|
<link rel="canonical" href="https://hanzoskills.com/security-vulnerability-assessment">
|
|
</head>
|
|
<!-- Reading this with a machine? Every page here is also plain markdown.
|
|
This one: https://hanzoskills.com/security-vulnerability-assessment.md
|
|
Index: https://hanzoskills.com/llms.txt
|
|
Corpus: https://hanzoskills.com/all.md
|
|
Append .md to any path for the markdown twin. -->
|
|
<body>
|
|
<nav><div class="in">
|
|
<a class="brand" href="/"><svg class="mark" viewBox="0 0 67 67" fill="currentColor" aria-hidden="true"><path d="M22.21 67V44.6369H0V67H22.21Z"/><path d="M66.7038 22.3184H22.2534L0.0878906 44.6367H44.4634L66.7038 22.3184Z"/><path d="M22.21 0H0V22.3184H22.21V0Z"/><path d="M66.7198 0H44.5098V22.3184H66.7198V0Z"/><path d="M66.7198 67V44.6369H44.5098V67H66.7198Z"/></svg> HANZO<i>SKILLS</i></a>
|
|
<a class="up" href="/">All skills</a>
|
|
</div></nav>
|
|
|
|
<div class="wrap">
|
|
<h1>security-vulnerability-assessment</h1><p class="lede">Security testing methodologies, OWASP Top 10, vulnerability scanning tools, and penetration testing practices</p><h1>Security: Vulnerability Assessment</h1>
|
|
<p><strong>Scope</strong>: Security testing, OWASP Top 10, scanning tools, pentesting, security audits <strong>Lines</strong>: ~390 <strong>Last Updated</strong>: 2025-10-27</p>
|
|
<h2>When to Use This Skill</h2>
|
|
<p>Activate this skill when:</p>
|
|
<ul><li>Performing security audits of applications</li><li>Testing for OWASP Top 10 vulnerabilities</li><li>Setting up automated security scanning</li><li>Conducting penetration testing</li><li>Reviewing code for security issues</li><li>Preparing for security certifications</li><li>Implementing DevSecOps practices</li></ul>
|
|
<h2>OWASP Top 10 (2021)</h2>
|
|
<h3>A01: Broken Access Control</h3>
|
|
<p><strong>Description</strong>: Unauthorized access to resources or actions</p>
|
|
<p><strong>Testing</strong>:</p>
|
|
<pre><code class="lang-python">import requests
|
|
|
|
def test_broken_access_control():
|
|
"""Test for access control vulnerabilities"""
|
|
|
|
# Test 1: IDOR (Insecure Direct Object Reference)
|
|
# Try accessing another user's resource
|
|
user1_token = login("[email protected]", "password")
|
|
user2_id = 42
|
|
|
|
response = requests.get(
|
|
f"https://api.example.com/users/{user2_id}/profile",
|
|
headers={"Authorization": f"Bearer {user1_token}"}
|
|
)
|
|
|
|
# Should return 403 Forbidden
|
|
assert response.status_code == 403, "IDOR vulnerability detected"
|
|
|
|
# Test 2: Path traversal
|
|
response = requests.get(
|
|
"https://api.example.com/files/../../etc/passwd"
|
|
)
|
|
assert response.status_code in [400, 403, 404], "Path traversal possible"
|
|
|
|
# Test 3: Privilege escalation
|
|
# Try to access admin endpoint with regular user
|
|
response = requests.get(
|
|
"https://api.example.com/admin/users",
|
|
headers={"Authorization": f"Bearer {user1_token}"}
|
|
)
|
|
assert response.status_code == 403, "Privilege escalation possible"
|
|
|
|
# Test 4: Missing authorization check
|
|
# Try to access protected resource without authentication
|
|
response = requests.get("https://api.example.com/admin/dashboard")
|
|
assert response.status_code == 401, "Missing authentication check"</code></pre>
|
|
<h3>A02: Cryptographic Failures</h3>
|
|
<p><strong>Description</strong>: Weak or missing encryption, exposed sensitive data</p>
|
|
<p><strong>Testing</strong>:</p>
|
|
<pre><code class="lang-python">def test_cryptographic_failures():
|
|
"""Test for weak cryptography"""
|
|
|
|
# Test 1: Check HTTPS enforcement
|
|
response = requests.get("http://example.com", allow_redirects=False)
|
|
assert response.status_code == 301, "HTTP not redirected to HTTPS"
|
|
assert response.headers['Location'].startswith('https://'), "No HTTPS redirect"
|
|
|
|
# Test 2: Check TLS version
|
|
import ssl
|
|
import socket
|
|
|
|
context = ssl.create_default_context()
|
|
context.minimum_version = ssl.TLSVersion.TLSv1_2
|
|
|
|
with socket.create_connection(("example.com", 443)) as sock:
|
|
with context.wrap_socket(sock, server_hostname="example.com") as ssock:
|
|
version = ssock.version()
|
|
assert version in ["TLSv1.2", "TLSv1.3"], f"Weak TLS: {version}"
|
|
|
|
# Test 3: Check for sensitive data in response
|
|
response = requests.get("https://api.example.com/users/me")
|
|
data = response.json()
|
|
|
|
# Password should never be in response
|
|
assert 'password' not in data, "Password exposed in response"
|
|
assert 'password_hash' not in data, "Password hash exposed"
|
|
|
|
# Test 4: Check cookie security
|
|
response = requests.get("https://example.com")
|
|
cookies = response.cookies
|
|
|
|
for cookie in cookies:
|
|
assert cookie.secure, f"Cookie {cookie.name} not secure"
|
|
assert cookie.has_nonstandard_attr('HttpOnly'), f"Cookie {cookie.name} not HttpOnly"</code></pre>
|
|
<h3>A03: Injection</h3>
|
|
<p><strong>Description</strong>: SQL injection, command injection, XSS</p>
|
|
<p><strong>Testing</strong>:</p>
|
|
<pre><code class="lang-python">def test_sql_injection():
|
|
"""Test for SQL injection vulnerabilities"""
|
|
|
|
# Test payloads
|
|
# Example SQL injection attack payloads - for security testing only
|
|
payloads = [
|
|
"' OR '1'='1",
|
|
"' OR '1'='1' --",
|
|
"'; DROP TABLE users; --", # Example of destructive injection payload
|
|
"' UNION SELECT NULL, NULL, NULL --",
|
|
"admin'--",
|
|
]
|
|
|
|
for payload in payloads:
|
|
response = requests.post(
|
|
"https://api.example.com/login",
|
|
json={"username": payload, "password": "test"}
|
|
)
|
|
|
|
# Should return error, not success
|
|
assert response.status_code in [400, 401], f"SQL injection with: {payload}"
|
|
|
|
# Check error message doesn't leak SQL details
|
|
assert 'SQL' not in response.text.upper(), "SQL error leaked"
|
|
assert 'syntax' not in response.text.lower(), "SQL syntax error leaked"
|
|
|
|
def test_command_injection():
|
|
"""Test for command injection"""
|
|
|
|
payloads = [
|
|
"google.com; ls -la",
|
|
"google.com && cat /etc/passwd",
|
|
"google.com | whoami",
|
|
"$(cat /etc/passwd)",
|
|
"`cat /etc/passwd`",
|
|
]
|
|
|
|
for payload in payloads:
|
|
response = requests.get(
|
|
f"https://api.example.com/ping?host={payload}"
|
|
)
|
|
|
|
# Should not execute commands
|
|
assert 'root:' not in response.text, f"Command injection: {payload}"
|
|
assert 'bin/bash' not in response.text, f"Command injection: {payload}"
|
|
|
|
def test_xss():
|
|
"""Test for XSS vulnerabilities"""
|
|
|
|
payloads = [
|
|
"<script>alert('XSS')</script>",
|
|
"<img src=x onerror=alert('XSS')>",
|
|
"javascript:alert('XSS')",
|
|
"<svg onload=alert('XSS')>",
|
|
]
|
|
|
|
for payload in payloads:
|
|
response = requests.post(
|
|
"https://example.com/comments",
|
|
json={"content": payload}
|
|
)
|
|
|
|
# Fetch the comment
|
|
comment_id = response.json()['id']
|
|
response = requests.get(f"https://example.com/comments/{comment_id}")
|
|
|
|
# Script tags should be escaped
|
|
assert '<script>' not in response.text, f"XSS vulnerability: {payload}"
|
|
assert 'onerror=' not in response.text, f"XSS vulnerability: {payload}"</code></pre>
|
|
<h3>A04: Insecure Design</h3>
|
|
<p><strong>Description</strong>: Missing or ineffective control design</p>
|
|
<p><strong>Testing</strong>:</p>
|
|
<pre><code class="lang-python">def test_insecure_design():
|
|
"""Test for design flaws"""
|
|
|
|
# Test 1: Rate limiting
|
|
for i in range(20):
|
|
response = requests.post(
|
|
"https://api.example.com/login",
|
|
json={"email": "[email protected]", "password": "wrong"}
|
|
)
|
|
|
|
# Should be rate limited after multiple attempts
|
|
assert response.status_code == 429, "No rate limiting on auth endpoint"
|
|
|
|
# Test 2: Account enumeration
|
|
response1 = requests.post(
|
|
"https://api.example.com/login",
|
|
json={"email": "[email protected]", "password": "wrong"}
|
|
)
|
|
|
|
response2 = requests.post(
|
|
"https://api.example.com/login",
|
|
json={"email": "[email protected]", "password": "wrong"}
|
|
)
|
|
|
|
# Error messages should be identical
|
|
assert response1.json()['error'] == response2.json()['error'], \
|
|
"Account enumeration possible via error messages"
|
|
|
|
# Test 3: Password reset flow
|
|
# Should require email verification
|
|
response = requests.post(
|
|
"https://api.example.com/password-reset",
|
|
json={"email": "[email protected]"}
|
|
)
|
|
|
|
# Should not reveal if email exists
|
|
assert "email sent" in response.json()['message'].lower(), \
|
|
"Password reset reveals account existence"</code></pre>
|
|
<h3>A05: Security Misconfiguration</h3>
|
|
<p><strong>Description</strong>: Insecure default configs, unnecessary features enabled</p>
|
|
<p><strong>Testing</strong>:</p>
|
|
<pre><code class="lang-python">def test_security_misconfiguration():
|
|
"""Test for misconfigurations"""
|
|
|
|
# Test 1: Security headers
|
|
response = requests.get("https://example.com")
|
|
|
|
required_headers = [
|
|
'Strict-Transport-Security',
|
|
'X-Frame-Options',
|
|
'X-Content-Type-Options',
|
|
'Content-Security-Policy'
|
|
]
|
|
|
|
for header in required_headers:
|
|
assert header in response.headers, f"Missing security header: {header}"
|
|
|
|
# Test 2: Exposed debug information
|
|
assert 'X-Powered-By' not in response.headers, "Server info exposed"
|
|
assert 'Server' not in response.headers or \
|
|
'nginx' not in response.headers.get('Server', '').lower(), \
|
|
"Detailed server version exposed"
|
|
|
|
# Test 3: Directory listing
|
|
response = requests.get("https://example.com/static/")
|
|
assert 'Index of' not in response.text, "Directory listing enabled"
|
|
|
|
# Test 4: Default credentials
|
|
default_creds = [
|
|
("admin", "admin"),
|
|
("admin", "password"),
|
|
("root", "root"),
|
|
]
|
|
|
|
for username, password in default_creds:
|
|
response = requests.post(
|
|
"https://api.example.com/login",
|
|
json={"username": username, "password": password}
|
|
)
|
|
assert response.status_code == 401, f"Default credentials work: {username}"</code></pre>
|
|
<h3>A06: Vulnerable and Outdated Components</h3>
|
|
<p><strong>Description</strong>: Using components with known vulnerabilities</p>
|
|
<p><strong>Testing</strong>:</p>
|
|
<pre><code class="lang-bash"># Python dependencies
|
|
pip install safety
|
|
safety check
|
|
|
|
pip install pip-audit
|
|
pip-audit
|
|
|
|
# Node.js dependencies
|
|
npm audit
|
|
npm audit fix
|
|
|
|
# Check Docker base images
|
|
docker scan myimage:latest
|
|
|
|
# Use Snyk
|
|
snyk test
|
|
snyk monitor
|
|
|
|
# Use Trivy
|
|
trivy image myimage:latest</code></pre>
|
|
<pre><code class="lang-python"># Automated dependency checking
|
|
import requests
|
|
import json
|
|
|
|
def check_dependencies_for_vulnerabilities(requirements_file):
|
|
"""Check Python dependencies against OSV database"""
|
|
|
|
with open(requirements_file) as f:
|
|
packages = [line.strip() for line in f if line.strip()]
|
|
|
|
vulnerabilities = []
|
|
|
|
for package in packages:
|
|
name, version = package.split('==')
|
|
|
|
response = requests.post(
|
|
'https://api.osv.dev/v1/query',
|
|
json={'package': {'name': name, 'ecosystem': 'PyPI'},
|
|
'version': version}
|
|
)
|
|
|
|
if response.status_code == 200:
|
|
data = response.json()
|
|
if 'vulns' in data and data['vulns']:
|
|
vulnerabilities.append({
|
|
'package': name,
|
|
'version': version,
|
|
'vulnerabilities': data['vulns']
|
|
})
|
|
|
|
return vulnerabilities</code></pre>
|
|
<h3>A07: Identification and Authentication Failures</h3>
|
|
<p><strong>Description</strong>: Weak authentication, session management issues</p>
|
|
<p><strong>Testing</strong>:</p>
|
|
<pre><code class="lang-python">def test_authentication_failures():
|
|
"""Test authentication mechanisms"""
|
|
|
|
# Test 1: Weak passwords accepted
|
|
weak_passwords = ["password", "12345678", "qwerty", "admin"]
|
|
|
|
for pwd in weak_passwords:
|
|
response = requests.post(
|
|
"https://api.example.com/register",
|
|
json={"email": "[email protected]", "password": pwd}
|
|
)
|
|
assert response.status_code == 400, f"Weak password accepted: {pwd}"
|
|
|
|
# Test 2: Session fixation
|
|
# Get session ID before login
|
|
session = requests.Session()
|
|
response1 = session.get("https://example.com")
|
|
session_id_before = session.cookies.get('session_id')
|
|
|
|
# Login
|
|
session.post("https://example.com/login",
|
|
json={"email": "[email protected]", "password": "password"})
|
|
|
|
# Session ID should change after login
|
|
session_id_after = session.cookies.get('session_id')
|
|
assert session_id_before != session_id_after, "Session fixation vulnerability"
|
|
|
|
# Test 3: Brute force protection
|
|
for i in range(10):
|
|
response = requests.post(
|
|
"https://api.example.com/login",
|
|
json={"email": "[email protected]", "password": "wrong"}
|
|
)
|
|
|
|
# Should be locked or rate limited
|
|
assert response.status_code in [429, 403], "No brute force protection"
|
|
|
|
# Test 4: JWT validation
|
|
# Try using expired token
|
|
expired_token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." # Test token for security validation only
|
|
response = requests.get(
|
|
"https://api.example.com/protected",
|
|
headers={"Authorization": f"Bearer {expired_token}"}
|
|
)
|
|
assert response.status_code == 401, "Expired JWT accepted"</code></pre>
|
|
<h3>A08-A10: Other OWASP Vulnerabilities</h3>
|
|
<pre><code class="lang-python">def test_software_data_integrity_failures():
|
|
"""A08: Software and Data Integrity Failures"""
|
|
|
|
# Test unsigned packages, missing integrity checks
|
|
response = requests.get("https://example.com")
|
|
html = response.text
|
|
|
|
# Check for Subresource Integrity (SRI)
|
|
if '<script src="https://cdn' in html:
|
|
assert 'integrity="sha' in html, "Missing SRI for external scripts"
|
|
|
|
def test_logging_monitoring_failures():
|
|
"""A09: Security Logging and Monitoring Failures"""
|
|
|
|
# Attempt suspicious activity
|
|
requests.post(
|
|
"https://api.example.com/login",
|
|
json={"email": "' OR '1'='1", "password": "test"}
|
|
)
|
|
|
|
# Check if activity is logged (requires access to logs)
|
|
# In practice, verify logging configuration
|
|
|
|
def test_ssrf():
|
|
"""A10: Server-Side Request Forgery"""
|
|
|
|
# Try to access internal services
|
|
payloads = [
|
|
"http://localhost:8080",
|
|
"http://127.0.0.1",
|
|
"http://169.254.169.254/latest/meta-data/", # AWS metadata
|
|
"file:///etc/passwd",
|
|
]
|
|
|
|
for payload in payloads:
|
|
response = requests.post(
|
|
"https://api.example.com/fetch-url",
|
|
json={"url": payload}
|
|
)
|
|
|
|
assert response.status_code in [400, 403], f"SSRF possible: {payload}"</code></pre>
|
|
<h2>Automated Security Scanning Tools</h2>
|
|
<h3>Static Analysis (SAST)</h3>
|
|
<pre><code class="lang-bash"># Python: Bandit
|
|
pip install bandit
|
|
bandit -r . -f json -o bandit-report.json
|
|
|
|
# Python: Semgrep
|
|
pip install semgrep
|
|
semgrep --config=auto --json --output=semgrep-report.json
|
|
|
|
# Python: Pylint security plugin
|
|
pip install pylint-security
|
|
pylint --load-plugins=pylint_security myapp/
|
|
|
|
# Node.js: ESLint with security plugins
|
|
npm install --save-dev eslint-plugin-security
|
|
eslint . --ext .js,.ts
|
|
|
|
# Go: Gosec
|
|
go install github.com/securego/gosec/v2/cmd/gosec@latest
|
|
gosec ./...</code></pre>
|
|
<h3>Dynamic Analysis (DAST)</h3>
|
|
<pre><code class="lang-bash"># OWASP ZAP (Zed Attack Proxy)
|
|
docker run -t owasp/zap2docker-stable zap-baseline.py \
|
|
-t https://example.com \
|
|
-r zap-report.html
|
|
|
|
# Burp Suite (commercial)
|
|
# Use for manual penetration testing
|
|
|
|
# Nikto (web server scanner)
|
|
nikto -h https://example.com -o nikto-report.txt
|
|
|
|
# SQLMap (SQL injection)
|
|
sqlmap -u "https://example.com/page?id=1" --batch
|
|
|
|
# Nuclei (vulnerability scanner)
|
|
nuclei -u https://example.com -t cves/</code></pre>
|
|
<h3>Dependency Scanning (SCA)</h3>
|
|
<pre><code class="lang-bash"># Python: Safety
|
|
safety check --json --output safety-report.json
|
|
|
|
# Python: pip-audit
|
|
pip-audit --format json --output pip-audit-report.json
|
|
|
|
# Node.js: npm audit
|
|
npm audit --json > npm-audit-report.json
|
|
|
|
# Node.js: Snyk
|
|
snyk test --json > snyk-report.json
|
|
|
|
# Docker: Trivy
|
|
trivy image myimage:latest --format json --output trivy-report.json
|
|
|
|
# Docker: Grype
|
|
grype myimage:latest -o json > grype-report.json</code></pre>
|
|
<h3>Container Security</h3>
|
|
<pre><code class="lang-bash"># Scan container image
|
|
docker scan myimage:latest
|
|
|
|
# Trivy comprehensive scan
|
|
trivy image --severity HIGH,CRITICAL myimage:latest
|
|
|
|
# Clair (open source)
|
|
docker run -d --name clair arminc/clair-local-scan:latest
|
|
clair-scanner myimage:latest
|
|
|
|
# Anchore Engine
|
|
anchore-cli image add myimage:latest
|
|
anchore-cli image vuln myimage:latest all</code></pre>
|
|
<h2>Penetration Testing Methodology</h2>
|
|
<h3>Reconnaissance</h3>
|
|
<pre><code class="lang-python">import nmap
|
|
import requests
|
|
from bs4 import BeautifulSoup
|
|
|
|
def passive_reconnaissance(domain):
|
|
"""Gather information without touching target"""
|
|
|
|
# DNS lookup
|
|
import dns.resolver
|
|
resolver = dns.resolver.Resolver()
|
|
|
|
records = {
|
|
'A': resolver.resolve(domain, 'A'),
|
|
'MX': resolver.resolve(domain, 'MX'),
|
|
'TXT': resolver.resolve(domain, 'TXT'),
|
|
}
|
|
|
|
# WHOIS lookup
|
|
import whois
|
|
domain_info = whois.whois(domain)
|
|
|
|
# Subdomain enumeration (passive)
|
|
# Use crt.sh (certificate transparency logs)
|
|
response = requests.get(f"https://crt.sh/?q=%.{domain}&output=json")
|
|
subdomains = set()
|
|
|
|
if response.status_code == 200:
|
|
for cert in response.json():
|
|
subdomains.add(cert['name_value'])
|
|
|
|
return {
|
|
'dns_records': records,
|
|
'whois': domain_info,
|
|
'subdomains': list(subdomains)
|
|
}
|
|
|
|
def active_reconnaissance(target):
|
|
"""Active scanning (requires permission)"""
|
|
|
|
# Port scanning
|
|
nm = nmap.PortScanner()
|
|
nm.scan(target, '1-1000')
|
|
|
|
open_ports = []
|
|
for host in nm.all_hosts():
|
|
for proto in nm[host].all_protocols():
|
|
ports = nm[host][proto].keys()
|
|
for port in ports:
|
|
if nm[host][proto][port]['state'] == 'open':
|
|
open_ports.append({
|
|
'port': port,
|
|
'service': nm[host][proto][port]['name']
|
|
})
|
|
|
|
return open_ports</code></pre>
|
|
<h3>Security Testing Checklist</h3>
|
|
<p><strong>Before Testing</strong>:</p>
|
|
<ul><li>[ ] Get written authorization</li><li>[ ] Define scope clearly</li><li>[ ] Set up isolated test environment</li><li>[ ] Backup production data</li><li>[ ] Schedule testing window</li></ul>
|
|
<p><strong>Authentication</strong>:</p>
|
|
<ul><li>[ ] Test weak passwords</li><li>[ ] Test account lockout</li><li>[ ] Test session management</li><li>[ ] Test JWT validation</li><li>[ ] Test MFA bypass</li></ul>
|
|
<p><strong>Authorization</strong>:</p>
|
|
<ul><li>[ ] Test IDOR vulnerabilities</li><li>[ ] Test privilege escalation</li><li>[ ] Test missing auth checks</li><li>[ ] Test cross-tenant access</li></ul>
|
|
<p><strong>Input Validation</strong>:</p>
|
|
<ul><li>[ ] Test SQL injection</li><li>[ ] Test XSS (reflected, stored, DOM)</li><li>[ ] Test command injection</li><li>[ ] Test path traversal</li><li>[ ] Test file upload vulnerabilities</li></ul>
|
|
<p><strong>Configuration</strong>:</p>
|
|
<ul><li>[ ] Test security headers</li><li>[ ] Test HTTPS enforcement</li><li>[ ] Test exposed debug info</li><li>[ ] Test default credentials</li><li>[ ] Test directory listing</li></ul>
|
|
<p><strong>Business Logic</strong>:</p>
|
|
<ul><li>[ ] Test rate limiting</li><li>[ ] Test race conditions</li><li>[ ] Test workflow bypass</li><li>[ ] Test payment manipulation</li></ul>
|
|
<h2>CI/CD Security Integration</h2>
|
|
<h3>GitHub Actions Security Scanning</h3>
|
|
<pre><code class="lang-yaml">name: Security Scan
|
|
|
|
on: [push, pull_request]
|
|
|
|
jobs:
|
|
security:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Run Bandit (Python SAST)
|
|
run: |
|
|
pip install bandit
|
|
bandit -r . -f json -o bandit-report.json
|
|
continue-on-error: true
|
|
|
|
- name: Run Safety (Dependency Check)
|
|
run: |
|
|
pip install safety
|
|
safety check --json --output safety-report.json
|
|
continue-on-error: true
|
|
|
|
- name: Run Semgrep
|
|
uses: returntocorp/semgrep-action@v1
|
|
|
|
- name: Run Trivy (Container Scan)
|
|
uses: aquasecurity/trivy-action@master
|
|
with:
|
|
image-ref: 'myapp:${{ github.sha }}'
|
|
format: 'sarif'
|
|
output: 'trivy-results.sarif'
|
|
|
|
- name: Upload results to GitHub Security
|
|
uses: github/codeql-action/upload-sarif@v2
|
|
with:
|
|
sarif_file: 'trivy-results.sarif'</code></pre>
|
|
<h2>Security Best Practices</h2>
|
|
<h3>Security Testing Checklist</h3>
|
|
<p><strong>Automated Testing</strong>:</p>
|
|
<ul><li>[ ] SAST in CI/CD pipeline</li><li>[ ] Dependency scanning daily</li><li>[ ] Container scanning before deployment</li><li>[ ] DAST on staging environment</li><li>[ ] Security regression tests</li></ul>
|
|
<p><strong>Manual Testing</strong>:</p>
|
|
<ul><li>[ ] Quarterly penetration tests</li><li>[ ] Annual security audits</li><li>[ ] Code reviews for security</li><li>[ ] Architecture reviews</li><li>[ ] Threat modeling sessions</li></ul>
|
|
<p><strong>Monitoring</strong>:</p>
|
|
<ul><li>[ ] Security logging enabled</li><li>[ ] Anomaly detection configured</li><li>[ ] Intrusion detection system (IDS)</li><li>[ ] WAF (Web Application Firewall)</li><li>[ ] Regular log reviews</li></ul>
|
|
<h2>Level 3 Resources</h2>
|
|
<p>This skill includes <strong>executable scripts, detailed references, and validated examples</strong> in the <code>resources/</code> directory.</p>
|
|
<h3>๐ Resources Directory Structure</h3>
|
|
<pre><code>skills/security/vulnerability-assessment/resources/
|
|
โโโ REFERENCE.md # Detailed OWASP Top 10 reference, CVE patterns, tools
|
|
โโโ scripts/
|
|
โ โโโ README.md # Script documentation and usage
|
|
โ โโโ test_owasp_top10.py # Executable OWASP Top 10 test suite
|
|
โ โโโ scan_dependencies.sh # Automated dependency vulnerability scanning
|
|
โโโ examples/
|
|
โโโ python/ # Standalone test examples
|
|
โโโ ci-cd/ # CI/CD integration examples</code></pre>
|
|
<h3>๐ Quick Start: Run Security Tests</h3>
|
|
<p><strong>Test for OWASP Top 10 vulnerabilities</strong>:</p>
|
|
<pre><code class="lang-bash"># Full test suite
|
|
python resources/scripts/test_owasp_top10.py \
|
|
--target https://staging.example.com \
|
|
--report security-report.json \
|
|
--verbose
|
|
|
|
# Specific test
|
|
python resources/scripts/test_owasp_top10.py \
|
|
--target https://staging.example.com \
|
|
--test A01 \
|
|
--verbose</code></pre>
|
|
<p><strong>Scan dependencies for vulnerabilities</strong>:</p>
|
|
<pre><code class="lang-bash"># Scan Python project
|
|
./resources/scripts/scan_dependencies.sh \
|
|
--project-dir /path/to/project \
|
|
--output scan-results.json
|
|
|
|
# Scan Docker image
|
|
./resources/scripts/scan_dependencies.sh \
|
|
--docker-image myapp:latest \
|
|
--output docker-scan.json</code></pre>
|
|
<h3>๐ Reference Material</h3>
|
|
<p><strong>Load detailed reference</strong>:</p>
|
|
<pre><code class="lang-bash">cat resources/REFERENCE.md</code></pre>
|
|
<p>Contains:</p>
|
|
<ul><li>OWASP Top 10 (2021) detailed breakdown with CWE mappings</li><li>Real-world CVE examples (Log4Shell, Heartbleed, GitLab bypass)</li><li>Security testing tools comparison (SAST, DAST, SCA)</li><li>Common vulnerability patterns and exploitation techniques</li><li>Compliance frameworks (OWASP ASVS, PCI DSS, CWE Top 25)</li><li>Vulnerability databases and resources</li></ul>
|
|
<h3>โ๏ธ Scripts Overview</h3>
|
|
<p>| Script | Purpose | On-Demand Context Loading | |--------|---------|--------------------------| | <code>test_owasp_top10.py</code> | Automated OWASP Top 10 testing suite | Run via bash - code never loaded into context | | <code>scan_dependencies.sh</code> | Multi-tool dependency scanner (Safety, pip-audit, npm, Trivy) | Executable script, minimal context | | <code>REFERENCE.md</code> | Detailed specs, CVE examples, tool comparisons | Load only when needed for deep reference |</p>
|
|
<p><strong>Benefits of Level 3 Resources</strong>:</p>
|
|
<ul><li>โ
<strong>Context-efficient</strong>: Scripts executed via bash without loading code into context</li><li>โ
<strong>Production-ready</strong>: Validated, executable tools ready for immediate use</li><li>โ
<strong>Comprehensive</strong>: Detailed reference material available on-demand</li><li>โ
<strong>CI/CD-ready</strong>: JSON output for easy integration with pipelines</li></ul>
|
|
<hr>
|
|
<h2>Related Skills</h2>
|
|
<ul><li><code>security-authentication.md</code> - Testing auth mechanisms</li><li><code>security-authorization.md</code> - Testing access control</li><li><code>security-input-validation.md</code> - Testing input validation</li><li><code>security-headers.md</code> - Testing security headers</li><li><code>testing-integration.md</code> - Security integration tests</li></ul>
|
|
<hr>
|
|
<p><strong>Last Updated</strong>: 2025-10-27 <strong>Format Version</strong>: 1.0 (Atomic) + Level 3 Resources</p>
|
|
<footer>
|
|
<div class="fmap">
|
|
<div><b>Build</b>
|
|
<a href="https://hanzo.app">hanzo.app</a> app builder
|
|
<a href="https://hanzo.codes">hanzo.codes</a> code with an agent
|
|
<a href="https://hanzoskills.com">hanzoskills.com</a> what an agent reads</div>
|
|
<div><b>Run</b>
|
|
<a href="https://console.hanzo.ai">console.hanzo.ai</a> cloud console
|
|
<a href="https://api.hanzo.ai">api.hanzo.ai</a> the API</div>
|
|
<div><b>Account</b>
|
|
<a href="https://hanzo.id">hanzo.id</a> sign in
|
|
<a href="https://pay.hanzo.ai">pay.hanzo.ai</a> top up
|
|
<a href="https://billing.hanzo.ai">billing.hanzo.ai</a> invoices and usage</div>
|
|
<div><b>Company</b>
|
|
<a href="https://hanzo.ai">hanzo.ai</a> canonical
|
|
<a href="https://hanzo.ventures">hanzo.ventures</a> ventures</div>
|
|
</div>
|
|
<div class="fend"><a href="/security-vulnerability-assessment.md">This page as plain text</a> ยท <a href="/llms.txt">Index for agents</a></div>
|
|
</footer>
|
|
</div></body></html> |