What Is SQL Injection?

December 1, 2026
6 min read

In a nutshell

SQL injection: breaking into a sealed facility from a spot that makes you go, “Wait, from THERE?”

Sato from Ajin.

What else?

It doesn’t need to break any walls; it comes in through the front input box. But if the site never reads input as an instruction, the hole is closed.

What Is SQL Injection?

The name combines SQL, the language for giving instructions to a database, with injection (Japan’s Ministry of Internal Affairs glossary (Japanese)).

Professor (lecturing in his lab coat)Professor

SQL injection is Sato from Ajin. Think of the “teleport” in volume 8.

Mecha-Ujiro (not in the mood)Mecha-Ujiro

He’s way too scary every time he shows up.

Professor (lecturing in his lab coat)Professor

The building was sealed with no gaps. Even so, he got inside by “teleporting.”

Mecha-Ujiro (bored)Mecha-Ujiro

Hmm. But our site has a lock on the front door, so we’re fine.

The way in is an ordinary input box

What you type into a site’s search box or login form is written, behind the scenes, into an instruction sheet for the database: SQL (Sitomo: What Is SQL?).

If the sheet is put together the wrong way, the text you typed gets read as part of the instructions.

SQL injection exploits that weakness to make the database do things it shouldn’t (IPA, “How to Secure Your Website: 1.1 SQL Injection” (Japanese)).

Normal input:  Tanaka
Instruction:   show people where name = 'Tanaka'

Sato's input:  ' OR '1'='1
Instruction:   show people where name = '' OR '1'='1'
               └─ "name is empty, OR 1=1"
                  1=1 is always true, so everyone comes back

An input box is not just a counter. It becomes part of the instructions.

What happens once they’re in

IPA lists the damage it can cause (IPA (Japanese)).

  • Snooping: Private information and personal data leak out.
  • Rewriting: Data is altered or deleted.
  • Impersonation: Attackers get past the login without knowing the password.
  • Takeover: The server is taken over and used as a stepping stone for other attacks.
Mecha-Ujiro (excited despite himself)Mecha-Ujiro

Then just stop people from typing weird symbols into the box!

Professor (lecturing in his lab coat)Professor

That’s one way. What matters is building it so the text that comes in is never read as an instruction.

Other kinds of injection attacks

SQL isn’t the only place where input gets read as an instruction. IPA and others list attacks of the same shape.

  • OS command injection: Makes the web server run commands on its operating system (IPA (Japanese)).
  • Cross-site scripting: Embeds scripts inside a web page (IPA (Japanese)).
  • HTTP header injection: Adds unwanted fields to the headers (HTTP headers) the server sends back (IPA (Japanese)).
  • Mail header injection: Uses a contact form or similar to add recipients and send mail (IPA (Japanese)).
  • Prompt injection: Slips instructions into the input of a generative AI (Sitomo, “What Is Generative AI?”) so that it behaves or answers in ways its makers never intended. The instructions can even be hidden in a web page or file the AI is asked to read (OWASP).

How to keep them out

Closing this hole is the job of the people who build and run the site.

  • Fix the sheet’s format first: Build all SQL with placeholders. The shape of the instruction is fixed first, and input goes only into the “value” slots, so it is never read as an instruction (IPA (Japanese)).
  • If you build it by joining strings, neutralize them properly: Use the escaping that the database itself provides.
  • Don’t show error details on screen: They teach attackers how the database is built.
  • Keep privileges to a minimum: Give the database account only the commands it needs.
  • Keep the software you use up to date: Software you buy can have this weakness too (see MOVEit Transfer below).

Takeaways

For engineers, this is a case of “if you didn’t defend against this, that’s on you.”

To you, the one running an app with input forms:

It may not be a must every time, but keep these defenses in mind 👍

Trivia

  • SQL: The language for asking a database to do things.
  • Placeholder: A blank in the instruction sheet that only holds a value.
  • Escaping: Making symbols with special meaning count as plain text.
  • OWASP: An international nonprofit focused on web application security. It publishes the “Top 10” list of risks.
  • IPA: The Information-technology Promotion Agency, a Japanese government body that supports IT policy.
  • Exploits of a Mom: An xkcd web comic about a mother who put an SQL command in her son’s name. The boy is known as “Little Bobby Tables.”

History

The beginning: an instruction sheet you could add to

On December 25, 1998, the hacker magazine Phrack ran an article by rain.forest.puppy.

It showed that you could add other commands to the SQL instructions a web server put together (Phrack issue 54).

The weakness of input boxes becoming part of the instructions was found a quarter century ago.

The turning point: from an input box to 130 million card numbers

On August 17, 2009, US prosecutors indicted three men for breaking into five companies, including Heartland.

More than 130 million card numbers were stolen, and the method was SQL injection (US Attorney’s Office, District of New Jersey).

From around May 27, 2023, the ransomware group CL0P exploited this weakness in MOVEit Transfer, software for exchanging files (CISA; see also Sitomo: What Is Ransomware?).

Twenty-five years after it was found, it is still the way in for major incidents.

Recent moves

  • 2021: In the OWASP Top 10, a ranking of web application risks, injection was number 3. 94% of the applications were tested for some form of it (OWASP).
  • 2025: In the 2025 edition of the same list, injection was number 5 (OWASP).

Trickier variations

It isn’t always a matter of typing into a box and getting everyone’s data on the spot (PortSwigger).

  • Asking without seeing the answer: Even when neither results nor errors appear on screen, the attacker sends yes-or-no questions over and over, watching how the page changes, and pieces the data together bit by bit. This is called blind SQL injection (PortSwigger).
  • Letting the delay answer: When the page doesn’t change at all, the attacker makes the database wait a few seconds only if a condition is true. The slow reply is the answer (PortSwigger).
  • Sneaking data out another way: The database is made to contact an outside server the attacker controls, carrying the data out inside that connection (PortSwigger).
  • Setting it off later: The input is first stored, and only later, when another part of the system builds a query with that stored value, is it read as an instruction. This is called second-order SQL injection (PortSwigger).

Guarding only the front input box isn’t enough. They can get in from places you never expected.

Timeline

PeriodKey eventsKey people and organizationsCountry or regionNotes
December 1998A Phrack article shows commands can be added to SQLrain.forest.puppyUSGave examples of adding another command to the instructions. [Phrack 54](http://phrack.org/issues/54/8.html)
August 2009Three indicted over breaches at Heartland and four othersUS Attorney, D.N.J.USOver 130 million card numbers. The method was SQL injection. [Announcement](https://www.justice.gov/archive/usao/nj/Press/files/pdffiles/2009/gonz0817%20rel.pdf)
2021Injection ranks 3rd in the OWASP Top 10OWASPGlobalA ranking of web application risks. [OWASP](https://owasp.org/Top10/2021/A03_2021-Injection/)
May 2023CL0P exploits a weakness in MOVEit TransferCL0PGlobalA ransomware group got in through SQL injection. [CISA](https://www.cisa.gov/news-events/cybersecurity-advisories/aa23-158a)
2025Injection ranks 5th in the OWASP Top 10OWASPGlobalThe 2025 edition of the list. [OWASP](https://owasp.org/Top10/2025/A05_2025-Injection/)