Skip to main content
HighContentOWASP A05:2021CWE-209

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

  1. 1Wrap all database calls in try/catch blocks
  2. 2Return only generic error messages (status 500) to the client
  3. 3Log the full SQL error server-side with a correlation ID for debugging

Code examples

Catch database errors before they reach the response

JavaScript
// 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.

See every content check

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.

Propose a checkHow a check is built

Scan your own site for sql error message in page content

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: SQL error message in page content | VulnRadar