CVE-2026-41246: Contour: Lua code injection via Cookie Path Rewrite Policy
Impact
Contour's Cookie Rewriting feature is vulnerable to Lua code injection. An attacker with RBAC permissions to create or modify HTTPProxy resources can craft a malicious value in the following fields that results in arbitrary code execution in the Envoy proxy:
- spec.routes[].cookieRewritePolicies[].pathRewrite.value - spec.routes[].services[].cookieRewritePolicies[].pathRewrite.value
The cookie rewriting feature is internally implemented using Envoy's HTTP Lua filter. User-controlled values are interpolated into Lua source code using Go text/template without sufficient sanitization.
The injected code only executes when processing traffic on the attacker's own route, which they already control. However, since Envoy runs as shared infrastructure, the injected code can also:
- Read Envoy's xDS client credentials from the filesystem, which could be used to read all Contour xDS configuration, including TLS certificates and private keys of other tenants. - Cause denial of service for other tenants sharing the Envoy instance.
Other use cases of Lua filter are not vulnerable.
Patches
The fix is available in Contour v1.33.4, v1.32.5, and v1.31.6.
- v1.33.4: User-provided values are no longer interpolated into Lua code. Use of text/template is removed. Requires Envoy 1.35.0 or later. - v1.32.5, v1.31.6: User-provided values are escaped before interpolation into Lua code.
Workarounds
There are no workarounds. Users should upgrade to a patched version.
Other sources
Contour is a Kubernetes ingress controller using Envoy proxy. From v1.19.0 to before v1.33.4, v1.32.5, and v1.31.6, Contour's Cookie Rewriting feature is vulnerable to Lua code injection. An attacker with RBAC permissions to create or modify HTTPProxy resources can craft a malicious value in spec.routes[].cookieRewritePolicies[].pathRewrite.value or spec.routes[].services[].cookieRewritePolicies[].pathRewrite.value that results in arbitrary code execution in the Envoy proxy. The cookie rewriting feature is internally implemented using Envoy's HTTP Lua filter. User-controlled values are interpolated into Lua source code using Go text/template without sufficient sanitization. The injected code only executes when processing traffic on the attacker's own route, which they already control. However, since Envoy runs as shared infrastructure, the injected code can also read Envoy's xDS client credentials from the filesystem or cause denial of service for other tenants sharing the Envoy instance. This vulnerability is fixed in v1.33.4, v1.32.5, and v1.31.6.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
go/github.com/projectcontour/contourto a version that resolves this vulnerability.Fixed in 1.33.4 - Upgrade
Upgrade
go/github.com/projectcontour/contourto a version that resolves this vulnerability.Fixed in 1.32.5 - Upgrade
Upgrade
go/github.com/projectcontour/contourto a version that resolves this vulnerability.Fixed in 1.31.6 - Upgrade
Upgrade
Contour (HTTPProxy / Cookie Rewriting via Envoy HTTP Lua filter)to a version that resolves this vulnerability.Fixed in v1.33.4 - Upgrade
Upgrade
Contour (HTTPProxy / Cookie Rewriting via Envoy HTTP Lua filter)to a version that resolves this vulnerability.Fixed in v1.32.5 - Upgrade
Upgrade
Contour (HTTPProxy / Cookie Rewriting via Envoy HTTP Lua filter)to a version that resolves this vulnerability.Fixed in v1.31.6
Event History
Frequently Asked Questions
What is the severity of CVE-2026-41246?
CVE-2026-41246 has a critical severity due to its potential for remote code execution.
How do I fix CVE-2026-41246?
To fix CVE-2026-41246, upgrade to Contour versions v1.33.4 or later, v1.32.6, or v1.31.7.
What specific versions are affected by CVE-2026-41246?
CVE-2026-41246 affects Contour versions from v1.19.0 to before v1.33.4, including v1.32.5 and v1.31.6.
Can an attacker exploit CVE-2026-41246 without special permissions?
No, an attacker must have RBAC permissions to create or modify Cookie Path Rewrite Policies to exploit CVE-2026-41246.
What type of vulnerability is CVE-2026-41246?
CVE-2026-41246 is a Lua code injection vulnerability in the Cookie Rewriting feature of Contour.