Skip to content

fix(sof): refuse fts3_tokenizer in SQL-on-FHIR queries - #2955

Open
angela-helios wants to merge 1 commit into
mainfrom
fix/sof-sql-deny-fts3-tokenizer
Open

angela-helios wants to merge 1 commit into
mainfrom
fix/sof-sql-deny-fts3-tokenizer

Conversation

@angela-helios

Copy link
Copy Markdown
Contributor

Stacked on #2901. This branch starts from #2901's branch so that Test FHIRPath passes against the current fhir-test-cases master; its commit leaves this diff once #2901 merges.

Closes #2954

Summary

The SQL query engine's read-only authorizer allowed every function call. The bundled SQLite includes FTS3, so SELECT fts3_tokenizer('simple') returned the address of a tokenizer module inside the server process: an address-layout leak to any $sql-run or sof-server caller. The two-argument form registers a tokenizer at a caller-given address.

The authorizer now denies AuthAction::Function for fts3_tokenizer, in any case. The refusal is reported as SqlQueryError::NotSelect("the SQL function fts3_tokenizer() is not permitted"), the same error class as a refused write. A small Refusal enum keeps the statement message ("only SELECT queries are allowed; … statements are not permitted") for statements.

Tests

sqlquery::engine::tests::execute_select_refuses_fts3_tokenizer checks:

  • fts3_tokenizer('simple'), FTS3_Tokenizer('porter'), the call nested in length(...), and the call with a bound parameter :t are all refused, with the message;
  • upper('ok') still runs.

With the refusal disabled, SELECT fts3_tokenizer('simple') runs and the test fails, which also confirms the function is reachable in the bundled build.

The 30 engine tests pass. Clippy on helios-sof --all-targets is clean.

The read-only authorizer allowed every function, and the bundled SQLite
has FTS3, so SELECT fts3_tokenizer('simple') returned the address of a
tokenizer module in the server process. The authorizer now denies that
function and reports it as a refused function.

Closes #2954
@claude

claude Bot commented Nov 25, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL-on-FHIR queries can call fts3_tokenizer and read a server process address

1 participant