Skip to content

Improved security of wire-protocol connections and schema listings - #11185

Merged
lvca merged 5 commits into
mainfrom
security-26.11.1-b
Nov 3, 2026
Merged

lvca merged 5 commits into
mainfrom
security-26.11.1-b

Conversation

@lvca

@lvca lvca commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

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)

  • New 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.socketTimeout only closed an IDLE connection, so a client sending a few bytes now and then (a refused command, a BOLT NOOP chunk) held its slot of arcadedb.network.maxPreAuthConnections indefinitely. Enforced by PreAuthConnectionGate: 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.
  • Protocol errors from unauthenticated connections go through a throttled log on the gate (at most one record per 10 s per listener, with a count of what was held back). Covers Redis protocol errors and the BOLT handshake/version/TLS refusals, which used to write a WARNING (or a SEVERE with stack trace) per connection.

BOLT

  • A refused LOGON (bad password, unknown user, missing credentials) from READY used to leave the previous principal bound, so the RESET a pool sends before reuse brought the connection back to READY as the old user. The principal is now dropped before the attempt and bound only on success.

Schema listings and the per-type ACL

  • New 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 (MCP get_schema, the arcadedb://{db}/schema resource, the Studio AI assistant), AiSchemaDigest, MCP sample_records, and the Cypher meta.schema / meta.stats / meta.graph / meta.nodeTypeProperties / meta.relTypeProperties procedures. 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.
  • gRPC getDatabaseInfo now binds the caller and counts only the readable types. Unbound, the per-bucket gate of LocalBucket.count() was a no-op, so it counted every type.
  • SchemaPresentationReadableWalkCensusTest scans the main sources of every module (and the engine's Cypher procedures) for a getTypes() walk that is neither on the readable walk nor allow-listed with a reason.

MCP

  • allowSchemaChange=false now also covers types a write creates implicitly: a Cypher CREATE/MERGE naming a label or relationship type that does not exist, through execute_command or the upsert tools. It analyzes as a write, not a schema change. The tools run as MCPScopedDatabaseUser, the caller's principal narrowed to refuse UPDATE_SCHEMA, so the engine refuses it on every route. Writes to existing types are unaffected (the engine only asks for UPDATE_SCHEMA when the schema actually changes).
  • A database the caller may not reach (not granted, or not opened to it over MCP) is answered exactly as one that does not exist. The same applies to the AI assistant's get_schema / get_type.

Behaviour changes

  • MCP upsert tools no longer create a missing type unless allowSchemaChange is enabled. It defaults to false, so existing tests that relied on auto-creation now set it.
  • An unauthenticated connection is closed after 30 s even if it is active.

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 the verify phase, for the Gremlin shaded jar).

Summary by CodeRabbit

  • New Features
    • Added a configurable deadline for unauthenticated Bolt, PostgreSQL, and Redis connections. Expired connections are closed, and repeated pre-authentication errors are rate-limited in logs.
  • Bug Fixes
    • Schema listings, metadata, GraphQL introspection, PostgreSQL catalogs, database summaries, and AI schema details now show only types readable by the current user.
    • Failed Bolt re-authentication clears the previous user’s access.
    • MCP operations now respect database and schema-change permissions, and inaccessible databases are reported consistently as unavailable.

- 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.
@lvca lvca added this to the 26.11.1 milestone Nov 3, 2026
@lvca lvca self-assigned this Nov 3, 2026
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Walkthrough

The changes add configurable deadlines and bounded protocol-error logging for unauthenticated BOLT, PostgreSQL, and Redis connections. They also filter schema metadata by read access across several interfaces and apply configured database and schema-change permissions to MCP operations.

Changes: Pre-authentication connection controls

Layer / File(s) Summary
Deadline gate and logging
engine/src/main/java/com/arcadedb/GlobalConfiguration.java, server/src/main/java/com/arcadedb/server/network/PreAuthConnectionGate.java, server/src/test/java/com/arcadedb/server/network/PreAuthConnectionGateTest.java
Adds a configurable pre-authentication timeout, socket tracking, permit release on expiration, and throttled logging. Tests cover deadline behavior, permit reclamation, and log counts.
Protocol listener and executor integration
bolt/src/main/java/com/arcadedb/bolt/*, postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkListener.java, redisw/src/main/java/com/arcadedb/redis/*, bolt/src/test/java/com/arcadedb/bolt/*, postgresw/src/test/java/com/arcadedb/postgres/PostgresPreAuthDeadlineIT.java, redisw/src/test/java/com/arcadedb/redis/*
The listeners pass accepted sockets to the gate. BOLT and Redis executors use ticket logging for pre-authentication errors; BOLT authentication clears the existing user before checking credentials. Integration tests cover deadlines and authentication behavior.

Readable schema presentation

Layer / File(s) Summary
Readable-type helpers and coverage
engine/src/main/java/com/arcadedb/security/SecurityHelper.java, server/src/test/java/com/arcadedb/server/SchemaPresentationReadableWalkCensusTest.java
Adds helpers that return readable types and check read access for one type. The census test scans selected Java sources for schema-wide type walks.
Cypher and GraphQL introspection
engine/src/main/java/com/arcadedb/query/opencypher/procedures/meta/*, graphql/src/main/java/com/arcadedb/graphql/schema/GraphQLSchema.java, corresponding engine/src/test/.../CypherMetaProceduresPerTypeAclTest.java and graphql/src/test/.../GraphQLIntrospectionPerTypeAclTest.java
Cypher metadata procedures and GraphQL introspection omit unreadable database types and related metadata. Tests compare results with and without a bound user.
Server schema and AI metadata
server/src/main/java/com/arcadedb/server/ai/*, server/src/main/java/com/arcadedb/server/info/SchemaInfo.java, server/src/test/java/com/arcadedb/server/info/SchemaInfoPerTypeAclTest.java
Schema JSON and AI schema summaries filter unreadable types and parent types. Type and database lookups use not-found-style responses for inaccessible resources.
PostgreSQL catalog visibility
postgresw/src/main/java/com/arcadedb/postgres/PostgresCatalog.java, postgresw/src/test/java/com/arcadedb/postgres/PostgresCatalogPerTypeAclTest.java
Catalog lookups and listings use readable types. Dependency and inheritance results omit unreadable types.
gRPC database information
grpcw/src/main/java/com/arcadedb/server/grpc/ArcadeDbGrpcAdminService.java, grpcw/src/test/java/com/arcadedb/server/grpc/GrpcDatabaseInfoPerTypeAclTest.java
Database-info collection runs in the requesting user’s context and derives counts from readable types.

MCP database and schema scoping

Layer / File(s) Summary
Scoped principal and database resolution
mcp/src/main/java/com/arcadedb/mcp/MCPScopedDatabaseUser.java, mcp/src/main/java/com/arcadedb/mcp/MCPResources.java, mcp/src/main/java/com/arcadedb/mcp/tools/MCPToolUtils.java, server/src/main/java/com/arcadedb/server/security/DatabaseUserContext.java
MCP binds configured database permissions through a scoped principal. Database resolution uses a shared not-found-style refusal for unavailable, inaccessible, and excluded databases.
MCP tool permissions and validation
mcp/src/main/java/com/arcadedb/mcp/tools/*, mcp/src/test/java/com/arcadedb/mcp/*
Sample-record selection excludes unreadable types. Upsert descriptions condition automatic type creation on schema-change permission. Tests cover schema-change and database refusals.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Listener
  participant PreAuthConnectionGate
  participant Socket
  participant BoltNetworkExecutor
  Listener->>PreAuthConnectionGate: accept(Socket)
  PreAuthConnectionGate->>Socket: associate socket with ticket
  BoltNetworkExecutor->>PreAuthConnectionGate: log pre-authentication protocol error
  PreAuthConnectionGate->>Socket: close socket when ticket expires
Loading

Suggested labels: bug, engine, network, server, mcp, grpc, graphql, opencypher

Suggested reviewers: robfrank

Merge Risk: Moderate · up to 6ed50

Fix the MCP context restoration problem before merging, since it can leave a reused worker thread running without per-user permission checks. The pre-authentication startup-failure leaks and the remaining schema-visibility gaps are narrower but should be addressed.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 38.30% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "Improved security of wire-protocol connections and schema listings" matches the main themes of the changeset. The PR adds pre-authentication deadlines and throttled logging for Postgres, Re…
Description check Passed The description follows the template's main sections. It has "What", "Behaviour changes", and "Tests" content, which covers the template's "What does this PR do?" intent. The "Motivation" section is m…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Improved security of wire-protocol connections and schema listings" matches the main themes of the changeset. The PR adds pre-authentication deadlines and throttled logging for Postgres, Redis, and BOLT listeners. It also restricts schema listings (PostgreSQL catalog, GraphQL introspection, SchemaInfo, MCP, Cypher meta procedures, gRPC database info) to types the caller can read. The title is somewhat broad and does not mention the MCP behavior change or the BOLT LOGON fix, but it refers to real, central aspects of the change.

Full details: Description check

Explanation

The description follows the template's main sections. It has "What", "Behaviour changes", and "Tests" content, which covers the template's "What does this PR do?" intent. The "Motivation" section is missing, and the "Related issues" section is absent. The "Additional Notes" content is folded into "Behaviour changes" and "Tests". The checklist is absent, so the build command and the coverage checkbox are not confirmed. The description is detailed and covers the substantive changes, so it is mostly complete.

Resolution

Consider adding a Motivation section that explains why these hardening changes are needed. Add a Related issues section (or state that there are none). Add the template checklist and mark the mvn clean package build and the failure and success test coverage items.

Full details: Docstring Coverage

Explanation

Docstring coverage is 38.30% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 94 functions across 41 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ast-grep (0.51.1)

ast-grep could not parse rule config: /ast-grep-rules/ast-grep-essentials/rules/php/security/debug-mode-on.yml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1eca3ecd-242a-4f95-97d7-179ec0950061
Commits

Reviewing files that changed from the base of the PR and between 633f9c3 and 8ecac09.

Files selected for processing: 41
  • bolt/src/main/java/com/arcadedb/bolt/BoltNetworkExecutor.java
  • bolt/src/main/java/com/arcadedb/bolt/BoltNetworkListener.java
  • bolt/src/test/java/com/arcadedb/bolt/BoltFailedLogonIT.java
  • bolt/src/test/java/com/arcadedb/bolt/BoltPreAuthDeadlineIT.java
  • engine/src/main/java/com/arcadedb/GlobalConfiguration.java
  • engine/src/main/java/com/arcadedb/query/opencypher/procedures/meta/MetaGraph.java
  • engine/src/main/java/com/arcadedb/query/opencypher/procedures/meta/MetaNodeTypeProperties.java
  • engine/src/main/java/com/arcadedb/query/opencypher/procedures/meta/MetaRelTypeProperties.java
  • engine/src/main/java/com/arcadedb/query/opencypher/procedures/meta/MetaSchema.java
  • engine/src/main/java/com/arcadedb/query/opencypher/procedures/meta/MetaStats.java
  • engine/src/main/java/com/arcadedb/security/SecurityHelper.java
  • engine/src/test/java/com/arcadedb/query/opencypher/procedures/CypherMetaProceduresPerTypeAclTest.java
  • graphql/src/main/java/com/arcadedb/graphql/schema/GraphQLSchema.java
  • graphql/src/test/java/com/arcadedb/graphql/GraphQLIntrospectionPerTypeAclTest.java
  • grpcw/src/main/java/com/arcadedb/server/grpc/ArcadeDbGrpcAdminService.java
  • grpcw/src/test/java/com/arcadedb/server/grpc/GrpcDatabaseInfoPerTypeAclTest.java
  • mcp/src/main/java/com/arcadedb/mcp/MCPResources.java
  • mcp/src/main/java/com/arcadedb/mcp/MCPScopedDatabaseUser.java
  • mcp/src/main/java/com/arcadedb/mcp/tools/MCPToolUtils.java
  • mcp/src/main/java/com/arcadedb/mcp/tools/SampleRecordsTool.java
  • mcp/src/main/java/com/arcadedb/mcp/tools/UpsertEntityTool.java
  • mcp/src/main/java/com/arcadedb/mcp/tools/UpsertRelationshipTool.java
  • mcp/src/test/java/com/arcadedb/mcp/MCPDatabaseScopingTest.java
  • mcp/src/test/java/com/arcadedb/mcp/MCPSchemaChangeAndDatabaseRefusalTest.java
  • mcp/src/test/java/com/arcadedb/mcp/MCPServerPluginTest.java
  • postgresw/src/main/java/com/arcadedb/postgres/PostgresCatalog.java
  • postgresw/src/main/java/com/arcadedb/postgres/PostgresNetworkListener.java
  • postgresw/src/test/java/com/arcadedb/postgres/PostgresCatalogPerTypeAclTest.java
  • postgresw/src/test/java/com/arcadedb/postgres/PostgresPreAuthDeadlineIT.java
  • redisw/src/main/java/com/arcadedb/redis/RedisNetworkExecutor.java
  • redisw/src/main/java/com/arcadedb/redis/RedisNetworkListener.java
  • redisw/src/test/java/com/arcadedb/redis/Issue10597RedisMalformedInputTest.java
  • redisw/src/test/java/com/arcadedb/redis/RedisPreAuthDeadlineTest.java
  • server/src/main/java/com/arcadedb/server/ai/AiSchemaDigest.java
  • server/src/main/java/com/arcadedb/server/ai/ToolDispatcher.java
  • server/src/main/java/com/arcadedb/server/info/SchemaInfo.java
  • server/src/main/java/com/arcadedb/server/network/PreAuthConnectionGate.java
  • server/src/main/java/com/arcadedb/server/security/DatabaseUserContext.java
  • server/src/test/java/com/arcadedb/server/SchemaPresentationReadableWalkCensusTest.java
  • server/src/test/java/com/arcadedb/server/info/SchemaInfoPerTypeAclTest.java
  • server/src/test/java/com/arcadedb/server/network/PreAuthConnectionGateTest.java

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

@mergify

mergify Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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.

@claude

claude Bot commented Nov 3, 2026

Copy link
Copy Markdown

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

  • PreAuthConnectionGate uses one lazy daemon reaper. expire() and release() race on a single CAS, so a connection that authenticates at the deadline cannot double-release a permit. The reaper catches RuntimeException per ticket, so one bad ticket cannot stop the periodic task. The log is throttled per listener.
  • The BOLT fix drops the principal before a LOGON attempt and binds it only on success. That closes the stale-principal-after-RESET path.
  • SecurityHelper.readableTypes / isReadable give one shared per-type ACL filter. The Database-typed signatures widen the API without behavior change. The javadoc says an unreadable type must answer exactly like a missing one, which avoids an existence oracle.
  • Each surface has its own regression test (Postgres, GraphQL, gRPC, MCP, Cypher meta procedures, SchemaInfo, pre-auth deadlines), and there is a census test for the schema-walking routes.

Minor suggestions

  1. The reaper walks TRACKED once a second, so the deadline is accurate to about 1 s. That is fine, but worth stating in the NETWORK_PREAUTH_TIMEOUT description.
  2. In expire(), socket.getRemoteSocketAddress() is evaluated before close(). It is safe, but for a TLS listener that hands over the raw socket, check that SSLSocket shutdown cannot block. Closing the underlying socket should not.
  3. Reaper.start() uses EXECUTOR.getPoolSize() only for its side effect. A short comment is there already, which is enough. An explicit static init method would be clearer, but this is optional.
  4. Tests that depend on the reaper's 1 s period (*PreAuthDeadline*) should use polling with generous timeouts rather than wall-clock bounds. CLAUDE.md asks for StallAwareStopwatch or @Timeout sized as a hang detector. Please confirm they follow that.
  5. Please check the listener tests bind their ports through the fixture bases or allocateFreePorts, so HardcodedTestServerPortsTest stays green.

Nothing blocking from my side.

@codacy-production

codacy-production Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 68 complexity

Metric Results
Complexity 68

View in Codacy

🟢 Coverage 91.32% diff coverage · -4.60% coverage variation

Metric Results
Coverage variation ✅ -4.60% coverage variation
Diff coverage ✅ 91.32% diff coverage

View coverage diff in Codacy

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.

@claude

claude Bot commented Nov 3, 2026

Copy link
Copy Markdown

Review of the pre-auth hardening (PreAuthConnectionGate, BOLT LOGON, per-type ACL listings). I read the gate in full and only skimmed the rest of the diff. I did not build the PR or run its tests.

Security: no hazard found. The change reduces attack surface.

  • The reaper only calls socket.close(), which doesn't block, so a peer can't stall it.
  • release() and expire() both use a CAS on released, so the race with a connection that authenticates at that moment is handled correctly, and the permit is returned only once.
  • A ticket is added to TRACKED only after it is fully built, and it is removed on both the release and expire paths, so there is no leak.
  • Logging of unauthenticated peers is throttled. Attacker-controlled text goes in as a format argument, not as the pattern, so there is no format-string injection.
  • Dropping the BOLT principal before the LOGON attempt closes the stale-principal-after-RESET hole.

Minor points

  1. reap() catches RuntimeException and logs it at FINE. If expire() throws after the permit is released but before the socket is closed, the socket stays open and nothing visible says so. Consider closing the socket in a finally, or logging at WARNING.
  2. The deadline has a granularity of up to about 1 s. That is fine and the Javadoc says so, but the config description for arcadedb.network.preAuthTimeout should say it too.
  3. Reaper.start() calls EXECUTOR.getPoolSize(), which relies on side effects. It works, but a short comment on why would help. Your holder-idiom comment already covers most of it.
  4. The metric name comes from protocol.toLowerCase(Locale.ROOT) + ".connection.preauth.expired". A Micrometer Metrics.counter lookup on every expiry is cheap, but caching the counter in the gate would avoid the lookup.
  5. Tests: the gate and each protocol have deadline tests, and the ACL changes have per-module tests. Please check that the deadline ITs (BoltPreAuthDeadlineIT, RedisPreAuthDeadlineTest) don't assert on raw wall-clock elapsed time. CLAUDE.md asks for StallAwakeStopwatch-style handling via com.arcadedb.utility.StallAwareStopwatch. Use assertGaveUpWithin for the "closed within N seconds" checks.

Overall this looks good to me. The only thing I'd ask for is the stopwatch check in the tests.

@claude

claude Bot commented Nov 3, 2026

Copy link
Copy Markdown

Review (partial, focused on PreAuthConnectionGate, SecurityHelper.readableTypes/isReadable and the config change; I did not read every listener/handler diff).

Looks good

  • The reaper design is sound: a single lazy daemon thread, an idempotent release()/expire() race decided by CAS, and the socket close sits in finally. A per-ticket RuntimeException is caught so the periodic task can't die silently.
  • Throttled pre-auth logging with a suppressed-count is a good fit for attacker-controlled input.
  • The BOLT fix (drop the principal before the LOGON attempt and bind it only on success) closes a real RESET-as-old-user hole, and BoltFailedLogonIT covers it.
  • readableTypes/isReadable apply the same "unreadable looks like nonexistent" rule as schema:types. Widening canAccessType/currentUser to Database is backward compatible.

Suggestions (non-blocking)

  1. Reaper.start() relies on EXECUTOR.getPoolSize() to force class init. It works, but a comment or a plain init() no-op would be clearer. Because the reaper is JVM-wide and its executor is never shut down, make sure the test suites that restart servers don't leak tickets in TRACKED. Tickets for sockets closed before auth are removed by release(), so this should be fine as long as every listener releases on all exit paths.
  2. The reaper granularity is 1 s, so the effective deadline is timeout + up to 1 s. This is fine, but worth a line in the config description.
  3. logPreAuthProtocolError uses String.format on a message that may contain attacker-influenced args. The args are not the format string, so this is safe, but make sure no caller passes peer data as message.
  4. Test coverage is good (gate unit test, BOLT IT, per-type ACL tests). If not already there, a Postgres/Redis pre-auth deadline IT mirroring BoltPreAuthDeadlineIT would round out the three listeners.

I found no security hazards. The PR tightens security.

@claude

claude Bot commented Nov 3, 2026

Copy link
Copy Markdown

Reviewed the PR, with most attention on PreAuthConnectionGate. I did not build the PR or run its tests.

What looks good

  • Ticket.release() and expire() race on released.compareAndSet, so the permit is returned exactly once. The socket is closed in a finally block.
  • Log throttling bounds what an unauthenticated peer can write to the log. User-controlled text is passed as a %s argument, never as the format string.
  • The BOLT fix (the principal is dropped before a LOGON attempt and bound only on success) closes a real identity-reuse hole after RESET.
  • The per-type ACL filtering is applied consistently across the Postgres, GraphQL, MCP, Cypher meta, gRPC and SchemaInfo paths. The census test that scans for ungated getTypes() walks should stop new leaks from appearing.
  • Each new behaviour comes with tests.

Minor suggestions (non-blocking)

  • The reaper walks TRACKED once a second. That is cheap, but the deadline has about 1 s of slack. If it is meant as a hard bound, say so in the config description.
  • Reaper.start() calls EXECUTOR.getPoolSize() only to trigger class initialisation. That works, but a comment or a no-op static init() would be clearer. It is already commented, so this is optional.
  • The tests for the pre-auth deadlines (*PreAuthDeadline*) should use StallAwareStopwatch or generous bounds, as CLAUDE.md requires, instead of raw wall-clock assertions. Please check that they do.
  • The PR is large and mixes pre-auth hardening, schema ACL and MCP changes. That is fine here, but smaller PRs would be easier to review.

I found no security hazards. The change reduces exposure.

@lvca

lvca commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix comments: Fix CodeRabbit comments on this PR

@claude

claude Bot commented Nov 3, 2026

Copy link
Copy Markdown

Review (partial: the diff is large and I read only part of it - the BOLT listener, the config option, SecurityHelper and the Cypher meta procedures).

Security

  • This is a hardening PR from a maintainer. I saw nothing that adds a hazard.
  • The BOLT fix is right: dropping the principal before LOGON and binding it only on success closes the stale-principal-after-RESET hole.
  • SecurityHelper.readableTypes and isReadable reuse canAccessType. A null user sees everything, which matches the existing embedded/internal semantics.

Notes

  • readableTypes allocates a new list per call. That is fine for schema listings, but don't use it on hot paths. When the user is null it returns the live getTypes() collection, so callers must not mutate it.
  • isReadable calls canAccessType(SecurityDatabaseUser, ...) with a possibly-null user. Please confirm that overload treats null as allow.
  • PreAuthConnectionGate is one reaper thread that wakes once a second. Please confirm the ticket is removed on every exit path (successful auth, close, exception), so tickets can't leak and the reaper can't close a socket that is already authenticated.
  • The tests look thorough (BoltPreAuthDeadlineIT, BoltFailedLogonIT, the per-type ACL test and the census test). If any assert on timing, use StallAwareStopwatch per CLAUDE.md.

I found no blocking issues in the parts I read.

@lvca
lvca merged commit 289ef95 into main Nov 3, 2026
41 of 42 checks passed
@lvca
lvca deleted the security-26.11.1-b branch November 3, 2026 03:43
@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.15094% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.36%. Comparing base (aa6f2f8) to head (6ed509d).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...in/java/com/arcadedb/bolt/BoltNetworkExecutor.java 57.14% 11 Missing and 1 partial ⚠️
...arcadedb/server/network/PreAuthConnectionGate.java 89.01% 5 Missing and 5 partials ⚠️
...n/java/com/arcadedb/mcp/MCPScopedDatabaseUser.java 75.00% 2 Missing and 2 partials ⚠️
...in/java/com/arcadedb/server/ai/ToolDispatcher.java 0.00% 1 Missing and 2 partials ⚠️
...ava/com/arcadedb/graphql/schema/GraphQLSchema.java 92.59% 0 Missing and 2 partials ⚠️
...arcadedb/server/grpc/ArcadeDbGrpcAdminService.java 89.47% 0 Missing and 2 partials ⚠️
...in/java/com/arcadedb/postgres/PostgresCatalog.java 87.50% 1 Missing and 1 partial ⚠️
.../java/com/arcadedb/redis/RedisNetworkExecutor.java 33.33% 1 Missing and 1 partial ⚠️
.../arcadedb/server/security/DatabaseUserContext.java 33.33% 2 Missing ⚠️
...java/com/arcadedb/mcp/tools/SampleRecordsTool.java 66.66% 0 Missing and 1 partial ⚠️
... and 2 more
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

robfrank pushed a commit that referenced this pull request Nov 5, 2026
…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)
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.

1 participant