Skip to content

Crash in api_key_auth HTTP filter when hiding credentials on requests without a :path header (CONNECT)

Moderate
phlax published GHSA-47vj-9r25-wv5j Oct 6, 2026

Package

Envoy (Envoy Proxy)

Affected versions

>= 1.33.0

Patched versions

1.36.12 1.37.8 1.38.6 1.39.3

Description

Brief description

The api_key_auth HTTP filter (envoy.filters.http.api_key_auth) dereferences the :path pseudo-header without a null check when stripping a query key source from the request. A classic HTTP CONNECT request legitimately carries no :path, and Envoy explicitly permits that. A client holding a valid API key can crash the Envoy process with a single request when the filter is configured with forwarding.hide_credentials: true and a query key source alongside another key source.

Affected component

  • envoy.filters.http.api_key_auth — security_posture: robust_to_untrusted_downstream, status: alpha.
  • Sink: KeySources::Source::removeKey in source/extensions/filters/http/api_key_auth/api_key_auth.cc, reached from the unconditional loop in KeySources::removeKey.

Attack vector

A client holding a valid API key sends a path-less CONNECT with the key in a header-backed key source, against a filter configured with at least two key sources (one of them query) and forwarding.hide_credentials: true. Authentication succeeds, credential stripping then walks every configured source, and the query source dereferences the absent :path.

Envoy runs all workers in a single process, so the crash drops every connection the instance was serving and can be replayed indefinitely.

Example exploit or proof-of-concept

- name: envoy.filters.http.api_key_auth
  typed_config:
    "@type": type.googleapis.com/envoy.extensions.filters.http.api_key_auth.v3.ApiKeyAuth
    key_sources:
    - header: "x-api-key"
    - query: "api_key"
    forwarding:
      hide_credentials: true
    credentials:
    - key: "supersecret"
      client: "acme"

with an ordinary route table (match: { prefix: "/" }, no connect_matcher). Trigger, with a valid key:

printf 'CONNECT anything:443 HTTP/1.1\r\nHost: anything:443\r\nx-api-key: supersecret\r\n\r\n' \
  | nc <envoy-host> 10000

Result: SIGSEGV in KeySources::Source::removeKey.

Details

Why :path can be absent

HeaderUtility::checkRequiredRequestHeaders requires :path only in the non-CONNECT branch; for CONNECT it requires only Host. The HTTP/1 server codec does not set :path for an authority-form CONNECT target, and an HTTP/2 CONNECT with :authority and no :path/:scheme/:protocol reaches the same state.

Why the filter chain runs at all

The connection manager's "route does not permit upgrades" 403 is only evaluated when a route has matched. For a path-less request no route matches unless a connect_matcher route is configured, because RouteMatcher::route skips every candidate whose supportsPathlessHeaders() is false and only ConnectRouteEntryImpl overrides that to true. So under any ordinary prefix/path/safe_regex route table the request falls through directly to the filter chain. Omitting CONNECT support from the route table is the vulnerable configuration, not a mitigation.

The defect

KeySources::removeKey iterates every configured source, regardless of which one actually produced the validated key:

void KeySources::removeKey(Http::RequestHeaderMap& headers) const {
  for (const auto& source : key_sources_) {
    source.removeKey(headers);
  }
}

and the query branch of KeySources::Source::removeKey ends with:

headers.setPath(params.replaceQueryString(headers.Path()->value()));   // null deref

The lookup path is already null-safe — KeySources::Source::getKey reads the path through headers.getPathValue(), which returns an empty view when :path is absent. Only the removal path dereferences the pointer. That asymmetry is why the bug survives normal testing: the query source correctly finds nothing, a header source supplies the key, authentication succeeds, and the crash happens afterwards during credential stripping.

Fix

The query branch of KeySources::Source::removeKey now returns early when :path is absent, so credential stripping skips query-string rewriting for path-less requests. A regression test covering a path-less CONNECT has been added.

Affected versions

All versions since the filter was introduced in 1.33.0.

Fixed versions

1.36.12, 1.37.8, 1.38.6, 1.39.3

Mitigations

Insert an RBAC filter before api_key_auth in http_filters, denying :method: CONNECT:

- name: envoy.filters.http.rbac
  typed_config:
    "@type": type.googleapis.com/envoy.extensions.filters.http.rbac.v3.RBAC
    rules:
      action: DENY
      policies:
        deny-connect:
          permissions:
          - header: { name: ":method", string_match: { exact: "CONNECT" } }
          principals:
          - any: true

This is safe on path-less requests: the header matcher reads :method, which is always present, and RBAC's own path matcher explicitly handles a null :path.

Alternatively, either drop the query key source or set forwarding.hide_credentials: false. Either alone prevents the sink from being reached.

Not a mitigation: omitting CONNECT from upgrade_configs. As shown above, that is the vulnerable configuration.

Detection

The process dies while handling the request, so the offending request generally does not reach the access log. Look for:

  1. Fatal-error backtrace with frames through Envoy::Extensions::HttpFilters::ApiKeyAuth::KeySources::Source::removeKey.
  2. Repeated process restarts on listeners running the filter, especially at a steady interval, indicating a replayed request.
  3. Upstream of the proxy, in CDN or load-balancer logs: authority-form CONNECT requests with no path, immediately followed by a connection reset.
  4. On patched builds, an access log format including %REQ(:METHOD)% and %REQ(:PATH)% will show CONNECT with an empty path reaching these listeners — each such entry would have crashed a vulnerable build.

Credits

threatroute66

References

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

CVE ID

No known CVE

Weaknesses

NULL Pointer Dereference

The product dereferences a pointer that it expects to be valid but is NULL. Learn more on MITRE.

Credits