Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 870166 (CVE-2022-36113, CVE-2022-36114)

Summary: <dev-lang/rust-1.63.0-r1 <dev-lang/rust-bin-1.64.0: multiple vulnerabilities
Product: Gentoo Security Reporter: John Helmert III <ajak>
Component: VulnerabilitiesAssignee: Gentoo Security <security>
Status: RESOLVED FIXED    
Severity: minor CC: gyakovlev, rust
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard: B4 [glsa+]
Package list:
Runtime testing required: ---
Bug Depends on: 872560, 877005    
Bug Blocks:    

Description John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-09-14 22:32:40 UTC
CVE-2022-36113 (https://github.com/rust-lang/cargo/security/advisories/GHSA-rfj2-q3h3-hm5j):
https://github.com/rust-lang/cargo/commit/97b80919e404b0768ea31ae329c3b4da54bed05a

Cargo is a package manager for the rust programming language. After a package is downloaded, Cargo extracts its source code in the ~/.cargo folder on disk, making it available to the Rust projects it builds. To record when an extraction is successful, Cargo writes "ok" to the .cargo-ok file at the root of the extracted source code once it extracted all the files. It was discovered that Cargo allowed packages to contain a .cargo-ok symbolic link, which Cargo would extract. Then, when Cargo attempted to write "ok" into .cargo-ok, it would actually replace the first two bytes of the file the symlink pointed to with ok. This would allow an attacker to corrupt one file on the machine using Cargo to extract the package. Note that by design Cargo allows code execution at build time, due to build scripts and procedural macros. The vulnerabilities in this advisory allow performing a subset of the possible damage in a harder to track down way. Your dependencies must still be trusted if you want to be protected from attacks, as it's possible to perform the same attacks with build scripts and procedural macros. The vulnerability is present in all versions of Cargo. Rust 1.64, to be released on September 22nd, will include a fix for it. Since the vulnerability is just a more limited way to accomplish what a malicious build scripts or procedural macros can do, we decided not to publish Rust point releases backporting the security fix. Patch files are available for Rust 1.63.0 are available in the wg-security-response repository for people building their own toolchain. Mitigations We recommend users of alternate registries to exercise care in which package they download, by only including trusted dependencies in their projects. Please note that even with these vulnerabilities fixed, by design Cargo allows arbitrary code execution at build time thanks to build scripts and procedural macros: a malicious dependency will be able to cause damage regardless of these vulnerabilities. crates.io implemented server-side checks to reject these kinds of packages years ago, and there are no packages on crates.io exploiting these vulnerabilities. crates.io users still need to exercise care in choosing their dependencies though, as remote code execution is allowed by design there as well.

CVE-2022-36114 (https://github.com/rust-lang/cargo/security/advisories/GHSA-2hvr-h6gw-qrxp):
https://github.com/rust-lang/cargo/commit/d1f9553c825f6d7481453be8d58d0e7f117988a7

Cargo is a package manager for the rust programming language. It was discovered that Cargo did not limit the amount of data extracted from compressed archives. An attacker could upload to an alternate registry a specially crafted package that extracts way more data than its size (also known as a "zip bomb"), exhausting the disk space on the machine using Cargo to download the package. Note that by design Cargo allows code execution at build time, due to build scripts and procedural macros. The vulnerabilities in this advisory allow performing a subset of the possible damage in a harder to track down way. Your dependencies must still be trusted if you want to be protected from attacks, as it's possible to perform the same attacks with build scripts and procedural macros. The vulnerability is present in all versions of Cargo. Rust 1.64, to be released on September 22nd, will include a fix for it. Since the vulnerability is just a more limited way to accomplish what a malicious build scripts or procedural macros can do, we decided not to publish Rust point releases backporting the security fix. Patch files are available for Rust 1.63.0 are available in the wg-security-response repository for people building their own toolchain. We recommend users of alternate registries to excercise care in which package they download, by only including trusted dependencies in their projects. Please note that even with these vulnerabilities fixed, by design Cargo allows arbitrary code execution at build time thanks to build scripts and procedural macros: a malicious dependency will be able to cause damage regardless of these vulnerabilities. crates.io implemented server-side checks to reject these kinds of packages years ago, and there are no packages on crates.io exploiting these vulnerabilities. crates.io users still need to excercise care in choosing their dependencies though, as the same concerns about build scripts and procedural macros apply here.

So, the fixes will be in 1.64 but we can also apply the patch to
1.63. Given the low severity and relatively high time cost of Rust, I
don't feel strongly about whether it's necessary to go ahead and apply
the patch now.
Comment 1 Georgy Yakovlev archtester gentoo-dev 2022-09-15 03:07:43 UTC
eh, I wanted 1.63.0 to be next stable.
can no longer do due to -bin unfixable and does not look like there will be 1.63.1
Comment 2 Larry the Git Cow gentoo-dev 2022-09-15 03:15:52 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f36a42fed54e19b300f243f14523fc4267907426

commit f36a42fed54e19b300f243f14523fc4267907426
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2022-09-15 03:03:41 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2022-09-15 03:03:41 +0000

    dev-lang/rust: revbump 1.63.0, add cargo security fixes
    
    Bug: https://bugs.gentoo.org/870166
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 dev-lang/rust/files/1.63.0-CVE-2022-36113.patch    |  48 ++++++++++
 dev-lang/rust/files/1.63.0-CVE-2022-36114.patch    | 102 +++++++++++++++++++++
 .../{rust-1.63.0.ebuild => rust-1.63.0-r1.ebuild}  |   2 +
 3 files changed, 152 insertions(+)
Comment 3 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-09-15 03:19:44 UTC
Ah, thanks!
Comment 4 Larry the Git Cow gentoo-dev 2022-09-23 20:06:11 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4c25a3d2937bd55112f65c9bb0899116306d16e0

commit 4c25a3d2937bd55112f65c9bb0899116306d16e0
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2022-09-23 20:04:37 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2022-09-23 20:05:46 +0000

    dev-lang/rust: drop 1.59.0, 1.60.0, 1.61.0-r2, 1.62.0
    
    Bug: https://bugs.gentoo.org/870166
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 dev-lang/rust/Manifest                             | 104 ---
 .../files/1.49.0-gentoo-musl-target-specs.patch    | 164 -----
 .../rust/files/1.61.0-llvm_addrspacecast.patch     |  52 --
 .../files/1.61.0-llvm_selectInterleaveCount.patch  |  66 --
 dev-lang/rust/files/1.61.0-miri-cow.patch          |  98 ---
 dev-lang/rust/rust-1.59.0.ebuild                   | 707 --------------------
 dev-lang/rust/rust-1.60.0.ebuild                   | 714 --------------------
 dev-lang/rust/rust-1.61.0-r2.ebuild                | 733 --------------------
 dev-lang/rust/rust-1.62.0.ebuild                   | 737 ---------------------
 9 files changed, 3375 deletions(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1d7beced12a5daddbb6584f238c667fc80e6c11d

commit 1d7beced12a5daddbb6584f238c667fc80e6c11d
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2022-09-23 20:00:42 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2022-09-23 20:05:40 +0000

    dev-lang/rust-bin: drop 1.59.0, 1.60.0, 1.61.0, 1.62.0
    
    Bug: https://bugs.gentoo.org/870166
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 dev-lang/rust-bin/Manifest               | 134 -------------------
 dev-lang/rust-bin/rust-bin-1.59.0.ebuild | 214 -----------------------------
 dev-lang/rust-bin/rust-bin-1.60.0.ebuild | 219 ------------------------------
 dev-lang/rust-bin/rust-bin-1.61.0.ebuild | 223 -------------------------------
 dev-lang/rust-bin/rust-bin-1.62.0.ebuild | 221 ------------------------------
 5 files changed, 1011 deletions(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=afad1a3097b154fd4195834c2778bcbf71cc2167

commit afad1a3097b154fd4195834c2778bcbf71cc2167
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2022-09-23 19:59:48 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2022-09-23 20:05:27 +0000

    virtual/rust: drop 1.59.0, 1.60.0, 1.61.0, 1.62.0
    
    Bug: https://bugs.gentoo.org/870166
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 virtual/rust/rust-1.59.0.ebuild | 19 -------------------
 virtual/rust/rust-1.60.0.ebuild | 19 -------------------
 virtual/rust/rust-1.61.0.ebuild | 19 -------------------
 virtual/rust/rust-1.62.0.ebuild | 19 -------------------
 4 files changed, 76 deletions(-)
Comment 5 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-09-24 20:09:31 UTC
Thanks!
Comment 6 Larry the Git Cow gentoo-dev 2022-10-13 17:41:46 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=53f2e771432ee61187a0154f96250372f92d7712

commit 53f2e771432ee61187a0154f96250372f92d7712
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2022-10-13 17:40:47 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2022-10-13 17:41:02 +0000

    dev-lang/rust: drop 1.62.1, 1.63.0-r1
    
    Bug: https://bugs.gentoo.org/870166
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 dev-lang/rust/Manifest                             |  68 --
 .../files/1.61.0-gentoo-musl-target-specs.patch    | 166 -----
 dev-lang/rust/files/1.63.0-CVE-2022-36113.patch    |  48 --
 dev-lang/rust/files/1.63.0-CVE-2022-36114.patch    | 102 ---
 dev-lang/rust/rust-1.62.1.ebuild                   | 741 --------------------
 dev-lang/rust/rust-1.63.0-r1.ebuild                | 774 ---------------------
 6 files changed, 1899 deletions(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f4e0cde71804913b0c9754ce0a8ce72e6431fbe8

commit f4e0cde71804913b0c9754ce0a8ce72e6431fbe8
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2022-10-13 17:35:56 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2022-10-13 17:41:02 +0000

    dev-lang/rust-bin: drop 1.62.1, 1.63.0
    
    Bug: https://bugs.gentoo.org/870166
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 dev-lang/rust-bin/Manifest               |  68 ----------
 dev-lang/rust-bin/rust-bin-1.62.1.ebuild | 221 ------------------------------
 dev-lang/rust-bin/rust-bin-1.63.0.ebuild | 222 -------------------------------
 3 files changed, 511 deletions(-)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cbb188bf659435e9aff0cd41cbdafb80bc9ec295

commit cbb188bf659435e9aff0cd41cbdafb80bc9ec295
Author:     Georgy Yakovlev <gyakovlev@gentoo.org>
AuthorDate: 2022-10-13 17:35:06 +0000
Commit:     Georgy Yakovlev <gyakovlev@gentoo.org>
CommitDate: 2022-10-13 17:41:01 +0000

    virtual/rust: drop 1.62.1, 1.63.0
    
    Bug: https://bugs.gentoo.org/870166
    Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>

 virtual/rust/rust-1.62.1.ebuild | 19 -------------------
 virtual/rust/rust-1.63.0.ebuild | 19 -------------------
 2 files changed, 38 deletions(-)
Comment 7 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-10-13 17:55:51 UTC
Thanks!
Comment 8 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-10-14 03:20:46 UTC
GLSA request filed
Comment 9 Larry the Git Cow gentoo-dev 2022-10-16 14:46:24 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/data/glsa.git/commit/?id=cda5f646cd9bc370223b79be59deee389a0caeef

commit cda5f646cd9bc370223b79be59deee389a0caeef
Author:     GLSAMaker <glsamaker@gentoo.org>
AuthorDate: 2022-10-16 14:43:11 +0000
Commit:     John Helmert III <ajak@gentoo.org>
CommitDate: 2022-10-16 14:45:25 +0000

    [ GLSA 202210-09 ] Rust: Multiple Vulnerabilities
    
    Bug: https://bugs.gentoo.org/782367
    Bug: https://bugs.gentoo.org/807052
    Bug: https://bugs.gentoo.org/821157
    Bug: https://bugs.gentoo.org/831638
    Bug: https://bugs.gentoo.org/870166
    Signed-off-by: GLSAMaker <glsamaker@gentoo.org>
    Signed-off-by: John Helmert III <ajak@gentoo.org>

 glsa-202210-09.xml | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)
Comment 10 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-10-16 15:04:28 UTC
GLSA released, all done!
Comment 11 Luke-Jr 2022-10-25 20:10:25 UTC
Why was 1.63.0-r1 dropped [on non-riscv]? Didn't that have the security fixes? 1.64 requires 1.63 to build :/
Comment 12 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-10-25 21:47:35 UTC
(In reply to Luke-Jr from comment #11)
> Why was 1.63.0-r1 dropped [on non-riscv]? Didn't that have the security
> fixes? 1.64 requires 1.63 to build :/

If it wasn't vulnerable, that would make it unrelated to this bug, wouldn't it?