Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLTY2cTktZjdmZi1tbXg2
Local file inclusion vulnerability in http4s
Impact
This vulnerability applies to all users of:
org.http4s.server.staticcontent.FileService
org.http4s.server.staticcontent.ResourceService
org.http4s.server.staticcontent.WebjarService
Path escaping
URI normalization is applied incorrectly. Requests whose path info contain ../
or //
can expose resources outside of the configured location. Specifically:
FileService
may expose any file on the local file system.ResourceService
may expose any resource on the class path.
Prefix matching
When the service is configured with a non-empty pathPrefix
that doesn't end in a slash, any directories whose names are a prefix of systemPath
(from FileService
) or pathPrefix
(from ResourceService
) are exposed. For example, if pathPrefix
is /foo
and systemPath
is /bar
, a request to /foobaz/quux.txt
exposes file /barbaz/quux.txt
, when only files beneath /bar
should be available.
URI decoding
URI segments are not decoded before resource resolution. This causes resources with reserved characters in their name to incorrectly return a 404. It also may incorrectly expose the rare resource whose name is URI encoded. This applies to FileService
, ResourceService
, and WebjarService
.
Patches
In all three services, paths with an empty segment, a .
segment, or a ..
segment are now rejected with a 400 Bad Request
response. This fixes exposure outside the configured root. Many clients already eliminate dot segments according to the rules in RFC3986, Section 5.2.4. A middleware that does so at the server level may be considered if there is demand.
If pathInfo
is non-empty, and does not begin with /
, then a 404 response is generated. This fixes the prefix matching exposure.
All path segments are URI decoded before being passed to the file system or resource path. This allows resolution of resources with reserved characters in the name, and prevents incorrect exposure of resources whose names are themselves URI encoded.
Workarounds
The recommended course is to upgrade:
- v0.18.26, binary compatible with the 0.18.x series
- v0.20.20, binary compatible with the 0.20.x series
- v0.21.2, binary compatible with the 0.21.x series
Note that 0.19.0 is a deprecated release and has never been supported.
If an upgrade is impossible:
- Temporarily copy
FileService.scala
,ResourceService.scala
, andWebjarService.scala
from the appropriate release series into your project and recompile with that, changing the package name and reference in your application. - Users of a servlet backend can use the servlet container's file serving capabilities.
Credits
Thank you to Thomas Gøytil for the discovery, responsible disclosure, and assistance testing of this vulnerability.
For more information
If you have any questions or comments about this advisory:
- Open an issue in http4s/http4s
- Email a maintainer:
JSON: https://advisories.ecosyste.ms/api/v1/advisories/MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLTY2cTktZjdmZi1tbXg2
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Critical
Classification: General
Published: almost 5 years ago
Updated: about 2 years ago
CVSS Score: 7.6
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:L/A:N
EPSS Percentage: 0.02547
EPSS Percentile: 0.89873
Identifiers: GHSA-66q9-f7ff-mmx6, CVE-2020-5280
References:
- https://github.com/http4s/http4s/security/advisories/GHSA-66q9-f7ff-mmx6
- https://github.com/http4s/http4s/commit/250afddbb2e65b70ca9ddaec9d1eb3aaa56de7ec
- https://github.com/http4s/http4s/commit/752b3f63a05a31d2de4f8706877aa08d6b89efca
- https://github.com/http4s/http4s/commit/b87f31b2292dabe667bec3b04ce66176c8a3e17b
- https://nvd.nist.gov/vuln/detail/CVE-2020-5280
- https://github.com/advisories/GHSA-66q9-f7ff-mmx6
Blast Radius: 4.6
Affected Packages
maven:org.http4s:http4s-server_2.12
Dependent packages: 67Dependent repositories: 4
Downloads:
Affected Version Ranges: >= 0.21.0, < 0.21.2, >= 0.19.0, < 0.20.20, < 0.18.26
Fixed in: 0.21.2, 0.20.20, 0.18.26
All affected versions: 0.15.0, 0.15.1, 0.15.2, 0.15.3, 0.15.4, 0.15.5, 0.15.6, 0.15.7, 0.15.8, 0.15.9, 0.15.10, 0.15.11, 0.15.12, 0.15.13, 0.15.14, 0.15.15, 0.15.16, 0.16.0, 0.16.1, 0.16.2, 0.16.3, 0.16.4, 0.16.5, 0.16.6, 0.17.0, 0.17.1, 0.17.2, 0.17.3, 0.17.4, 0.17.5, 0.17.6, 0.18.0, 0.18.1, 0.18.2, 0.18.3, 0.18.4, 0.18.5, 0.18.6, 0.18.7, 0.18.8, 0.18.9, 0.18.10, 0.18.11, 0.18.12, 0.18.13, 0.18.14, 0.18.15, 0.18.16, 0.18.17, 0.18.18, 0.18.19, 0.18.20, 0.18.21, 0.18.22, 0.18.23, 0.18.24, 0.18.25, 0.19.0, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.20.4, 0.20.5, 0.20.6, 0.20.7, 0.20.8, 0.20.9, 0.20.10, 0.20.11, 0.20.12, 0.20.13, 0.20.14, 0.20.15, 0.20.16, 0.20.17, 0.20.18, 0.20.19, 0.21.0, 0.21.1
All unaffected versions: 0.18.26, 0.20.20, 0.20.21, 0.20.22, 0.20.23, 0.21.2, 0.21.3, 0.21.4, 0.21.5, 0.21.6, 0.21.7, 0.21.8, 0.21.9, 0.21.11, 0.21.12, 0.21.13, 0.21.14, 0.21.15, 0.21.16, 0.21.17, 0.21.18, 0.21.19, 0.21.20, 0.21.21, 0.21.22, 0.21.23, 0.21.24, 0.21.25, 0.21.26, 0.21.27, 0.21.28, 0.21.29, 0.21.30, 0.21.31, 0.21.33, 0.21.34, 0.22.0, 0.22.1, 0.22.2, 0.22.3, 0.22.4, 0.22.5, 0.22.6, 0.22.7, 0.22.8, 0.22.9, 0.22.10, 0.22.11, 0.22.12, 0.22.13, 0.22.14, 0.22.15, 0.23.0, 0.23.1, 0.23.2, 0.23.3, 0.23.4, 0.23.5, 0.23.6, 0.23.7, 0.23.8, 0.23.9, 0.23.10, 0.23.11, 0.23.12, 0.23.13, 0.23.14, 0.23.15, 0.23.16, 0.23.17, 0.23.18, 0.23.19, 0.23.20, 0.23.21, 0.23.22, 0.23.23, 0.23.24, 0.23.25, 0.23.26, 0.23.27, 0.23.28, 0.23.29, 0.23.30