A handpicked, educational repository featuring 60 side-by-side vulnerable vs. secure code patterns across modern web applications, APIs, authentication mechanisms, cryptography, and artificial intelligence systems.
Every guide follows a structured standard:
- Introduction: Conceptual overview of the security flaw and attacker impact.
- Vulnerable Code: Real-world code sample demonstrating the exploitable pattern.
- Exploit & Flaw Breakdown: Step-by-step root-cause analysis.
- Secure Code: Production-grade refactored implementation applying robust security controls.
- Remediation Controls: Deep architectural defense guidance.
- LLM01: Prompt Injection — Direct and indirect prompt injection attacks.
- LLM02: Sensitive Information Disclosure — LLMs returning private credentials, PII, and internal secrets.
- LLM03: Supply Chain Vulnerabilities in AI Systems — Compromised base models, packages, and unverified AI dependencies.
- LLM04: Data and Model Poisoning — Manipulating training and fine-tuning data to introduce backdoors.
- LLM05: Improper Output Handling — Executing unsanitized model output leading to XSS, SSRF, or RCE.
- LLM06: Excessive Agency in AI Agents — Autonomous agents granted excessive permissions or destructive tools.
- LLM07: System Prompt Leakage — Extracting hidden developer instructions and guardrails.
- LLM08: Vector and Embedding Weaknesses — Manipulating semantic distance and vector similarity in RAG.
- LLM09: Misinformation and Overreliance — Uncritical acceptance of hallucinated, factually false, or unsafe LLM outputs.
- LLM10: Unbounded Consumption — Context window flooding and resource exhaustion denial of service.
- SQL Injection (SQLi) — Unsanitized query concatenation leading to database compromise.
- NoSQL Injection — Bypassing authentication via MongoDB/CouchDB query operators.
- Remote Code Execution (RCE) — Arbitrary operating system command execution.
- Server-Side Template Injection (SSTI) — Template expression evaluation leading to sandbox escape.
- HTTP Response Header Injection (CRLF) — Newline injection causing HTTP response splitting.
- Host Header Injection — Manipulating HTTP Host headers for password reset poisoning.
- LDAP Injection — Manipulating directory service queries to bypass authentication.
- XPath Injection — Exploiting XML database queries to extract sensitive nodes.
- XML External Entity (XXE) Injection — Arbitrary file disclosure and SSRF via XML parsers.
- Log Injection — Forging audit log entries through newline injection.
- JWT Authentication Bypass — None algorithm and weak HMAC signing keys.
- Brute Force Attacks — Defending login endpoints with adaptive rate limiting and account lockouts.
- Insecure Password Storage — Replacing MD5/SHA1 with Argon2id and bcrypt.
- Weak Password Policy — Enforcing robust length, entropy, and dictionary checks.
- Insecure Password Reset – Token Exposed in Response — Preventing reset tokens from leaking in API responses.
- Session Fixation — Regenerating session tokens upon authentication state transitions.
- Missing Session Expiry & Logout Invalidation — Server-side session termination.
- Insecure Direct Object References (IDOR) — Missing horizontal object authorization checks.
- Broken Function Level Authorization (BFLA) — Unprivileged access to administrative API functions.
- Mass Assignment (BOPLA) — Overwriting privileged database fields through auto-binding.
- Stored Cross-Site Scripting (XSS) — Persisted script execution in user-facing views.
- Reflected Cross-Site Scripting (XSS) — Immediate reflected script execution from query parameters.
- DOM Cross-Site Scripting (XSS) — Dangerous client-side sinks (
innerHTML,eval). - Cross-Site Request Forgery (CSRF) — Defending state-changing requests with anti-CSRF tokens and SameSite cookies.
- Clickjacking — UI redressing defense with
frame-ancestorsandX-Frame-Options. - Prototype Pollution — Object prototype manipulation in JavaScript applications.
- Open Redirection — Validating redirect parameters against strict allowlists.
- Sensitive Data Stored in Browser Storage — Eliminating secrets from localStorage and sessionStorage.
- CORS Misconfiguration — Preventing arbitrary Origin reflection with credentials.
- Missing Rate Limiting on APIs — Throttling high-frequency requests.
- Disabled TLS Certificate Validation — Enforcing strict certificate pinning and trust stores.
- Hardcoded Credentials — Migrating secrets to environment variables and vault managers.
- Missing CSP Header — Restricting resource origins with Content-Security-Policy.
- HSTS not Implemented — Enforcing strict HTTPS transport encryption.
- HttpOnly Flag not Set — Protecting cookies from client-side script access.
- Secure Cookie not Set — Preventing cookie transmission over cleartext HTTP.
- Verbose Error Messages & Stack Trace Disclosure — Sanitizing error responses.
- Java Deserialization — Vulnerable
ObjectInputStreamgadget chains. - Insecure Deserialization in Python (Pickle) — Remote code execution via untrusted
pickle.loads. - Zip Slip (Insecure Archive Extraction) — Path traversal during archive decompression.
- Local File Inclusion (LFI) — Arbitrary local system file reading.
- Remote File Inclusion (RFI) — Remote script execution through dynamic inclusion.
- Unrestricted File Upload — Enforcing extension allowlists, MIME checks, and storage segregation.
- Server-Side Request Forgery (SSRF) — Restricting outbound HTTP requests from backend servers.
- Use of Weak Cryptographic Algorithms — Upgrading MD5/DES to AES-GCM and SHA-256.
- Insecure Randomness in Security Tokens — Using cryptographically secure pseudorandom number generators (
CSPRNG). - GraphQL Introspection & Query Depth Abuse — Mitigating schema exposure and denial of service.
- Race Condition (TOCTOU) — Database transactions and mutex locks to prevent double-spending.
- Application-Level Denial of Service (DoS) — Mitigating CPU and memory exhaustion attacks.
- Regular Expression Denial of Service (ReDoS) — Eliminating polynomial and exponential regex backtracking.
Developed and maintained by Piyush Kumawat at SecurityCipher.
- Website: securitycipher.com
- Documentation: securitycipher.com/docs-category/secure-code
- Twitter / X: @piyush_supiy · @bountywriteups
- Telegram Channel: t.me/dailybountywriteup
- Discord Community: Join Discord