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

The Problem: SQL Injection's Enduring Threat

Despite being understood and documented for decades, SQL injection (SQLi) remains a prevalent and critical vulnerability in web applications and APIs. Attackers exploit SQLi by inserting malicious database commands into user inputs, tricking the application into executing them as legitimate SQL queries [1][2]. This can lead to a cascade of severe consequences, including unauthorized access to sensitive data, data corruption or deletion, denial of service, and in some advanced scenarios, full system compromise or remote code execution [1][3]. The persistence of SQLi is not due to a lack of available defenses, but often stems from weaknesses in implementation, governance, and secure development practices, as well as the prevalence of legacy systems and rapid development cycles that prioritize speed over security [1].

Core Mechanics: How SQL Injection Works

At its heart, SQL injection exploits the fundamental way applications interact with databases: by constructing SQL queries. When user-supplied input is not properly validated, sanitized, or escaped before being incorporated into an SQL query, it can be manipulated by an attacker. The database, trusting the input as part of its instructions, executes the attacker's injected commands alongside the intended query [1][4][5][6][3].

The core vulnerability lies in the direct concatenation of untrusted input into SQL statements. Instead of treating user input purely as data, the application inadvertently allows it to be interpreted as executable SQL code. This can happen in various parts of a query, including WHERE clauses, INSERT/UPDATE statements, ORDER BY clauses, and even table or column names in some complex scenarios [7][8][9][10][11][12][2][13][14][15].

Consider a simple example where a user's input is directly embedded into a SQL query:

-- Vulnerable Code Example (Conceptual)

SELECT * FROM users WHERE username = '" + userInput + "';

If an attacker provides the input ' OR '1'='1, the resulting query becomes:

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

The OR '1'='1' clause is always true, effectively bypassing the intended username check and returning all records from the users table [16][17][10][18][19][15]. Similarly, an attacker can use comment characters (--, #, / /) to terminate the original query and execute their own malicious statements, such as DELETE or UPDATE [1][20][16][17][10][11][18][15].

More sophisticated attacks can leverage database-specific functions and syntax to achieve greater impact, including data exfiltration, privilege escalation, and even remote code execution [21][22][23][24][12].

Notable Techniques and Attack Vectors

SQL injection techniques have evolved significantly, moving beyond simple error messages to exploit subtle behaviors and advanced database features. Understanding these methods is crucial for both offensive and defensive perspectives.

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

This is the most common category, where attackers receive results or error messages directly through the application's response channel [16][19].

Inferential (Blind) SQLi

Blind SQLi is employed when an application does not directly return database errors or query results. Attackers infer information by observing indirect clues, such as differences in page content, response times, or out-of-band signals [27][16][19][2].

Out-of-Band (OOB) SQLi

This technique is used when direct feedback channels are blocked. Attackers force the database to make external network calls (like DNS lookups or HTTP requests) to a server they control, exfiltrating data via these callbacks [27][16][19][15]. This often relies on database functions that can initiate network connections, such as xp_dirtree in SQL Server or load_file() in MySQL.

Second-Order SQLi

In second-order SQLi, the malicious payload is not executed immediately. Instead, it is stored in the database (e.g., in a user profile comment or a feedback entry) and then executed later when that stored data is retrieved and used in a different SQL query [34][35][36][28][15]. This makes detection more challenging as the immediate request doesn't show obvious signs of compromise.

Advanced and Context-Specific Techniques

Detection and Prevention Strategies

Effective defense against SQL injection requires a multi-layered approach, integrating secure coding practices, robust validation, and runtime protection.

Secure Coding Practices: The Foundation

The primary and most effective defense is to prevent user input from ever being interpreted as SQL code. This is achieved through:

Runtime Protection and Monitoring

Even with secure coding practices, vulnerabilities can exist in dependencies or be introduced unintentionally. Runtime defenses and vigilant monitoring are essential:

Tooling for SQL Injection Analysis

A robust toolkit is indispensable for identifying, exploiting, and understanding SQL injection vulnerabilities.

Recent Developments and Trends

SQL injection continues to evolve, with new vectors and attack chains emerging regularly:

Where to Go Deeper

For those looking to deepen their understanding and practical skills in SQL injection, the following resources offer invaluable insights and hands-on experience:

Sources cited in this guide

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