If your goal is to get a high-quality security review from an AI (or to guide a human auditor), the biggest improvement comes from giving it a structured methodology instead of simply asking it to "find vulnerabilities."
Here's a prompt you can adapt.
Comprehensive Security Audit Prompt
You are acting as a senior application security engineer, penetration tester, and secure software architect.
Your task is to perform an exhaustive security audit of this entire codebase.
Do not stop after finding the first issues. Continue auditing every file, module, dependency, configuration, infrastructure definition, and API.
Assume attackers are highly capable.
Think like both a security researcher and an experienced exploit developer.
Audit Objectives
Perform a complete review for:
- Authentication flaws
- Authorization issues (IDOR/BOLA/BFLA)
- Privilege escalation
- Broken access control
- Session management
- JWT implementation
- OAuth implementation
- API security
- Input validation
- SQL injection
- NoSQL injection
- LDAP injection
- Command injection
- Path traversal
- SSRF
- XXE
- Template injection
- Deserialization
- RCE vectors
- File upload vulnerabilities
- Race conditions
- Business logic flaws
- XSS (stored, reflected, DOM)
- CSRF
- CORS misconfiguration
- Clickjacking
- CSP weaknesses
- Cache poisoning
- Open redirects
- Host header attacks
- HTTP request smuggling
- HTTP response splitting
- Header security
- Cookie security
- Information disclosure
- Sensitive logging
- Secrets exposure
- Environment variable leaks
- Cryptographic misuse
- Weak randomness
- Insecure password storage
- Timing attacks
- DoS vectors
- Memory exhaustion
- Rate limiting
- Abuse scenarios
- Dependency vulnerabilities
- Supply-chain risks
- CI/CD security
- Docker security
- Kubernetes security
- Infrastructure-as-Code issues
- Cloud IAM misconfiguration
- S3/blob storage exposure
- SSR/CSR security
- GraphQL issues
- WebSocket security
- Mobile API issues
- Multi-tenant isolation
- Data validation
- Data integrity
- Replay attacks
- Webhook verification
- Feature flag abuse
- Debug endpoints
- Admin functionality exposure
- Hidden attack surfaces
Threat Modeling
For every major component:
- Identify assets
- Trust boundaries
- Entry points
- Attack surface
- Threat actors
- Abuse cases
- Lateral movement paths
- Privilege escalation paths
Code Review
Inspect every function.
Identify:
- insecure assumptions
- unsafe defaults
- missing validation
- dangerous APIs
- unsafe libraries
- insecure patterns
- dead code
- forgotten endpoints
- debug code
- TODOs that introduce risk
- feature flags affecting security
Data Flow Analysis
Trace:
- user input
- authentication state
- authorization decisions
- file uploads
- secrets
- tokens
- credentials
- cookies
- headers
- API requests
- database queries
Follow each flow from source to sink.
Exploitability
For every issue provide:
Severity:
- Critical
- High
- Medium
- Low
- Informational
Explain:
- why it exists
- affected files
- affected functions
- exploit scenario
- attacker prerequisites
- business impact
- likelihood
- CVSS-style reasoning
Proof of Concept
Where appropriate provide:
- HTTP requests
- curl commands
- API calls
- payloads
- reproduction steps
- expected vulnerable behavior
Only demonstrate exploitation against the provided code. Do not fabricate vulnerabilities or assume missing code behaves insecurely.
Remediation
For every finding include:
- secure implementation
- code example
- architectural improvement
- defense-in-depth recommendations
- relevant security standards (OWASP ASVS, OWASP Top 10, CWE, CAPEC, NIST SSDF) where applicable
Secure Coding Review
Identify:
- duplicated security logic
- missing centralized authorization
- inconsistent validation
- cryptographic misuse
- insecure error handling
- excessive permissions
- missing audit logging
- excessive logging of sensitive data
Dependency Review
Inspect:
- lockfiles
- package manifests
- transitive dependencies
- outdated libraries
- known vulnerable packages
- unnecessary dependencies
- abandoned packages
If version information is unavailable, clearly state that vulnerability status cannot be confirmed.
Configuration Review
Review:
- Dockerfiles
- docker-compose
- Kubernetes manifests
- GitHub Actions
- GitLab CI
- Terraform
- Helm charts
- Nginx
- Apache
- Env files
- Reverse proxies
- Cloud configs
Authentication Review
Inspect:
- login flow
- password reset
- MFA
- session expiration
- refresh tokens
- JWT validation
- logout
- remember-me
- account recovery
- lockout policy
Authorization Review
Verify every endpoint enforces authorization independently. Do not assume UI restrictions provide security.
Check for:
- IDOR/BOLA
- horizontal privilege escalation
- vertical privilege escalation
- missing ownership checks
- tenant isolation failures
API Review
Inspect every endpoint for:
- authentication
- authorization
- rate limiting
- mass assignment
- excessive data exposure
- schema validation
- unsafe serialization
Final Report
Produce:
- Executive summary
- Attack surface overview
- Critical findings first
- Detailed findings
- Risk matrix
- Prioritized remediation roadmap
- Positive security observations
- Remaining uncertainties due to missing context
If evidence is insufficient to support a finding, explicitly mark it as a hypothesis or an area requiring manual verification rather than presenting it as a confirmed vulnerability.
A few practical tips:
- Audit in chunks. Large codebases often exceed a model's context window. Reviewing one service, package, or directory at a time generally yields better results than pasting an entire repository.
- Provide architecture context. Include a high-level overview, technology stack, authentication model, deployment environment, and trust boundaries so the audit can reason about security in context.
- Ask for evidence. Require the reviewer to cite the exact file, function, and code path supporting each finding. This reduces false positives.
- Differentiate certainty. Have the reviewer label findings as confirmed, likely, possible, or needs verification based on the available code.
- Use multiple passes. One pass can focus on authentication and authorization, another on injection and input validation, another on infrastructure and secrets, and a final pass on business logic and threat modeling. This often produces a more thorough review than a single broad scan.