CRLF Injection in RestSharp's RestRequest.AddHeader method
CVE-2024-45302 · GHSA-4rr6-2v9v-wcpc
- Affected
- NuGet restsharp >= 107.0.0-preview.1, < 112.0.0
- Fixed in
- 112.0.0· Vendor fix available
- Issue
- The second argument to RestRequest.AddHeader (the header value) is vulnerable to CRLF injection. The same applies to RestRequest.AddOrUpdateHeader and RestClient.AddDefaultHeader. Details The way HTTP headers are added to a request is via the HttpHeaders.TryAddWithoutValidation method: <https://github.com/restsharp/RestSharp/blob/777bf194ec2d14271e7807cc704e73ec18fcaf7e/src/RestSharp/Request/HttpRequestMessageExtensions.cs#L32 This method does not check for CRLF characters in the header value. This means that any headers from a RestSharp.RequestHeaders object are added to the request in such a way that they are vulnerable to CRLF-injection. In general, CRLF-injection into a HTTP header (when using HTTP/1.1) means that one can inject additional HTTP headers or smuggle whole HTTP requests. PoC The below example code creates a console app that takes one command line variable "api key" and then makes a request to some status page with the provided key inserted in the…
Recommended action: Upgrade to 112.0.0 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.