Summary
Marten's full-text search APIs previously interpolated the user-controlled regConfig parameter directly into SQL queries without parameterization or validation.
When application code passes untrusted input into regConfig, this behavior can allow attackers to inject arbitrary SQL into PostgreSQL queries, leading to data compromise or full database takeover.
Affected context
The vulnerability exists in applications using Marten's full-text search capabilities where the regConfig argument is influenced by untrusted data (such as HTTP query parameters, request bodies, or user preferences).
Any code path that forwards user-controllable values into regConfig without strict whitelisting or transformation effectively creates a SQL injection sink.
The issue is scoped to environments where Marten constructs SQL for PostgreSQL full-text search using string interpolation for the configuration parameter rather than safe parameter binding.
Exploit preconditions
- Attack surface: Application endpoints or services that invoke Marten full-text search APIs and expose
regConfigor a derived value to callers. - Required access: Ability to supply or influence input that is eventually passed to Marten's full-text search
regConfigparameter (typically unauthenticated or low-privilege web/API access). - Trigger point: Execution of a full-text search query where
regConfigis concatenated into the SQL statement rather than parameterized. - Why exploitation is possible: The
regConfigvalue is embedded directly into SQL as part of the full-text search configuration, so malicious content can escape its intended context and alter the structure of the query.
Why this happens
The root cause is a failure to treat the regConfig parameter as untrusted data when constructing SQL for PostgreSQL full-text search.
Instead of using parameterized queries or a constrained mapping of symbolic configuration names to safe SQL fragments, Marten interpolated regConfig directly into the query string.
This pattern matches CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where attacker-controlled data is concatenated into SQL without proper encoding, parameterization, or strict validation.
Potential impact
- Arbitrary modification of database contents (INSERT, UPDATE, DELETE)
- Unauthorized reading of sensitive data across tables and schemas
- Bypassing application-level authorization by manipulating WHERE clauses
- Creation or alteration of database roles, functions, or extensions (subject to DB permissions)
- Destruction of data integrity or availability through crafted SQL payloads
- Potential pivot to underlying host or other services via database-level features and misconfigurations
General mitigation guidance
Effective mitigation focuses on eliminating string concatenation for SQL construction and narrowing trust around configuration-like inputs:
- Treat all full-text search inputs, including
regConfig, as untrusted and pass them through parameterized query APIs, not string interpolation. - Restrict
regConfigto a fixed set of known-safe values (e.g., enum or configuration mapping) and resolve them server-side rather than accepting arbitrary strings from clients. - Centralize full-text search query building in a small, well-reviewed module where safe patterns can be consistently enforced.
- Apply the principle of least privilege to the database user used by Marten, limiting its ability to perform schema changes or other high-impact operations.
- Use defense-in-depth validation at the application boundary so that unexpected characters or structures in configuration parameters are rejected early.
How teams detect issues like this
Detection can combine code-centric and runtime approaches:
- Static analysis: Search for usages of Marten full-text APIs where
regConfigis derived from request data or other untrusted sources; flag any string concatenation into SQL-building routines. - Code review: Examine query construction layers to ensure all parameters, including configuration values, use parameterization or whitelisted mappings rather than direct interpolation.
- Security linters and SAST tools: Configure rules that detect SQL concatenation patterns and flag dynamic construction around full-text search or configuration parameters.
- Runtime monitoring: Enable database logging for slow or error-prone queries and analyze for unusual patterns (e.g., stacked queries, tautological predicates) that may indicate SQL injection attempts.

