appsec.fyi

SQLi — A Practical Guide

A curated AppSec resource library covering XSS, SQLi, SSRF, IDOR, RCE, XXE, OSINT, and more.

SQLi: A Practical Guide

Curated and synthesized by . Last updated 2026-08-16. Synthesized from 143 of 143 curated resources. Browse all 143 SQLi resources →

The Persistent Threat of SQL Injection

SQL Injection (SQLi) remains a foundational and incredibly potent vulnerability class within the application security landscape. Despite its age and the availability of well-understood mitigations, SQLi continues to be a primary vector for data breaches and system compromise across diverse applications and industries. Recent analyses indicate a sustained or even increasing trend in SQLi advisories year-over-year [1][2]. This resilience stems from a combination of human error, complex application logic, the adoption of new technologies without adequate security foresight, and the sheer volume of legacy codebases that continue to harbor these flaws [1][3][4].

Understanding the mechanics of SQLi is crucial for any application security practitioner. It's not merely about detecting a stray quote; it's about recognizing how dynamic query construction, coupled with insufficient input validation, can allow an attacker to manipulate database interactions to their advantage. This can range from simply retrieving sensitive data to achieving full command execution on the underlying server [1][5][6]. The recent exploitation of a critical SQLi in Metabase, allowing unauthenticated administrative access, highlights the real-world impact, with a CVSS score of 10.0 underscoring its severity [7][8][9]. Similarly, SQLi vulnerabilities in AI/LLM frameworks like LiteLLM and LangGraph demonstrate that even cutting-edge technologies are not immune [10][11][12][13][14][15][16].

Core Mechanics of SQL Injection

At its heart, SQL injection occurs when an application takes user-supplied input and incorporates it directly into a SQL query without adequate sanitization or parameterization. This allows an attacker to break out of the intended data context and inject their own SQL code, altering the query's execution path [5][4].

The fundamental flaw lies in the application’s failure to differentiate between executable SQL code and literal data. When user input is concatenated directly into a SQL string, special characters like single quotes ('), double quotes ("), semicolons (;), and comments (--, / ... /) can be used to terminate the original query and introduce new SQL commands [17][18][19][20].

Consider a simplified example of a vulnerable query intended to fetch user data:

SELECT * FROM users WHERE username = '';

If an attacker provides the input ' OR '1'='1, the query transforms into:

SELECT * FROM users WHERE username = '' OR '1'='1';

Since '1'='1' is always true, this modified query bypasses the intended username check and returns all rows from the users table [5][21][6][17].

Beyond simple tautologies, attackers can leverage various SQL constructs to:

Notable Techniques and Attack Vectors

The versatility of SQLi is evident in the myriad techniques attackers employ to find and exploit vulnerabilities, often adapting to specific database behaviors and security controls.

1. In-Band SQLi (Error-Based and UNION-Based)

In-band SQLi is the most straightforward, where the results of the injection are returned directly through the same channel. Error-based SQLi exploits verbose database error messages to reveal information about the database structure and data [31][32][17]. UNION-based SQLi is a powerful method for data exfiltration, allowing attackers to append the results of a second, crafted SELECT statement to the original query’s results, provided the column count and types match [33][32][17][18][19].

2. Inferential (Blind) SQLi

When direct error messages or data returns are suppressed, attackers resort to blind SQLi. This involves inferring information indirectly.

3. Out-of-Band (OOB) SQLi

OOB SQLi is used when the database cannot return data directly through the application's response channel. Instead, attackers leverage database functions to trigger external network requests (e.g., DNS lookups or HTTP callbacks) to an attacker-controlled server to exfiltrate data [41][32][18].

4. Database-Specific Exploits

Modern SQLi exploitation often goes beyond simple data retrieval. Attackers can abuse database features for more profound impact:

5. WAF Bypass Techniques

Web Application Firewalls (WAFs) are a common defense, but attackers constantly develop methods to evade them. Techniques include using comments to obfuscate keywords, encoding payloads (URL, double encoding), case manipulation, whitespace substitution, character set manipulation, and exploiting parsing discrepancies between HTTP/2 and HTTP/1.1 [45][49][50][51][52][53][54][55]. The use of JSON payloads can also bypass WAFs that lack proper JSON syntax parsing [51]. Automated tools like SQLMap offer built-in tamper scripts to aid in WAF evasion [49][31][56][57][58][59][60][61][62].

6. SQLi in Modern Frameworks and APIs

SQLi vulnerabilities continue to emerge in newer technologies, demonstrating that fundamental security principles remain critical:

Detection and Prevention

Effective defense against SQLi requires a multi-layered approach, focusing on both secure coding practices and robust runtime protection.

Secure Coding Practices:

Detection and Runtime Protection:

Tooling for SQLi Hunting and Exploitation

A robust toolkit is essential for practitioners aiming to identify and exploit SQLi vulnerabilities effectively.

Recent Developments and Emerging Trends

The SQLi landscape continues to evolve, with new vectors and challenges emerging:

Where to Go Deeper

For those looking to expand their expertise in SQL injection, numerous resources are available:

Sources cited in this guide

  1. SQL injection isn't dead — aikido.dev
  2. SQL injection isn't dead — aikido.dev
  3. Vibe-Coding's Hidden Danger: SQL Injection Risks Go Live — techbuzz.ai
  4. SQL Attack (Constraint-based) - Dhaval Kapil — dhavalkapil.com
  5. SQL Injection - OWASP — owasp.org
  6. SQL Injection for Bug Bounty Hunters | YesWeHack — yeswehack.com
  7. Critical SQL Injection in Metabase via Password Reset: CVE-2026-72898 — bishopfox.com
  8. Inside the Metabase SQLi: Exploited in the Wild — wiz.io
  9. Metabase Zero-Day Exploited in Wild Allows Admin Access Without Authentication — thehackernews.com
  10. From SQLi to RCE - Exploiting LangGraphs Checkpointer — research.checkpoint.com
  11. U.S. CISA adds a flaw in BerriAI LiteLLM to its Known Exploited Vulnerabilities catalog — securityaffairs.com
  12. CVE-2026-42208: Critical Pre-Auth SQL Injection in LiteLLM Actively Exploited Within 36 Hours of Disclosure — rescana.com
  13. CVE-2026-42208: LiteLLM SQL Injection Leaks Upstream API Keys — abhs.in
  14. CVE-2026-42208: LiteLLM bug exploited 36 hours after its disclosure — securityaffairs.com
  15. LiteLLM CVE-2026-42208 SQL Injection Exploited within 36 Hours of Disclosure — thehackernews.com
  16. Hackers are exploiting a critical LiteLLM pre-auth SQLi flaw — bleepingcomputer.com
  17. SQL Injection Cheatsheet 2021 — hackersonlineclub.com
  18. https://portswigger.net/web-security/sql-injection/cheat-sheet — portswigger.net
  19. Identifying & Exploiting SQL Injection: Manual & Automated — link.medium.com
  20. SQL Injection 101: Common Defense Methods Hackers Should Be Aware Of — null-byte.wonderhowto.com
  21. 7 Types of SQL Injection Attacks & How to Prevent Them — sentinelone.com
  22. Attackers Compile khunt Inside Oracle to Turn SQL Injection Into Windows SYSTEM Access — thehackernews.com
  23. Attackers hid malware inside Oracle Database after SQL injection breach — csoonline.com
  24. Oracle SQL Injection Attack Enables Remote Code Execution — esecurityplanet.com
  25. Hackers run khunt post-exploitation toolkit from Oracle database — bleepingcomputer.com
  26. Hackers Smuggle Post-Exploitation Toolkit Into Oracle Database Via Classic SQL Injection Flaw — itsecurityguru.org
  27. From SQL Injection to Infrastructure-Level RCE: A PostgreSQL Superuser Compromise — infosecwriteups.com
  28. SQL Injection and Postgres: An Adventure to Eventual RCE — pulsesecurity.co.nz
  29. CVE-2025-1094 WebSocket and SQL Injection Exploit Script — github.com
  30. How to turn SQL injection into an RCE or a file read? Case study of 128 bug bounty reports — youtube.com
  31. SQLMap Cheat Sheet: Commands, Options, and Advanced Features — stationx.net
  32. SQL Injection Tutorial & Examples - PortSwigger — portswigger.net
  33. SQL Injection Cheat Sheet - Invicti — invicti.com
  34. Making a Blind SQL Injection a Little Less Blind — medium.com
  35. Discovering an Time-Based Blind SQL Injection in a Tamil Nadu Government Web Portal (TANGEDCO) — infosecwriteups.com
  36. Exploiting Time-Based SQL Injections: Data Exfiltration — medium.com
  37. Advanced SQL Injection Techniques in Modern Web Apps — gauravsingh-cybersecurity.github.io
  38. Bug Bounty Bootcamp #29: Boolean Blind SQL Injection Part 2 — infosecwriteups.com
  39. https://medium.com/bugbountywriteup/sql-injection-time-and-boolean-based-27239b6a55e8?source=twitterShare-1764222123d3-1576594710&_referrer=twitter&_branch_match_id=732557985002302401 — medium.com
  40. GitHub - danialhalo/SqliSniper: Advanced Time-based Blind SQL Injection fuzzer for HTTP Headers — github.com
  41. When the Database Won't Talk: A Deep Dive into Blind SQLi — hadrian.io
  42. Vulnerability analysis, Security Papers, Exploit Tutorials - Part 12975 — exploit-db.com
  43. Vulnerability analysis, Security Papers, Exploit Tutorials - Part 12975 — exploit-db.com
  44. Snowflake SQL Injection via Compile-Time Constant Folding with SYSTEM$WAIT — infosecwriteups.com
  45. Rapid7 Analysis: CVE-2024-12356 — rapid7.com
  46. CVE-2025-1094: PostgreSQL SQL Injection Vulnerability — armosec.io
  47. CVE-2025-1094: PostgreSQL psql SQL Injection (Fixed) — Rapid7 — rapid7.com
  48. PostgreSQL CVE-2025-1094: Quoting APIs SQL Injection — postgresql.org
  49. SQLMap Tamper Collection: Modern WAF Bypass Scripts (Cloudflare, AWS, Azure) — github.com
  50. WAF Bypass Techniques for SQL Injection — nav1n0x.gitbook.io
  51. WAF Bypass Using JSON-Based SQL Injection Attacks — picussecurity.com
  52. WAF Testing Guide: How to Validate Web Application Firewalls — picussecurity.com
  53. Bypassing WAFs in 2025: New Techniques and Evasion Tactics — medium.com
  54. SQL Injection Bypassing WAF | OWASP — owasp.org
  55. open-appsec ML-based WAF protects against modern SQLi AutoSpear evasion techniques — openappsec.io
  56. https://vavkamil.cz/2019/10/09/understanding-the-full-potential-of-sqlmap-during-bug-bounty-hunting/ — vavkamil.cz
  57. SQLMap Command Generator — acorzo1983.github.io
  58. 9 SQLi Detection Tools You Need to Know in 2023 — analyticsinsight.net
  59. TryHackMe | SQHell — tryhackme.com
  60. How I Found multiple SQL Injection with FFUF and Sqlmap in a few minutes — 0xmahmoudjo0.medium.com
  61. https://secnhack.in/website-penetration-testing-and-database-hacking-with-sqlmap/ — secnhack.in
  62. Understanding the full potential of sqlmap during bug bounty hunting — vavkamil.cz
  63. Identifying SQL Injections in a GraphQL API — praetorian.com
  64. SQL Injection in GraphQL — 0xgad.medium.com
  65. Hackers Exploit Newly Patched WordPress Vulnerabilities — techrepublic.com
  66. Unauthenticated RCE in WordPress core (wp2shell), via SQL injection — aikido.dev
  67. Unauthenticated RCE in WordPress core (wp2shell) — aikido.dev
  68. Getting started with query parameterization — snyk.io
  69. Preventing SQL injection attacks in Node.js — snyk.io
  70. Preventing SQL injection in C# with Entity Framework — snyk.io
  71. What is SQL Injection? How to Prevent SQL Injection | Fortinet — fortinet.com
  72. SQL Injection Wiki — sqlwiki.netspi.com
  73. Demystifying SQL Injection: A Comprehensive Guide to Understanding SQL Injection Risks — akto.io
  74. SQL Injection Cheat Sheet by Netsparker — netsparker.com
  75. Bug hunter tracks down three serious MCP database flaws one left unpatched — theregister.com
  76. CVE-2026-5197: Student Membership System SQLi Vulnerability — sentinelone.com
  77. New cPanel Critical Flaw Could Let Hosting Customers Run SQL as Database Root — thehackernews.com
  78. Test website for SQL injection vulnerabilities using Python — imran-niaz.medium.com
  79. Comprehensive Guide to Sqlmap (Target Options) — linkedin.com
  80. CVE-2026-26116: SQL Server SQL Injection — sentinelone.com
  81. SQL Injection Wiki — sqlwiki.netspi.com
  82. BChecks/vulnerability-classes/injection at main · PortSwigger/BChecks · GitHub — github.com
  83. http://www.darknet.org.uk/2017/09/bsqlinjector-blind-sql-injection-tool-download-ruby/ — darknet.org.uk
  84. BSQLinjector – Blind SQL Injection Tool Download in Ruby — darknet.org.uk
  85. NucleiFuzzer - Powerful Automation Tool For Detecting XSS, SQLi, SSRF, Open — kitploit.com
  86. Favorite tweet by @harshbothra_ — twitter.com
  87. DVWA 1.9+: Blind SQL Injection with SQLMap — link.medium.com
  88. SQL Attack (Constraint-based) - Dhaval Kapil — dhavalkapil.com
  89. SQL Injection Cheat Sheet by Netsparker — netsparker.com
  90. SQL Injection in Password Reset: Full Database, One Email — infosecwriteups.com
  91. Exploiting Second-Order SQL Injection to Retrieve the Flag — medium.com
  92. Exploiting SQL Injection Vulnerability - Bug Bounty Writeup — medium.com
  93. How I Found Multiple SQL Injections in 5 Minutes in Bug Bounty — medium.com
  94. https://github.com/yeswehack/vulnerable-code-snippets — github.com
  95. Advanced SQL Injection Cheatsheet — github.com
  96. 10 Types of Web Vulnerabilities that are Often Missed — labs.detectify.com
  97. SQL injection to RCE — medium.com
📚 This guide is synthesized from the full text of resources curated in the SQLi library, and refreshed as new material is added.