Security Penetration Testing
Hands-on offensive security testing skill for finding vulnerabilities before attackers do. This is NOT compliance checking (see senior-secops) or security policy writing (see senior-security) — this is about systematic vulnerability discovery through authorized testing.
Table of Contents
Overview
What This Skill Does
This skill provides the methodology, checklists, and automation for offensive security testing — actively probing systems to discover exploitable vulnerabilities. It covers web applications, APIs, infrastructure, and supply chain security.
Distinction from Other Security Skills
| Skill |
Focus |
Approach |
| security-pen-testing (this) |
Finding vulnerabilities |
Offensive — simulate attacker techniques |
| senior-secops |
Security operations |
Defensive — monitoring, incident response, SIEM |
| senior-security |
Security policy |
Governance — policies, frameworks, risk registers |
| skill-security-auditor |
CI/CD gates |
Automated — pre-merge security checks |
Prerequisites
All testing described here assumes written authorization from the system owner. Unauthorized testing is illegal under the CFAA and equivalent laws worldwide. Always obtain a signed scope-of-work or rules-of-engagement document before starting.
OWASP Top 10 Systematic Audit
Use the vulnerability scanner tool for automated checklist generation:
# Generate OWASP checklist for a web application
python scripts/vulnerability_scanner.py --target web --scope full
# Quick API-focused scan
python scripts/vulnerability_scanner.py --target api --scope quick --json
Quick Reference
| # |
Category |
Key Tests |
| A01 |
Broken Access Control |
IDOR, vertical escalation, CORS, JWT claim manipulation, forced browsing |
| A02 |
Cryptographic Failures |
TLS version, password hashing, hardcoded keys, weak PRNG |
| A03 |
Injection |
SQLi, NoSQLi, command injection, template injection, XSS |
| A04 |
Insecure Design |
Rate limiting, business logic abuse, multi-step flow bypass |
| A05 |
Security Misconfiguration |
Default credentials, debug mode, security headers, directory listing |
| A06 |
Vulnerable Components |
Dependency audit (npm/pip/go), EOL checks, known CVEs |
| A07 |
Auth Failures |
Brute force, session cookie flags, session invalidation, MFA bypass |
| A08 |
Integrity Failures |
Unsafe deserialization, SRI checks, CI/CD pipeline integrity |
| A09 |
Logging Failures |
Auth event logging, sensitive data in logs, alerting thresholds |
| A10 |
SSRF |
Internal IP access, cloud metadata endpoints, DNS rebinding |
# Audit dependencies
python scripts/dependency_auditor.py --file package.json --severity high
python scripts/dependency_auditor.py --file requirements.txt --json
See owasp_top_10_checklist.md for detailed test procedures, code patterns to detect, remediation steps, and CVSS scoring guidance for each category.
Static Analysis
Recommended tools: CodeQL (custom queries for project-specific patterns), Semgrep (rule-based scanning with auto-fix), ESLint security plugins (eslint-plugin-security, eslint-plugin-no-unsanitized).
Key patterns to detect: SQL injection via string concatenation, hardcoded JWT secrets, unsafe YAML/pickle deserialization, missing security middleware (e.g., Express without Helmet).
See attack_patterns.md for code patterns and detection payloads across injection types.
Dependency Vulnerability Scanning
Ecosystem commands: npm audit, pip audit, govulncheck ./..., bundle audit check
CVE Triage Workflow:
- Collect — Run ecosystem audit tools, aggregate findings
- Deduplicate — Group by CVE ID across direct and transitive deps
- Prioritize — Critical + exploitable + reachable = fix immediately
- Remediate — Upgrade, patch, or mitigate with compensating controls
- Verify — Rerun audit to confirm fix, update lock files
python scripts/dependency_auditor.py --file package.json --severity critical --json
Secret Scanning
Tools: TruffleHog (git history + filesystem), Gitleaks (regex-based with custom rules).
# Scan git history for verified secrets
trufflehog git file://. --only-verified --json
# Scan filesystem
trufflehog filesystem . --json
Integration points: Pre-commit hooks (gitleaks, trufflehog), CI/CD gates (GitHub Actions with trufflesecurity/trufflehog@main). Configure .gitleaks.toml for custom rules (AWS keys, API keys, private key headers) and allowlists for test fixtures.
API Security Testing
Authentication Bypass
- JWT manipulation: Change
alg to none, RS256-to-HS256 confusion, claim modification (role: "admin", exp: 9999999999)
- Session fixation: Check if session ID changes after authentication
Authorization Flaws
- IDOR/BOLA: Change resource IDs in every endpoint — test read, update, delete across users
- BFLA: Regular user tries admin endpoints (expect 403)
- Mass assignment: Add privileged fields (
role, is_admin) to update requests
Rate Limiting & GraphQL
- Rate limiting: Rapid-fire requests to auth endpoints; expect 429 after threshold
- GraphQL: Test introspection (should be disabled in prod), query depth attacks, batch mutations bypassing rate limits
See attack_patterns.md for complete JWT manipulation payloads, IDOR testing methodology, BFLA endpoint lists, GraphQL introspection/depth/batch attack patterns, and rate limiting bypass techniques.
Web Vulnerability Testing
| Vulnerability |
Key Tests |
| XSS |
Reflected (script/img/svg payloads), Stored (persistent fields), DOM-based (innerHTML + location.hash) |
| CSRF |
Replay without token (expect 403), cross-session token replay, check SameSite cookie attribute |
| SQL Injection |
Error-based (' OR 1=1--), union-based enumeration, time-based blind (SLEEP(5)), boolean-based blind |
| SSRF |
Internal IPs, cloud metadata endpoints (AWS/GCP/Azure), IPv6/hex/decimal encoding bypasses |
| Path Traversal |
../../../etc/passwd, URL encoding, double encoding bypasses |
See attack_patterns.md for complete test payloads (XSS filter bypasses, context-specific XSS, SQL injection per database engine, SSRF bypass techniques, and DOM-based XSS source/sink pairs).
Infrastructure Security
Key checks:
- Cloud storage: S3 bucket public access (
aws s3 ls s3://bucket --no-sign-request), bucket policies, ACLs
- HTTP security headers: HSTS, CSP (no
unsafe-inline/unsafe-eval), X-Content-Type-Options, X-Frame-Options, Referrer-Policy
- TLS configuration:
nmap --script ssl-enum-ciphers -p 443 target.com or testssl.sh — reject TLS 1.0/1.1, RC4, 3DES, export-grade ciphers
- Port scanning:
nmap -sV target.com — flag dangerous open ports (FTP/21, Telnet/23, Redis/6379, MongoDB/27017)
Pen Test Report Generation
Generate professional reports from structured findings:
# Generate markdown report from findings JSON
python scripts/pentest_report_generator.py --findings findings.json --format md --output report.md
# Generate JSON report
python scripts/pentest_report_generator.py --findings findings.json --format json --output report.json
Findings JSON Format
[
{
"title": "SQL Injection in Login Endpoint",
"severity": "critical",
"cvss_score": 9.8,
"cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"category": "A03:2021 - Injection",
"description": "The /api/login endpoint is vulnerable to SQL injection via the email parameter.",
"evidence": "Request: POST /api/login {\"email\": \"' OR 1=1--\", \"password\": \"x\"}\nResponse: 200 OK with admin session token",
"impact": "Full database access, authentication bypass, potential remote code execution",
"remediation": "Use parameterized queries. Replace string concatenation with prepared statements.",
"references": ["https://cwe.mitre.org/data/definitions/89.html"]
}
]
Report Structure
- Executive Summary: Business impact, overall risk level, top 3 findings
- Scope: What was tested, what was excluded, testing dates
- Methodology: Tools used, testing approach (black/gray/white box)
- Findings Table: Sorted by severity with CVSS scores
- Detailed Findings: Each with description, evidence, impact, remediation
- Remediation Priority Matrix: Effort vs. impact for each fix
- Appendix: Raw tool output, full payload lists
Responsible Disclosure Workflow
Responsible disclosure is mandatory for any vulnerability found during authorized testing. Standard timeline: report on day 1, follow up at day 7, status update at day 30, public disclosure at day 90.
Key principles: Never exploit beyond proof of concept, encrypt all communications, do not access real user data, document everything with timestamps.
See responsible_disclosure.md for full disclosure timelines (standard 90-day, accelerated 30-day, extended 120-day), communication templates, legal considerations, bug bounty program integration, and CVE request process.
Workflows
Workflow 1: Quick Security Check (15 Minutes)
For pre-merge reviews or quick health checks:
# 1. Generate OWASP checklist
python scripts/vulnerability_scanner.py --target web --scope quick
# 2. Scan dependencies
python scripts/dependency_auditor.py --file package.json --severity high
# 3. Check for secrets in recent commits
# (Use gitleaks or trufflehog as described in Secret Scanning section)
# 4. Review HTTP security headers
curl -sI https://target.com | grep -iE "(strict-transport|content-security|x-frame|x-content-type)"
Decision: If any critical or high findings, block the merge.
Workflow 2: Full Penetration Test (Multi-Day Assessment)
Day 1 — Reconnaissance:
- Map the attack surface: endpoints, authentication flows, third-party integrations
- Run automated OWASP checklist (full scope)
- Run dependency audit across all manifests
- Run secret scan on full git history
Day 2 — Manual Testing:
- Test authentication and authorization (IDOR, BOLA, BFLA)
- Test injection points (SQLi, XSS, SSRF, command injection)
- Test business logic flaws
- Test API-specific vulnerabilities (GraphQL, rate limiting, mass assignment)
Day 3 — Infrastructure and Reporting:
- Check cloud storage permissions
- Verify TLS configuration and security headers
- Port scan for unnecessary services
- Compile findings into structured JSON
- Generate pen test report
# Generate final report
python scripts/pentest_report_generator.py --findings findings.json --format md --output pentest-report.md
Workflow 3: CI/CD Security Gate
Automated security checks on every PR: secret scanning (TruffleHog), dependency audit (npm audit, pip audit), SAST (Semgrep with p/security-audit, p/owasp-top-ten), and security headers check on staging.
Gate Policy: Block merge on critical/high findings. Warn on medium. Log low/info.
Anti-Patterns
- Testing in production without authorization — Always get written permission and use staging/test environments when possible
- Ignoring low-severity findings — Low findings compound; a chain of lows can become a critical exploit path
- Skipping responsible disclosure — Every vulnerability found must be reported through proper channels
- Relying solely on automated tools — Tools miss business logic flaws, chained exploits, and novel attack vectors
- Testing without a defined scope — Scope creep leads to legal liability; document what is and isn't in scope
- Reporting without remediation guidance — Every finding must include actionable remediation steps
- Storing evidence insecurely — Pen test evidence (screenshots, payloads, tokens) is sensitive; encrypt and restrict access
- One-time testing — Security testing must be continuous; integrate into CI/CD and schedule periodic assessments
Cross-References
| Skill |
Relationship |
| senior-secops |
Defensive security operations — monitoring, incident response, SIEM configuration |
| senior-security |
Security policy and governance — frameworks, risk registers, compliance |
| dependency-auditor |
Deep supply chain security — SBOMs, license compliance, transitive risk |
| code-reviewer |
Code review practices — includes security review checklist |
1---2name: security-pen-testing3description: "Use when the user asks to perform security audits, penetration testing, vulnerability scanning, OWASP Top 10 checks, or offensive security assessments. Covers static analysis, dependency scanning, secret detection, API security testing, and pen test report generation."4metadata:5 source: https://skillmd.com/skills/bestagentkits/security-pen-testing6---78# Security Penetration Testing910Hands-on offensive security testing skill for finding vulnerabilities before attackers do. This is NOT compliance checking (see senior-secops) or security policy writing (see senior-security) — this is about systematic vulnerability discovery through authorized testing.1112---1314## Table of Contents1516- [Overview](#overview)17- [OWASP Top 10 Systematic Audit](#owasp-top-10-systematic-audit)18- [Static Analysis](#static-analysis)19- [Dependency Vulnerability Scanning](#dependency-vulnerability-scanning)20- [Secret Scanning](#secret-scanning)21- [API Security Testing](#api-security-testing)22- [Web Vulnerability Testing](#web-vulnerability-testing)23- [Infrastructure Security](#infrastructure-security)24- [Pen Test Report Generation](#pen-test-report-generation)25- [Responsible Disclosure Workflow](#responsible-disclosure-workflow)26- [Workflows](#workflows)27- [Anti-Patterns](#anti-patterns)28- [Cross-References](#cross-references)2930---3132## Overview3334### What This Skill Does3536This skill provides the methodology, checklists, and automation for **offensive security testing** — actively probing systems to discover exploitable vulnerabilities. It covers web applications, APIs, infrastructure, and supply chain security.3738### Distinction from Other Security Skills3940| Skill | Focus | Approach |41|-------|-------|----------|42| **security-pen-testing** (this) | Finding vulnerabilities | Offensive — simulate attacker techniques |43| senior-secops | Security operations | Defensive — monitoring, incident response, SIEM |44| senior-security | Security policy | Governance — policies, frameworks, risk registers |45| skill-security-auditor | CI/CD gates | Automated — pre-merge security checks |4647### Prerequisites4849All testing described here assumes **written authorization** from the system owner. Unauthorized testing is illegal under the CFAA and equivalent laws worldwide. Always obtain a signed scope-of-work or rules-of-engagement document before starting.5051---5253## OWASP Top 10 Systematic Audit5455Use the vulnerability scanner tool for automated checklist generation:5657```bash58# Generate OWASP checklist for a web application59python scripts/vulnerability_scanner.py --target web --scope full6061# Quick API-focused scan62python scripts/vulnerability_scanner.py --target api --scope quick --json63```6465### Quick Reference6667| # | Category | Key Tests |68|---|----------|-----------|69| A01 | Broken Access Control | IDOR, vertical escalation, CORS, JWT claim manipulation, forced browsing |70| A02 | Cryptographic Failures | TLS version, password hashing, hardcoded keys, weak PRNG |71| A03 | Injection | SQLi, NoSQLi, command injection, template injection, XSS |72| A04 | Insecure Design | Rate limiting, business logic abuse, multi-step flow bypass |73| A05 | Security Misconfiguration | Default credentials, debug mode, security headers, directory listing |74| A06 | Vulnerable Components | Dependency audit (npm/pip/go), EOL checks, known CVEs |75| A07 | Auth Failures | Brute force, session cookie flags, session invalidation, MFA bypass |76| A08 | Integrity Failures | Unsafe deserialization, SRI checks, CI/CD pipeline integrity |77| A09 | Logging Failures | Auth event logging, sensitive data in logs, alerting thresholds |78| A10 | SSRF | Internal IP access, cloud metadata endpoints, DNS rebinding |7980```bash81# Audit dependencies82python scripts/dependency_auditor.py --file package.json --severity high83python scripts/dependency_auditor.py --file requirements.txt --json84```8586See [owasp_top_10_checklist.md](references/owasp_top_10_checklist.md) for detailed test procedures, code patterns to detect, remediation steps, and CVSS scoring guidance for each category.8788---8990## Static Analysis9192**Recommended tools:** CodeQL (custom queries for project-specific patterns), Semgrep (rule-based scanning with auto-fix), ESLint security plugins (`eslint-plugin-security`, `eslint-plugin-no-unsanitized`).9394Key patterns to detect: SQL injection via string concatenation, hardcoded JWT secrets, unsafe YAML/pickle deserialization, missing security middleware (e.g., Express without Helmet).9596See [attack_patterns.md](references/attack_patterns.md) for code patterns and detection payloads across injection types.9798---99100## Dependency Vulnerability Scanning101102**Ecosystem commands:** `npm audit`, `pip audit`, `govulncheck ./...`, `bundle audit check`103104**CVE Triage Workflow:**1051. **Collect** — Run ecosystem audit tools, aggregate findings1062. **Deduplicate** — Group by CVE ID across direct and transitive deps1073. **Prioritize** — Critical + exploitable + reachable = fix immediately1084. **Remediate** — Upgrade, patch, or mitigate with compensating controls1095. **Verify** — Rerun audit to confirm fix, update lock files110111```bash112python scripts/dependency_auditor.py --file package.json --severity critical --json113```114115---116117## Secret Scanning118119**Tools:** TruffleHog (git history + filesystem), Gitleaks (regex-based with custom rules).120121```bash122# Scan git history for verified secrets123trufflehog git file://. --only-verified --json124125# Scan filesystem126trufflehog filesystem . --json127```128129**Integration points:** Pre-commit hooks (gitleaks, trufflehog), CI/CD gates (GitHub Actions with `trufflesecurity/trufflehog@main`). Configure `.gitleaks.toml` for custom rules (AWS keys, API keys, private key headers) and allowlists for test fixtures.130131---132133## API Security Testing134135### Authentication Bypass136137- **JWT manipulation:** Change `alg` to `none`, RS256-to-HS256 confusion, claim modification (`role: "admin"`, `exp: 9999999999`)138- **Session fixation:** Check if session ID changes after authentication139140### Authorization Flaws141142- **IDOR/BOLA:** Change resource IDs in every endpoint — test read, update, delete across users143- **BFLA:** Regular user tries admin endpoints (expect 403)144- **Mass assignment:** Add privileged fields (`role`, `is_admin`) to update requests145146### Rate Limiting & GraphQL147148- **Rate limiting:** Rapid-fire requests to auth endpoints; expect 429 after threshold149- **GraphQL:** Test introspection (should be disabled in prod), query depth attacks, batch mutations bypassing rate limits150151See [attack_patterns.md](references/attack_patterns.md) for complete JWT manipulation payloads, IDOR testing methodology, BFLA endpoint lists, GraphQL introspection/depth/batch attack patterns, and rate limiting bypass techniques.152153---154155## Web Vulnerability Testing156157| Vulnerability | Key Tests |158|--------------|-----------|159| **XSS** | Reflected (script/img/svg payloads), Stored (persistent fields), DOM-based (innerHTML + location.hash) |160| **CSRF** | Replay without token (expect 403), cross-session token replay, check SameSite cookie attribute |161| **SQL Injection** | Error-based (`' OR 1=1--`), union-based enumeration, time-based blind (`SLEEP(5)`), boolean-based blind |162| **SSRF** | Internal IPs, cloud metadata endpoints (AWS/GCP/Azure), IPv6/hex/decimal encoding bypasses |163| **Path Traversal** | `../../../etc/passwd`, URL encoding, double encoding bypasses |164165See [attack_patterns.md](references/attack_patterns.md) for complete test payloads (XSS filter bypasses, context-specific XSS, SQL injection per database engine, SSRF bypass techniques, and DOM-based XSS source/sink pairs).166167---168169## Infrastructure Security170171**Key checks:**172- **Cloud storage:** S3 bucket public access (`aws s3 ls s3://bucket --no-sign-request`), bucket policies, ACLs173- **HTTP security headers:** HSTS, CSP (no `unsafe-inline`/`unsafe-eval`), X-Content-Type-Options, X-Frame-Options, Referrer-Policy174- **TLS configuration:** `nmap --script ssl-enum-ciphers -p 443 target.com` or `testssl.sh` — reject TLS 1.0/1.1, RC4, 3DES, export-grade ciphers175- **Port scanning:** `nmap -sV target.com` — flag dangerous open ports (FTP/21, Telnet/23, Redis/6379, MongoDB/27017)176177---178179## Pen Test Report Generation180181Generate professional reports from structured findings:182183```bash184# Generate markdown report from findings JSON185python scripts/pentest_report_generator.py --findings findings.json --format md --output report.md186187# Generate JSON report188python scripts/pentest_report_generator.py --findings findings.json --format json --output report.json189```190191### Findings JSON Format192193```json194[195 {196 "title": "SQL Injection in Login Endpoint",197 "severity": "critical",198 "cvss_score": 9.8,199 "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",200 "category": "A03:2021 - Injection",201 "description": "The /api/login endpoint is vulnerable to SQL injection via the email parameter.",202 "evidence": "Request: POST /api/login {\"email\": \"' OR 1=1--\", \"password\": \"x\"}\nResponse: 200 OK with admin session token",203 "impact": "Full database access, authentication bypass, potential remote code execution",204 "remediation": "Use parameterized queries. Replace string concatenation with prepared statements.",205 "references": ["https://cwe.mitre.org/data/definitions/89.html"]206 }207]208```209210### Report Structure2112121. **Executive Summary**: Business impact, overall risk level, top 3 findings2132. **Scope**: What was tested, what was excluded, testing dates2143. **Methodology**: Tools used, testing approach (black/gray/white box)2154. **Findings Table**: Sorted by severity with CVSS scores2165. **Detailed Findings**: Each with description, evidence, impact, remediation2176. **Remediation Priority Matrix**: Effort vs. impact for each fix2187. **Appendix**: Raw tool output, full payload lists219220---221222## Responsible Disclosure Workflow223224Responsible disclosure is **mandatory** for any vulnerability found during authorized testing. Standard timeline: report on day 1, follow up at day 7, status update at day 30, public disclosure at day 90.225226**Key principles:** Never exploit beyond proof of concept, encrypt all communications, do not access real user data, document everything with timestamps.227228See [responsible_disclosure.md](references/responsible_disclosure.md) for full disclosure timelines (standard 90-day, accelerated 30-day, extended 120-day), communication templates, legal considerations, bug bounty program integration, and CVE request process.229230---231232## Workflows233234### Workflow 1: Quick Security Check (15 Minutes)235236For pre-merge reviews or quick health checks:237238```bash239# 1. Generate OWASP checklist240python scripts/vulnerability_scanner.py --target web --scope quick241242# 2. Scan dependencies243python scripts/dependency_auditor.py --file package.json --severity high244245# 3. Check for secrets in recent commits246# (Use gitleaks or trufflehog as described in Secret Scanning section)247248# 4. Review HTTP security headers249curl -sI https://target.com | grep -iE "(strict-transport|content-security|x-frame|x-content-type)"250```251252**Decision**: If any critical or high findings, block the merge.253254### Workflow 2: Full Penetration Test (Multi-Day Assessment)255256**Day 1 — Reconnaissance:**2571. Map the attack surface: endpoints, authentication flows, third-party integrations2582. Run automated OWASP checklist (full scope)2593. Run dependency audit across all manifests2604. Run secret scan on full git history261262**Day 2 — Manual Testing:**2631. Test authentication and authorization (IDOR, BOLA, BFLA)2642. Test injection points (SQLi, XSS, SSRF, command injection)2653. Test business logic flaws2664. Test API-specific vulnerabilities (GraphQL, rate limiting, mass assignment)267268**Day 3 — Infrastructure and Reporting:**2691. Check cloud storage permissions2702. Verify TLS configuration and security headers2713. Port scan for unnecessary services2724. Compile findings into structured JSON2735. Generate pen test report274275```bash276# Generate final report277python scripts/pentest_report_generator.py --findings findings.json --format md --output pentest-report.md278```279280### Workflow 3: CI/CD Security Gate281282Automated security checks on every PR: secret scanning (TruffleHog), dependency audit (`npm audit`, `pip audit`), SAST (Semgrep with `p/security-audit`, `p/owasp-top-ten`), and security headers check on staging.283284**Gate Policy**: Block merge on critical/high findings. Warn on medium. Log low/info.285286---287288## Anti-Patterns2892901. **Testing in production without authorization** — Always get written permission and use staging/test environments when possible2912. **Ignoring low-severity findings** — Low findings compound; a chain of lows can become a critical exploit path2923. **Skipping responsible disclosure** — Every vulnerability found must be reported through proper channels2934. **Relying solely on automated tools** — Tools miss business logic flaws, chained exploits, and novel attack vectors2945. **Testing without a defined scope** — Scope creep leads to legal liability; document what is and isn't in scope2956. **Reporting without remediation guidance** — Every finding must include actionable remediation steps2967. **Storing evidence insecurely** — Pen test evidence (screenshots, payloads, tokens) is sensitive; encrypt and restrict access2978. **One-time testing** — Security testing must be continuous; integrate into CI/CD and schedule periodic assessments298299---300301## Cross-References302303| Skill | Relationship |304|-------|-------------|305| [senior-secops](../senior-secops/SKILL.md) | Defensive security operations — monitoring, incident response, SIEM configuration |306| [senior-security](../senior-security/SKILL.md) | Security policy and governance — frameworks, risk registers, compliance |307| [dependency-auditor](engineering/skills/dependency-auditor/SKILL.md) | Deep supply chain security — SBOMs, license compliance, transitive risk |308| [code-reviewer](../code-reviewer/SKILL.md) | Code review practices — includes security review checklist |