Skip to content
Path traversal Write-up Intermediate

CVE-2021-43557: Apache APISIX: Path traversal in requesturi variable

The uri-blocker plugin in Apache APISIX used the unnormalised request_uri variable to decide whether to block a request, so a path containing dot-segments or encoded slashes could reach a protected route. An attacker could bypass access-control rules and access routes that should have been blocked.

xvnpw.github.io

Published on xvnpw.github.io

In this article I will present my research on insecure usage of $requesturi variable in Apache APISIX ingress controller. My work end up in submit of security vulnerability, which was positively confirmed and got CVE-2021-43557.

The author, 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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The uri-blocker plugin made its blocking decision using the raw, unnormalised request_uri variable instead of a normalised path.

Impact

An attacker could bypass access-control restrictions and reach routes that should have been blocked; the author also suspects other plugins using the same variable may be affected.

What the attacker needed

APISIX gateway with a plugin using request_uri; A route protected by such a plugin; Ability to send crafted paths

The fix

Plugins should normalise the path before using the request_uri variable, or use a normalised variable instead.

How it was found

  1. Deploy APISIX in Kubernetes with an ingress route that blocks a protected path and rewrites a public path.
  2. Confirm the public path is reachable and the protected path returns 403.
  3. Send a request to the public path containing a dot-segment that climbs to the protected path.
  4. Observe that the protected data is returned, bypassing the block rule.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A gateway sits in front of web services and can block certain paths. It checked the raw path exactly as typed, including tricks like '..' that mean 'go up one folder'. Because it did not clean up the path first, a request that looked like it was for a public path could actually reach a protected one.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.