From: "Anil Dongare -X (adongare - E INFOCHIPS PRIVATE LIMITED at Cisco)" <adongare@cisco.com>
To: openembedded-core@lists.openembedded.org
Cc: xe-linux-external@cisco.com, Anil Dongare <adongare@cisco.com>
Subject: [OE-core] [wrynose] [PATCH 2/2] cargo: Fix CVE-2026-5223
Date: Mon, 29 Jun 2026 05:39:16 -0700 [thread overview]
Message-ID: <20260629123917.60003-2-adongare@cisco.com> (raw)
In-Reply-To: <20260629123917.60003-1-adongare@cisco.com>
From: Anil Dongare <adongare@cisco.com>
This patch applies the upstream fix as referenced in [2], using the commit shown in [1].
[1] https://github.com/rust-lang/cargo/commit/285cebf58911eca5b7f177f5d0b1c53e1f646577
[2] https://security-tracker.debian.org/tracker/CVE-2026-5223
Signed-off-by: Anil Dongare <adongare@cisco.com>
---
.../rust/files/CVE-2026-5223.patch | 125 ++++++++++++++++++
meta/recipes-devtools/rust/rust-source.inc | 1 +
2 files changed, 126 insertions(+)
create mode 100644 meta/recipes-devtools/rust/files/CVE-2026-5223.patch
diff --git a/meta/recipes-devtools/rust/files/CVE-2026-5223.patch b/meta/recipes-devtools/rust/files/CVE-2026-5223.patch
new file mode 100644
index 0000000000..5041dedac5
--- /dev/null
+++ b/meta/recipes-devtools/rust/files/CVE-2026-5223.patch
@@ -0,0 +1,125 @@
+From 285cebf58911eca5b7f177f5d0b1c53e1f646577 Mon Sep 17 00:00:00 2001
+From: Josh Triplett <josh@joshtriplett.org>
+Date: Mon, 30 Mar 2026 10:35:55 -0700
+Subject: [PATCH] CVE-2026-5223: prohibit unpacking symlinks and other
+ unexpected entries
+
+Cargo has historically not allowed creating .crate packages containing
+symlinks. (It packages the symlink target in place of the symlink,
+instead.) So, any package containing a symlink would have to be
+hand-constructed. Such packages are also not allowed on crates.io, so it
+could only come from an alternate registry.
+
+Rather than dealing with symlink traversal attacks when unpacking a
+crate, just prohibit symlinks entirely.
+
+In the process, also prohibit other kinds of unusual entries. As an
+exception, allow character devices but warn about them, because some
+exist in crates on crates.io.
+
+CVE: CVE-2026-5223
+Upstream-Status: Backport [https://github.com/rust-lang/cargo/commit/285cebf58911eca5b7f177f5d0b1c53e1f646577]
+
+(cherry picked from commit 285cebf58911eca5b7f177f5d0b1c53e1f646577)
+Signed-off-by: Anil Dongare <adongare@cisco.com>
+---
+ src/tools/cargo/src/cargo/sources/registry/mod.rs | 10 +++++-
+ src/tools/cargo/tests/testsuite/registry.rs | 39 ++++++++++-------------
+ 2 files changed, 26 insertions(+), 23 deletions(-)
+
+diff --git a/src/tools/cargo/src/cargo/sources/registry/mod.rs b/src/tools/cargo/src/cargo/sources/registry/mod.rs
+index 04d4ec3..d152a1e 100644
+--- a/src/tools/cargo/src/cargo/sources/registry/mod.rs
++++ b/src/tools/cargo/src/cargo/sources/registry/mod.rs
+@@ -197,7 +197,7 @@ use cargo_util::paths::{self, exclude_from_backups_and_indexing};
+ use flate2::read::GzDecoder;
+ use serde::Deserialize;
+ use serde::Serialize;
+-use tar::Archive;
++use tar::{Archive, EntryType};
+ use tracing::debug;
+
+ use crate::core::dependency::Dependency;
+@@ -1088,6 +1088,14 @@ fn unpack(
+ )
+ }
+
++ // Prevent unpacking symlinks and other unexpected entry types
++ match entry.header().entry_type() {
++ EntryType::Regular | EntryType::Directory => {}
++ t => anyhow::bail!(
++ "invalid tarball downloaded, contains an entry at {entry_path:?} with invalid type {t:?}",
++ ),
++ }
++
+ // Prevent unpacking the lockfile from the crate itself.
+ if entry_path
+ .file_name()
+diff --git a/src/tools/cargo/tests/testsuite/registry.rs b/src/tools/cargo/tests/testsuite/registry.rs
+index 5a30dad..4a4e836 100644
+--- a/src/tools/cargo/tests/testsuite/registry.rs
++++ b/src/tools/cargo/tests/testsuite/registry.rs
+@@ -3274,8 +3274,7 @@ fn package_lock_inside_package_is_overwritten() {
+ }
+
+ #[cargo_test]
+-fn package_lock_as_a_symlink_inside_package_is_overwritten() {
+- let registry = registry::init();
++fn package_lock_as_a_symlink_inside_package_is_invalid() {
+ let p = project()
+ .file(
+ "Cargo.toml",
+@@ -3298,21 +3297,23 @@ fn package_lock_as_a_symlink_inside_package_is_overwritten() {
+ .symlink(".cargo-ok", "src/lib.rs")
+ .publish();
+
+- p.cargo("check").run();
++ p.cargo("check")
++ .with_status(101)
++ .with_stderr_data(str![[r#"
++[UPDATING] `dummy-registry` index
++[LOCKING] 1 package to latest compatible version
++[DOWNLOADING] crates ...
++[DOWNLOADED] bar v0.0.1 (registry `dummy-registry`)
++[ERROR] failed to download replaced source registry `crates-io`
+
+- let id = SourceId::for_registry(registry.index_url()).unwrap();
+- let hash = cargo::util::hex::short_hash(&id);
+- let pkg_root = paths::cargo_home()
+- .join("registry")
+- .join("src")
+- .join(format!("-{}", hash))
+- .join("bar-0.0.1");
+- let ok = pkg_root.join(".cargo-ok");
+- let librs = pkg_root.join("src/lib.rs");
++Caused by:
++ failed to unpack package `bar v0.0.1 (registry `dummy-registry`)`
+
+- // Is correctly overwritten and doesn't affect the file linked to
+- assert_eq!(ok.metadata().unwrap().len(), 7);
+- assert_eq!(fs::read_to_string(librs).unwrap(), "pub fn f() {}");
++Caused by:
++ invalid tarball downloaded, contains an entry at "bar-0.0.1/.cargo-ok" with invalid type Symlink
++
++"#]])
++ .run();
+ }
+
+ #[cargo_test]
+@@ -4751,13 +4752,7 @@ Caused by:
+ failed to unpack package `bar v1.0.0 (registry `dummy-registry`)`
+
+ Caused by:
+- failed to unpack entry at `bar-1.0.0/smuggled`
+-
+-Caused by:
+- failed to unpack `[ROOT]/home/.cargo/registry/src/-[HASH]/bar-1.0.0/smuggled`
+-
+-Caused by:
+- [..] when creating dir [ROOT]/home/.cargo/registry/src/-[HASH]/bar-1.0.0/smuggled
++ invalid tarball downloaded, contains an entry at "bar-1.0.0/smuggled" with invalid type Symlink
+
+ "#]])
+ .run();
+--
+2.44.4
diff --git a/meta/recipes-devtools/rust/rust-source.inc b/meta/recipes-devtools/rust/rust-source.inc
index 36407fa975..d897b2c262 100644
--- a/meta/recipes-devtools/rust/rust-source.inc
+++ b/meta/recipes-devtools/rust/rust-source.inc
@@ -12,6 +12,7 @@ SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;n
file://0001-Adjust-loongarch-assembly-test.patch;patchdir=${RUSTSRC} \
file://0001-Fix-multiple-option-or-permutations-test-for-big-end.patch;patchdir=${RUSTSRC} \
file://CVE-2026-5222.patch;patchdir=${RUSTSRC} \
+ file://CVE-2026-5223.patch;patchdir=${RUSTSRC} \
"
SRC_URI[rust.sha256sum] = "174fce10ce012317ca995810296d8af199318838180b03d68a853e0f02d4b571"
--
2.44.4
prev parent reply other threads:[~2026-06-29 12:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 12:39 [OE-core] [wrynose] [PATCH 1/2] cargo: Fix CVE-2026-5222 Anil Dongare -X (adongare - E INFOCHIPS PRIVATE LIMITED at Cisco)
2026-06-29 12:39 ` Anil Dongare -X (adongare - E INFOCHIPS PRIVATE LIMITED at Cisco) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260629123917.60003-2-adongare@cisco.com \
--to=adongare@cisco.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=xe-linux-external@cisco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox