Skip to content
Access control Write-up Intermediate

External Authentication bypass in ingress-nginx

The ingress-nginx controller passes the unnormalised request URI to an external authentication service in headers such as X-Original-Url and X-Auth-Request-Redirect. An attacker can use path traversal in the URI so that the auth service sees a public path and allows the request, while the backend receives the protected path.

Niemiec Marcin Follow

Published on xvnpw.github.io

Bounty$500 View original

In October 2021 I was researched ingress-nginx for possibility to bypass external authentication using path traversal. It was origin story for other investigations regarding insecure usage of $requesturi which leaded to Apache APISIX CVE-2021-43557.

Niemiec Marcin (@xvnpw), on xvnpw.github.io

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 7 min read.

Context

In October 2021 I looked at ingress-nginx, the NGINX-based ingress controller for Kubernetes, to see whether its external authentication feature could be bypassed with path traversal. That work became the starting point for a wider investigation into insecure use of the $request_uri variable, which later led to Apache APISIX CVE-2021-43557.

The feature under test is the controller's external auth integration: the ingress is annotated with nginx.ingress.kubernetes.io/auth-url, and before a request reaches the backend, the controller sends a subrequest to that URL. The auth service decides whether to allow the request, and the controller forwards several headers describing the original request to it, including X-Original-Url and X-Auth-Request-Redirect. If the auth service makes its decision from those headers, the decision is only as trustworthy as the values in them.

I filed this on HackerOne against the Kubernetes project (report 1357948). The team took a long time to investigate and paid a bounty, and closed the report as informative. They asked me to open a normal GitHub issue instead (kubernetes/ingress-nginx#8644), because they consider the behaviour not a security issue. I still consider it an issue of insecure design.

Setup

The test environment is a Kubernetes cluster with ingress-nginx installed via Helm, plus a small test application deployed from a manifest. The steps below are the ones in the write-up.

Install ingress-nginx into Kubernetes

Bash
helm upgrade --install ingress-nginx ingress-nginx \
  --repo https://kubernetes.github.io/ingress-nginx \
  --namespace ingress-nginx --create-namespace

Deploy the test application

Bash
kubectl apply -f \
  https://raw.githubusercontent.com/xvnpw/k8s-ingress-auth-bypass/master/app.yaml

Optionally forward the ingress port

Bash
kubectl port-forward service/ingress-nginx-controller \
  -n ingress-nginx 8080:80

Verify the services

The public service should be reachable without authentication:

Bash
$ curl http://[redacted]:8080/public-service/public -H "Host: app.test"
{"data":"public data"}

The protected service requires an API key:

Bash
$ curl http://[redacted]:8080/protected-service/protected  -H "Host: app.test"
<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx</center>
</body>
</html>

$ curl http://[redacted]:8080/protected-service/protected \
  -H "X-Api-Key: secret-api-key" -H "Host: app.test"
{"data":"protected data"}

So the protected resource is only returned when the request carries the X-Api-Key: secret-api-key header.

Finding it

The question that started this was simple: what exactly does the controller send to the external auth service, and can those values be made to say something different from what the backend will actually serve? The headers of interest are X-Original-Url and X-Auth-Request-Redirect. Here is what the auth service receives for a request that uses an encoded traversal segment:

FALLBACK
X-Request-Id: [redacted]
Host: auth-service.default.svc.[redacted]
X-Original-Url: http://app.test/public-service/..%2Fprotected-service/protected
X-Original-Method: GET
X-Sent-From: nginx-ingress-controller
X-Real-Ip: [redacted]
X-Forwarded-For: [redacted]
X-Auth-Request-Redirect: /public-service/..%2Fprotected-service/protected
Connection: close
User-Agent: curl/7.75.0
Accept: */*

Both X-Original-Url and X-Auth-Request-Redirect still carry the ..%2F sequence. The path the auth service is asked to judge is not normalised, so a service that checks a prefix such as /public-service/ sees a public path, while the backend may resolve the same request to a different service.

The root cause is how NGINX handles the $request_uri variable. Its documentation is, in my words, very frugal:

That is not enough. The risks of consuming non-normalised paths should be documented. When I raised this with the NGINX team, the response was that it is obvious $request_uri is not normalised and that developers should take care of their own projects. That would be a perfect world, but we do not live in one. For comparison, the Envoy documentation covers this area explicitly, for example with material on rejecting client requests with escaped slashes, the advisory GHSA-xcx5-93pw-jw2w (CVE-2019-9901) describing the risks of normalising paths, and the HTTP connection manager options normalize_path and path_with_escaped_slashes_action.

Exploitation

Step 1: send a traversal request to the public path

The request goes to the public service path but contains ../ to climb out of it, with --path-as-is so curl does not normalise the path before sending:

Bash
$ curl \
  --path-as-is http://[redacted]:8080/public-service/../protected-service/protected
  -H "Host: app.test"
{"data":"protected data"}

The response is the protected data, without any X-Api-Key header. The URI restriction was bypassed.

Step 2: understand why the auth service allowed it

The bypass depends on the auth service. Not all authentication services are vulnerable: only those that make decisions based on the requested path. In this test the service looks like this:

Python
@app.route('/verify')
def verify():
    print(request.headers, file=sys.stderr)
    api_key = request.headers.get('X-Api-Key')
    request_redirect = request.headers.get('X-Auth-Request-Redirect')

    if request_redirect and request_redirect.startswith("/public-service/"):
        return Response(status = HTTPStatus.NO_CONTENT)

    if api_key == "secret-api-key":
        return Response(status = HTTPStatus.NO_CONTENT)

    return Response(status = HTTPStatus.UNAUTHORIZED)

The service returns 204 (allow) if X-Auth-Request-Redirect starts with /public-service/, or if the API key matches. Because the redirect header contains the unnormalised /public-service/..%2Fprotected-service/protected, the prefix check passes and the request is allowed, even though the backend resolves it to the protected service.

The ingress that wires this together is:

YAML
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/auth-url: http://auth-service.default.svc.[redacted]:8080/verify
spec:
  rules:
    - host: app.test
      http:
        paths:
          - path: /public-service/(.*)
            pathType: Prefix
            backend:
              service:
                name: public-service
                port:
                  number: 8080
          - path: /protected-service/(.*)
            pathType: Prefix
            backend:
              service:
                name: protected-service
                port:
                  number: 8080

Both paths use rewrite-target: /$1, and the auth URL is the same for both, so the auth service has to distinguish public from protected requests on its own, using the headers the controller passes.

Root cause

The controller passes the raw, unnormalised request URI to the auth service in X-Original-Url and X-Auth-Request-Redirect, because those values derive from $request_uri, which NGINX does not normalise. The auth service then makes an authorisation decision on a string that does not match the path the backend will actually serve. The design assumes the auth service will normalise or otherwise treat the header safely, and nothing in the controller enforces that. The prefix check in the auth service is a plain string comparison against the unnormalised value.

Impact

An attacker can reach a backend service that is supposed to require authentication, without credentials, whenever the external auth service makes its decision from the path in X-Original-Url or X-Auth-Request-Redirect. The bypass is conditional: auth services that do not base decisions on the requested path are not affected. In this setup the attacker obtained the protected data with a single unauthenticated request.

Fix

One mitigation is simply not to trust the contents of the X-Original-Uri and X-Auth-Request-Redirect headers in the auth service. A better option is to use the $service_name variable, which gives the name of the Kubernetes service targeted by the request, and pass it to the auth URL. That value cannot be manipulated this way. The ingress configuration becomes:

YAML
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/auth-url: http://auth-service.default.svc.[redacted]:8080/verify
    nginx.ingress.kubernetes.io/configuration-snippet: |
      more_set_input_headers "X-Forwarded-Scheme: $scheme";
      more_set_input_headers "X-Forwarded-Uri: $uri";
      more_set_input_headers "X-Forwarded-Prefix: $service_name";
      more_set_input_headers "X-Forwarded-Host: $http_host";

With this, the auth service can decide on the service name rather than on a path string the client controls.

Variants to test

  1. Prefix-based auth checks on other ingress controllers. Send a request to a public path with an encoded traversal segment, for example /public-service/..%2Fprotected-service/protected, using --path-as-is. A positive result is a response containing protected data without credentials, or an auth service log showing the unnormalised path in the header it checks.
  2. Auth services that compare X-Original-Url or X-Auth-Request-Redirect against an allowlist. Look for any string prefix or suffix match on those headers. A positive result is a 204 or other allow response for a path that the backend resolves outside the allowed prefix.
  3. Other controllers that expose $request_uri-derived values to auth. Related articles in the series cover Apache APISIX (CVE-2021-43557), Traefik, HAProxy, Emissary, Kong and F5 NGINX. For each, check whether the value passed to the authorisation component is normalised. A positive result is a mismatch between the path the authoriser sees and the path the backend serves.
  4. Encoded slash variants. Try the ..%2F form in the path segment that the auth service inspects. A positive result is the same allow decision with a different encoding.

The full example code is at https://github.com/xvnpw/k8s-ingress-auth-bypass.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 17 min read.

What happened, in plain words

In October 2021 I spent some time looking at a piece of software called ingress-nginx. It is a component that sits in front of the applications running inside a Kubernetes cluster and decides how incoming web requests are routed to them. I wanted to know whether one of its features, external authentication, could be tricked into letting a request through that should have been stopped. The trick I had in mind is called path traversal, and I will explain it from scratch below.

That investigation turned out to be the starting point for a much wider look at how safely a particular NGINX variable, $request_uri, is used. That wider work later led to a published vulnerability in Apache APISIX, tracked as CVE-2021-43557.

I reported what I found to the Kubernetes project on HackerOne, a platform where security researchers report bugs to companies. The report number was 1357948. The team took a long time to investigate and paid a bounty, and closed the report as informative, which means they did not treat it as a security vulnerability. They asked me to open a normal issue on GitHub instead (kubernetes/ingress-nginx#8644), because in their view the behaviour is not a security issue. I still consider it an issue of insecure design: the software works as written, but the way it is designed makes it easy for people building on top of it to make a mistake with security consequences.

The pieces involved, explained from zero

Before the technical steps, here is what each moving part is, in everyday terms.

  • Kubernetes is a system for running many small programs (called services) on a group of computers and letting them talk to each other. Think of it as a large office building: many departments, each with its own room number, and a reception desk that sends visitors to the right room.
  • ingress-nginx is that reception desk. It is the front door for web traffic coming from outside. It looks at the address a visitor asked for and forwards the request to the right internal service. It is built on NGINX, a very common web server and reverse proxy (a program that sits in front of other programs and passes requests to them).
  • External authentication is a feature where the reception desk, before letting a visitor into a room, first phones a separate security office and asks: is this visitor allowed in? In ingress-nginx you switch this on with a setting called nginx.ingress.kubernetes.io/auth-url, which points at the security office. For every incoming request, the controller sends a subrequest (an internal side request) to that address. The security office answers allow or deny, and the controller acts on that answer.
  • Headers are small labelled pieces of text that travel with every web request, like the fields on the outside of an envelope: who sent it, what they want, what format they accept. When the controller phones the security office, it attaches several headers describing the original visitor's request, including X-Original-Url (the address the visitor asked for) and X-Auth-Request-Redirect (roughly, where the visitor was heading). If the security office bases its decision on those headers, then the decision is only as trustworthy as the values inside them.
  • Path traversal is the trick of putting .. (meaning "go up one folder") inside a web address so that the address looks like it points at one place but actually resolves to another. On a computer, if you are in the folder /home/me/photos and you type ../documents, you end up in /home/me/documents. Web addresses work the same way. A security check that only reads the beginning of the address can be fooled: it sees /public-service/... and thinks "public", while the server, which resolves the .., ends up serving something else.
  • Normalisation means cleaning up an address into its final, unambiguous form before comparing or acting on it. /public-service/../protected-service/protected normalises to /protected-service/protected. If one part of the system normalises and another does not, they can disagree about which place the same request refers to. That disagreement is the heart of this whole story.
  • URL encoding is a way of writing characters that would otherwise be awkward in a web address. A slash / can be written as %2F. So ..%2F is the same idea as ../, just written in encoded form. Some software decodes it early, some late, and some not at all, which is exactly where confusion and bugs come from.
  • An API key is a long secret string that a program sends to prove who it is, a bit like a password for software rather than for a person. In this test the protected service expects the key secret-api-key.
  • curl is a command-line tool for sending web requests by hand. It is useful in security testing because it lets you send exactly the request you want, including odd addresses and custom headers, rather than whatever a browser decides to send.
  • Helm is a package manager for Kubernetes: it installs and upgrades bundles of Kubernetes configuration. kubectl is the command-line tool for talking to a Kubernetes cluster.

Setting up the test

The test environment is a Kubernetes cluster with ingress-nginx installed, plus a small test application deployed from a manifest (a file describing what to run). The steps below are the ones from the write-up.

Install ingress-nginx into Kubernetes

Bash
helm upgrade --install ingress-nginx ingress-nginx \
  --repo https://kubernetes.github.io/ingress-nginx \
  --namespace ingress-nginx --create-namespace

Line by line:

  1. helm upgrade --install ingress-nginx ingress-nginx tells Helm to install the package called ingress-nginx under the local name ingress-nginx. The upgrade --install combination means "install it if it is not there, upgrade it if it is", which is a convenient way to make the command safe to run repeatedly.
  2. --repo https://kubernetes.github.io/ingress-nginx says where to download the package from.
  3. --namespace ingress-nginx --create-namespace puts everything into a Kubernetes namespace (a labelled area inside the cluster, like a folder for related resources) called ingress-nginx, and creates that namespace if it does not exist yet.

Deploy the test application

Bash
kubectl apply -f \
  https://raw.githubusercontent.com/xvnpw/k8s-ingress-auth-bypass/master/app.yaml

This tells kubectl to read a file (-f) from the given web address and apply it to the cluster. The file describes the test application: the public service, the protected service, and the authentication service. Applying it creates those pieces inside the cluster.

Optionally forward the ingress port

Bash
kubectl port-forward service/ingress-nginx-controller \
  -n ingress-nginx 8080:80

This creates a temporary tunnel from your own computer into the cluster. It takes port 8080 on your machine and forwards it to port 80 of the ingress-nginx-controller service in the ingress-nginx namespace. The point is convenience: you can then send requests to http://[redacted]:8080 (your own machine) and they arrive at the front door of the cluster, without needing a real public address.

Verify the services

First, the public service. It should be reachable without any authentication:

Bash
$ curl http://[redacted]:8080/public-service/public -H "Host: app.test"
{"data":"public data"}

curl sends a request to the local forwarded port, asking for /public-service/public. The -H "Host: app.test" part adds a Host header saying the visitor is looking for the site app.test. The Host header matters because the ingress rules are written per host name; without it, the controller would not know which set of rules to use. The answer is {"data":"public data"}, which confirms the public service works and needs no credentials.

Now the protected service:

Bash
$ curl http://[redacted]:8080/protected-service/protected  -H "Host: app.test"
<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx</center>
</body>
</html>

$ curl http://[redacted]:8080/protected-service/protected \
  -H "X-Api-Key: secret-api-key" -H "Host: app.test"
{"data":"protected data"}

The first request asks for the protected path with no credentials. The reply is an HTML error page with status 401 Authorization Required, which is the standard web code for "you are not allowed in without identifying yourself". The second request is identical except that it adds -H "X-Api-Key: secret-api-key", an API key header. This time the reply is {"data":"protected data"}. So the protected resource is only returned when the request carries the correct key. That is the behaviour we are about to try to break.

Finding it

The question that started this was simple: what exactly does the controller send to the external auth service, and can those values be made to say something different from what the backend will actually serve? The headers of interest are X-Original-Url and X-Auth-Request-Redirect. Here is what the auth service receives for a request that uses an encoded traversal segment:

FALLBACK
X-Request-Id: [redacted]
Host: auth-service.default.svc.[redacted]
X-Original-Url: http://app.test/public-service/..%2Fprotected-service/protected
X-Original-Method: GET
X-Sent-From: nginx-ingress-controller
X-Real-Ip: [redacted]
X-Forwarded-For: [redacted]
X-Auth-Request-Redirect: /public-service/..%2Fprotected-service/protected
Connection: close
User-Agent: curl/7.75.0
Accept: */*

Reading this block: it is a dump of the headers the security office received. X-Request-Id is a unique label for this one request, useful for finding it in logs. Host shows the request arrived at the auth service's internal address. X-Original-Url is the full address the visitor asked for, and X-Auth-Request-Redirect is the path part of it. Both still contain the ..%2F sequence, meaning the encoded "go up one folder" is passed along untouched. X-Original-Method says it was a GET (a normal read request). X-Sent-From says the request came from the ingress controller. X-Real-Ip and X-Forwarded-For carry the visitor's address as seen by the controller. Connection: close asks for the connection to be closed after the reply. User-Agent and Accept identify the client tool (here curl) and what it accepts back.

The important point: the path the auth service is asked to judge is not normalised. A service that checks a prefix such as /public-service/ sees a public path, while the backend may resolve the same request to a different service. The two parts of the system disagree about where the request is going.

The root cause is how NGINX handles the $request_uri variable, which holds the raw address exactly as the client sent it. Its documentation is, in my words, very frugal:

That is not enough. The risks of consuming non-normalised paths should be documented. When I raised this with the NGINX team, the response was that it is obvious $request_uri is not normalised and that developers should take care of their own projects. That would be a perfect world, but we do not live in one. For comparison, the Envoy documentation covers this area explicitly, for example with material on rejecting client requests with escaped slashes, the advisory GHSA-xcx5-93pw-jw2w (CVE-2019-9901) describing the risks of normalising paths, and the HTTP connection manager options normalize_path and path_with_escaped_slashes_action.

Exploitation

Step 1: send a traversal request to the public path

The request goes to the public service path but contains ../ to climb out of it, with --path-as-is so curl does not normalise the path before sending:

Bash
$ curl \
  --path-as-is http://[redacted]:8080/public-service/../protected-service/protected
  -H "Host: app.test"
{"data":"protected data"}

Line by line:

  1. curl sends the request.
  2. --path-as-is is the crucial flag. Normally curl tidies up the address before sending, turning /public-service/../protected-service/protected into /protected-service/protected. That would defeat the test, because the server would never see the ... With --path-as-is, curl sends the address exactly as typed, traversal and all.
  3. The address starts with /public-service/, so any check that only looks at the beginning sees a public request.
  4. -H "Host: app.test" again selects the right ingress rules.
  5. The reply is {"data":"protected data"}, the protected data, with no X-Api-Key header anywhere. The URI restriction was bypassed.

Step 2: understand why the auth service allowed it

The bypass depends on the auth service. Not all authentication services are vulnerable: only those that make decisions based on the requested path. In this test the service looks like this:

Python
@app.route('/verify')
def verify():
    print(request.headers, file=sys.stderr)
    api_key = request.headers.get('X-Api-Key')
    request_redirect = request.headers.get('X-Auth-Request-Redirect')

    if request_redirect and request_redirect.startswith("/public-service/"):
        return Response(status = HTTPStatus.NO_CONTENT)

    if api_key == "secret-api-key":
        return Response(status = HTTPStatus.NO_CONTENT)

    return Response(status = HTTPStatus.UNAUTHORIZED)

This is a small web application written in Python. Line by line:

  1. @app.route('/verify') says: when someone asks for the address /verify, run the function below. That is the address the ingress controller phones for every request.
  2. def verify(): starts the function.
  3. print(request.headers, file=sys.stderr) writes all the incoming headers to the error log. This is how the header dump shown earlier was captured.
  4. api_key = request.headers.get('X-Api-Key') reads the API key header, if present.
  5. request_redirect = request.headers.get('X-Auth-Request-Redirect') reads the redirect header, if present.
  6. if request_redirect and request_redirect.startswith("/public-service/"): is the flawed check. It asks: does the redirect header exist, and does it begin with the text /public-service/? If yes, the next line returns status 204 No Content, which in this setup means "allowed, go ahead".
  7. if api_key == "secret-api-key": is the legitimate check: if the key matches, also return 204, allowed.
  8. return Response(status = HTTPStatus.UNAUTHORIZED) is the fallback: if neither check passed, return 401, denied.

The flaw is that the prefix check is a plain text comparison against an unnormalised value. The header contains /public-service/..%2Fprotected-service/protected, which does begin with /public-service/, so the check passes and the request is allowed, even though the backend resolves it to the protected service. The security office was shown a public-looking address and believed it.

The ingress that wires this together is:

YAML
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/auth-url: http://auth-service.default.svc.[redacted]:8080/verify
spec:
  rules:
    - host: app.test
      http:
        paths:
          - path: /public-service/(.*)
            pathType: Prefix
            backend:
              service:
                name: public-service
                port:
                  number: 8080
          - path: /protected-service/(.*)
            pathType: Prefix
            backend:
              service:
                name: protected-service
                port:
                  number: 8080

This is a Kubernetes configuration file, written in a format called YAML, which uses indentation to show structure. Reading it:

  1. apiVersion and kind: Ingress say this file describes an ingress, the routing rules for incoming web traffic.
  2. metadata.name: my-ingress is just the name of this set of rules.
  3. Under annotations are extra settings. kubernetes.io/ingress.class: "nginx" says these rules are handled by the NGINX-based controller. nginx.ingress.kubernetes.io/rewrite-target: /$1 says: take the part of the address captured by (.*) in the path rule and rewrite the request to /$1 before passing it to the backend. nginx.ingress.kubernetes.io/auth-url points at the security office: every request must first be checked at http://auth-service.default.svc.[redacted]:8080/verify.
  4. Under spec.rules there is one rule for the host app.test, with two paths. Requests whose address starts with /public-service/ go to the public-service backend on port 8080. Requests whose address starts with /protected-service/ go to the protected-service backend on port 8080.
  5. Both paths use the same rewrite-target and the same auth URL, so the auth service has to distinguish public from protected requests on its own, using the headers the controller passes. That is exactly the weak point.

Root cause

The controller passes the raw, unnormalised request URI to the auth service in X-Original-Url and X-Auth-Request-Redirect, because those values derive from $request_uri, which NGINX does not normalise. The auth service then makes an authorisation decision on a string that does not match the path the backend will actually serve. The design assumes the auth service will normalise or otherwise treat the header safely, and nothing in the controller enforces that. The prefix check in the auth service is a plain string comparison against the unnormalised value.

Impact

An attacker can reach a backend service that is supposed to require authentication, without credentials, whenever the external auth service makes its decision from the path in X-Original-Url or X-Auth-Request-Redirect. The bypass is conditional: auth services that do not base decisions on the requested path are not affected. In this setup the attacker obtained the protected data with a single unauthenticated request.

Fix

One mitigation is simply not to trust the contents of the X-Original-Uri and X-Auth-Request-Redirect headers in the auth service. A better option is to use the $service_name variable, which gives the name of the Kubernetes service targeted by the request, and pass it to the auth URL. That value cannot be manipulated this way. The ingress configuration becomes:

YAML
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/auth-url: http://auth-service.default.svc.[redacted]:8080/verify
    nginx.ingress.kubernetes.io/configuration-snippet: |
      more_set_input_headers "X-Forwarded-Scheme: $scheme";
      more_set_input_headers "X-Forwarded-Uri: $uri";
      more_set_input_headers "X-Forwarded-Prefix: $service_name";
      more_set_input_headers "X-Forwarded-Host: $http_host";

What changed: a new annotation, configuration-snippet, adds a few extra NGINX instructions. more_set_input_headers sets a header on the request before it is forwarded. The four lines add X-Forwarded-Scheme (http or https), X-Forwarded-Uri (the cleaned-up path, from $uri, which unlike $request_uri is normalised), X-Forwarded-Prefix (the name of the Kubernetes service the request is routed to, from $service_name), and X-Forwarded-Host (the host name). With this, the auth service can decide on the service name rather than on a path string the client controls.

Variants to test

  1. Prefix-based auth checks on other ingress controllers. Send a request to a public path with an encoded traversal segment, for example /public-service/..%2Fprotected-service/protected, using --path-as-is. A positive result is a response containing protected data without credentials, or an auth service log showing the unnormalised path in the header it checks.
  2. Auth services that compare X-Original-Url or X-Auth-Request-Redirect against an allowlist. Look for any string prefix or suffix match on those headers. A positive result is a 204 or other allow response for a path that the backend resolves outside the allowed prefix.
  3. Other controllers that expose $request_uri-derived values to auth. Related articles in the series cover Apache APISIX (CVE-2021-43557), Traefik, HAProxy, Emissary, Kong and F5 NGINX. For each, check whether the value passed to the authorisation component is normalised. A positive result is a mismatch between the path the authoriser sees and the path the backend serves.
  4. Encoded slash variants. Try the ..%2F form in the path segment that the auth service inspects. A positive result is the same allow decision with a different encoding.

The full example code is at https://github.com/xvnpw/k8s-ingress-auth-bypass.

Glossary

  • API: a way for one program to talk to another, like a service counter where you ask for something specific and get a specific answer back.
  • API key: a secret string a program sends to prove its identity, similar to a password for software.
  • Auth service: a separate program that decides whether a request is allowed, like a security office at the entrance.
  • Backend: the program that actually serves the content, sitting behind the front door.
  • Bounty: money paid by a company to a researcher who reports a valid security problem.
  • CVE: a public catalogue number given to a known security vulnerability so people can refer to it unambiguously.
  • curl: a command-line tool for sending web requests by hand.
  • Encoded slash: a slash written as %2F in a web address, so it survives transport without being treated as a path separator.
  • Envoy: another front-door proxy program, used as a comparison point for how documentation should warn about path handling.
  • External authentication: a setup where the front door asks a separate service whether each request is allowed.
  • Header: a labelled piece of text travelling with a web request, like a field on an envelope.
  • Helm: a package manager for Kubernetes that installs and upgrades bundles of configuration.
  • HackerOne: a platform where researchers report security bugs to companies.
  • Informative: a report status meaning the company looked at it but did not treat it as a security vulnerability.
  • Ingress: the set of routing rules that decide which internal service receives an incoming request.
  • ingress-nginx: the NGINX-based program that applies ingress rules inside Kubernetes.
  • Insecure design: a weakness built into how a system is designed, rather than a coding mistake in one line.
  • kubectl: the command-line tool for talking to a Kubernetes cluster.
  • Kubernetes: a system for running and connecting many small programs across a group of computers.
  • Manifest: a file describing what should be running in a cluster.
  • Namespace: a labelled area inside a cluster, like a folder for related resources.
  • NGINX: a widely used web server and reverse proxy.
  • Normalisation: cleaning an address into its final, unambiguous form before comparing or acting on it.
  • Path traversal: using .. in an address to climb out of the intended location and reach another one.
  • Prefix check: a security check that only looks at the beginning of a string.
  • Reverse proxy: a program that sits in front of other programs and passes requests to them.
  • Status code: a number in a web reply saying what happened, such as 200 for success, 204 for allowed with no content, 401 for not authorised.
  • Subrequest: an internal side request the front door makes on its own behalf, here to the auth service.
  • URL encoding: writing awkward characters in a web address in a safe form, such as %2F for a slash.
  • YAML: a text format for configuration files that uses indentation to show structure.
  • $request_uri: an NGINX variable holding the raw address exactly as the client sent it, without normalisation.
  • $service_name: an NGINX variable holding the name of the Kubernetes service a request is routed to, which the client cannot control.

More by Niemiec Marcin

View all

3 more disclosed reports, best first.

More from Kubernetes

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.