Skip to main content
Menu
Advisories

Impact Native-image server builds only; the JVM build of the same release refuses every statement below

GHSA-84M7-76GH-RM42Published Updated GitHub

Description

Impact

Native-image server builds only; the JVM build of the same release refuses every statement below. An authenticated client can run writes that are nested in a SELECT (projection subquery, LET clause) through paths that are meant to be read-only, because the nested-statement check sees an empty AST in the native binary and classifies the statement as idempotent and READ. Tested on 26.10.2: two inserts written durably through POST /api/v1/query, which refuses them on the JVM. From the code (not run): the same misclassification reaches the MCP read-only mode (ExecuteCommandTool, QueryTool, SampleRecordsTool), which an operator may rely on to keep an AI agent from writing; HA leader routing in RaftReplicatedDatabase (isDDL() || !isIdempotent()), so a nested write on a follower is not forwarded to the leader; and the parallel-safety and correlated-subquery-cache checks, which answer "safe" for every fragment. Not tested: whether record-level security (a user whose groups allow reads only) still blocks the write; if it does, the impact is limited to the read-only modes and the HA routing above. Reported privately per SECURITY.md because of the MCP read-only and HA paths; please make it a public issue if you judge it is not a security problem.

Summary

SqlAstInspector walks the parsed SQL AST with Class.getDeclaredFields() (engine/src/main/java/com/arcadedb/query/sql/executor/SqlAstInspector.java line 68), and Statement.classifyNested() and SqlAstInspector.isParallelSafe() / allNodesMatch() depend on that walk. native/src/main/resources/META-INF/native-image/com.arcadedb/arcadedb-native/reachability-metadata.json has 586 reflection entries on main (569 at 26.10.2) and none under com.arcadedb.query.sql.parser, so in the native binary getDeclaredFields() returns an empty array for every AST class, the walk visits only the root, and it reports "complete". A statement that holds a write inside a SELECT projection, a SELECT LET clause or a LET right-hand side is therefore classified isIdempotent() == true, isDDL() == false, getOperationTypes() == [READ] (the exact misclassification fixed for the JVM in #9628 / #9687), and the read-only door database.query() / POST /api/v1/query executes it. Top-level writes are still refused, because they are classified by their own class. Every gate that consumes the classification fails open on native: the query endpoint, the MCP read-only mode, the HA leader routing in RaftReplicatedDatabase (isDDL() || !isIdempotent()), requireStreamableStatement, VectorSearch/HybridSearch, and the parallel-safety and correlated-subquery-cache checks (allNodesMatch with a root-only walk answers "safe" for every fragment).

Reproduction

Images, both amd64, current release 26.10.2: arcadedata/arcadedb:26.10.2-native-amd64 (digest sha256:fa4a4aa353986c5260a293ce1862842ea9a653d53336daed04f04c59b54e5dd1, the manifest-list tag 26.10.2-native is sha256:407cc519e35d...) and the JVM control arcadedata/arcadedb:26.10.2 (sha256:7a498ebbbb9a5f02f7d43487c13b6632f83eb7fff345968baf220ac9266fd791).

docker run -d --name insp-native -p 127.0.0.1:12480:2480 arcadedata/arcadedb:26.10.2-native-amd64 -Darcadedb.server.rootPassword=playwithdata123
docker run -d --name insp-jvm    -p 127.0.0.1:12481:2480 -e JAVA_OPTS="-Darcadedb.server.rootPassword=playwithdata123" arcadedata/arcadedb:26.10.2
./repro.sh 12481   # JVM
./repro.sh 12480   # native

repro.sh (attached next to this file) creates a database insp with a vertex type T holding one row {a:1} through POST /api/v1/command, then sends each statement to POST /api/v1/query/insp as {"language":"sql","command":"..."} with root credentials, and finally reads the state back. Full outputs are in out-jvm.txt and out-native.txt.

statement sent to POST /api/v1/query/inspJVM 26.10.2native 26.10.2
SELECT FROM T200, 1 row200, 1 row
INSERT INTO T SET a = 2400 QueryNotIdempotentException400 QueryNotIdempotentException
CREATE VERTEX TYPE Top400 QueryNotIdempotentException400 QueryNotIdempotentException
SELECT (INSERT INTO T SET a = 3) AS r FROM T LIMIT 1400 Query '...' is not idempotent200, {"r":[{"@rid":"#1:1","@type":"T","a":3}]}, row written
SELECT FROM T LET $y = (INSERT INTO T SET a = 4)400 Query '...' is not idempotent200, returns the rows, row a = 4 written
SELECT FROM (CREATE VERTEX TYPE FromDdl)400 Query '...' is not idempotent200, "result":[] (accepted by the read-only door; the type did not appear in schema:types afterwards)
SELECT FROM T LET $y = (DELETE FROM T WHERE a = 1)400 Query '...' is not idempotent500 UnsupportedOperationException: Implement DeleteStatement.refersToParent() (the classification also let it past the gate; it failed later in the planner, row a = 1 still present)

State read back afterwards: JVM has rows a = 1 only; native has rows a = 1, 3, 4, so two writes went through the read-only endpoint durably.

repro.sh:

#!/usr/bin/env bash
# usage: repro.sh PORT   (server started with root password playwithdata123)
P=$1; A="root:playwithdata123"; B=http://localhost:$P/api/v1
post() { # path, json
  curl -s -u $A -H 'Content-Type: application/json' -X POST "$B/$1" -d "$2" -w '  [HTTP %{http_code}]\n'; }
echo "== setup (via command endpoint)"
curl -s -u $A -X POST "$B/server" -d '{"command":"create database insp"}' -w '  [HTTP %{http_code}]\n'
post command/insp '{"language":"sql","command":"CREATE VERTEX TYPE T"}'
post command/insp '{"language":"sql","command":"INSERT INTO T SET a = 1"}'
Q() { echo; echo "== POST /query: $1"; python3 -I -c 'import json,sys;print(json.dumps({"language":"sql","command":sys.argv[1]}))' "$1" > /tmp/insp_body.json
  curl -s -u $A -H 'Content-Type: application/json' -X POST "$B/query/insp" -d @/tmp/insp_body.json -w '  [HTTP %{http_code}]\n'; }
Q 'SELECT FROM T'
Q 'INSERT INTO T SET a = 2'
Q 'CREATE VERTEX TYPE Top'
Q 'SELECT FROM (CREATE VERTEX TYPE FromDdl)'
Q 'SELECT (INSERT INTO T SET a = 3) AS r FROM T LIMIT 1'
Q 'SELECT FROM T LET $y = (INSERT INTO T SET a = 4)'
Q 'SELECT FROM T LET $y = (DELETE FROM T WHERE a = 1)'
echo; echo "== state after (via command endpoint, a write-capable path used only for reading)"
post command/insp '{"language":"sql","command":"SELECT a FROM T ORDER BY a"}'
post command/insp '{"language":"sql","command":"SELECT name FROM schema:types ORDER BY name"}'

Cause

Without allDeclaredFields metadata for the classes in com.arcadedb.query.sql.parser (and the holder classes in AST_HOLDER_CLASSES), getDeclaredFields() yields nothing in a GraalVM native image, so AST_FIELDS is empty for every node. allNodesMatch then tests only the root and forEachNestedStatement returns true ("complete") after visiting nothing, which bypasses the fail-closed branch in Statement.classifyNested() ("PART OF THE TREE COULD NOT BE READ"). That branch only triggers on an IllegalAccessException, never on an empty field array. #9495 / PR #9524 removed one reflective use from the AST (copy()) for the same reason; this is the other one.

Suggested fix

Either (a) add {"type": "...", "allDeclaredFields": true} for every class under com.arcadedb.query.sql.parser plus the holder classes (our own spike needed it on about 220 classes), generated rather than hand-listed, or (b) make the walk reflection-free (an acceptChildren-style visitor generated on the node classes, or a generated field table), which also removes the setAccessible(true) from the hot classification path. Independently, SqlAstHolderClassesTest style coverage should run in the native build: a native smoke test that sends SELECT (INSERT INTO T SET a = 1) FROM T to /api/v1/query and asserts the 400 would have caught it. A cheap guard in SqlAstInspector is also possible: if a non-trivial node class (one that is not a leaf such as Identifier) reports zero AST fields, treat the walk as incomplete and fail closed.

Related

#9628 and PR #9687 (nested-statement classification on the JVM), #9495 / PR #9524 (reflection-free copy() for native), #10423 (spatial4j metadata). No existing issue covers the inspector on native: searches for "SqlAstInspector", "native image reflection", "getDeclaredFields", "idempotent native" and "read-only native" found nothing, and none of the results is by ruispereira about native.

Related advisories

This advisory and its CVE also cover the following advisories, fixed in the same release (26.11.1):

  • GHSA-ww64-52x2-w3x2: Addendum to GHSA-84m7-76gh-rm42: the native-image read-only bypass covers the whole nesting surface and top-level PROFILE INSERT (46 of 177 shapes accepted, 38 persist; still open on main)

Affected versions

References

GitHub · ArcadeData/arcadedb