Home / Learn Secure SQL / Error-Based Injection: the Concept
Error-Based Injection: the Concept
When a database's own error messages leak more than intended.
Theory in plain words
The basic idea
An error-based approach (conceptually) relies on a database returning a detailed error message that reveals information about the query, schema, or data as a side effect of a malformed or unexpected input reaching an unseparated query. The leak happens through the error text itself, not through the normal result set.
Why this comes up
This is precisely why "generic errors to users, detailed logs internally" (covered in the Error handling group) is such a load-bearing rule: even a database that is otherwise well protected can leak meaningful information if raw error detail reaches the end user.
The mechanics
Treat any database error message reaching an end user as a finding worth fixing immediately, regardless of whether a specific exploit is known, because the fix (generic user-facing errors) is the same regardless of which downstream technique the leak would have enabled.
Where it is used
- Web application code review
- Backend development
- Database administration
try {
db.execute(sql, [value]);
} catch (err) {
logger.error(err); // full detail, internal only
return res.status(400).send('Something went wrong. Please try again.');
}The fix is the one this course already teaches: catch the error, log full detail internally, and show the user a short, generic message with no schema or query detail.
Quick check
1. Error-based injection relies on information leaking through...
The leak is carried in the error text.