Summary
psqlODBC's SQLSpecialColumns function inserts table and schema names into a catalog query without escaping them. If an application passes untrusted names to this function, a caller may be able to execute arbitrary SQL with the privileges of the database connection.
Affected context
The issue occurs in psqlODBC's SQLSpecialColumns catalog function when it constructs a query using table or schema names that have not been escaped. Applications are at risk when they pass names influenced by untrusted input to this function. The description identifies versions before 18.00.0006 as affected.
Exploit preconditions
- Attack surface: An application using psqlODBC's
SQLSpecialColumnsfunction - Required access: Ability to influence the table or schema name supplied by the application
- Trigger point: The function's catalog query construction and execution
- Why exploitation is possible: The supplied names are spliced into the query without escaping, allowing them to alter its SQL structure
Why this happens
The function constructs a SQL catalog query by inserting table and schema names without appropriately escaping them. When those values are influenced by untrusted input, query syntax and data are not kept separate, which is the insecure pattern described by CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Potential impact
- An attacker may execute arbitrary SQL using the connection's privileges.
- Database records could be read, altered, or deleted, depending on the connection's permissions.
- Database availability or integrity could be affected.
- Access to connected database resources could be misused within the privileges available to the application.
General mitigation guidance
Defensive approaches focus on preventing untrusted names from changing query structure:
- Use parameterized query mechanisms where supported, and safe identifier-quoting APIs for SQL identifiers.
- Validate table and schema names against trusted, narrowly defined allowlists when possible.
- Avoid passing caller-controlled names directly into catalog-query construction.
- Apply least privilege to database connections so that a compromised query path has limited capabilities.
- Prefer APIs and designs that minimize the need to construct SQL from dynamic identifiers.
How teams detect issues like this
- Use static analysis to identify SQL construction that concatenates or interpolates table and schema names.
- Review call sites of
SQLSpecialColumnsand trace whether supplied names can be influenced by external input. - Check that dynamic identifiers are validated or safely quoted, and that query values use parameterized interfaces where applicable.
- Apply code-review policies that flag untrusted data entering SQL construction, and use database monitoring to investigate unexpected statements.

