#1103833 rust-protobuf: CVE-2024-7254

Package:
src:rust-protobuf
Source:
src:rust-protobuf
Submitter:
Salvatore Bonaccorso
Date:
2025-09-21 17:49:02 UTC
Severity:
normal
Tags:
#1103833#5
Date:
2025-04-21 18:10:37 UTC
From:
To:
Hi,

The following vulnerability was published for rust-protobuf.

CVE-2024-7254[0]:
| Any project that parses untrusted Protocol Buffers data containing
| an arbitrary number of nested groups / series of SGROUP tags can
| corrupted by exceeding the stack limit i.e. StackOverflow. Parsing
| nested groups as unknown fields with DiscardUnknownFieldsParser or
| Java Protobuf Lite parser, or against Protobuf map fields, creates
| unbounded recursions that can be abused by an attacker.


If you fix the vulnerability please also make sure to include the
CVE (Common Vulnerabilities & Exposures) id in your changelog entry.

For further information see:

[0] https://security-tracker.debian.org/tracker/CVE-2024-7254
https://www.cve.org/CVERecord?id=CVE-2024-7254
[1] https://github.com/stepancheg/rust-protobuf/issues/749
[2] https://rustsec.org/advisories/RUSTSEC-2024-0437.html

Regards,
Salvatore

#1103833#12
Date:
2025-04-25 01:02:57 UTC
From:
To:
I looked into this, I will try to summarize the situation to the best of my
knowledge.

CVE-2024-7254 was fixed in rust-protobuf 3.7.2, but testing ships 2.27.1 and
the fix was not backported to v2. An informal backport request was made in [1],
a backport commit was proposed in [2] but ignored, and earlier today I filed
a more formal backport request in [3] explaining our position.

As usual we have 3 ways to fix this: backport, remove, update.


* Backporting

As I said above, no official backport is currently available. The developer who
proposed [2] does not seem to be entirely sure about why one test is not
failing in the first place and the proposal was not reviewed. I'm not
personally going down this route because I'm not knowledgeable enough about
Protocol Buffers to attempt fixing a CVE that affects how parsing is
implemented. But if someone is able to take a shot at this, this is probably
the best solution. Also, maybe [3] will receive an answer, who knows?


* Removing

Static-Built-Using and company [4] say there are only 3 applications in
testing built against rust-protobuf:

- erbium (maintainer: Jelmer Vernooij <jelmer@debian.org>, popcon: 1)
- protobuf-codegen (maintainer: Ximin Luo <infinity0@debian.org>, popcon: 40)
- scaphandre (maintainer: Jonas Smedegaard <dr@jones.dk>, popcon: 22)

Their maintainers are cc'ed to this email. I did not investigate whether the
dependency on rust-protobuf can be patched out for these.

According to codesearch, the full (r)dependency tree is:

- rust-protobuf-codegen (leaf + library, rdeps below)
- rust-protobuf-codegen-pure (rdeps below)
- rust-protoc-rust (no rdeps, essentially unmaintained, can be removed)
- rust-pprof (pending autoremoval, Rust Team already wants to see it gone)
  - rust-handlebars (only tests depend on pprof, has many rdeps, cannot be
    removed, needs decoupling)
- rust-prometheus
  - rust-erbium-core
    - rust-erbium (leaf, no rdeps)
  - rust-opendal (no rdeps, never in testing, can be removed)
- rust-ttrpc (no rdeps)
- scaphandre (leaf, no rdeps)

Library-wise, it seems many of these packages can already be removed. But we
must hear from the applications' maintainers before going down this route [5].


* Updating

Updating requires 2 transitions: rust-prometheus is currently at v0.13, but
only v0.14 is compatible with protobuf 3. Porting prometheus to protobuf 3
seems to be non trivial: it was done in [6] with a +1400,-1500 LOC PR. Thus in
addition to updating the toplevel crates in the list above -- a draft for which
is kinda complete in [7] -- we should also update prometheus' rdeps -- namely,
rust-erbium-core and rust-opendal (but the latter could just be removed). Note
that the version of rust-protobuf-codegen that goes with the fixed version of
rust-protobuf (3.7.2) requires a package not in Debian: rust-protobuf-parse.
So to update we would not only need an unblock for a full transition and a
semver-breaking update/small transition, but also an unblock from NEW (the
package is not even in NEW yet, to be clear). Clearly this is the least
feasible option, only motivated by the high-severity CVE (score: 8.7) if there
is a strong need to keep the three applications above, no way to decouple them
from the insecure behavior in rust-protobuf and no way to backport the fix.


Cheers!


[1] https://github.com/stepancheg/rust-protobuf/pull/756#issuecomment-2710162444
[2] https://github.com/stepancheg/rust-protobuf/pull/756#issuecomment-2715961002
[3] https://github.com/stepancheg/rust-protobuf/issues/763
[4] `grep-dctrl -s Package -F Static-Built-Using,X-Cargo-Built-Using rust-protobuf /var/lib/apt/lists/*Packages | sort -u`
[5] I understand based on recent history Ximin Luo may not answer.
[6] https://github.com/tikv/rust-prometheus/pull/541
[7] https://salsa.debian.org/rust-team/debcargo-conf/-/merge_requests/896

#1103833#19
Date:
2025-04-25 05:05:49 UTC
From:
To:
Quoting NoisyCoil (2025-04-25 03:02:57)

Scaphande is now (pending upload) patched to no longer build-depend on
the protobuf crate.  Turns out it was optional and already unused for
other reasons (will file a bug about that upstream).

Thanks!

 - Jonas

#1103833#24
Date:
2025-04-25 18:32:50 UTC
From:
To:
Thanks Jonas!

As for erbium (via erbium-core), it looks like the functionality it uses
from prometheus (mostly DNS and DHCP) is independent of Protocol
Buffers, and decoupling prometheus from protobuf can be done without
erbium-core FTBFS. So if we're ok with removing protobuf-codegen we
should be able to remove protobuf v2 and reintroduce v3 in forky when we
need it.

#1103833#29
Date:
2025-04-26 14:30:33 UTC
From:
To:
I decoupled handlebars from the rest and filed [1] to also decouple
prometheus: erbium (its only (transitive) reverse dependency
application) doesn't use protobuf's functionality. This however is not a
small change, so it needs consensus from the team (hence the MR). Pros
and cons are detailed in [1].


[1] https://salsa.debian.org/rust-team/debcargo-conf/-/merge_requests/898

#1103833#34
Date:
2025-04-30 09:11:00 UTC
From:
To:
Because of this bug, rust-protobuf is now marked for autoremoval
together with the following packages:

rust-erbium, rust-erbium-core, rust-pprof, rust-prometheus,
rust-protobuf-codegen, rust-protobuf-codegen-pure, rust-protoc-rust,
rust-ttrpc, scaphandre.

scaphandre was already decoupled from it, the autoremoval should be
avoided once it migrates to testing (5 more days). As for the others,
neither erbium's maintainer nor the Rust Team for protobuf-codegen
showed interest in preventing their removal, and I'm not familiar enough
with these programs to make a decision, so I'll leave this bug hanging.
Options to prevent them from being removed are discussed in the present bug.

Cheers!

#1103833#39
Date:
2025-07-05 09:00:26 UTC
From:
To:
The rust protobuf crate got a separate CVE assigned for
RUSTSEC-2024-0437, so adjusting the subject.

Regards,
Salvatore

#1103833#46
Date:
2025-09-21 17:47:01 UTC
From:
To: