HIGH 7.1

CVE-2026-49839: jq Heap Buffer Overflow via --rawfile String Handling

jq is a widely-used command-line tool for processing JSON data. This vulnerability exists in how jq handles very large files when using the `--rawfile` option. When jq reads an oversized file, it is supposed to stop and report an error once the file exceeds the string size limit. However, in versions before 1.8.2, the error handling is incomplete: the tool continues trying to read more data from the file even after detecting it is too large. This causes jq to write data to memory locations it shouldn't access, potentially leading to a crash or allowing an attacker to execute code. An attacker would need to trick a user into running jq on a specially crafted large file.

Source data · NVD / CISA · public domain

CVSS
3.1 · 7.1 HIGH · CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H
Weaknesses (CWE)
CWE-787
Affected products
1 configuration(s)
Published / Modified
2026-06-25 / 2026-06-26

NVD description (verbatim)

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 jv_load_file(raw=1) reads an attacker-controlled file, it repeatedly appends file chunks to the same jv string accumulator. Once jv_string_append_buf() returns jv_invalid_with_msg("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 jvp_string_ptr(). 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.

2 reference(s) · View on NVD →

SEC.co analysis · AI-assisted, reviewed against source

Technical summary

The vulnerability resides in jq's jv_load_file() function when invoked with the raw file mode (raw=1). The function accumulates file chunks into a jv string object via repeated jv_string_append_buf() calls. When the accumulated string exceeds the maximum allowed size, jv_string_append_buf() returns jv_invalid_with_msg("String too long") to signal error. The critical flaw is that the raw-file reading loop does not halt upon receiving this error state; if additional bytes remain in the file, the next iteration attempts to append to the already-invalid jv object. In assertion-enabled builds, this triggers an abort in jvp_string_ptr(). In assertion-disabled production builds, the invalid object is misinterpreted as a valid string, leading to out-of-bounds memory writes. This is classified as a heap-buffer-overflow under CWE-787 (Out-of-bounds Write).

Business impact

For organizations using jq in automated JSON processing pipelines, CI/CD workflows, or data transformation scripts, this vulnerability presents a denial-of-service risk if an attacker can supply malformed input files. In environments where jq processes untrusted data (such as log aggregation, API response parsing, or user-uploaded documents), the out-of-bounds write could potentially be leveraged for remote code execution. The impact is heightened in containerized or serverless deployments where jq runs with broad process permissions, and in scenarios where users unknowingly process attacker-controlled JSON files.

Affected systems

jq versions prior to 1.8.2 are vulnerable. This affects all deployments of jqlang/jq on Linux, macOS, and other Unix-like systems where jq is installed as a system utility or embedded in applications. Particular risk applies to systems that automatically or semi-automatically process JSON files from external sources (e.g., APIs, uploads, inter-service data exchange) using the `--rawfile` flag.

Exploitability

The vulnerability requires user interaction: an attacker must supply a crafted oversized file and cause a user or automated process to invoke jq with the `--rawfile` flag on that file. This is a local attack vector (AV:L) with no special privileges required (PR:N), but user involvement in triggering the command is necessary (UI:R). The simplicity of constructing a large, malformed JSON or text file makes the technical barrier to crafting a proof-of-concept low. However, real-world exploitation depends on how jq is integrated into workflows and whether users/systems can be socially engineered or misconfigured to process untrusted input.

Remediation

Upgrade jq to version 1.8.2 or later. This patch corrects the error-handling logic in jv_load_file() to immediately cease file reading when the string-too-long error is detected. After patching, verify the fix in your environment by testing jq with oversized input files to confirm it properly rejects them without crashing or producing unexpected behavior.

Patch guidance

Obtain jq 1.8.2 from the official jqlang/jq repository or your Linux distribution's package manager. Most major distributions have already backported or updated their jq packages; check your vendor's advisory or run `jq --version` to confirm your installed version. For containerized deployments, rebuild images with the patched jq version and redeploy. For development and CI/CD environments, update jq in your build toolchains and container base images. Test JSON processing workflows post-update to ensure no regressions.

Detection guidance

Monitor for jq process crashes or segmentation faults, especially when processing large JSON or text files via `--rawfile`. Review process logs and core dumps for evidence of jvp_string_ptr() assertions or heap-buffer-overflow signals. In networks, observe for unusual jq invocations with atypical file arguments or unexpected process terminations. Conduct a code review of any scripts or applications that call jq with user-supplied or external data sources to identify risk points and enforce input validation independent of jq's built-in limits.

Why prioritize this

This vulnerability merits immediate attention due to its HIGH CVSS score (7.1), the combination of integrity and availability impacts, and the ease of weaponization. While it requires user interaction, jq's prevalence in data processing workflows and the simplicity of constructing exploit input make it a practical threat. Organizations should prioritize patching systems where jq processes any untrusted JSON or large files, particularly in automated pipelines or public-facing services.

Risk score, explained

The CVSS 3.1 score of 7.1 reflects a HIGH severity assessment driven by the out-of-bounds write capability (CWE-787), which enables both integrity compromise (potential code execution) and availability impact (process crashes). The local attack vector and requirement for user interaction lower the score compared to network-based vulnerabilities, but the lack of privilege escalation requirement and the straightforward nature of the exploit scenario maintain a high baseline risk. Organizations without active protections against malicious file processing or those running unpatched jq are at elevated practical risk.

Frequently asked questions

Do I need to update jq immediately, or can I wait for my next maintenance window?

If your organization processes JSON files from any external source—APIs, user uploads, inter-service communication, or logs—prioritize patching within your next 1–2 weeks. The vulnerability is easily exploitable and can cause crashes or worse in assertion-disabled builds. Non-critical dev environments can wait longer, but production systems should be treated as urgent.

Can I mitigate this without upgrading if patching is delayed?

Partial mitigations include: restricting who can run jq, enforcing file-size limits at the application or OS level before jq processes input, disabling the `--rawfile` flag if not strictly needed, and validating file sizes with separate tools before jq processing. However, these are workarounds; upgrading to 1.8.2 is the only complete fix.

Does this affect jq if I only use it for command-line queries without --rawfile?

No. The vulnerability is specific to jq's `--rawfile` option, which reads entire files into jq as raw strings. If your workflows use jq for JSON filtering, transformation, or API response processing without explicitly invoking `--rawfile`, you are not directly affected by this CVE.

Is this vulnerability being actively exploited in the wild?

As of the publication date, this CVE is not listed on CISA's Known Exploited Vulnerabilities (KEV) catalog, meaning there is no evidence of active exploitation at scale. However, given the low barrier to creating a proof-of-concept, defenders should not assume it will remain unexploited indefinitely. Patch according to your risk assessment and change-management processes.

This analysis is provided for informational purposes to assist security professionals in risk assessment and remediation planning. The vulnerability details, CVSS score, and patch information are drawn from official CVE records and vendor advisories. Organizations should verify all patch version numbers and compatibility details against official jq release notes and their vendor's guidance before deploying patches. SEC.co does not guarantee the completeness or real-time accuracy of this intelligence and recommends cross-referencing with primary sources and your security team's assessment. This is not legal or compliance advice; consult your organization's security and legal teams for regulatory and policy implications. Source: NVD (public-domain), retrieved 2026-08-03. Analysis generated by SEC.co (claude-haiku-4-5).