name security-audit description Audit web applications for security vulnerabilities
Web Application Security Audit
Systematic checklist for auditing web application security. Organized around the OWASP Top 10 with concrete checks and fix patterns. Framework-agnostic.
Pre-Audit
Identify the tech stack — language, framework, database, auth provider, hosting
Map the attack surface — list all endpoints, forms, file uploads, auth flows, API integrations
Check for existing security tooling — linters, SAST, dependency scanners
Review the threat model — what data is sensitive? Who are the likely attackers?
Audit Checklist
Work through each section. Items are ordered by typical severity.
1. Injection (SQL, NoSQL, OS Command, LDAP)
The most exploitable class of vulnerabilities. Never interpolate user input into queries or commands.
2. Broken Authentication
3. Sensitive Data Exposure
Scan for hardcoded secrets — API keys, passwords, tokens, connection strings
grep -rn "password\s*=\s*['\"]" --include="*.{js,ts,py,go,java,rb}"
grep -rn "API_KEY\|SECRET\|TOKEN\|PRIVATE_KEY" --include="*.{js,ts,py,go,java,rb}"
Check .gitignore covers .env, *.pem, *.key, credentials files
Review git history for accidentally committed secrets — rotate any found
Encrypt sensitive data at rest — use AES-256-GCM or similar, never ECB mode
Use TLS everywhere — no mixed content, no HTTP fallback
Never log sensitive data — mask PII, tokens, passwords in log output
Strip sensitive fields from API responses — don't rely on frontend to hide data
res.json (user)
const { id, name, email } = user
res.json ({ id, name, email })
4. Cross-Site Scripting (XSS)
Use framework auto-escaping — don't bypass it (dangerouslySetInnerHTML, | safe, {!! !!})
Audit all uses of raw HTML rendering — search for innerHTML, v-html, [innerHTML], markSafe
Sanitize user-generated HTML with a strict allowlist library (DOMPurify, bleach)
const clean = DOMPurify .sanitize (userHtml, {
ALLOWED_TAGS : ['b' , 'i' , 'em' , 'strong' , 'a' , 'p' ],
ALLOWED_ATTR : ['href' ]
})
Encode output based on context — HTML body, attributes, JavaScript, CSS, URLs each need different encoding
Validate and sanitize URL schemes — block javascript:, data:, vbscript: in user-provided links
function isSafeUrl (url ) {
try {
const parsed = new URL (url)
return ['http:' , 'https:' ].includes (parsed.protocol )
} catch {
return false
}
}
Set Content-Type headers correctly — API endpoints returning JSON must set application/json, not text/html
5. Cross-Site Request Forgery (CSRF)
6. Security Headers
7. Broken Access Control
8. API Security
9. Dependencies & Supply Chain
10. File Uploads
11. Logging & Monitoring
Post-Audit
Categorize findings by severity — Critical / High / Medium / Low
Prioritize fixes — Critical and High first, anything actively exploitable is immediate
Verify fixes — re-test each vulnerability after patching
Document findings — record what was found, where, and how it was fixed
Add automated checks — integrate SAST/DAST into CI to prevent regressions
Quick Wins Summary
Action Blocks Add security headers XSS, clickjacking, MIME sniffing Set SameSite on cookies CSRF Run npm audit / pip audit Known CVEs in dependencies Switch to parameterized queries SQL injection Remove hardcoded secrets Credential exposure Add rate limiting to auth routes Brute-force, credential stuffing Set HttpOnly + Secure on cookies Session hijacking via XSS Add CORS allowlist Unauthorized cross-origin access
Useful Commands
grep -rn "password\|secret\|api_key\|token" --include="*.{js,ts,py,go}" -i
grep -rn "query\|execute\|raw(" --include="*.{js,ts,py,go}"
grep -rn "innerHTML\|dangerouslySetInnerHTML\|v-html\|markSafe\|\| safe" --include="*.{js,ts,jsx,tsx,vue,py,html}"
grep -rn "\beval\b\|\bexec\b\|\bspawn\b\|\bsystem\b" --include="*.{js,ts,py,rb,go}"
grep -rn "origin.*\*\|Access-Control-Allow-Origin" --include="*.{js,ts,py,go}"