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-09-01. Synthesized from 152 of 152 curated resources. Browse all 152 SQLi resources →

Problem Framing

SQL injection (SQLi) remains a persistent and critical vulnerability in application security, despite decades of awareness and established mitigation techniques [1][2][3][4][5][6][7][8][9][10][11]. Attackers leverage SQLi to manipulate database queries by inserting malicious SQL code into application input fields, leading to unauthorized access, data theft, data corruption, or even full system compromise [1][4][5][6][7][8][9][10][11]. The prevalence of SQLi is attributed to weaknesses in input validation and sanitization, inadequate secure software development practices, reliance on legacy systems, and the speed of modern development cycles that can sometimes prioritize functionality over security [1][2][3][12].

Recent disclosures highlight the ongoing threat. In August 2026, ServiceNow patched three critical vulnerabilities, including an SQL injection flaw (CVE-2026-74820) that allowed unauthenticated attackers to execute arbitrary SQL statements against its database [13][14][15]. Similarly, critical SQL injection vulnerabilities in Metabase (CVE-2026-72898) were actively exploited in the wild, granting attackers administrative access without authentication [16][17][18][19][20][21]. The continued discovery of SQLi in widely used platforms and frameworks, such as WordPress [22][23][24], LiteLLM [25][26][27][28][29][30][31], and various CMS platforms [32][33][34][35][36][37][38][39], demonstrates that SQLi is far from a solved problem [1][2][3][12]. Furthermore, sophisticated attacks leveraging SQLi to achieve Remote Code Execution (RCE) and operate within database internals, such as the Khunt toolkit campaign against Oracle databases, showcase the evolving threat landscape [40][41][42][43][44].

Core Mechanics

At its heart, SQL injection occurs when user-supplied input is not properly validated, sanitized, or parameterized before being incorporated into SQL queries. This allows an attacker to inject SQL meta-characters or entire SQL statements that are interpreted by the database as legitimate commands. The fundamental vulnerability stems from treating user input as code rather than data [1][4][45][46][5][6][7][8][9][10][47][48][49].

When an application directly concatenates user input into a SQL query string, an attacker can manipulate the query's structure. For instance, injecting a single quote (') can terminate the intended string literal, allowing subsequent SQL syntax to be appended. This can be used to bypass authentication, extract data from unintended tables, modify data, or even execute arbitrary commands on the database server or the underlying operating system [1][5][6][7][8][9][10][47][48][49].

The core mechanics involve:

Notable Techniques

SQL injection techniques have evolved from simple error-based injections to sophisticated methods that can bypass security controls and achieve complex outcomes. The following are some of the notable techniques observed in recent reports:

In-band SQLi (Classic SQLi)

This category includes attacks where attackers use the same communication channel to launch the attack and retrieve results. It is further divided into error-based and UNION-based techniques [1][6][11][60][61][62][63][64][65][8][9][66][67][10][47][48][49][59]:

Inferential (Blind) SQLi

In blind SQL injection, the application does not directly return query results or error messages. Attackers infer information by observing indirect clues, such as differences in page content or response times [1][68][55][69][70][51][50][56][71][6][72][60][61][62][7][66][67][10][48][73][49][59]:

Second-Order SQL Injection

In this variant, the malicious SQL code is first stored in the database by one part of the application and then executed later by another part, often without re-validating the stored input. This makes detection more challenging as the exploitation is delayed [80][77][81][82][10][49].

SQLi Leading to RCE

More severe than data exfiltration, SQL injection can be chained with other vulnerabilities or database features to achieve Remote Code Execution (RCE). This can involve leveraging database functions to execute OS commands, writing malicious files (like web shells) to the server, or abusing embedded scripting capabilities within the database itself [83][84][40][41][42][43][44][85][62][82]. For example, attackers have used Oracle's embedded JVM to compile and execute Java code stored within the database, bypassing traditional endpoint defenses [40][41][42][43][44]. PostgreSQL's lo_export function, in conjunction with WebSocket hijacking, has also been demonstrated to achieve RCE [86].

WAF Bypass Techniques

Web Application Firewalls (WAFs) are often deployed to detect and block common SQLi payloads. However, attackers employ various techniques to evade WAF detection, including:

Database-Specific Exploitation

Different database systems have unique functions and behaviors that can be exploited:

Exploiting GraphQL APIs

Even modern API technologies like GraphQL are not immune to SQL injection. Attackers can inject SQL payloads into GraphQL queries, often by manipulating parameters or leveraging how the underlying data is fetched and processed [101][102].

Detection & Prevention

Effectively mitigating SQL injection requires a multi-layered approach encompassing secure coding practices, robust input validation, and runtime security measures.

Secure Coding Practices

The most fundamental and effective defense is to strictly separate SQL code from user-supplied data. This is achieved through:

Input Validation and Sanitization

While not a replacement for parameterized queries, robust input validation acts as a crucial defense-in-depth layer:

Database and Application Security

Runtime Protection

AI in Security

AI-powered tools are emerging for both detecting and preventing SQLi, including identifying complex, logic-dependent injections missed by traditional SAST, and potentially assisting in WAF rule generation [17][2][3][12][94]. However, AI coding assistants can also inadvertently introduce SQLi if not carefully guided and reviewed [12][117].

Tooling

A robust set of tools exists for identifying, exploiting, and even helping to prevent SQL injection vulnerabilities:

Recent Developments

SQL injection continues to be a prominent threat vector, with ongoing research and real-world exploitation demonstrating its adaptability and persistence:

Where to Go Deeper

For those looking to deepen their understanding and practical skills in SQL injection, the following resources are highly recommended:

Sources cited in this guide

  1. SQL injection remains a persistent cyber threat after two decades — informante.web.na
  2. SQL injection isn't dead — aikido.dev
  3. SQL injection isn't dead — aikido.dev
  4. Getting started with query parameterization — snyk.io
  5. SQL Injection - OWASP — owasp.org
  6. SQL Injection 101: Common Defense Methods Hackers Should Be Aware Of — null-byte.wonderhowto.com
  7. 10 Types of Web Vulnerabilities that are Often Missed — labs.detectify.com
  8. https://secnhack.in/website-penetration-testing-and-database-hacking-with-sqlmap/ — secnhack.in
  9. SQL Injection Cheat Sheet by Netsparker — netsparker.com
  10. SQL Injection 101: Common Defense Methods Hackers Should Be Aware Of — null-byte.wonderhowto.com
  11. 9 SQLi Detection Tools You Need to Know in 2023 — analyticsinsight.net
  12. Vibe-Coding's Hidden Danger: SQL Injection Risks Go Live — techbuzz.ai
  13. ServiceNow Patches 3 Critical Code Injection Vulnerabilities — securityweek.com
  14. Three CVSS 10.0 ServiceNow Flaws Could Let Unauthenticated Attackers Execute Code and SQL — thehackernews.com
  15. ServiceNow warns of three max severity security vulnerabilities — bleepingcomputer.com
  16. Critical SQL Injection in Metabase via Password Reset: CVE-2026-72898 — bishopfox.com
  17. Inside the Metabase SQLi: Exploited in the Wild — wiz.io
  18. Inside the Metabase SQLi: Exploited in the Wild — wiz.io
  19. Metabase Zero-Day Exploited in Wild Allows Admin Access Without Authentication — thehackernews.com
  20. Metabase flaw hands attackers admin access with no login and it is already being exploited — pasqualepillitteri.it
  21. Trezor Data Breach Analysis: 14000 Customers Exposed in ShipMonk Metabase SQL Injection Incident — rescana.com
  22. Hackers Exploit Newly Patched WordPress Vulnerabilities — techrepublic.com
  23. Unauthenticated RCE in WordPress core (wp2shell), via SQL injection — aikido.dev
  24. Unauthenticated RCE in WordPress core (wp2shell) — aikido.dev
  25. U.S. CISA adds a flaw in BerriAI LiteLLM to its Known Exploited Vulnerabilities catalog — securityaffairs.com
  26. CVE-2026-42208: Critical Pre-Auth SQL Injection in LiteLLM Actively Exploited Within 36 Hours of Disclosure — rescana.com
  27. CVE-2026-42208: LiteLLM SQL Injection Leaks Upstream API Keys — abhs.in
  28. CVE-2026-42208: LiteLLM bug exploited 36 hours after its disclosure — securityaffairs.com
  29. Fresh LiteLLM Vulnerability Exploited Shortly After Disclosure — securityweek.com
  30. LiteLLM CVE-2026-42208 SQL Injection Exploited within 36 Hours of Disclosure — thehackernews.com
  31. Hackers are exploiting a critical LiteLLM pre-auth SQLi flaw — bleepingcomputer.com
  32. Vulnerabilities in Windu CMS software — cert.pl
  33. Vulnerabilities in Redeight CMS software — cert.pl
  34. Ghost CMS Vulnerability Exploited to Hack Over 700 Websites — securityweek.com
  35. Ghost CMS CVE-2026-26980 Exploited to Hijack 700 Sites for ClickFix Attacks — thehackernews.com
  36. Avada Builder Flaws Expose One Million WordPress Sites — infosecurity-magazine.com
  37. Unauthenticated SQL Injection in GUI — Fortinet PSIRT — fortiguard.fortinet.com
  38. CVE-2026-27697: Basercms SQLi Vulnerability — sentinelone.com
  39. CVE-2026-5197: Student Membership System SQLi Vulnerability — sentinelone.com
  40. Attackers Compile khunt Inside Oracle to Turn SQL Injection Into Windows SYSTEM Access — thehackernews.com
  41. Attackers hid malware inside Oracle Database after SQL injection breach — csoonline.com
  42. Oracle SQL Injection Attack Enables Remote Code Execution — esecurityplanet.com
  43. Hackers run khunt post-exploitation toolkit from Oracle database — bleepingcomputer.com
  44. Hackers Smuggle Post-Exploitation Toolkit Into Oracle Database Via Classic SQL Injection Flaw — itsecurityguru.org
  45. Preventing SQL injection attacks in Node.js — snyk.io
  46. Preventing SQL injection in C# with Entity Framework — snyk.io
  47. Barebones Application Security — SQL Injection (SQLi) — medium.com
  48. SQL Injection Wiki — sqlwiki.netspi.com
  49. SQL Attack (Constraint-based) - Dhaval Kapil — dhavalkapil.com
  50. PayloadsAllTheThings - SQL Injection — github.com
  51. SQLi Payloads - Classic, Blind, Error-Based, Time-Based, WAF Bypass — github.com
  52. SQL Injection and Postgres: An Adventure to Eventual RCE — pulsesecurity.co.nz
  53. SQL Injection Cheat Sheet - Invicti — invicti.com
  54. Advanced Boolean-Based SQLi Filter Bypass Techniques — secjuice.com
  55. SQL Injection Tutorial & Examples - PortSwigger — portswigger.net
  56. SQL Injection Wiki — sqlwiki.netspi.com
  57. SQL Injection Cheat Sheet by Netsparker — netsparker.com
  58. Vulnerability analysis, Security Papers, Exploit Tutorials - Part 12975 — exploit-db.com
  59. Vulnerability analysis, Security Papers, Exploit Tutorials - Part 12975 — exploit-db.com
  60. Demystifying SQL Injection: A Comprehensive Guide to Understanding SQL Injection Risks — akto.io
  61. Favorite tweet by @harshbothra_ — twitter.com
  62. Advanced SQL Injection Cheatsheet — github.com
  63. Web Attack Cheat Sheet — github.com
  64. DVWA 1.9+: Blind SQL Injection with SQLMap — link.medium.com
  65. Exploiting Error Based SQL Injections & Bypassing Restrictions — link.medium.com
  66. https://medium.com/bugbountywriteup/sql-injection-time-and-boolean-based-27239b6a55e8?source=twitterShare-1764222123d3-1576594710&_referrer=twitter&_branch_match_id=732557985002302401 — medium.com
  67. Making a Blind SQL Injection a Little Less Blind — medium.com
  68. When the Database Won't Talk: A Deep Dive into Blind SQLi — hadrian.io
  69. Bug Bounty Bootcamp #29: Boolean Blind SQL Injection Part 2 — infosecwriteups.com
  70. 7 Types of SQL Injection Attacks & How to Prevent Them — sentinelone.com
  71. https://medium.com/bugbountywriteup/sql-injection-time-and-boolean-based-27239b6a55e8?source=twitterShare-1764222123d3-1576594710&_referrer=twitter&_branch_match_id=732557985002302401 — medium.com
  72. TryHackMe | SQHell — tryhackme.com
  73. BSQLinjector – Blind SQL Injection Tool Download in Ruby — darknet.org.uk
  74. Snowflake SQL Injection via Compile-Time Constant Folding with SYSTEM$WAIT — infosecwriteups.com
  75. Discovering an Time-Based Blind SQL Injection in a Tamil Nadu Government Web Portal (TANGEDCO) — infosecwriteups.com
  76. Exploiting Time-Based SQL Injections: Data Exfiltration — medium.com
  77. Advanced SQL Injection Techniques in Modern Web Apps — gauravsingh-cybersecurity.github.io
  78. Second-Order SQL Injection with Stored Procedures and DNS-Based Egress — netspi.com
  79. https://portswigger.net/web-security/sql-injection/cheat-sheet — portswigger.net
  80. Exploiting Second-Order SQL Injection to Retrieve the Flag — medium.com
  81. Exploiting second order blind SQL injection — link.medium.com
  82. SQL injection to RCE — medium.com
  83. From SQL Injection to Remote Code Execution: Following an Unexpected Attack Chain — infosecwriteups.com
  84. Early exploitation attempts observed of GeoServer zero day — fieldeffect.com
  85. How to turn SQL injection into an RCE or a file read? Case study of 128 bug bounty reports — youtube.com
  86. CVE-2025-1094 WebSocket and SQL Injection Exploit Script — github.com
  87. SQLMap Tamper Collection: Modern WAF Bypass Scripts (Cloudflare, AWS, Azure) — github.com
  88. WAF Bypass Techniques for SQL Injection — nav1n0x.gitbook.io
  89. Bypassing WAF with Adversarial SQL — dl.acm.org
  90. WAF Bypass Using JSON-Based SQL Injection Attacks — picussecurity.com
  91. WAF Testing Guide: How to Validate Web Application Firewalls — picussecurity.com
  92. Bypassing WAFs in 2025: New Techniques and Evasion Tactics — medium.com
  93. SQL Injection Bypassing WAF | OWASP — owasp.org
  94. open-appsec ML-based WAF protects against modern SQLi AutoSpear evasion techniques — openappsec.io
  95. New "LeakyLooker" Flaws in Google Looker Studio Could Enable Cross-Tenant SQL Queries — thehackernews.com
  96. PostgreSQL CVE-2025-1094: Quoting APIs SQL Injection — postgresql.org
  97. Rapid7 Analysis: CVE-2024-12356 — rapid7.com
  98. CVE-2025-1094: PostgreSQL SQL Injection Vulnerability — armosec.io
  99. CVE-2025-1094: PostgreSQL psql SQL Injection (Fixed) — Rapid7 — rapid7.com
  100. SQL Attack (Constraint-based) - Dhaval Kapil — dhavalkapil.com
  101. Identifying SQL Injections in a GraphQL API — praetorian.com
  102. SQL Injection in GraphQL — 0xgad.medium.com
  103. What is SQL Injection? How to Prevent SQL Injection | Fortinet — fortinet.com
  104. SQL Injection for Bug Bounty Hunters | YesWeHack — yeswehack.com
  105. https://github.com/yeswehack/vulnerable-code-snippets — github.com
  106. CVE-2025-26794: Blind SQL Injection in Exim 4.98 — Writeup — github.com
  107. 38 Vulnerabilities Found in OpenEMR Medical Software — securityweek.com
  108. CVE-2025-52694 PoC: Critical SQL Injection in Advantech IoTSuite/SaaS-Composer — github.com
  109. April 2026 Patch Tuesday: Critical Vulnerabilities in SAP Adobe Microsoft SharePoint Fortinet and ColdFusion Threaten Enterprise Security — rescana.com
  110. SAP Security Patch Day April 2026: Critical Vulnerabilities CVSS 9.9 SQL Injection and Authorization Risks — erp.today
  111. 400K WordPress Sites Exposed by Elementor Ally Plugin SQL Flaw — esecurityplanet.com
  112. CVE-2026-26116: SQL Server SQL Injection — sentinelone.com
  113. Writeups for Damn Vulnerable Web Application (DVWA) — medium.com
  114. Test website for SQL injection vulnerabilities using Python — imran-niaz.medium.com
  115. Exploiting an SQL Injection with WAF Bypass — vaadata.com
  116. Comprehensive Guide to Sqlmap (Target Options) — linkedin.com
  117. https://weekly.infosecwriteups.com/iw-weekly-39-10-000-bounty-zero-click-account-takeover-stored-xss-open-redirection-vulnerability-sql-injection-rce-reconnaissance-techniques-and-much-more/ — weekly.infosecwriteups.com
  118. SQLMap Cheat Sheet: Commands, Options, and Advanced Features — stationx.net
  119. https://vavkamil.cz/2019/10/09/understanding-the-full-potential-of-sqlmap-during-bug-bounty-hunting/ — vavkamil.cz
  120. SQLMap Command Generator — acorzo1983.github.io
  121. How I Found multiple SQL Injection with FFUF and Sqlmap in a few minutes — 0xmahmoudjo0.medium.com
  122. Understanding the full potential of sqlmap during bug bounty hunting — vavkamil.cz
  123. BChecks/vulnerability-classes/injection at main · PortSwigger/BChecks · GitHub — github.com
  124. NucleiFuzzer - Powerful Automation Tool For Detecting XSS, SQLi, SSRF, Open — kitploit.com
  125. http://www.darknet.org.uk/2017/09/bsqlinjector-blind-sql-injection-tool-download-ruby/ — darknet.org.uk
  126. GitHub - danialhalo/SqliSniper: Advanced Time-based Blind SQL Injection fuzzer for HTTP Headers — github.com
  127. From SQL Injection to Infrastructure-Level RCE: A PostgreSQL Superuser Compromise — infosecwriteups.com
  128. From SQLi to RCE - Exploiting LangGraphs Checkpointer — research.checkpoint.com
  129. Pentesting PostgreSQL with SQL Injections — onsecurity.io
  130. MCP Vulnerability Case Study: SQL Injection in the Postgres MCP Server — securitylabs.datadoghq.com
  131. Identifying & Exploiting SQL Injection: Manual & Automated — link.medium.com
📚 This guide is synthesized from the full text of resources curated in the SQLi library, and refreshed as new material is added.