Skip to content

The build guard added to stop a raw exception message reaching an InsertError would have caught only 2 of the 6 sites it was written for: its regex only recognises six variable names #7911

Closed

Description

@rspereiratech

Summary

Issue7472EveryGrpcFailureIsConcealableTest is a source-level guard, and its own javadoc says why it has to be: a call site that omits concealment "COMPILES, it PASSES every behavioural test ... and the only thing wrong with it is that it puts the exception's own message on the wire in production. No behavioural test can see that". So the guard is the ONLY thing standing between the next such site and production.

Two of its four scans - noInsertErrorCarriesARawExceptionMessage and noDirectStatusMappingPutsAThrowablesMessageOnTheWire - decide "is this a throwable's own message" with one regex:

  private static final Pattern MESSAGE_OF_A_THROWABLE =
      Pattern.compile("\\b(e|ex|t|cause|error|throwable)\\.getMessage\\(\\)");

That is an allow-list of six variable spellings, and it is case sensitive. The defect the scan was written for - reported in the PR #7755 review as "a DuplicatedKeyException here still carried the index name and the offending key VALUE" - lived in catch (DuplicatedKeyException dup) and catch (DuplicatedKeyException retryDup) / catch (Exception retryEx) arms. None of dup, retryDup, retryEx is in the list, so the guard does not see any of them.

The fifth test, everyScanFindsTheConstructsItJudges, was added specifically to catch a scan that has gone blind - but it only asserts that each scan FINDS STATEMENTS to judge, not that the judgement itself still recognises anything. The InsertError scan finds 13 statements and is therefore "not blind" by that measure while missing two thirds of the sites it exists for.

Where (HEAD 06b033d)

grpcw/src/test/java/com/arcadedb/server/grpc/Issue7472EveryGrpcFailureIsConcealableTest.java:71-76

  /**
   * A description interpolating a THROWABLE's own message - {@code e.getMessage()}, {@code cause.getMessage()}.
   * Not {@code request.getX()}, which is the caller's own input echoed back.
   */
  private static final Pattern MESSAGE_OF_A_THROWABLE =
      Pattern.compile("\\b(e|ex|t|cause|error|throwable)\\.getMessage\\(\\)");

The sites it was written for, as they stood before the fix (grpcw/src/main/java/com/arcadedb/server/grpc/ArcadeDbGrpcService.java at 417314c, lines 4513-4537):

          case CONFLICT_ABORT, UNRECOGNIZED -> c.err(c.received - 1, "CONFLICT", dup.getMessage(), "");
                c.err(c.received - 1, "CONFLICT", dup.getMessage(), "");
              c.err(c.received - 1, "CONFLICT", retryDup.getMessage(), "");
              c.err(c.received - 1, "DB_ERROR", retryEx.getMessage(), "");
          case CONFLICT_ERROR -> c.err(c.received - 1, "CONFLICT", dup.getMessage(), "");
        c.err(c.received - 1, "DB_ERROR", e.getMessage(), "");

Repro

The scan's own logic (statementsMatching + MESSAGE_OF_A_THROWABLE, copied verbatim) run against the file as it stood before the fix - i.e. asking "would this guard have failed the build on the defect it was written for?":

$ git show 417314c18d:grpcw/src/main/java/com/arcadedb/server/grpc/ArcadeDbGrpcService.java > Old.java
$ java -cp . ScanEmu Old.java
statements scanned = 13
offenders found    = 2
   perChunk.errors.add(InsertError.newBuilder().setRowIndex(-1).setCode( "DB_ERROR") .setMessage(String.valueOf(e.getMessage())).build())
   c.err(c.received - 1, "DB_ERROR", e.getMessage(), "")

Two offenders, from six raw-message sites. The four it walks past are the dup / retryDup / retryEx ones - and those are the DuplicatedKeyException ones, the leak the review actually reported.

Suggested fix

Ask the question by SHAPE rather than by name. Either match any receiver followed by .getMessage() and subtract the known-safe receivers (request, req, the protobuf getters), or - better, and what the production side already did - match on what a SAFE site looks like: an InsertError message that is not insertErrorMessage( (and a catch-all description that is not concealable(). That inverts the rule from "spot every unsafe spelling", which an allow-list of names can never do, into "spot anything that is not the one safe call", which is exact.
While there, make everyScanFindsTheConstructsItJudges assert that the JUDGEMENT still fires: keep a fixture string carrying one known-bad statement per scan and assert each scan flags it, so a regex that stops recognising anything fails loudly instead of passing quietly.

Scope / confidence

Tried to refute it three ways. (1) Maybe the four sites match after all: run above, case-sensitively, \b(e|ex|t|cause|error|throwable)\.getMessage\(\) requires the receiver token to BE one of the six - dup, retryDup, retryEx end in p/p/x with no word boundary before a matching alternative, and retryEx's Ex is capitalised besides. (2) Maybe another scan covers them: the mapper-call scan looks for GrpcErrorMapper. calls and these are none; the direct-status scan uses the same regex; the conceal-must-log scan keys off CONCEALED_DESCRIPTION, which a site that never conceals does not mention. (3) Maybe it does not matter because the current sites are all fixed: it matters precisely because they are - the guard's stated job is the NEXT site, and the next one is as likely as not to be written catch (ValidationException ve). Severity is low because nothing is broken today; what is broken is the assurance that it stays that way.

Activity

  1. added
    grpc
    on Sep 18, 2026
  2. added this to the 26.10.1 milestone on Sep 18, 2026
  3. added
    in progress
    on Sep 19, 2026
  4. self-assigned this
    on Sep 19, 2026
  5. added 2 commits that reference this issue on Sep 19, 2026
  6. lvca commented on Sep 19, 2026

    @lvca
    Member

    Fixed in 26.10.1 (#7942).

    This is a hardening change with no user-visible effect. The build-time check that stops a raw exception message reaching a gRPC client only recognised a handful of variable names, so it would have missed most of the cases it exists to catch. It now checks the shape of the call instead of the variable name, and a second test verifies the check itself still works - so the guard cannot quietly stop protecting anything.

    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  7. removed
    in progress
    on Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

buggrpcsecurity

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions