Code Security Review
Overview
Performs comprehensive security code reviews to identify vulnerabilities, assess security risks, and provide actionable remediation guidance. Covers OWASP Top 10, CWE classifications, compliance requirements, and security best practices.
Security Review Workflow
1. Initial Assessment
Gather context about the application:
- Application type: Web app, API, mobile, desktop, embedded
- Data sensitivity: PII, financial data, healthcare records, proprietary information
- Compliance requirements: PCI-DSS, GDPR, HIPAA, SOC 2, ISO 27001
- Authentication mechanisms: OAuth, JWT, session-based, API keys
- Technology stack: Languages, frameworks, libraries, databases
- External integrations: Third-party APIs, cloud services, payment processors
Perform threat modeling:
- Identify critical assets (data, functions, resources)
- Map attack surfaces (user inputs, APIs, file uploads, network interfaces)
- Determine threat actors (external attackers, malicious insiders, automated bots)
- Assess existing security controls
2. Code Analysis
Systematically review code for security vulnerabilities:
Priority Areas:
- Authentication & Authorization - Login flows, session management, access controls
- Input Validation - All user inputs, API parameters, file uploads
- Data Protection - Encryption at rest and in transit, sensitive data handling
- API Security - Rate limiting, authentication, input validation
- Dependency Security - Third-party libraries, outdated packages, known CVEs
- Configuration - Security headers, CORS, environment variables, secrets management
- Error Handling - Information disclosure, stack traces, error messages
- Business Logic - Race conditions, workflow bypasses, state manipulation
3. Vulnerability Classification
Classify each finding:
- Severity: Critical, High, Medium, Low, Informational
- CWE ID: Common Weakness Enumeration identifier
- OWASP Category: Map to OWASP Top 10 if applicable
- CVSS Score: Calculate if applicable (use CVSS 3.1)
- Exploitability: How easy to exploit
- Impact: Data loss, privilege escalation, DoS, data breach
4. Documentation
Produce comprehensive security report:
- Executive Summary - High-level findings and risk overview
- Detailed Findings - Each vulnerability with code examples and exploit scenarios
- Remediation Guidance - Specific fixes with secure code examples
- Compliance Assessment - Status against required standards
- Remediation Timeline - Prioritized action plan
- Security Metrics - Vulnerability counts by severity and category
Severity Classification
Critical (CVSS 9.0-10.0):
- Remote code execution
- Authentication bypass
- SQL injection with data access
- Hardcoded credentials for production systems
- Complete access control bypass
High (CVSS 7.0-8.9):
- Privilege escalation
- Sensitive data exposure (PII, financial)
- Cross-site scripting (XSS) with session theft
- Insecure deserialization
- XML external entity (XXE) injection
Medium (CVSS 4.0-6.9):
- Information disclosure
- Cross-site request forgery (CSRF)
- Weak cryptography
- Security misconfiguration
- Missing security headers
Low (CVSS 0.1-3.9):
- Version disclosure
- Verbose error messages
- Missing best practices
- Security through obscurity
Informational:
- Recommendations for defense in depth
- Future-proofing suggestions
- Security hygiene improvements
Report Structure
Generate security reports in this format:
Executive Summary
- Total vulnerabilities by severity
- Critical risk areas
- Compliance status summary
- Overall security posture rating
- Recommended immediate actions
Detailed Findings
For each vulnerability:
## [SEVERITY] Finding Title (CWE-XXX)
**Severity**: Critical/High/Medium/Low
**CWE ID**: CWE-XXX
**OWASP**: A0X:YYYY
**CVSS Score**: X.X (if applicable)
**Description**:
[Clear explanation of the vulnerability]
**Location**:
- File: path/to/file.ext
- Lines: XX-XX
- Function/Class: function_name()
**Vulnerable Code**:
```language
[Actual vulnerable code snippet]
Exploit Scenario:
[Step-by-step demonstration of how an attacker could exploit this]
Impact:
[What could happen if exploited - data breach, privilege escalation, etc.]
Remediation:
[Specific steps to fix the vulnerability]
Secure Code Example:
[Working secure implementation]
References:
- [Relevant CWE, CVE, or documentation links]
### Remediation Timeline
- **Phase 1 (Critical - Week 1)**: List of critical issues
- **Phase 2 (High - Weeks 2-3)**: List of high severity issues
- **Phase 3 (Medium - Month 2)**: List of medium severity issues
- **Phase 4 (Low - Month 3)**: List of low severity issues
### Compliance Assessment
For each applicable standard, document:
- Requirements checked
- Compliance status (Compliant/Non-Compliant/Partially Compliant)
- Specific gaps identified
- Remediation needed for compliance
## Detailed References
For comprehensive vulnerability patterns, testing procedures, and compliance details:
- **OWASP Top 10 & CWE Patterns**: See [security-review-workflow.md](references/security-review-workflow.md) for:
- Detailed vulnerability patterns for each OWASP Top 10 category
- Code examples of vulnerable and secure implementations
- Testing procedures and detection methods
- Complete CWE mappings and classifications
- **Security Testing Procedures**: See [security-testing-checklist.md](references/security-testing-checklist.md) for:
- Comprehensive testing checklist by category
- Manual and automated testing techniques
- Security testing tools and configurations
- API security testing procedures
- **Compliance Requirements**: See [compliance-requirements.md](references/compliance-requirements.md) for:
- PCI-DSS requirements and validation
- GDPR data protection requirements
- HIPAA security and privacy rules
- SOC 2 security controls
- **Report Examples**: See [report-example.md](references/report-example.md) for:
- Complete security report template
- Example findings with remediation guidance
- Executive summary examples
- Remediation timeline structures
## Best Practices
**Be Thorough:**
- Review ALL user input points
- Check ALL database queries
- Verify ALL authentication and authorization checks
- Test ALL file operations and uploads
- Examine ALL external integrations
**Be Practical:**
- Prioritize by risk (likelihood × impact)
- Consider exploitability and business context
- Account for compensating controls
- Balance security with usability
**Be Clear:**
- Provide step-by-step exploit scenarios
- Show exact vulnerable code locations
- Give specific, actionable remediation steps
- Include working secure code examples
**Be Professional:**
- Focus on code issues, not developers
- Use industry-standard classifications (CWE, OWASP, CVSS)
- Provide credible references (NIST, OWASP, vendor documentation)
- Document assumptions and testing limitations
1---
2name: code-security-review
3description: Conducts comprehensive security code reviews including vulnerability detection (OWASP Top 10, CWE), authentication/authorization flaws, injection attacks, cryptography issues, sensitive data exposure, API security, dependency vulnerabilities, security misconfigurations, and compliance validation (PCI-DSS, GDPR, HIPAA). Produces detailed security assessment reports with CVE references, CVSS scores, exploit scenarios, and remediation guidance. Use when reviewing code security, performing security audits, checking for vulnerabilities, validating security controls, assessing security risks, or when users mention "security review", "vulnerability scan", "security audit", "penetration test", "OWASP", "security assessment", "secure coding", or "security compliance".
4metadata:
5 source: https://skillmd.com/skills/aibot88/code-security-review
6---
7
8# Code Security Review
9
10## Overview
11
12Performs comprehensive security code reviews to identify vulnerabilities, assess security risks, and provide actionable remediation guidance. Covers OWASP Top 10, CWE classifications, compliance requirements, and security best practices.
13
14## Security Review Workflow
15
16## 1. Initial Assessment
17
18Gather context about the application:
19
20- **Application type**: Web app, API, mobile, desktop, embedded
21- **Data sensitivity**: PII, financial data, healthcare records, proprietary information
22- **Compliance requirements**: PCI-DSS, GDPR, HIPAA, SOC 2, ISO 27001
23- **Authentication mechanisms**: OAuth, JWT, session-based, API keys
24- **Technology stack**: Languages, frameworks, libraries, databases
25- **External integrations**: Third-party APIs, cloud services, payment processors
26
27Perform threat modeling:
28
29- Identify critical assets (data, functions, resources)
30- Map attack surfaces (user inputs, APIs, file uploads, network interfaces)
31- Determine threat actors (external attackers, malicious insiders, automated bots)
32- Assess existing security controls
33
34### 2. Code Analysis
35
36Systematically review code for security vulnerabilities:
37
38**Priority Areas:**
39
401. **Authentication & Authorization** - Login flows, session management, access controls
412. **Input Validation** - All user inputs, API parameters, file uploads
423. **Data Protection** - Encryption at rest and in transit, sensitive data handling
434. **API Security** - Rate limiting, authentication, input validation
445. **Dependency Security** - Third-party libraries, outdated packages, known CVEs
456. **Configuration** - Security headers, CORS, environment variables, secrets management
467. **Error Handling** - Information disclosure, stack traces, error messages
478. **Business Logic** - Race conditions, workflow bypasses, state manipulation
48
49### 3. Vulnerability Classification
50
51Classify each finding:
52
53- **Severity**: Critical, High, Medium, Low, Informational
54- **CWE ID**: Common Weakness Enumeration identifier
55- **OWASP Category**: Map to OWASP Top 10 if applicable
56- **CVSS Score**: Calculate if applicable (use CVSS 3.1)
57- **Exploitability**: How easy to exploit
58- **Impact**: Data loss, privilege escalation, DoS, data breach
59
60### 4. Documentation
61
62Produce comprehensive security report:
63
64- **Executive Summary** - High-level findings and risk overview
65- **Detailed Findings** - Each vulnerability with code examples and exploit scenarios
66- **Remediation Guidance** - Specific fixes with secure code examples
67- **Compliance Assessment** - Status against required standards
68- **Remediation Timeline** - Prioritized action plan
69- **Security Metrics** - Vulnerability counts by severity and category
70
71## Severity Classification
72
73**Critical (CVSS 9.0-10.0):**
74
75- Remote code execution
76- Authentication bypass
77- SQL injection with data access
78- Hardcoded credentials for production systems
79- Complete access control bypass
80
81**High (CVSS 7.0-8.9):**
82
83- Privilege escalation
84- Sensitive data exposure (PII, financial)
85- Cross-site scripting (XSS) with session theft
86- Insecure deserialization
87- XML external entity (XXE) injection
88
89**Medium (CVSS 4.0-6.9):**
90
91- Information disclosure
92- Cross-site request forgery (CSRF)
93- Weak cryptography
94- Security misconfiguration
95- Missing security headers
96
97**Low (CVSS 0.1-3.9):**
98
99- Version disclosure
100- Verbose error messages
101- Missing best practices
102- Security through obscurity
103
104**Informational:**
105
106- Recommendations for defense in depth
107- Future-proofing suggestions
108- Security hygiene improvements
109
110## Report Structure
111
112Generate security reports in this format:
113
114### Executive Summary
115
116- Total vulnerabilities by severity
117- Critical risk areas
118- Compliance status summary
119- Overall security posture rating
120- Recommended immediate actions
121
122### Detailed Findings
123
124For each vulnerability:
125
126```
127## [SEVERITY] Finding Title (CWE-XXX)
128
129**Severity**: Critical/High/Medium/Low
130**CWE ID**: CWE-XXX
131**OWASP**: A0X:YYYY
132**CVSS Score**: X.X (if applicable)
133
134**Description**:
135[Clear explanation of the vulnerability]
136
137**Location**:
138- File: path/to/file.ext
139- Lines: XX-XX
140- Function/Class: function_name()
141
142**Vulnerable Code**:
143```language
144[Actual vulnerable code snippet]
145```
146
147**Exploit Scenario**:
148[Step-by-step demonstration of how an attacker could exploit this]
149
150**Impact**:
151[What could happen if exploited - data breach, privilege escalation, etc.]
152
153**Remediation**:
154[Specific steps to fix the vulnerability]
155
156**Secure Code Example**:
157
158```language
159[Working secure implementation]
160```
161
162**References**:
163
164- [Relevant CWE, CVE, or documentation links]
165
166```
167
168### Remediation Timeline
169- **Phase 1 (Critical - Week 1)**: List of critical issues
170- **Phase 2 (High - Weeks 2-3)**: List of high severity issues
171- **Phase 3 (Medium - Month 2)**: List of medium severity issues
172- **Phase 4 (Low - Month 3)**: List of low severity issues
173
174### Compliance Assessment
175For each applicable standard, document:
176- Requirements checked
177- Compliance status (Compliant/Non-Compliant/Partially Compliant)
178- Specific gaps identified
179- Remediation needed for compliance
180
181## Detailed References
182
183For comprehensive vulnerability patterns, testing procedures, and compliance details:
184
185- **OWASP Top 10 & CWE Patterns**: See [security-review-workflow.md](references/security-review-workflow.md) for:
186 - Detailed vulnerability patterns for each OWASP Top 10 category
187 - Code examples of vulnerable and secure implementations
188 - Testing procedures and detection methods
189 - Complete CWE mappings and classifications
190
191- **Security Testing Procedures**: See [security-testing-checklist.md](references/security-testing-checklist.md) for:
192 - Comprehensive testing checklist by category
193 - Manual and automated testing techniques
194 - Security testing tools and configurations
195 - API security testing procedures
196
197- **Compliance Requirements**: See [compliance-requirements.md](references/compliance-requirements.md) for:
198 - PCI-DSS requirements and validation
199 - GDPR data protection requirements
200 - HIPAA security and privacy rules
201 - SOC 2 security controls
202
203- **Report Examples**: See [report-example.md](references/report-example.md) for:
204 - Complete security report template
205 - Example findings with remediation guidance
206 - Executive summary examples
207 - Remediation timeline structures
208
209## Best Practices
210
211**Be Thorough:**
212- Review ALL user input points
213- Check ALL database queries
214- Verify ALL authentication and authorization checks
215- Test ALL file operations and uploads
216- Examine ALL external integrations
217
218**Be Practical:**
219- Prioritize by risk (likelihood × impact)
220- Consider exploitability and business context
221- Account for compensating controls
222- Balance security with usability
223
224**Be Clear:**
225- Provide step-by-step exploit scenarios
226- Show exact vulnerable code locations
227- Give specific, actionable remediation steps
228- Include working secure code examples
229
230**Be Professional:**
231- Focus on code issues, not developers
232- Use industry-standard classifications (CWE, OWASP, CVSS)
233- Provide credible references (NIST, OWASP, vendor documentation)
234- Document assumptions and testing limitations
235