How to fix: SQL error message in page content
The page contains an SQL error message that reveals database type, query structure, or table names.
Why it matters
SQL error messages expose database type (MySQL, PostgreSQL, MSSQL), query structure, column names, and table names, giving attackers direct feedback for SQL injection probing without needing blind techniques.
Database errors must be caught server-side and never exposed to users.
How to fix it
- 1Wrap all database calls in try/catch blocks
- 2Return only generic error messages (status 500) to the client
- 3Log the full SQL error server-side with a correlation ID for debugging
Code examples
Catch database errors before they reach the response
// Unsafe: SQL error leaks table/column names
try {
const result = await db.query(sql);
} catch (err) {
// err.message may contain table names, column names
res.send(err.message); // NEVER do this
}
// Safe: log internally, return generic message
catch (err) {
logger.error({ err }, 'DB query failed');
res.status(500).json({ error: 'Database error' });
}References
Detected automatically by VulnRadar. The check id is sql-error-in-page, stable across every scan so you can filter or diff on it.
More content checks
- MediumPotential Open Redirect Parameters
- HighDirectory Listing Appears Enabled
- MediumSensitive File References Detected
- HighPotentially Outdated JavaScript Libraries
- Inforobots.txt Present - Review Manually
- InfoCMS / Technology Fingerprinting
- MediumPotentially Dangerous Inline JavaScript
- LowServer version disclosed in response header
Questions
- How severe is SQL error message in page content?
- VulnRadar rates this high severity in the content category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id sql-error-in-page, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does SQL error message in page content map to?
- It maps to CWE-209. In the OWASP Top 10 it falls under A05:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.