security-analysis
Security Analysis
Procedures for security vulnerability analysis and code auditing.
When to Use
- Reviewing code for security vulnerabilities
- Conducting security audits
- Implementing security best practices
Core Principles
- Assume All External Input is Malicious - Validate and sanitize all user input
- Principle of Least Privilege - Only grant necessary permissions
- Fail Securely - Never expose sensitive information in errors
Vulnerability Categories
Injection (OWASP A03)
Look for:
- SQL queries with string concatenation
- Shell commands with user input
- Template injection vulnerabilities
# VULNERABLE
query = f"SELECT * FROM users WHERE id = {user_id}"
# SECURE
query = "SELECT * FROM users WHERE id = %s"
cursor.execute(query, (user_id,))
Broken Authentication (OWASP A07)
Check for:
- Weak session token generation
- Missing rate limiting on auth endpoints
- Insecure password reset flows
Sensitive Data Exposure (OWASP A02)
Check for:
- Hardcoded secrets in code
- PII in logs
- Unencrypted sensitive data storage
# VULNERABLE - PII in logs
logger.info(f"Processing payment for {user_email}: ${amount}")
# SECURE
logger.info(f"Processing payment for user_id={user_id}: ${amount}")
Security Misconfiguration (OWASP A05)
Check for:
- Debug mode enabled in production
- Verbose error messages
- Unnecessary services/ports exposed
Analysis Procedure
- Identify Privacy Sources - User input, API parameters, files
- Trace to Privacy Sinks - Logs, external APIs, responses
- Check for Sanitization - Validation, encoding, parameterization
- Assess Severity - Critical, High, Medium, Low
Severity Levels
| Level | Impact | Example |
|---|---|---|
| Critical | RCE, full compromise | SQL injection with RCE |
| High | Data breach, auth bypass | IDOR on sensitive data |
| Medium | Limited data access | Reflected XSS |
| Low | Minor info disclosure | Verbose errors |
Resources
More from kinhluan/skills
scheduling-algorithms
Job scheduling algorithms for parallel and distributed systems
5ddd-core
Professional Strategic Domain-Driven Design (DDD) Hub. Use this skill for Event Storming, identifying Subdomains, defining Bounded Contexts, and mapping Domain Models to the heart of your architecture.
4c4-model
Professional C4 model architecture hub for "Design-to-Code Sync". Use this skill to navigate the C4 hierarchy, map diagrams to stakeholders, avoid architectural anti-patterns, and choose the right level for designing or documenting existing codebases.
4ddd-tactical
Tactical Domain-Driven Design (DDD) with Scoring Rubric. Use this skill when designing internal domain models or performing architectural reviews to ensure domain logic is isolated and rich.
4ddd-patterns
Advanced Domain-Driven Design (DDD) Integration Patterns. Use this skill for implementing CQRS, Event Sourcing, the Outbox Pattern, and Anti-Corruption Layers (ACL) in distributed systems.
4c4-level4-code
Specialized in Code diagrams (Level 4) of the C4 model. Use this skill when the user needs to describe the internal implementation of a component using UML class diagrams or database ER diagrams.
4