What happened
A discrepancy between the MCP identifier validator and the SurrealQL lexer allows delimiter escape. MCP tool arguments are interpolated into SQL, and passing an identifier with an escaped backtick escapes the quoted identifier, permitting statement injection through MCP tool invocation and bypassing the tool's argument constraints.
Why it matters
An agent driving a SurrealDB MCP server can be steered — via a crafted tool argument or injected tool output — to execute arbitrary SQL, exfiltrating or tampering with the database beyond what the tool contract allows.
Attack vector
The MCP tool identifier validator (consume_backtick_ident / validate_identifier) treats the first backtick as the closing identifier delimiter and ignores escape characters that the SurrealQL lexer honours. A crafted identifier containing an escaped backtick breaks out of the quoted identifier into raw SurrealQL statement execution, so a tool call with a malicious argument injects arbitrary SQL.
Affected systems
SurrealDB (surrealdb) MCP server integration — versions 3.1.0 before 4.0.0
Mitigation
Fix committed that makes MCP identifier parsing reject escaped-backtick breakout; version 4.0.0 and later are not affected. Advisory GHSA-cr79-9p8r-p5wx.