Craticula

The safety model

This page lists what Craticula does to keep a hostile request from hurting your database, and what it does not do. It is for a developer or reviewer who needs to judge whether Craticula fits a system that faces the public.

Values are parameters #

Every value from the request goes into the query as a parameter. It is never pasted into the text.

For SQL, the statement holds placeholders such as $1 and the values travel in a separate list. For the quickstart request, the text contains no "acme" and no 100. See How a request becomes a query.

The specification applies the same idea to MongoDB and OpenSearch. There, values go into the pipeline or query document as data. A text search value that holds pattern characters is escaped. The compilers have helpers for that.

A value such as '; DROP TABLE users; -- sent in an ordinary text filter is just a string. It is compared and does nothing else. The adversarial fixtures are about the shape of the request, not about string contents.

Identifiers come from your schema #

Table names, collection names and column names come only from the schema you wrote. The request never supplies one.

The request names columns by their grid id, such as customer. Craticula looks that id up in the schema and uses the physical name you declared. For SQL, the name is quoted for the dialect, and a quote character inside a name is doubled.

Unknown columns are refused #

A column that is not in the schema is refused before any query exists. The quickstart shows a filter on password being rejected.

A column that is not in the schema cannot be used to group, aggregate or sort, in any mode. A filter on such a column is refused in Strict mode and dropped in Lenient mode; see Strict and Lenient. A schema can also mark a column as not filterable, groupable or exportable.

Malformed input is refused #

The adapter and the checks reject input they do not recognise:

Each of these has a fixture that expects a clean rejection.

Resource limits #

A request cannot ask for unlimited work. These are the defaults in ResourceLimits:

LimitDefault
Filter tree depth8
Conditions in the whole filter64
Values in one in or not-in list1000
Rows in one page1000
Rows returned by a distinct-values requestat most 10000
Rows in a request that sends no row windowa default page of 100 (every row only by an export, or by a flag you switch on)
Query time on MongoDB and Searchnot set; you set it and the database enforces it

You can set each one higher or lower. You cannot turn a limit off, except that the query time limit is optional and unset until you set it. Zero or a negative number is refused when you set it. See Limits.

The fixtures test each limit one step past the edge, and with extreme values such as a 5000-value list or a page of one million rows.

What Craticula does not protect against #

Where this comes from #