REDHAT-BUG-2493020: Medium severity jqlang jq vulnerability
jq is a command-line JSON processor. Prior to 1.8.2, jq --rawfile can turn a handled oversized-string error into invalid-state reuse and a real heap out-of-bounds write in assertion-disabled builds. When jvloadfile(raw=1) reads an attacker-controlled file, it repeatedly appends file chunks to the same jv string accumulator. Once jvstringappendbuf() returns jvinvalidwithmsg("String too long"), the raw-file loop does not stop. If the file contains at least one more byte, the next loop iteration appends a new chunk to an object that is already invalid. With assertions enabled this aborts in jvpstringptr(). With assertions disabled, the invalid object is interpreted as a string object and ASan reports heap-buffer-overflow. This vulnerability is fixed in 1.8.2.
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.
Fixed in 1.8.2
Event History
Frequently Asked Questions
Who is exposed to this issue?
Systems that use jq to read an attacker-controlled file through the raw-file path are exposed, particularly where jq is built with assertions disabled. The vulnerable behavior occurs while jv_load_file(raw=1) accumulates file contents.
What does an attacker need to trigger the flaw?
An attacker needs control over a file processed with jq --rawfile. The file must be large enough to trigger the handled "String too long" condition and contain at least one additional byte so processing continues after the accumulator becomes invalid.
How does the build configuration affect impact?
With assertions enabled, jq aborts when the invalid object is used as a string. With assertions disabled, the invalid object can be treated as a string and lead to a heap out-of-bounds write.
What version fixes the issue?
The issue is fixed in jq 1.8.2. Versions prior to 1.8.2 are affected under the described raw-file processing conditions.