If SQL injection leaks customer data, when would you know? Detection after the web application firewall
· DataMint · 8 min read
The security monitoring screen fills up with requests the web application firewall (WAF) blocked. A number comes up every day saying how many SQL injection attempts were stopped. Yet there is a question you cannot answer while looking at that number. "If there was one we did not block, when would we know?"
The honest answer is "with the current setup, possibly late." The WAF records what it blocked and leaves the requests it let through as normal. The database sees that query as ordinary SQL run by the shared account of the web application server (WAS). On neither side does a line appear saying "an unusual SQL statement read customers' resident registration numbers (RRN, Korea's national ID number)." That means the first you hear of the leak may come from outside the company.
This post thinks about SQL injection detection from the position after the WAF. It does not cover attack methods. It covers which device sees what, and what signal lets you notice the one that got through.
How SQL injection leads to a personal data leak
The principle is simple. Input from the user does not stay in the "value" position of the SQL but changes the "structure" of the SQL. This can happen when an application concatenates input straight into an SQL string. As a result the screen reads a table or column it never read before, or far more rows than it should.
With queries that pass input as parameters (prepared statements), input is handled only as a value. So code written today is usually safe. The risk tends to remain in old places. A bulletin board built years ago, a lookup screen that assembles search conditions as a string, a list that takes the sort order from the screen and appends it, a page built by an outside contractor back when source control was loose. Legacy screens carried over as they were after a core system replacement project ("next-generation" project in Korea) often fall here.
In the OWASP Top 10:2025, injection is still on the list as A05. It is an old problem, but it has not gone away.
What a WAF sees and does not see
A WAF looks at requests. It checks the address, parameters and headers for patterns of known attacks and blocks the request on a match. It is necessary as the first line of defense. Its limits come not from its performance but from where it stands.
- It sees the request, not the result. It cannot know what a request that passed actually read in the database, or for how many people.
- Patterns rely on what is known. A shape slightly different from the rules, or one that is hard to tell apart from a normal request, can get through. More so where the rules were loosened so false positives would not stop work.
- Some paths do not go through it. Business systems on the internal network, or integration requests coming from inside the WAF, may not be inspected at all.
So in the WAF's records, an attack that passed remains a "normal request." The number blocked is easy to see. The number missed is, by definition, not visible.
Why database access control sees SQL injection as a normal query
Database access control looks at who connected to the database and what they did. It is strong on the path where a person connects with an SQL tool. But injected SQL is run by the application, not by a person. What the database sees is the WAS's shared account connecting as it always does and running one SQL statement.
Even if the database side keeps every SQL statement, a problem remains. Nothing links the statement to which user's which request it came from. And you still have to build a separate basis for picking out the one odd statement among the normal SQL that piles up all day.
| Device | What it sees | How it is recorded |
|---|---|---|
| Web application firewall | Only the pattern of the request | A normal request |
| Database access control | The account and the SQL | A query by the WAS shared account |
| WAS agent | User, path, SQL shape, number of personal data rows | Alerted as never-seen SQL |
Why "never-seen SQL" is a signal for SQL injection detection
A business system runs fewer kinds of SQL than you might think. Even with hundreds of screens, the SQL each screen runs is fixed and only the values change. Whether the customer number is 1001 or 2002, the shape of the SQL is the same.
Remove the values and keep only the shape, and this becomes clear. Watch the system for a period and collect the shapes, and you have a list of the SQL that system uses. When an injection succeeds, the input changes the structure of the SQL, so the shape is different even with the values removed. It becomes a shape that is not on the list.
| SQL executed | Shape with values removed | Verdict |
|---|---|---|
| Customer lookup, customer number 1001 | Same shape | On the list |
| Customer lookup, customer number 2002 | Same shape | On the list |
| On a bulletin board screen, structure changed to read RRNs from the customer table | A shape not on the list | Never-seen SQL |
The strength of this signal is that it does not depend on the count. Even if an injection takes only two rows at a time, it is caught if SQL of a first-seen shape read a personal data column. This is where quiet attempts that a bulk query limit would not catch are caught.
The weakness is just as clear. When you release a new feature, normal SQL is never-seen SQL too. So is a report screen opened once a quarter. That is why you need a generous learning period, together with a procedure where a person checks never-seen SQL and approves it as "normal." Alerts that only pile up without approval will soon be looked at by no one.
Responding to SQL injection: prevent in the code, detect where it runs
Detection does not replace prevention. The OWASP SQL Injection Prevention Cheat Sheet puts parameterized queries as the primary defense and says manually escaping input is error-prone and strongly discouraged. It also cites the principle of least privilege: do not give the application account DBA or admin-level privileges.
Detection is a requirement too. In Korea, Article 6(1) of the Standards for Measures to Ensure the Safety of Personal Information (in Korean), a notice of the Personal Information Protection Commission (PIPC), says to analyze the IP addresses and the like that accessed a personal information processing system to detect and respond to attempts to leak personal data. The OWASP Top 10:2025 lists "Security Logging and Alerting Failures" as A09 and counts as a weakness the state of being unable to detect and alert on active attacks in real time or close to it.
| Layer | What it does | If it is missing |
|---|---|---|
| Code | Parameterized queries, input validation, secure coding reviews | Screens open to injection appear |
| Web application firewall | Blocks known attack requests | Modified requests and internal paths get through |
| Database account privileges | Only the privileges the application account needs | Once breached, the range that can be read is wider |
| Detection at the point of execution | Alerts right away on never-seen SQL and bulk queries | You learn late about the one that got through |
Never-seen SQL detection in DataMint Scope
DataMint Scope, our product, attaches to the WAS as a Java agent and counts the SQL executed over JDBC and the number of personal data rows in the results. Application code is not changed. You add one line to the WAS startup options. It records the requesting user (the session or client IP before login), the path and the SQL together in one line, which creates the link that was broken between the WAF and the database.
It learns, alerts when something different shows up, and a person decides. There are four steps.
- Learn. Set a learning period in the policy and Scope collects the shapes of the SQL executed during it. A shape is the SQL with string and numeric values and IN lists removed, so no values remain.
- Detect. After learning ends, when SQL of a shape not on the list touches a personal data column, it is recorded as "never-seen SQL" regardless of the count. If many rows go out at once it is also caught as "result limit exceeded," and if they add up in pieces over a short time, as "session total exceeded."
- Alert. Scope notifies the person in charge on the admin console and also sends to webhooks (SIEM, security monitoring, messengers), syslog and email.
- Approve. If on checking it turns out to be SQL from a normal release, approve it right there on the detection events screen. Approved SQL goes into the policy as an exception and applies to every WAS within 1 minute.
| When | Scope feature | What changes |
|---|---|---|
| An injection that got past the WAF reads the customer table | Never-seen SQL detection | An alert right after execution even when the count is small. The user, client IP, path and SQL shape are kept together, so the investigation starts on that screen |
| An injection sends out many rows at once | Result limit exceeded detection | The count shows how many people's data went out |
| SQL from a new screen raises alerts right after a release | Approve SQL on the detection events screen | Once checked, the same shape does not alert again |
| You have to scope an investigation | SQL shape rankings on the dashboard (first seen, approval pending), status by path and WAS | Narrow down which SQL ran when, on which WAS |
| You have to tie it into existing security monitoring | Webhook and syslog delivery | See it together with other alerts in the SIEM |


What it does today and what it does not
What Scope provides today is detection and alerting. It does not block injected SQL and does not change results. So it does not replace secure coding or a WAF. Keep both as they are. Scope takes the position of noticing, before it is too late, the one that those two let through.
SQL that reads only data not defined as personal data columns in the policy is not caught by this rule even if its shape is first-seen. The list of learned SQL currently lives in the memory of the agent on each WAS, so restarting a WAS starts the learning period again. The path where an attacker takes over the WAS and connects directly with the database account is out of scope.
If the agent has a problem, it skips its checks and returns the response as it is. You can also pause the checks per WAS or for all of them from the admin console. The values of query results are not read or stored. The WAS versions we have verified are Tomcat 9 and WildFly 26. JEUS and WebLogic are verified together with the customer in the customer's environment.
FAQ: SQL injection detection
If we have a WAF, do we still need separate SQL injection detection?
A WAF blocks at the request stage and does not see what a request that passed read in the database. A device that blocks and a device that notices what got through cover different positions. It is not a matter of choosing one of the two.
Won't there be too many never-seen SQL alerts?
Right after a release, or on rarely used screens, normal SQL raises alerts too. Set a generous learning period that matches your business cycle and approve the SQL you have checked, and the same shape does not alert again. How many alerts come differs by system, so we recommend turning on detection only at first and measuring the actual count.
Does Scope store the customer data values in the SQL?
No. SQL is kept only as a shape with values removed, and the values of query results are neither read nor stored. What remains is the user, the client IP, the path, the SQL shape and the row count.
Summary: SQL injection detection in the position after the WAF
- SQL injection is the problem of input changing the structure of SQL. The basics of prevention are parameterized queries and least privilege.
- A WAF looks at requests, and database access control looks at accounts and SQL. The one that got through tends to remain normal on both sides.
- The SQL shapes of a business system are finite, so the moment a shape not on the list reads personal data is a signal that does not depend on the count.
- For the signal to be useful, a learning period, an approval procedure and alert channels have to come with it.
If you pick one thing to try tomorrow, open last month's WAF report and ask, "Can we tell whether any of the requests that passed read the customer table?" If you cannot answer, that position is empty. Bulk queries by legitimate users are covered in detecting bulk queries through business screens, and how to complement access log reviews in the post on personal data access log reviews.
- #SQL injection detection
- #data leak detection
- #WAF limitations
- #application server security
- #database access control
- #OWASP Top 10
- #secure coding