Forge SQL inspects every query submitted by your app before it reaches the
database. Queries that contain restricted functions, statements, or syntax are
rejected with a SQL_POLICY_VIOLATION
error before they execute.
This policy helps Forge SQL:
The query policy applies to all queries executed through the @forge/sql
package, including queries run via
sql.prepare and
sql.executeRaw.
The following terms automatically trigger an audit when detected in a query. Queries that use these terms are not immediately blocked, but may be rejected based on specific patterns:
COMPRESS(...)UNCOMPRESS(...) or DECOMPRESS(...)AES_ENCRYPT(...) or AES_DECRYPT(...)SHA2(...)SLEEP(...)BENCHMARK(...)ALTER USER ...LOCK TABLES ...During a triggered audit, the query is compared against patterns that indicate risks to Forge SQL security and stability. This can result in the query being rejected entirely (with an SQL_POLICY_VIOLATION error) or rate-limited.
Forge SQL also restricts certain syntax patterns, only permitting a subset of their normal use cases.
When detected in a query, Forge SQL rejects the query with a
SQL_POLICY_VIOLATION error.
| Restricted pattern | Description |
|---|---|
| Optimizer hints |
Only the following optimizer hints are permitted:
|
SET statements |
Only the following SET statements are permitted:
Statements such as
|
SHOW statements |
Only the following SHOW statements are permitted:
|
SQL-level PREPARE statements |
PREPARE, EXECUTE, or
DEALLOCATE PREPARE statements are not permitted.
|
| Multiple statements |
Each call to the Forge SQL API must contain only one statement. More than one ;-separated statement in a single request is not allowed.
|
| Fully qualified cross-installation table names |
References to objects in another app installation's schema (for
example, References to the |
USE statements |
The USE statement (for example,
USE other_app_installation) is not permitted. Forge SQL
automatically scopes queries to your app installation's schema, so this
statement is not required.
|
Queries that are empty or cannot be parsed are also rejected. Parse errors are
returned as
SQL_EXECUTION_ERROR
responses that mirror the native TiDB ER_PARSE_ERROR shape. See
Parse errors
for the full response shape.
When a query is rejected, the response includes a suggestion field describing
the recommended action. See
Error response shapes
for details and an example of handling a SQL_POLICY_VIOLATION error.
If your app has a use case that requires a restricted function or statement, you can request an exemption or propose a change to the policy through Developer and Marketplace Support.
Include the following information in your request:
app.id of your Forge app.Rate this page: