Skip to content

Enable AES-256-GCM OAuth2 cookie encryption by default in the proxy bootstrap #9830

Closed

Description

@zhaohuabing

Problem

Envoy Gateway's OIDC support (SecurityPolicy.spec.oidc) is implemented with Envoy's envoy.filters.http.oauth2 filter (internal/xds/translator/oidc.go). That filter was affected by CVE-2026-47775 — a padding oracle in the AES-256-CBC session-cookie decryption path.

Envoy's fix (1.35.13 / 1.36.9 / 1.37.5 / 1.38.3 / 1.39.0) adds AES-256-GCM encryption with a gcm. algorithm marker, but it is opt-in. On upgrade the default behaviour is unchanged and the vulnerable CBC decrypt path stays reachable. Two runtime guards control the migration:

flag Envoy default effect at default
envoy.reloadable_features.oauth2_use_gcm_encryption false still issues unmarked AES-256-CBC cookies
envoy.reloadable_features.oauth2_legacy_cbc_decrypt_compat true legacy CBC decrypt path still reachable

Envoy Gateway sets neither. internal/xds/bootstrap/bootstrap.yaml.tpl currently has:

layered_runtime:
  layers:
  - name: global_config
    static_layer:
      re2.max_program_size.error_level: 4294967295
      re2.max_program_size.warn_level: 1000

So every Envoy Gateway user with OIDC enabled still has the vulnerable path reachable, even after upgrading to a patched Envoy image, and there is currently no Envoy Gateway API surface to change that (these are runtime guards, not filter config, so SecurityPolicy isn't the right place for them either).

Worth noting: setting only oauth2_use_gcm_encryption=true does not close the CVE. decrypt() still falls back to the CBC path for any cookie lacking the gcm. marker, so an attacker just submits an unmarked cookie. oauth2_legacy_cbc_decrypt_compat=false is the flag that actually removes the oracle.

Proposal

Set both flags in the global_config static layer:

layered_runtime:
  layers:
  - name: global_config
    static_layer:
      envoy.reloadable_features.oauth2_use_gcm_encryption: true
      envoy.reloadable_features.oauth2_legacy_cbc_decrypt_compat: false
      re2.max_program_size.error_level: 4294967295
      re2.max_program_size.warn_level: 1000

Rollout impact

During the proxy rolling update that picks this up, the fleet is transiently mixed: pods still on the old config issue unmarked CBC cookies, while pods on the new config reject them. GCM decryption is unconditional in every patched Envoy (only the CBC fallback is flag-gated), so the skew is one-directional — new-config pods and old-config pods both read GCM cookies, and only CBC cookies are affected. The effects are bounded and self-healing:

  • A login flow started on an old-config pod whose callback lands on a new-config pod fails with a 401, because decrypt() rejects the unmarked code_verifier cookie. The 401 path clears the csrf and code_verifier cookies, so the user retries and succeeds once the rollout completes.
  • Users holding a CBC session cookie are redirected to re-authenticate, and may be redirected more than once if the re-auth is served by an old-config pod. This is the same one-time re-login that oauth2_legacy_cbc_decrypt_compat: false costs in steady state.

Once every pod is on the new config, all issued cookies are GCM and behaviour is consistent. Given that the rollout window is short and the failure mode is a retryable 401 rather than anything persistent, landing both flags in a single change looks like the right trade-off against leaving the padding oracle reachable by default. Operators who want to avoid even that window can stage it themselves via the EnvoyProxy override below: set oauth2_use_gcm_encryption: true first, let it fully roll out, then set oauth2_legacy_cbc_decrypt_compat: false.

Envoy exposes a new counter oauth_legacy_cbc_decrypt, incremented on each successful legacy CBC decrypt, which operators can use to confirm the change took effect and to spot any proxy that missed it.

Versions

Both flags exist in Envoy >= 1.38.3 and >= 1.39.0. No image bump is needed: DefaultEnvoyProxyImage is already distroless-v1.38.3 on release/v1.8 (v1.8.2 and v1.8.3) and distroless-v1.39.0 on release/v1.9. So this can land on main and be cherry-picked to v1.8.4 and v1.9.1 as-is.

Workaround for users today

apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyProxy
metadata:
  name: custom-proxy-config
  namespace: envoy-gateway-system
spec:
  bootstrap:
    type: JSONPatch
    jsonPatches:
      - op: add
        path: /layered_runtime/layers/-
        value:
          name: oauth2_cve_2026_47775
          static_layer:
            envoy.reloadable_features.oauth2_use_gcm_encryption: true
            envoy.reloadable_features.oauth2_legacy_cbc_decrypt_compat: false

Happy to send a PR if this approach looks right.

Activity

  1. changed the title [-]Enable AES-256-GCM OAuth2 cookie encryption by default in the proxy bootstrap (CVE-2026-47775)[/-] [+]Enable AES-256-GCM OAuth2 cookie encryption by default in the proxy bootstrap[/+] on Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions