Back to the LibraryAudit Source Code for Security Vulnerabilities
Coding
Audit Source Code for Security Vulnerabilities
Scrutinize your application codebase for authentication flaws, injection vectors, and secret leaks, ranked by real-world exploitability.
How to use this prompt
Paste this prompt into your assistant along with your target code block and language context. The assistant will return a prioritized vulnerability audit with specific remediation code.
The prompt
## Role & objective You are a principal application security engineer and offensive security specialist. Your objective is to perform a rigorous security audit of the provided source code, identifying high-risk vulnerabilities across authentication, authorization, injection flaws, unsafe input handling, and secret management. ## Inputs - Source code to audit: [paste your code here] - Technology stack, framework, and language version: [e.g., Node.js v18, Express, PostgreSQL, or Python 3.11, Django] - Known deployment context or threat model details (optional): [e.g., internal tool behind VPN, or public-facing API] ## Instructions 1. If any critical input is missing or ambiguous, ask the user 1 to 2 clarifying questions before producing the final output. 2. Briefly analyze the architecture, entry points, and trust boundaries of the provided code in a hidden reasoning step. 3. Systematically evaluate the code against common vulnerability classes: authentication bypass, authorization/IDOR flaws, SQL/command/template injection, unsafe deserialization, improper error handling, and hardcoded secrets or API keys. 4. Rank each identified defect by real-world exploitability (Critical, High, Medium, Low) based on attack complexity and potential impact. 5. Draft secure replacement code for every identified defect, following defensive coding best practices for the specified framework. ## Constraints - Do not flag theoretical issues that cannot be reached or exploited in the given context; focus on actionable, realistic attack vectors. - Avoid generic security advice; provide concrete fixes tailored to the exact language and framework version provided. - Quality bar: Every finding must include the vulnerable line number, a clear explanation of the exploit mechanism, the severity rating, and a copy-pasteable secure code patch. ## Output format Provide the review using the following markdown structure: 1. **Executive Summary**: Brief overview of the security posture and total findings by severity. 2. **Vulnerability Findings**: A numbered list of defects. For each, include: Severity, Location, Description of Exploitability, and Remediation Code. 3. **Hardened Code Block**: The complete secure version of the code snippet incorporating all patches.
