Repository navigation
Improved security of wire-protocol connections and schema listings - #11185
Conversation
- Binary listeners (Postgres, Redis, BOLT): a connection must authenticate within arcadedb.network.preAuthTimeout (default 30 s) from accept, whatever it keeps sending. Errors reported by unauthenticated connections are logged at most once per 10 s per listener. - BOLT: a refused LOGON leaves no principal bound. - Schema listings show only the types the caller may read: PostgreSQL catalog, GraphQL introspection, the MCP/AI schema document, the Cypher meta.* procedures, the gRPC database info. New SecurityHelper.readableTypes, plus a census test over every schema walk that answers a caller. - MCP: allowSchemaChange=false also covers types created implicitly by a write (Cypher CREATE/MERGE, the upsert tools); a database the caller cannot reach is answered as one that does not exist.
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
|
Review of the PR diff (read-only, I did not build or run the tests). Summary: This hardens the pre-auth phase of the binary listeners, the schema listings and the BOLT/MCP auth state. It reads as sound and security-positive. I found no security hazard. Looks good
Minor suggestions
Nothing blocking from my side. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 68 |
🟢 Coverage 91.32% diff coverage · -4.60% coverage variation
Metric Results Coverage variation ✅ -4.60% coverage variation Diff coverage ✅ 91.32% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (aa6f2f8) 259040 226511 87.44% Head commit (6ed509d) 292417 (+33377) 242255 (+15744) 82.85% (-4.60%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#11185) 265 242 91.32% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Review of the pre-auth hardening ( Security: no hazard found. The change reduces attack surface.
Minor points
Overall this looks good to me. The only thing I'd ask for is the stopwatch check in the tests. |
|
Review (partial, focused on Looks good
Suggestions (non-blocking)
I found no security hazards. The PR tightens security. |
|
Reviewed the PR, with most attention on What looks good
Minor suggestions (non-blocking)
I found no security hazards. The change reduces exposure. |
|
@coderabbitai review |
Action performed
|
|
Review (partial: the diff is large and I read only part of it - the BOLT listener, the config option, Security
Notes
I found no blocking issues in the parts I read. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #11185 +/- ##
============================================
+ Coverage 79.34% 79.36% +0.01%
Complexity 4959 4959
============================================
Files 2322 2324 +2
Lines 259040 259590 +550
Branches 56762 56877 +115
============================================
+ Hits 205542 206030 +488
- Misses 32569 32580 +11
- Partials 20929 20980 +51 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…11185) * Improved security of wire-protocol connections and schema listings - Binary listeners (Postgres, Redis, BOLT): a connection must authenticate within arcadedb.network.preAuthTimeout (default 30 s) from accept, whatever it keeps sending. Errors reported by unauthenticated connections are logged at most once per 10 s per listener. - BOLT: a refused LOGON leaves no principal bound. - Schema listings show only the types the caller may read: PostgreSQL catalog, GraphQL introspection, the MCP/AI schema document, the Cypher meta.* procedures, the gRPC database info. New SecurityHelper.readableTypes, plus a census test over every schema walk that answers a caller. - MCP: allowSchemaChange=false also covers types created implicitly by a write (Cypher CREATE/MERGE, the upsert tools); a database the caller cannot reach is answered as one that does not exist. * Documented the granularity of the pre-authentication deadline * Pre-authentication gate always closes an expired socket and caches its counters * Test the pre-authentication deadline on the PostgreSQL listener * AI query tool answers an unreachable database as one that does not exist (cherry picked from commit 289ef95)
What
Hardening of the wire-protocol listeners, of the routes that list the schema, and of the MCP and BOLT authentication state.
Pre-authentication phase of the binary listeners (Postgres, Redis, BOLT)
arcadedb.network.preAuthTimeout(default 30000 ms, 0 disables): a connection that has not authenticated within it from the accept is closed, whatever it keeps sending.arcadedb.network.socketTimeoutonly closed an IDLE connection, so a client sending a few bytes now and then (a refused command, a BOLT NOOP chunk) held its slot ofarcadedb.network.maxPreAuthConnectionsindefinitely. Enforced byPreAuthConnectionGate: one JVM-wide daemon reaper thread, created lazily, walks the outstanding tickets once a second and closes the raw socket. Every listener gets it by passing the accepted socket to the gate. Metric<protocol>.connection.preauth.expired.BOLT
LOGON(bad password, unknown user, missing credentials) fromREADYused to leave the previous principal bound, so theRESETa pool sends before reuse brought the connection back toREADYas the old user. The principal is now dropped before the attempt and bound only on success.Schema listings and the per-type ACL
SecurityHelper.readableTypes(Database)/isReadable(Database, DocumentType): the types the bound principal may read. Now used by the PostgreSQL catalog emulation (pg_class, pg_attribute, pg_index, pg_inherits, pg_depend, information_schema, pg_matviews, pg_type row types), GraphQL introspection (__schema,__type, Query-root fields, embedded types),SchemaInfo(MCPget_schema, thearcadedb://{db}/schemaresource, the Studio AI assistant),AiSchemaDigest, MCPsample_records, and the Cyphermeta.schema/meta.stats/meta.graph/meta.nodeTypeProperties/meta.relTypePropertiesprocedures. An unreadable type looked up by name is answered exactly as one that does not exist, and an unreadable supertype is left out of a readable type's parents.getDatabaseInfonow binds the caller and counts only the readable types. Unbound, the per-bucket gate ofLocalBucket.count()was a no-op, so it counted every type.SchemaPresentationReadableWalkCensusTestscans the main sources of every module (and the engine's Cypher procedures) for agetTypes()walk that is neither on the readable walk nor allow-listed with a reason.MCP
allowSchemaChange=falsenow also covers types a write creates implicitly: a CypherCREATE/MERGEnaming a label or relationship type that does not exist, throughexecute_commandor the upsert tools. It analyzes as a write, not a schema change. The tools run asMCPScopedDatabaseUser, the caller's principal narrowed to refuseUPDATE_SCHEMA, so the engine refuses it on every route. Writes to existing types are unaffected (the engine only asks forUPDATE_SCHEMAwhen the schema actually changes).get_schema/get_type.Behaviour changes
allowSchemaChangeis enabled. It defaults tofalse, so existing tests that relied on auto-creation now set it.Tests
New:
PreAuthConnectionGateTest(deadline, release, throttled log),RedisPreAuthDeadlineTest,BoltPreAuthDeadlineIT,BoltFailedLogonIT,MCPSchemaChangeAndDatabaseRefusalTest,PostgresCatalogPerTypeAclTest,GraphQLIntrospectionPerTypeAclTest,SchemaInfoPerTypeAclTest,GrpcDatabaseInfoPerTypeAclTest,CypherMetaProceduresPerTypeAclTest,SchemaPresentationReadableWalkCensusTest. Every test class of the redis, mcp, graphql, postgres, grpc, Cypher-procedure and server ai/info/network/security packages passes locally (GraphQL in theverifyphase, for the Gremlin shaded jar).Summary by CodeRabbit