Read the docs

Unauthenticated remote crash (null pointer dereference) in the OAuth2 HTTP filter via a path-less CONNECT request

Priority MEDIUM 48CWE-476Published · Updated

Key facts

Attack vector
Network
Privileges required
None
User interaction
None
Attack complexity
Low
Impact type
Denial of service
Confidentiality · integrity · availability
None · None · High
Fix status
Fixed

Attack profile from CVSS 3.1 · GHSA-8vc2-jrm4-835w. Fix status from GitHub. Impact type from CWE-476.

Summary

## Brief description The OAuth2 HTTP filter (`envoy.filters.http.oauth2`) dereferences the `:path` pseudo-header without a null check, guarded only by an `ASSERT` that is compiled out of release builds. A classic HTTP `CONNECT` request legitimately carries no `:path`, and Envoy explicitly permits that. Any unauthenticated client that can reach a listener whose HTTP filter chain contains the OAuth2 filter can therefore crash the Envoy process with a single request. ## Affected component(s) - `envoy.filters.http.oauth2` — `security_posture: robust_to_untrusted_downstream`, `status: stable`. - Primary sink: `source/extensions/filters/http/oauth2/filter.cc:950-952` (`OAuth2Filter::decodeHeaders`). - Second instance of the same defect, reachable on the redirect-to-authorization-server path once the first is fixed: `source/extensions/filters/http/oauth2/filter.cc:1275` (`OAuth2Filter::redirectToOAuthServer`). ## Attack vector(s) A remote, unauthenticated client sends an HTTP `CONNECT` request in authority-form (or the HTTP/2 equivalent) to any listener running the OAuth2 filter. The worker process segfaults while processing the request headers. Because Envoy runs all workers in a single process, the entire proxy instance dies and all in-flight connections are dropped. The request can be replayed after every restart, so an attacker with a trivial loop can keep an edge Envoy permanently unavailable. The most exposed deployment is exactly the one the filter is built for: an edge or ingress Envoy fronting an OAuth2-protected application, reachable from the public internet. ## Discoverer(s)/Credits [threatroute66](https://github.com/threatroute66) (original reporter) [Michael-JRead](https://github.com/Michael-JRead) [kalt2212](https://github.com/kalt2212) ## Example exploit or proof-of-concept Minimal reproducing configuration — a stock OAuth2 setup with an ordinary prefix route: ```yaml static_resources: listeners: - name: listener_0 address: { socket_address: { address: 0.0.0.0, port_value: 10000 } } filter_chains: - filters: - name: envoy.filters.network.http_connection_manager typed_config: "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager stat_prefix: ingress_http route_config: virtual_hosts: - name: local domains: ["*"] routes: - match: { prefix: "/" } # ordinary route; no connect_matcher route: { cluster: service } http_filters: - name: envoy.filters.http.oauth2 typed_config: "@type": type.googleapis.com/envoy.extensions.filters.http.oauth2.v3.OAuth2 config: token_endpoint: cluster: oauth uri: https://example.com/token timeout: 3s authorization_endpoint: https://example.com/authorize redirect_uri: "https://%REQ(:authority)%/callback" redirect_path_matcher: { path: { exact: "/callback" } } signout_path: { path: { exact: "/signout" } } credentials: client_id: foo token_secret: { name: token } hmac_secret: { name: hmac } - name: envoy.filters.http.router typed_config: "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router ``` Trigger, HTTP/1.1: ``` printf 'CONNECT anything:443 HTTP/1.1\r\nHost: anything:443\r\n\r\n' | nc <envoy-host> 10000 ``` Trigger, HTTP/2 — a `HEADERS` frame with `:method: CONNECT` and `:authority: anything:443`, and **no** `:path`, `:scheme` or `:protocol` pseudo-headers. Observed result: the connection closes with no response and the Envoy process terminates with SIGSEGV. In a debug build the same request aborts at `ASSERT(path_header != nullptr)`, `source/extensions/filters/http/oauth2/filter.cc:951`, which confirms the same code path. Note there is deliberately **no** `upgrade_configs` and **no** `connect_matcher` in the config above — that is the default, and it is the vulnerable case. See "Details". ## Details ### The defect `source/extensions/filters/http/oauth2/filter.cc:950-952`: ```cpp const Http::HeaderEntry* path_header = headers.Path(); ASSERT(path_header != nullptr); const absl::string_view path_str = path_header->value().getStringView(); // null dereference ``` `ASSERT` expands to `_NULL_ASSERT_IMPL` when `NDEBUG` is defined and neither `ENVOY_LOG_DEBUG_ASSERT_IN_RELEASE` nor `ENVOY_LOG_FAST_DEBUG_ASSERT_IN_RELEASE` is set (`source/common/common/assert.h:260`). In shipped release binaries line 951 is a no-op and line 952 dereferences `nullptr`. ### Why `:path` can be absent A classic `CONNECT` request has no `:path`, and Envoy is explicit about permitting it. `HeaderUtility::checkRequiredRequestHeaders` (`source/common/http/header_utility.cc:497`) requires `:path` only in the non-CONNECT branch; for CONNECT it requires only `Host`, and separately rejects the mismatched combinations of `:path` and `:protocol` that would indicate a malformed extended CONNECT. The HTTP/1 server codec never sets `:path` for a CONNECT: `ServerConnectionImpl::handlePath` parses the authority-form target through `Utility::Url::initialize(..., is_connect=true)`, which yields an empty `pathAndQueryParams()`, and the assignment is guarded (`source/common/http/http1/codec_impl.cc:1177`): ```cpp if (!absolute_url.pathAndQueryParams().empty()) { headers.setPath(absolute_url.pathAndQueryParams()); } ``` The rest of core Envoy handles this correctly and defensively — `ConnectionManagerUtility::maybeNormalizePath` returns early on `!request_headers.Path()` (`conn_manager_utility.cc:785`), and the connection manager's `MissingPath` rejection is explicitly skipped for CONNECT (`conn_manager_impl.cc:1474`): ```cpp if ((!HeaderUtility::isConnect(*request_headers_) || request_headers_->Path()) && request_headers_->getPathValue().empty()) { sendLocalReply(Code::NotFound, "", ..., ResponseCodeDetails::get().MissingPath); return; } ``` ### Why the "route rejects CONNECT" path does not mitigate this The natural assumption is that a route table without `upgrade_configs` for CONNECT rejects the request before the filter chain runs. It does not, in the common case. The upgrade rejection at `conn_manager_impl.cc:1583-1592` is nested inside `if (hasCachedRoute())`: ```cpp if (hasCachedRoute()) { if (create_chain_result.upgradeRejected()) { ... sendLocalReply(Code::Forbidden, "", ..., ResponseCodeDetails::get().UpgradeFailed); return; } } ``` and `hasCachedRoute()` is `cached_route_.has_value() && cached_route_.value()` (`conn_manager_impl.h:423`) — false when no route matched. For a path-less request, no route matches unless the operator configured one specifically for CONNECT. `RouteMatcher::route` skips every candidate whose `supportsPathlessHeaders()` returns false (`source/common/router/config_impl.cc:1824`): ```cpp if (!route_match_context.headers().Path() && !(*route)->supportsPathlessHeaders()) { ``` and only `ConnectRouteEntryImpl` — a route built from a `connect_matcher` — overrides that to `true` (`source/common/router/config_impl.h:1181`). Prefix, path and safe_regex routes all return the base-class `false`. So under any ordinary route table: no route matches → `hasCachedRoute()` is false → the 403 branch is skipped → execution falls through to `filter_manager_.decodeHeaders()` at `conn_manager_impl.cc:1604` → the OAuth2 filter runs → crash. The only configuration that is *not* vulnerable is one where a `connect_matcher` route both matches the request and rejects CONNECT upgrades. If a `connect_matcher` route matches and *permits* CONNECT, the filter chain runs and the crash still occurs. ### Why no earlier code in the filter short-circuits Between `OAuth2Filter::decodeHeaders` entry (line 895) and the dereference (line 952): - lines 898-899 remove the `x-oauth-status` / failure-reason headers; - line 906 returns `Continue` only if no config resolved; - line 920 returns `Continue` only if a `pass_through_matcher` matches — none is configured by default; - line 925 sends a local reply only if secrets are not yet loaded; - line 934 `decryptAndUpdateOAuthTokenCookies` reads and rewrites only the `Cookie` header; - line 941 removes the `Authorization` header; - line 948 dereferences `headers.Host()`, which is safe because `Host` *is* required for CONNECT. None of these depends on or guards `:path`. ### Precedent in the codebase This class of bug is already recognised and fixed elsewhere, including in this same file: - `source/extensions/filters/http/oauth2/filter.cc:1798` — `OAuth2Filter::shouldAllowFailed` uses exactly the correct idiom: `const Http::HeaderEntry* path_header = headers.Path(); if (path_header != nullptr) { ... }` - `source/extensions/filters/http/jwt_authn/matcher.cc:125` — `if (headers.Path() == nullptr) { return false; }` - `source/extensions/filters/http/header_mutation/header_mutation.cc:117` — `if (query_query_parameter_mutations_.empty() || headers.Path() == nullptr) { return; }` - `source/common/router/router.cc:2210` — `if (!downstream_headers.Path()) { ... return false; }` - `source/extensions/filters/common/rbac/matchers.cc:391` — `if (headers.Path() == nullptr) { return false; }` `decodeHeaders` was simply not updated to match. ### Test coverage `test/extensions/filters/http/oauth2/` contains no test that exercises a CONNECT request. This is why six years of test runs did not surface it. ## Mitigations **Preferred: reject CONNECT before the OAuth2 filter.** Insert an RBAC filter *ahead of* `envoy.filters.http.oauth2` in `http_filters` that denies `:method: CONNECT`: ```yaml - 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 RBAC header matcher reads `:method`, which is always present, and RBAC's own path matcher explicitly handles a null `:path` (`source/extensions/filters/common/rbac/matchers.cc:391`). **Alternative:** if the deployment genuinely needs neither CONNECT nor the OAuth2 filter on the same listener, separate them onto different listeners. **Not a mitigation:** omitting `upgrade_configs`/CONNECT support from the route table. As shown above, that is the vulnerable configuration, not a safe one. **Build-level:** compiling with `ENVOY_LOG_DEBUG_ASSERT_IN_RELEASE` converts the crash from a segfault into a controlled abort with a log line. It does not keep the process alive and is not a mitigation for availability. ## Detection Because the process dies while handling the request, the offending request generally does not reach the access log. Look for: 1. **Fatal-error backtrace.** Envoy's fatal signal handler dumps a stack trace on SIGSEGV. An affected crash shows frames through `Envoy::Extensions::HttpFilters::Oauth2::OAuth2Filter::decodeHeaders` and `Envoy::Http::FilterManager::decodeHeaders`. 2. **Unexplained process restarts** on listeners running the OAuth2 filter, particularly repeated restarts at a steady interval, which indicates an attacker replaying the request. 3. **Upstream of the proxy**, if a load balancer or CDN logs requests Envoy never answered: `CONNECT` requests in authority-form with no path, immediately followed by a connection reset. 4. **Pre-emptively**, on unaffected or patched versions: an access log format including `%REQ(:METHOD)%` and `%REQ(:PATH)%` will show `CONNECT` with an empty path reaching listeners that run the OAuth2 filter. Any such entry indicates a request that would crash a vulnerable build. ## Fix The filter now rejects requests without a :path header with a 400 Bad Request local reply (response code detail `oauth_missing_path`) rather than dereferencing the missing header. ## References * Introducing commit: `c6bfd7f9f5` — "Add OAuth filter (#11268)", 2020-08-20 * Direct precedent for this defect class: CVE-2021-43824 (`jwt_authn` safe_regex null dereference), whose fix is the guard at `source/extensions/filters/http/jwt_authn/matcher.cc:125` * Threat model: https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/security/threat_model

Why it matters now

Fix Fixed Envoy (envoy proxy): 1.36.12 1.37.8 1.38.6 1.39.3

SSVC decision points

Not available: CISA has not published SSVC decision points for this record.

Affected products

VendorProductAffected versionsFixed inStatusSource
—Envoy (envoy proxy)>= 1.16.0, <1.40.01.36.12 1.37.8 1.38.6 1.39.3Patch availableGHSA-8vc2-jrm4-835w
  • Envoy (envoy proxy) Vendor— Affected >= 1.16.0, <1.40.0 Fixed in 1.36.12 1.37.8 1.38.6 1.39.3 Patch available GHSA-8vc2-jrm4-835w

Remediation

  • Fix · GHSA-8vc2-jrm4-835w Envoy (envoy proxy) Fixed in 1.36.12 1.37.8 1.38.6 1.39.3 Advisory →

Timeline

  1. 2026-11-12 Threatist record created from GHSA-8vc2-jrm4-835w

References

Sources

This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences