CVE-2022-21653: Hash collision in typelevel jawn
Summary
CVE-2022-21653: Hash collision in typelevel jawn. Affects org.typelevel:jawn-parser versions < 1.3.2. Fixed in 1.3.2. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The package under scrutiny is org.typelevel:jawn-parser, which is a JSON parser for Scala. It provides a set of traits, including org.typelevel.jawn.SimpleFacade and org.typelevel.jawn.MutableFacade, which can be extended to customize JSON parsing behavior. However, extenders who don't override objectContext() are vulnerable to a hash collision attack. This vulnerability affects various implementations inherited from the library, such as org.http4s::http4s-play-json, org.typelevel::jawn-ast (< 0.8.0), org.typelevel::jawn-play, org.typelevel::jawn-rojoma, and org.typelevel::jawn-spray. Unaffected implementations include io.argonaut::argonaut-jawn, io.circe::circe-parser, org.typelevel::jawn-ast (>= 0.8.0), org.typelevel::jawn-json4s, and org.typelevel::jawn-argonaut.
Vulnerability Detail
The vulnerability arises from a hash collision attack on the objectContext() method in the affected implementations. Extenders who don't override this method are susceptible to the attack. The impact of this vulnerability is moderate, as it allows an attacker to exploit hash collisions to cause denial of service (DoS) by consuming excessive CPU resources. The vulnerability has been assigned a CVSS score of 5.9.
How To Fix
Minimum fixed version
1.3.2
This is the first release that contains the fix.
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If updating the library is not immediately feasible, a workaround is to override the objectContext() method in the affected implementations to use a collision-safe collection. The patch provided in the GitHub pull request (https://github.com/typelevel/jawn/pull/390/files) offers an example of how to implement this workaround in both SimpleFacade and MutableFacade.
Conclusion
In conclusion, the org.typelevel:jawn-parser package is vulnerable to a hash collision attack in certain implementations. It is crucial to update the library to version 1.3.2 or apply the provided workaround to mitigate the risk of denial of service attacks. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for org.typelevel:jawn-parser →
FAQ
The vulnerability affects implementations inherited from the jawn-parser library, including org.http4s::http4s-play-json, org.typelevel::jawn-ast (< 0.8.0), org.typelevel::jawn-play, org.typelevel::jawn-rojoma, and org.typelevel::jawn-spray.
You can use Vulert's playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Vulert monitors and alerts in real-time for open-source vulnerabilities using just the pom.xml file.
The vulnerability allows an attacker to exploit hash collisions to cause denial of service (DoS) by consuming excessive CPU resources. However, it does not enable remote code execution or unauthorized access to sensitive information.
Yes, a workaround is to override the objectContext() method in the affected implementations to use a collision-safe collection. The provided patch in the GitHub pull request (https://github.com/typelevel/jawn/pull/390/files) demonstrates how to implement this workaround.
Yes, the vulnerability can be fixed by updating the jawn-parser library to version 1.3.2, which includes the necessary patches to address the issue.