The vulnerability is a path normalization bypass in Traefik, allowing attackers to use URL-encoded characters in the request path to bypass middleware restrictions. For instance, a request to /admin%2f would not match a rule for /admin/, but the backend service would receive a request for /admin/ after the path is decoded, thus bypassing security middleware for the /admin/ route.
The patch addresses this by introducing a new middleware that rejects requests containing certain encoded characters by default. This middleware is added at the entrypoint level, before the routing logic is executed.
The analysis of the patch reveals the following key changes:
- A new function
denyEncodedCharacters is added in pkg/server/server_entrypoint_tcp.go. This function is a http.Handler middleware that inspects the raw request path for a configurable set of disallowed encoded characters. If a disallowed character is found, it rejects the request with a 400 Bad Request. This function is the core of the fix. Before this patch, no such check was performed.
- The
createHTTPServer function in the same file is modified to include the denyEncodedCharacters middleware in the handler chain for every HTTP entrypoint, ensuring all incoming requests are checked.
- A new configuration struct
EncodedCharacters and a corresponding method Map() are added in pkg/config/static/entrypoints.go. The Map() method builds the set of disallowed characters from the configuration, which is then used by the denyEncodedCharacters middleware.
Based on this, the identified functions are relevant for profiling. server.denyEncodedCharacters.func1 directly processes the malicious request path. server.createHTTPServer is responsible for setting up the vulnerable (or patched) request handler chain. static.(*EncodedCharacters).Map is involved in configuring the security fix.