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

Problem Framing: The Enduring Threat of SQL Injection

SQL injection (SQLi) remains a persistent and critical vulnerability class in modern web applications. Despite decades of awareness, well-understood remediation techniques, and its consistent presence in the OWASP Top 10 [1][2], SQLi continues to be a leading cause of data breaches and system compromise. This enduring threat is not due to a lack of solutions, but rather the complex interplay of legacy systems, developer practices, evolving attack methodologies, and the sheer scale of interconnected software components.

The fundamental mechanism of SQLi is the injection of malicious SQL code into user-supplied input, which is then executed by the database. This bypasses intended application logic, allowing attackers to access, modify, or delete data, and in severe cases, gain control over the underlying server. The impact can be catastrophic, ranging from sensitive data exfiltration (credentials, PII, financial data) to complete system compromise and ransomware operations [3][4][5][6][7][8][9][10][11][12][13][14][15][2][16]. The persistence of SQLi is often attributed to the expediency of string concatenation over parameterized queries under development pressure, outdated codebases, and the propagation of insecure coding patterns from tutorials or Stack Overflow examples [1]. Even with the rise of ORMs and frameworks, vulnerabilities can still occur when raw SQL execution methods are used improperly [1]. The rapid adoption of AI-generated code also introduces risks, as developers may deploy code without fully understanding its security implications, inadvertently creating new SQLi avenues [17].

Core Mechanics: How SQL Injection Works

At its heart, SQL injection exploits the trust an application places in user input when constructing SQL queries. When an application dynamically builds SQL statements by directly concatenating user-provided strings without proper sanitization or parameterization, it creates an opening for attackers. By inserting SQL syntax into what is expected to be data, an attacker can alter the query's structure and intended execution path [3][1][18][4][6][8][19][9][20][11][21][22][23][24][25][26][27].

Consider a typical login query:

SELECT * FROM users WHERE username = 'user_input_username' AND password = 'user_input_password';

If the application concatenates the username input directly, an attacker could submit:

' OR '1'='1' --

This input, when injected, transforms the query into:

SELECT * FROM users WHERE username = '' OR '1'='1' --' AND password = '...';

The ' OR '1'='1' condition always evaluates to true, and the -- (or #, /* etc., depending on the SQL dialect) acts as a comment, effectively neutralizing the rest of the original query. This bypasses authentication, allowing the attacker to log in as any user without knowing their password [1][18][28][2][16][29][30][31][23][32][33].

The core vulnerability lies in the failure to separate SQL code from user-supplied data. This separation is primarily achieved through two methods: parameterized queries (using prepared statements) and strict input validation/sanitization [3][1][4][18]. Escaping characters is a less robust method, as it's prone to error and bypasses [4].

Notable Techniques and Attack Modes

SQL injection attacks can be broadly categorized based on how the attacker retrieves data or influences the database's behavior:

In-Band SQL Injection

This is the most common type, where the attacker uses the same communication channel to both launch the attack and retrieve results. This includes:

Inferential (Blind) SQL Injection

This technique is employed when the application does not directly return database query results or error messages. The attacker infers information by observing the application's behavior, often through indirect means [41][34][16][42][37][38][43][44].

Out-of-Band SQL Injection

This technique is used when the application's response channel cannot be used for data exfiltration. Attackers trigger the database to make an external network request (e.g., DNS lookup or HTTP request) to an attacker-controlled server. This is useful in highly restricted environments with blocked outbound HTTP/S traffic [1][41][34][47][48].

Examples include using functions that interact with the file system or trigger network calls. For instance, in PostgreSQL, lo_export() can be used with pg_read_file() to exfiltrate file contents [49][50][51][52].

Specific Attack Vectors and Bypass Techniques

Attackers continually develop methods to bypass security controls like Web Application Firewalls (WAFs) and discover novel ways to exploit vulnerabilities.

Detection and Prevention: Building Secure Systems

The most effective defense against SQL injection is the complete separation of SQL code from user-supplied data. This is achieved through:

Regular security audits, code reviews, and the use of security scanning tools (DAST) are also critical for identifying and mitigating SQL injection vulnerabilities [18][4][85][84][28][56][86][39][87][33].

Tooling for SQL Injection Testing

A variety of tools are available to assist practitioners in detecting and exploiting SQL injection vulnerabilities:

Recent Developments and Trends

The landscape of SQL injection is constantly evolving, with attackers finding new ways to bypass defenses and exploit novel technologies:

Where to Go Deeper

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

Sources cited in this guide

  1. SQL Injection: Why It Persists and How to Prevent It — latesthackingnews.com
  2. SQL Injection - OWASP — owasp.org
  3. Getting started with query parameterization — snyk.io
  4. Preventing SQL injection in C# with Entity Framework — snyk.io
  5. Ghost CMS Under Siege: How a SQL Injection Turned 700 Blogs Into Malware Distribution Networks — securityboulevard.com
  6. AnonymousPostgreSQL Injection in Drupal Core (CVE-2026-9082) — securityboulevard.com
  7. Drupal bug added to CISA list of known exploited vulnerabilities — scworld.com
  8. CISA Warns Drupal Core SQL Injection Vulnerability Is Being Exploited in Attacks — gbhackers.com
  9. CVE-2026-9082: Drupal's Highly Critical SQL Injection Flaw Is Already Under Active Attack — securityaffairs.com
  10. Drupal Core SQL Injection Vulnerability (CVE-2026-9082) — securityboulevard.com
  11. Drupal: Critical SQL injection flaw now targeted in attacks — bleepingcomputer.com
  12. Drupal Patches Highly Critical Vulnerability Exposing Websites to Hacking — securityweek.com
  13. 1 Million WordPress Sites Affected by Avada Builder File Read and SQL Injection Flaws — cybersecuritynews.com
  14. SAP Patches Critical SQL injection Vulnerability in SAP S/4HANA — cybersecuritynews.com
  15. 38 Vulnerabilities Found in OpenEMR Medical Software — securityweek.com
  16. 7 Types of SQL Injection Attacks & How to Prevent Them — sentinelone.com
  17. Vibe-Coding's Hidden Danger: SQL Injection Risks Go Live — techbuzz.ai
  18. Preventing SQL injection attacks in Node.js — snyk.io
  19. U.S. CISA adds a flaw in Drupal Core to its Known Exploited Vulnerabilities catalog — securityaffairs.com
  20. CVE-2026-9082: Critical Drupal Core SQLi Flaw — socprime.com
  21. SQL Injection for Bug Bounty Hunters | YesWeHack — yeswehack.com
  22. SQL Injection Bypassing WAF | OWASP — owasp.org
  23. SQL Injection 101: Common Defense Methods Hackers Should Be Aware Of — null-byte.wonderhowto.com
  24. Demystifying SQL Injection: A Comprehensive Guide to Understanding SQL Injection Risks — akto.io
  25. SQL Injection in GraphQL — 0xgad.medium.com
  26. Barebones Application Security — SQL Injection (SQLi) — medium.com
  27. SQL Attack (Constraint-based) - Dhaval Kapil — dhavalkapil.com
  28. SQLMap Cheat Sheet: Commands, Options, and Advanced Features — stationx.net
  29. SQLi Payloads - Classic, Blind, Error-Based, Time-Based, WAF Bypass — github.com
  30. PayloadsAllTheThings - SQL Injection — github.com
  31. SQL Injection Cheatsheet 2021 — hackersonlineclub.com
  32. SQL Injection 101: Common Defense Methods Hackers Should Be Aware Of — null-byte.wonderhowto.com
  33. Vulnerability analysis, Security Papers, Exploit Tutorials - Part 12975 — exploit-db.com
  34. SQL Injection Tutorial & Examples - PortSwigger — portswigger.net
  35. Exploiting Error Based SQL Injections & Bypassing Restrictions — link.medium.com
  36. https://medium.com/bugbountywriteup/sql-injection-time-and-boolean-based-27239b6a55e8?source=twitterShare-1764222123d3-1576594710&_referrer=twitter&_branch_match_id=732557985002302401 — medium.com
  37. https://medium.com/bugbountywriteup/sql-injection-time-and-boolean-based-27239b6a55e8?source=twitterShare-1764222123d3-1576594710&_referrer=twitter&_branch_match_id=732557985002302401 — medium.com
  38. Advanced SQL Injection Cheatsheet — github.com
  39. Identifying & Exploiting SQL Injection: Manual & Automated — link.medium.com
  40. SQL Injection Cheat Sheet by Netsparker — netsparker.com
  41. When the Database Won't Talk: A Deep Dive into Blind SQLi — hadrian.io
  42. http://www.darknet.org.uk/2017/09/bsqlinjector-blind-sql-injection-tool-download-ruby/ — darknet.org.uk
  43. DVWA 1.9+: Blind SQL Injection with SQLMap — link.medium.com
  44. BSQLinjector – Blind SQL Injection Tool Download in Ruby — darknet.org.uk
  45. Bug Bounty Bootcamp #29: Boolean Blind SQL Injection Part 2 — infosecwriteups.com
  46. SQL Injection 2025 Advanced Exploitation & Defense Guide — broadchannel.org
  47. SQL Injection Wiki — sqlwiki.netspi.com
  48. https://portswigger.net/web-security/sql-injection/cheat-sheet — portswigger.net
  49. CVE-2025-1094: PostgreSQL SQL Injection Vulnerability — armosec.io
  50. SQL Injection and Postgres: An Adventure to Eventual RCE — pulsesecurity.co.nz
  51. CVE-2025-52694 PoC: Critical SQL Injection in Advantech IoTSuite/SaaS-Composer — github.com
  52. CVE-2025-1094 WebSocket and SQL Injection Exploit Script — github.com
  53. SQL Injection Cheat Sheet by Netsparker — netsparker.com
  54. SQLMap Tamper Collection: Modern WAF Bypass Scripts (Cloudflare, AWS, Azure) — github.com
  55. BWAFSQLi: Bypassing Web Application Firewall with Adversarial SQL Injections — dl.acm.org
  56. WAF Bypass Techniques for SQL Injection — nav1n0x.gitbook.io
  57. Bypassing WAF with Adversarial SQL — dl.acm.org
  58. WAF Bypass Using JSON-Based SQL Injection Attacks — picussecurity.com
  59. open-appsec ML-based WAF protects against modern SQLi AutoSpear evasion techniques — openappsec.io
  60. Identifying SQL Injections in a GraphQL API — praetorian.com
  61. Rapid7 Analysis: CVE-2024-12356 — rapid7.com
  62. CVE-2025-1094: PostgreSQL psql SQL Injection (Fixed) — Rapid7 — rapid7.com
  63. PostgreSQL CVE-2025-1094: Quoting APIs SQL Injection — postgresql.org
  64. Second-Order SQL Injection with Stored Procedures and DNS-Based Egress — netspi.com
  65. Exploiting Second-Order SQL Injection to Retrieve the Flag — medium.com
  66. Exploiting second order blind SQL injection — link.medium.com
  67. SQL injection to RCE — medium.com
  68. Critical Vulnerability Chain in LangGraph Allows Attackers to Gain Full Server Control — cybersecuritynews.com
  69. From SQLi to RCE - Exploiting LangGraphs Checkpointer — research.checkpoint.com
  70. CVE-2026-42208: Pre-Authentication SQL Injection in LiteLLM Exposes API Credentials — securityboulevard.com
  71. CVE-2026-42208: Critical Pre-Auth SQL Injection in LiteLLM Actively Exploited Within 36 Hours of Disclosure — rescana.com
  72. ProFTPDs SQL Injection Vulnerability Enables Remote Code Execution Attacks — cybersecuritynews.com
  73. CVE-2026-42208: LiteLLM SQL Injection Leaks Upstream API Keys — abhs.in
  74. ProFTPD SQL Injection Flaw Enables Remote Code Execution — cyberpress.org
  75. CVE-2026-42208: LiteLLM bug exploited 36 hours after its disclosure — securityaffairs.com
  76. LiteLLM exploited within 36 hours of disclosure via SQL injection bug — scworld.com
  77. Fresh LiteLLM Vulnerability Exploited Shortly After Disclosure — securityweek.com
  78. LiteLLM CVE-2026-42208 SQL Injection Exploited within 36 Hours of Disclosure — thehackernews.com
  79. Hackers are exploiting a critical LiteLLM pre-auth SQLi flaw — bleepingcomputer.com
  80. Critical LiteLLM SQL Injection Vulnerability Exploited in the Wild — cybersecuritynews.com
  81. Critical LiteLLM SQL Injection Vulnerability Exploited in the Wild — cyberpress.org
  82. Critical LiteLLM Flaw Enables Database Attacks Through SQL Injection — gbhackers.com
  83. LiteLLM Contains Critical SQL Injection Vulnerability — letsdatascience.com
  84. Ghost CMS Users Under Attack: Why Developers Must Act Fast — techgig.com
  85. Making A SQLi Lab Is Not Difficult, Build One With Me. — infosecwriteups.com
  86. 9 SQLi Detection Tools You Need to Know in 2023 — analyticsinsight.net
  87. Understanding the full potential of sqlmap during bug bounty hunting — vavkamil.cz
  88. DVWA Cheat Sheet (Low & Medium) — infosecwriteups.com
  89. https://vavkamil.cz/2019/10/09/understanding-the-full-potential-of-sqlmap-during-bug-bounty-hunting/ — vavkamil.cz
  90. How I Found multiple SQL Injection with FFUF and Sqlmap in a few minutes — 0xmahmoudjo0.medium.com
  91. https://secnhack.in/website-penetration-testing-and-database-hacking-with-sqlmap/ — secnhack.in
  92. Comprehensive Guide to Sqlmap (Target Options) — linkedin.com
  93. Exploiting an SQL Injection with WAF Bypass — vaadata.com
  94. BChecks/vulnerability-classes/injection at main · PortSwigger/BChecks · GitHub — github.com
  95. NucleiFuzzer - Powerful Automation Tool For Detecting XSS, SQLi, SSRF, Open — kitploit.com
  96. GitHub - danialhalo/SqliSniper: Advanced Time-based Blind SQL Injection fuzzer for HTTP Headers — github.com
  97. LangChain framework hit by several worrying security issues here's what we know — msn.com
  98. LangChain framework hit by several worrying security issues here's what we know — msn.com
  99. 700 education and tech websites hijacked in huge ClickFix malware campaign — malwarebytes.com
  100. Ghost CMS Vulnerability Exploited to Hack Over 700 Websites — securityweek.com
  101. Ghost CMS Vulnerability Exploited to Hack Over 700 Websites — oodaloop.com
  102. Active Exploitation Alert: Ghost CMS CVE-2026-26980 Mass Attack Hijacks 700 Sites for ClickFix Malware Campaigns — rescana.com
  103. Ghost CMS SQL Injection Hits 700 Sites: Harvard DuckDuckGo Serve Fake Cloudflare Malware — techtimes.com
  104. Ghost CMS CVE-2026-26980 Exploited to Hijack 700 Sites for ClickFix Attacks — thehackernews.com
  105. Ghost CMS SQL injection flaw exploited in large-scale ClickFix campaign — bleepingcomputer.com
  106. Drupal Emergency Patch Issued As Critical SQL Injection Bug Hits Open Source Stack - Open Source For You — opensourceforu.com
  107. Drupal admins rushing to patch maximum severity SQL injection vulnerability — csoonline.com
  108. Critical PostgreSQL Vulnerabilities Enables Code Execution and SQL Injections — cybersecuritynews.com
  109. Critical PostgreSQL Flaws Enable Code Execution and SQL Injection — cyberpress.org
  110. PostgreSQL Flaws Expose Databases to Remote Code Execution and SQL Injection — gbhackers.com
  111. CVE Search: SQL Injection — cve.org
  112. SQL Injection Security Vulnerabilities — cvedetails.com
  113. Web Attack Cheat Sheet — github.com
  114. SQL Injection Cheat Sheet - Invicti — invicti.com
  115. SQLMap Command Generator — acorzo1983.github.io
  116. Drupal Vulnerability in Hacker Crosshairs Shortly After Disclosure — securityweek.com
  117. 1 Million WordPress Websites Exposed by Avada Builder Security Vulnerabilities — gbhackers.com
  118. SQL Injection File Read Vulnerability Affect 1M Avada WordPress Sites — cyberpress.org
  119. Two vulnerabilities found in popular WordPress plugin Avada Builder — scworld.com
  120. Avada Builder Flaws Expose One Million WordPress Sites — infosecurity-magazine.com
  121. SAP Releases Patch for Critical SQL Injection Flaw in S/4HANA — gbhackers.com
  122. SAP Patches Critical SQL Injection Flaw in SAP S/4HANA — cyberpress.org
  123. ProFTPD SQL Injection Flaw Opens Door To Remote Code Execution Attacks — gbhackers.com
  124. NoSQL Injection: Advanced Exploitation Guide — intigriti.com
  125. Exploits Explained: NoSQL Injection Returns Private Information — synack.com
  126. MCP Vulnerability Case Study: SQL Injection in the Postgres MCP Server — securitylabs.datadoghq.com
  127. Unauthenticated SQL Injection in GUI — Fortinet PSIRT — fortiguard.fortinet.com
  128. CVE-2025-26794: Blind SQL Injection in Exim 4.98 — Writeup — github.com
  129. April 2026 Patch Tuesday: Critical Vulnerabilities in SAP Adobe Microsoft SharePoint Fortinet and ColdFusion Threaten Enterprise Security — rescana.com
  130. Advanced Boolean-Based SQLi Filter Bypass Techniques — secjuice.com
  131. Exploiting SQL Injection Vulnerability - Bug Bounty Writeup — medium.com
  132. SAP Security Patch Day April 2026: Critical Vulnerabilities CVSS 9.9 SQL Injection and Authorization Risks — erp.today
  133. FortiClient Hit by Severe SQL Injection Vulnerability Enabling Database Intrusion — gbhackers.com
  134. CISA Warns of Fortinet SQL Injection Vulnerability Actively Exploited in Attacks — cybersecuritynews.com
  135. SAP Patch Day Fixes Critical SQL Injection DoS and Code Injection Flaws — gbhackers.com
  136. SAP Patch Day Fixes Critical SQL Injection DoS and Code Injection Flaws — cyberpress.org
  137. CISA Warns of Fortinet SQL Injection Flaw Actively Exploited in Attacks — cyberpress.org
  138. CISA Warns Fortinet SQL Injection Flaw Is Being Actively Exploited — gbhackers.com
  139. SAP Patch Day Fixes Critical SQL Injection DoS and Code Injection Flaws — cyberpress.org
  140. 400K WordPress Sites Exposed by Elementor Ally Plugin SQL Flaw — esecurityplanet.com
  141. Advanced SQL Injection Techniques in Modern Web Apps — gauravsingh-cybersecurity.github.io
  142. CVE-2026-26116: SQL Server SQL Injection — sentinelone.com
  143. CVE-2025-25257: Critical SQLi in Fortinet FortiWeb — socprime.com
  144. Multiple SonicWall Vulnerabilities Enable SQL Injection and Privilege Escalation Attacks — cybersecuritynews.com
  145. Multiple SonicWall Vulnerabilities Enable SQL Injection and Privilege Escalation — cyberpress.org
  146. Multiple SonicWall Flaws Enable SQL Injection and Privilege Escalation Attacks — gbhackers.com
  147. CVE-2026-27697: Basercms SQLi Vulnerability — sentinelone.com
  148. CVE-2026-5197: Student Membership System SQLi Vulnerability — sentinelone.com
  149. New "LeakyLooker" Flaws in Google Looker Studio Could Enable Cross-Tenant SQL Queries — thehackernews.com
  150. 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
  151. Writeups for Damn Vulnerable Web Application (DVWA) — medium.com
  152. How to turn SQL injection into an RCE or a file read? Case study of 128 bug bounty reports — youtube.com
  153. TryHackMe | SQHell — tryhackme.com
  154. Test website for SQL injection vulnerabilities using Python — imran-niaz.medium.com
  155. How I Found Multiple SQL Injections in 5 Minutes in Bug Bounty — medium.com
  156. Favorite tweet by @harshbothra_ — twitter.com
  157. 10 Types of Web Vulnerabilities that are Often Missed — labs.detectify.com
  158. Making a Blind SQL Injection a Little Less Blind — medium.com
  159. https://github.com/yeswehack/vulnerable-code-snippets — github.com
📚 This guide is synthesized from the full text of resources curated in the SQLi library, and refreshed as new material is added.