REDHAT-BUG-2457929: Buffer Overflow
jq is a command-line JSON processor. An integer overflow vulnerability exists through version 1.8.1 within the jvpstringappend() and jvpstringcopyreplacebad functions, where concatenating strings with a combined length exceeding 2^31 bytes causes a 32-bit unsigned integer overflow in the buffer allocation size calculation, resulting in a drastically undersized heap buffer. Subsequent memory copy operations then write the full string data into this undersized buffer, causing a heap buffer overflow classified as CWE-190 (Integer Overflow) leading to CWE-122 (Heap-based Buffer Overflow). Any system evaluating untrusted jq queries is affected, as an attacker can crash the process or potentially achieve further exploitation through heap corruption by crafting queries that produce extremely large strings. The root cause is the absence of string size bounds checking, unlike arrays and objects which already have size limits. The issue has been addressed in commit e47e56d226519635768e6aab2f38f0ab037c09e5.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Patch e47e56d226519635768e6aab2f38f0ab037c09e5
Event History
Frequently Asked Questions
Who is realistically exposed to this issue?
Systems that evaluate untrusted jq queries are affected. An attacker must be able to submit a crafted query that causes jq to concatenate strings whose combined length exceeds 2^31 bytes.
What impact can successful exploitation have?
The crafted string operation can cause an undersized heap allocation followed by writes of the full string data. This can crash the jq process and may allow further exploitation through heap corruption.
Which jq releases are affected?
The issue exists through jq version 1.8.1. The provided data does not identify the first fixed release, but identifies commit e47e56d226519635768e6aab2f38f0ab037c09e5 as addressing it.
What is the relevant remediation indicator if a package version is not available?
Check whether the jq source or package incorporates commit e47e56d226519635768e6aab2f38f0ab037c09e5. That commit addresses the missing string-size bounds checking that permits the integer overflow.