Scrubbing SQL Comments to Prevent Database Prompt Hijacking
Agents connected to corporate databases must be shielded from comment-based SQL injections. We detail regex filters in sanitize.rs.
Filtering SQL Block Comments at the Edge
If an agent compiles SQL queries dynamically based on prompts, attackers can insert comment characters (e.g. /* ... */ or --) to bypass query limits. ATL-Trust scrubs comment indicators at the local gateway before sending text to the model, preventing injection.
We use static regular expression patterns compiled in memory to detect and strip SQL comments. This ensures that the agent cannot generate query payloads that bypass the system's compliance checks.
// SQL comment scrubbing patterns
static SQL_LINE_COMMENT_REGEX: OnceLock = OnceLock::new();
static SQL_BLOCK_COMMENT_REGEX: OnceLock = OnceLock::new();
let sql_line_re = SQL_LINE_COMMENT_REGEX.get_or_init(|| Regex::new(r"--.*").unwrap());
let sql_block_re = SQL_BLOCK_COMMENT_REGEX.get_or_init(|| Regex::new(r"(?s)/\*.*?\*/").unwrap());
sanitized = sql_line_re.replace_all(&sanitized, "").into_owned();
Sanitization Regex Compiles
The sanitization engine uses thread-safe, static regular expression patterns to strip inline and block comments without adding execution latency to prompt lifecycles. This maintains high throughput under heavy concurrency.
By removing comments before the prompt is processed, we ensure that the model evaluates the input context cleanly, avoiding structural formatting issues that could lead to parser failures.
- Blocks comments that hide unauthorized database requests.
- Keeps prompt text formats compliant with database policies.
- Maintains low latency using pre-allocated regex matches.
Enterprise M&A Inquiry
For technical due diligence or architectural deep-dives into our zero-trust framework, please request access to our tech specs and roadmap.
Request Tech Specs