REDHAT-BUG-2458038: Medium severity JQ jq vulnerability
jq is a command-line JSON processor. In versions 1.8.1 and below, functions jvsetpath(), jvgetpath(), and delpathssorted() in jq's src/jvaux.c use unbounded recursion whose depth is controlled by the length of a caller-supplied path array, with no depth limit enforced. An attacker can supply a JSON document containing a flat array of ~65,000 integers (~200 KB) that, when used as a path argument by a trusted jq filter, exhausts the C call stack and crashes the process with a segmentation fault (SIGSEGV). This bypass works because the existing MAXPARSINGDEPTH (10,000) limit only protects the JSON parser, not runtime path operations where arrays can be programmatically constructed to arbitrary lengths. The impact is denial of service (unrecoverable crash) affecting any application or service that processes untrusted JSON input through jq's setpath, getpath, or delpaths builtins. This issue has been addressed in commit fb59f1491058d58bdc3e8dd28f1773d1ac690a1f.
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 fb59f1491058d58bdc3e8dd28f1773d1ac690a1f
Event History
Frequently Asked Questions
Who is realistically exposed to this denial-of-service issue?
Applications or services that process untrusted JSON with jq filters using the setpath, getpath, or delpaths builtins are affected. The risk is greatest where an attacker can influence the path array directly or cause the filter to construct an arbitrarily long path array from supplied input.
Does jq's existing parsing-depth limit prevent this crash?
No. MAX_PARSING_DEPTH limits JSON parser nesting depth, but it does not limit the depth of runtime path operations, including arrays programmatically constructed by a jq filter.
What input is needed to trigger the crash?
An attacker needs a caller-supplied path array long enough to drive unbounded recursion in the affected path functions. The provided example is a flat array of roughly 65,000 integers, about 200 KB, used as a path argument by a trusted jq filter.
How can we tell whether an application may be affected?
Review jq filters and calling code for use of setpath, getpath, or delpaths with path arrays derived from untrusted JSON or constructed without a length bound. Affected executions can terminate with a segmentation fault (SIGSEGV) from C call-stack exhaustion.
What can be done if the addressed code is not yet available?
Prevent untrusted input from supplying or generating arbitrarily long path arrays, and enforce a practical maximum path length before invoking setpath, getpath, or delpaths. This avoids reaching the recursive call depth that crashes the process.