GHSA-j3px-q95c-9683: Zlib rs Zlib-rs Stack Overflow During Decompression Vulnerability
MODERATEGHSA-j3px-q95c-9683 is a MODERATE (CVSS 5.3) zlib-rs stack overflow during decompression vulnerability (CWE-770: Allocation of Resources Without Limits or Throttling) affecting Zlib rs libraries in the crates.io ecosystem. The issue involves zlib-rs stack overflow during decompression with malicious input. Remediation is available by upgrading affected packages to version 0.4.0.
GHSA-j3px-q95c-9683 at a Glance
Security Impact
CVSS: 5.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L).
How to Fix GHSA-j3px-q95c-9683
To remediate this vulnerability, upgrade all affected Zlib rs dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade zlib-rs to 0.4.0
Upgrade libz-rs-sys to 0.4.0
Upgrade libz-rs-sys-cdylib to 0.4.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for zlib-rs
How to Check if You Are Affected
To determine whether your application is affected by GHSA-j3px-q95c-9683, inspect your project dependencies for Zlib rs:
inspect dependencies for zlib-rs
Analyze the terminal output to locate any version of Zlib rs in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.4.0), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-770: Allocation of Resources Without Limits or Throttling, where the product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. In Zlib rs, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
GHSA-j3px-q95c-9683 Affected Zlib rs Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
zlib-rs
|
crates.io |
< 0.4.0
|
0.4.0
|
|
libz-rs-sys
|
crates.io |
< 0.4.0
|
0.4.0
|
|
libz-rs-sys-cdylib
|
crates.io |
< 0.4.0
|
0.4.0
|
References
Frequently Asked Questions
What is GHSA-j3px-q95c-9683?
Which Zlib rs versions are affected?
What version fixes GHSA-j3px-q95c-9683?
Is zlib-rs affected?
Is libz-rs-sys affected?
What is the CVSS score of GHSA-j3px-q95c-9683?
What CWE is associated with GHSA-j3px-q95c-9683?
How can I check crates.io dependencies for GHSA-j3px-q95c-9683?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-j3px-q95c-9683",
"modified" : "2024-12-04T16:22:50Z",
"published" : "2024-11-14T18:09:33Z",
"aliases" : [ ],
"summary" : "zlib-rs stack overflow during decompression with malicious input",
"details" : "A denial of service vulnerability was found in zlib-rs, triggered by specially constructed input. This input causes a stack overflow, resulting in the process using zlib-rs to crash.\n\n### Impact\n\nDue to the way LLVM handles the zlib-rs codebase, tail calls were not guaranteed. This caused certain input patterns to result in a large number of stack frames being required, quickly resulting in a stack overflow. These are unlikely to occur in practice, but a dedicated attacker can construct malicious input files.\n\nAfter stack overflows were found by @inahga with a fuzzer, we dove into the assembly, and found some cases where the stack grew\n\n```asm\n.LBB109_326:\n mov rdi, rbx\n call zlib_rs::inflate::State::type_do\n jmp .LBB109_311\n\n.LBB109_311:\n lea rsp, [rbp - 40]\n pop rbx\n pop r12\n pop r13\n pop r14\n pop r15\n pop rbp\n .cfi_def_cfa rsp, 8\n ret\n```\n\nLLVM wants to centralize the cleanup before the return (many other blocks jump to `LBB109_311`), thereby invalidating a tail call to `type_do`. We were not able to get rid of this call without introducing one elsewhere: we just don't currently have the power to tell LLVM what we want it to do.\n\nSo, we switch back to loop+match waiting for changes to rust to make a more efficient implementation possible. Performance-wise, the damage is relatively minimal: we're just slower in cases where we already were slower than C. We are faster in cases where the relevant code is barely touched (in these cases the logic quickly moves into a hot inner loop and just spends most of its time there).\n\n### Patches\nVersion 0.4.0 patches the problem and is no longer vulnerable.\n\n### Workarounds\nUsers of zlib-rs should upgrade to the latest version. Users could alternatively run zlib-rs in a separate process to prevent a stack overflow crashing the entire program. In some situations a signal handler can be used to catch a stack overflow happening.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "crates.io",
"name" : "zlib-rs"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.4.0"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 0.3.1"
}
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "libz-rs-sys"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.4.0"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 0.3.1"
}
}, {
"package" : {
"ecosystem" : "crates.io",
"name" : "libz-rs-sys-cdylib"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.4.0"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 0.3.1"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/trifectatechfoundation/zlib-rs/security/advisories/GHSA-j3px-q95c-9683"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/trifectatechfoundation/zlib-rs"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2024-0401.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-770" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-11-14T18:09:33Z",
"nvd_published_at" : null
}
}