CVE-2021-32643: Http4s core StaticFile.fromUrl Can Leak Presence Of Vulnerability
MODERATECVE-2021-32643 is a MODERATE (CVSS 5.8) staticfile.fromurl can leak presence of vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Http4s core libraries in the Maven ecosystem. The issue involves staticfile.fromurl can leak presence of a directory. Remediation is available by upgrading affected packages to version 0.21.24, 0.22.0-RC1, 0.23.0-RC1, 1.0.0-M23.
CVE-2021-32643 at a Glance
Security Impact
CVSS: 5.8
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:C/C:L/I:N/A:N).
How to Fix CVE-2021-32643
To remediate this vulnerability, upgrade all affected Http4s core dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
<dependency>
<groupId>org.http4s</groupId>
<artifactId>http4s-core</artifactId>
<version>0.21.24</version>
</dependency>
<dependency>
<groupId>org.http4s</groupId>
<artifactId>http4s-core</artifactId>
<version>0.22.0-RC1</version>
</dependency>
<dependency>
<groupId>org.http4s</groupId>
<artifactId>http4s-core</artifactId>
<version>0.23.0-RC1</version>
</dependency>
<dependency>
<groupId>org.http4s</groupId>
<artifactId>http4s-core</artifactId>
<version>1.0.0-M23</version>
</dependency>
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-32643, 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 core in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.21.24), 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-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Http4s core, 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
CVE-2021-32643 Affected Http4s core Versions
4 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
org.http4s:http4s-core
|
Maven |
≥ 0.21.7
< 0.21.24
|
0.21.24
|
|
org.http4s:http4s-core
|
Maven |
≥ 0.22.0-M1
< 0.22.0-RC1
|
0.22.0-RC1
|
|
org.http4s:http4s-core
|
Maven |
≥ 0.23.0-M1
< 0.23.0-RC1
All 1 versions
0.23.0-M1
|
0.23.0-RC1
|
|
org.http4s:http4s-core
|
Maven |
≥ 1.0.0-M1
< 1.0.0-M23
|
1.0.0-M23
|
References
Frequently Asked Questions
What is CVE-2021-32643?
Which Http4s core versions are affected?
What version fixes CVE-2021-32643?
Is http4s-core affected?
What is the CVSS score of CVE-2021-32643?
What CWE is associated with CVE-2021-32643?
How can I check Maven dependencies for CVE-2021-32643?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-6h7w-fc84-x7p6",
"modified" : "2021-05-27T21:17:06Z",
"published" : "2021-05-28T15:54:39Z",
"aliases" : [ "CVE-2021-32643" ],
"summary" : "StaticFile.fromUrl can leak presence of a directory",
"details" : "### Impact\n\n`StaticFile.fromUrl` can leak the presence of a directory on a server when the `URL` scheme is not `file://`, and the URL points to a fetchable resource under its scheme and authority. The function returns `F[None]`, indicating no resource, if `url.getFile` is a directory, without first checking the scheme or authority of the URL. If a URL connection to the scheme and URL would return a stream, and the path in the URL exists as a directory on the server, the presence of the directory on the server could be inferred from the 404 response. The contents and other metadata about the directory are not exposed.\n\nThis affects http4s versions:\n* 0.21.7 through 0.21.23\n* 0.22.0-M1 through 0.22.0-M8\n* 0.23.0-M1\n* 1.0.0-M1 through 1.0.0-M22\n\n### Patches\n\nThe [patch](https://github.com/http4s/http4s/commit/52e1890665410b4385e37b96bc49c5e3c708e4e9) is available in the following versions:\n\n* v0.21.24\n* v0.22.0-RC1\n* v0.23.0-RC1\n* v1.0.0-M23\n\nNote: a previous version of this advisory incorrectly referred to 0.22.0-M9 and 0.23.0-M2.\n\n### Workarounds\n\nDon't call `StaticFile.fromUrl` with non-file URLs.\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n* Open an issue in [the http4s repository](https://github.com/http4s/http4s)\n* Disclose further vulnerabilities according to the [http4s security policy](https://github.com/http4s/http4s/blob/main/SECURITY.md)\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Maven",
"name" : "org.http4s:http4s-core"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.21.7"
}, {
"fixed" : "0.21.24"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Maven",
"name" : "org.http4s:http4s-core"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.22.0-M1"
}, {
"fixed" : "0.22.0-RC1"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 0.22.0-M8"
}
}, {
"package" : {
"ecosystem" : "Maven",
"name" : "org.http4s:http4s-core"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0.23.0-M1"
}, {
"fixed" : "0.23.0-RC1"
} ]
} ],
"versions" : [ "0.23.0-M1" ]
}, {
"package" : {
"ecosystem" : "Maven",
"name" : "org.http4s:http4s-core"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "1.0.0-M1"
}, {
"fixed" : "1.0.0-M23"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 1.0.0-M22"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/http4s/http4s/security/advisories/GHSA-6h7w-fc84-x7p6"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-32643"
}, {
"type" : "WEB",
"url" : "https://github.com/http4s/http4s/commit/52e1890665410b4385e37b96bc49c5e3c708e4e9"
}, {
"type" : "WEB",
"url" : "https://mvnrepository.com/artifact/org.http4s/http4s-core"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2021-05-27T21:17:06Z",
"nvd_published_at" : "2021-05-27T18:15:00Z"
}
}