🛡️ GHSA-j3px-q95c-9683 — libz-rs-sys

⚪ Unknown ✅ No Known Exploit CWE-770 OSV
N/A
CVSS Score
0 Low4 Medium7 High9 Critical10

Description

zlib-rs stack overflow during decompression with malicious input

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.

Impact

Due 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.

After stack overflows were found by @inahga with a fuzzer, we dove into the assembly, and found some cases where the stack grew

```asm

.LBB109_326:

mov rdi, rbx

call zlib_rs::inflate::State::type_do

jmp .LBB109_311

.LBB109_311:

lea rsp, [rbp - 40]

pop rbx

pop r12

pop r13

pop r14

pop r15

pop rbp

.cfi_def_cfa rsp, 8

ret

```

LLVM 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.

So, 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).

Patches

Version 0.4.0 patches the problem and is no longer vulnerable.

Workarounds

Users 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.

How this vulnerability can be exploited

This issue can be reached over the network, attack complexity is low, an attacker needs no privileges on the target. No user interaction is required. The scope is unchanged, so the impact stays within the vulnerable component. Rated impact: confidentiality none, integrity none, availability low.

Weakness class

GHSA-j3px-q95c-9683 is classified as CWE-770: Allocation of Resources Without Limits. Resources are allocated on request with no cap, so a client can exhaust them.

Affected software

GHSA-j3px-q95c-9683 is recorded against 3 packages.

  • libz-rs-sys
  • libz-rs-sys-cdylib
  • zlib-rs

Timeline and source

Published on 14 November 2024 and last revised on 4 December 2024. No public exploit is currently recorded for this entry. Record sourced from OSV.

References

github.com (Web)
github.com (Package)
rustsec.org (Web)

Details

Severity Unknown
CVSS Score N/A
CVSS Vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
CWE CWE-770
Public Exploit ✅ No
Source OSV
Published 2024-11-14
Updated 2026-08-12
Modified 2024-12-04
Fix URL N/A

Affected Packages

Software From version Fixed in
libz-rs-sys
libz-rs-sys-cdylib
zlib-rs

Free Vulnerability Check

Is your site affected by GHSA-j3px-q95c-9683?

BotEraser helps you identify potentially vulnerable plugins and themes by checking your installation against GHSA-j3px-q95c-9683 and other known CVE records.

Scan My Site Free →

No credit card required  ·  Results in minutes

ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.

Browse related advisories

All advisoriesGitHub AdvisoryGitHub Advisory Undated