The vulnerability, CVE-2024-58259, is a denial-of-service weakness in Rancher Manager caused by the absence of request body size limits on several API endpoints. This allows an attacker to exhaust server memory by sending excessively large HTTP requests.
The analysis of the provided patch, commit aee95d4e2a41ba2df6f88c9634d4fe1f42dee4d9, reveals that the vulnerability is one of omission, where a crucial security control was missing. The fix involves introducing a new middleware, APIBodyLimitingHandler, which uses the standard library's http.MaxBytesHandler to enforce these limits.
The vulnerable functions identified are the ones responsible for setting up the HTTP routing and handlers without this protection. While these functions do not process the malicious input directly (that's done by the actual endpoint handlers like publicAPI and managementAPI), they are the source of the insecure configuration. During exploitation on a vulnerable version, the server would attempt to read the entire malicious payload into memory within the context of the handler for the targeted endpoint.
The two primary functions modified by the patch are:
github.com/rancher/rancher/pkg/auth.newAPIManagement: This function configures authentication-related endpoints, including /v3-public and /v1-saml. The patch applies the new size-limiting middleware to these routes.
github.com/rancher/rancher/pkg/multiclustermanager.router: This function sets up a wide range of unauthenticated endpoints. The patch wraps the entire router for these endpoints with the size-limiting middleware.
By identifying these two functions, we pinpoint the exact locations in the code where the insecure configuration originated. A security engineer can use this information to understand that any endpoint configured within these functions was likely vulnerable before the patch was applied.