CVE-2021-42248: ReDoS via crafted JSON input in GJSON
Summary
CVE-2021-42248: Duplicate Advisory: ReDoS via crafted JSON input in GJSON. Affects github.com/tidwall/gjson versions < 1.9.3. Fixed in 1.9.3. How to fix ↓
Also tracked for
- golang-github-tidwall-gjson · Debian:11
The same CVE-2021-42248 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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 github.com/tidwall/gjson, which is a Go library for parsing JSON. It provides a simple and efficient way to extract values from JSON documents using a query syntax. GJSON is widely used in various Go applications for JSON parsing and manipulation.
Vulnerability Detail
GJSON version 1.9.2 and earlier are vulnerable to a Regular Expression Denial of Service (ReDoS) attack. Attackers can exploit this vulnerability by providing crafted JSON input, which triggers excessive backtracking in the regular expression engine used by GJSON. This can lead to a significant slowdown or even a denial of service condition. The vulnerability has a CVSS score of 7.5, indicating a high severity.
How To Fix
Latest published version: v1.20.0 as of 23 Oct 2026
go get github.com/tidwall/gjson@v1.20.0
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
1.9.3
This is the first release that contains the fix.
go get github.com/tidwall/gjson@v1.9.3
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
There is no known workaround for this vulnerability. It is essential to upgrade to the fixed version of GJSON to mitigate the risk.
Conclusion
In conclusion, GJSON version 1.9.2 and earlier are vulnerable to a ReDoS attack via crafted JSON input. To mitigate this vulnerability, it is recommended to upgrade to GJSON version 1.9.3 or later. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for github.com/tidwall/gjson →
FAQ
GJSON is a Go library for parsing JSON documents and extracting values using a query syntax. It is widely used in Go applications for JSON manipulation.
A ReDoS (Regular Expression Denial of Service) attack is a type of vulnerability where an attacker can exploit a regular expression pattern to cause excessive backtracking, leading to a significant slowdown or denial of service.
The vulnerability in GJSON can be exploited by attackers to cause a denial of service condition by providing crafted JSON input. This can lead to a slowdown or unresponsiveness of the affected application.
To fix this vulnerability, you should upgrade to GJSON version 1.9.3 or later, which includes a fix for the ReDoS vulnerability.
No, there is no known workaround for this vulnerability. It is crucial to upgrade to the fixed version of GJSON.
References
Related vulnerabilities
Recent vulnerabilities recorded for github.com/tidwall/gjson.