Skip to main content
Menu
Advisories

arcadedb-gremlin privilege escalation

GHSA-R946-225C-5X88Published Updated GitHub

Description

SEVERITY: MEDIUM (bounded to a bound server administrator, measured)

Summary

QueryEngine.analysisEvaluatesQuery() is the contract that lets a caller use analyze() as a check that runs before the text does anything. GremlinQueryEngine does not override it, although its analysis evaluates Groovy on the fallback arm. Measured consequence, worse than the lead claimed: analyze() of a script whose leading statement writes through the Graph API not only performs the write and makes it durable, it then classifies the script as idempotent with operation types [READ]. So the MCP query tool's own refusal, "!analyzed.isIdempotent()", never fires: the tool answers successfully and the vertex is in the database.

The guard arm that let the evaluation through, and the two bounds the lead could not settle, were measured rather than read. See "Scope / confidence" for the three answers.

Where (HEAD 7399c0d735)

  • gremlin/src/main/java/com/arcadedb/gremlin/query/GremlinQueryEngine.java:95-107, analyze(), with no analysisEvaluatesQuery() override anywhere in the class.
  • engine/src/main/java/com/arcadedb/query/QueryEngine.java:131-139, the contract, and :137 the default false.
  • engine/src/main/java/com/arcadedb/query/polyglot/PolyglotQueryEngine.java:131, the only override in the repository.
  • gremlin/src/main/java/com/arcadedb/gremlin/ArcadeGremlin.java:398-415 parse(), falling to parseGroovy() at :403-405 for any effective engine other than java, and :428-441 parseGroovy(), whose first statement evaluates the script.
  • gremlin/src/main/java/com/arcadedb/gremlin/ArcadeGremlin.java:423-424, the javadoc that already states the residue: Groovy writing through another API while it is evaluated still writes.
  • mcp/src/main/java/com/arcadedb/mcp/tools/MCPToolUtils.java:73-83, analyzableQueryEngine(), the consumer that refuses an engine only when analysisEvaluatesQuery() is true.
  • mcp/src/main/java/com/arcadedb/mcp/tools/QueryTool.java:93-97 and mcp/src/main/java/com/arcadedb/mcp/tools/ExecuteCommandTool.java:93-95, where analyze() runs before the idempotence refusal and before checkPermission respectively.
  • ha-raft/src/main/java/com/arcadedb/server/ha/raft/RaftReplicatedDatabase.java:1592 and :1832, the follower's forward decision, which calls queryEngine.analyze(query) for whatever language the client named with no analysisEvaluatesQuery() consultation.

Repro

Added gremlin/src/test/java/com/arcadedb/gremlin/R30AnalyzeGroovyWritesTest.java (a measurement, not committed, deleted after the run) and ran it through gremlin-it, which is where gremlin's test classes actually execute. Command:

mvn -pl gremlin install -DskipTests ... && mvn -pl gremlin-it test -Dtest=R30AnalyzeGroovyWritesTest

Recorded output, verbatim, with the surrounding log lines dropped only where marked:

[R30] GUARD ARM: DatabaseContext=PRESENT, currentUser=null [R30] engine=auto [R30] count(V) before analyze = 0 ... [R30] analyze() returned: idempotent=true types=[READ] [R30] GUARD ARM: DatabaseContext=PRESENT, currentUser=null [R30] count(V) immediately after analyze = 1 [R30] a transaction is still active after analyze; committing it [R30] count(V) after commit/settle = 1 [R30] count(V) after reopening the database = 1

The script was the one the lead named, "g.getGraph().addVertex('V'); g.V()". The count goes from 0 to 1 during analyze(), survives a close and reopen of the database, and the verdict analyze() hands back is READ.

Refutation attempted

Four controls, all run in the same class, all reported below as they came back.

NAMED CONTROL, the grammar-readable form. Would have shown "analysis writes in general" (which issue #11182 already fixed) rather than a Groovy-fallback defect:

[R30-C1] count(V) before = 0 [R30-C1] analyze() returned: idempotent=false types=[CREATE] [R30-C1] count(V) after = 0

It refutes nothing: the gremlin-lang arm is clean and correctly classifies the write. That isolates the Groovy fallback.

SECOND CONTROL, the same Groovy with arcadedb.gremlin.engine=java. Would have shown the fallback at ArcadeGremlin.java:403-405 is not the gate:

[R30-C2] engine=java [R30-C2] count(V) before = 0 [R30-C2] analyze() threw com.arcadedb.exception.CommandParsingException: Error on parsing gremlin query: Failed to interpret Gremlin query: Query parsing failed at line 1, character position at 2, error message : no viable alternative at input 'g.getGraph' [R30-C2] count(V) after = 0

Confirms the fallback is the gate.

THIRD CONTROL, mine, not the lead's: a bound SecurityDatabaseUser whose isServerAdministrator() is false, which is what an ordinary MCP caller binds. Would have shown the finding is unbounded:

[R30-C3] count(V) before = 0 [R30-C3] analyze() threw com.arcadedb.exception.CommandParsingException: Error on parsing command [R30-C3] count(V) after = 0

It came back the "wrong" way for an unbounded reading, and I am reporting it as such: the guard holds for a non-administrator and nothing is evaluated. GremlinQueryEngine.analyze wraps the SecurityException into a CommandParsingException, which is why the message is the generic one.

FOURTH CONTROL, mine: the same with isServerAdministrator() true, which is what root binds:

[R30-C4] count(V) before = 0 [R30-C4] analyze() RETURNED: idempotent=true types=[READ] [R30-C4] count(V) after = 1

So the defect is real on a server, for root, through a bound principal, not only for an unbound embedded caller.

Suggested fix

Override analysisEvaluatesQuery() in GremlinQueryEngine to return true whenever the effective engine is auto or groovy, which is the conservative answer the contract asks for and makes MCP refuse gremlin on such a server before anything runs. Better, and what the HA follower's forward decision also needs: have ArcadeGremlin.parse() refuse rather than evaluate when the grammar cannot read the script and the caller asked for an analysis, so the two consumers at RaftReplicatedDatabase.java:1592 and :1832 are covered without each having to ask. Independently of either, the classification is wrong on its own terms: a Groovy script whose write went through the Graph API rather than a traversal is reported as [READ], so the guarded source at GremlinStatementAnalyzer.guarded cannot be the only thing the verdict rests on.

The guarantee then: an engine whose analysis can run the text is named as such, and every caller that uses analyze() as a pre-check refuses it at one place instead of each discovering the hole.

Scope / confidence

Executed: the five cases above, measured on gremlin-it against the shaded jar. Read: the MCP and HA call sites.

The three things the lead could not determine:

  1. Which guard arm. GremlinHostAccessGuard.checkServerAdministrator returns early for a null DatabaseContext and, separately, for a null current user. The embedded reproduction used the NULL CURRENT USER arm, not the null context arm: the context was present every time it was printed, with currentUser=null. The two bound-user controls then show the arm does not matter for severity, because a bound server administrator reaches the Groovy evaluation as well.
  2. Whether a stock MCP deployment binds a server administrator. It binds a principal, always: MCPToolUtils.resolveDatabase at :105-106 calls bindCurrentUser before any tool analyses anything, and MCPScopedDatabaseUser.isServerAdministrator (:70-73) delegates to the caller's own user, where ServerSecurityDatabaseUser.isServerAdministrator (:110-113) is "not denyAll and the user name is root". So an ordinary MCP user is NOT a server administrator and is refused, as control three measured. The finding is bounded to root, or to any user the deployment has named root, reaching MCP on a database its configuration grants it.
  3. Whether the HA follower's forward decision is on the Groovy arm. Yes, by reading: RaftReplicatedDatabase.command at :1592 and :1832 calls queryEngine.analyze(query) for the client's language with no analysisEvaluatesQuery() consultation anywhere on that path, and GremlinStatementAnalyzer.java:50-53 is explicit that an analysis that evaluated is the #11182 failure. I did not stand up a cluster to measure it.

Residual severity: the MCP configuration's reads-only restriction and the read-only tool contract do not hold for a server administrator on the auto or groovy gremlin engine, and the write is additionally reported as a read. Not privilege escalation: a non-administrator is refused. Worth noting that the groovy engine already logs a loud RCE warning at startup ("DO NOT USE IN PRODUCTION"), so the deployment is one upstream already considers unsafe; what is new is that the analysis path, which exists precisely to be the safe pre-check, is on it.

Dedup

Grepped the whole alltitles.txt. No title mentions groovy, analysisEvaluatesQuery, or an analysis that evaluates. Neighbours checked: #11182 (CLOSED, "HA: one Gremlin write sent to a follower is applied several times and still returns an error"), which fixed the gremlin-lang arm and is what control one measures as clean, and #11170 (CLOSED, "MCP: tool annotations and a Claude Code plugin to connect to your own ArcadeDB server"), which is where the contract comment came from.

Related advisories

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

  • GHSA-6jr9-6vw5-xjf6: MCP: the two upsert tools create types with allowSchemaChange set to false, the same schema change execute_command refuses on the same server

Affected versions

References

GitHub · ArcadeData/arcadedb