From 0c235ed9b99a96ceb8dc6eab19cbc4f8fdb9454e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 13 May 2019 08:14:02 -0700 Subject: [PATCH 1/3] Destabilize the `Error::type_id` function This commit destabilizes the `Error::type_id` function in the standard library. This does so by effectively reverting #58048, restoring the `#[unstable]` attribute. The security mailing list has recently been notified of a vulnerability relating to the stabilization of this function. First stabilized in Rust 1.34.0, a stable function here allows users to implement a custom return value for this function: struct MyType; impl Error for MyType { fn type_id(&self) -> TypeId { // Enable safe casting to `String` by accident. TypeId::of::() } } This, when combined with the `Error::downcast` family of functions, allows safely casting a type to any other type, clearly a memory safety issue! A security announcement will be shortly posted to the security mailing list as well as the Rust Blog, and when those links are available they'll be filled in for this PR as well. This commit simply destabilizes the `Error::type_id` which, although breaking for users since Rust 1.34.0, is hoped to have little impact and has been deemed sufficient to mitigate this issue for the stable channel. The long-term fate of the `Error::type_id` API will be discussed at #60784. --- src/libstd/error.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libstd/error.rs b/src/libstd/error.rs index aec85b660cae0..41891e2a4c2d6 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -196,7 +196,10 @@ pub trait Error: Debug + Display { fn source(&self) -> Option<&(dyn Error + 'static)> { None } /// Gets the `TypeId` of `self` - #[stable(feature = "error_type_id", since = "1.34.0")] + #[doc(hidden)] + #[unstable(feature = "error_type_id", + reason = "this is memory unsafe to override in user code", + issue = "60784")] fn type_id(&self) -> TypeId where Self: 'static { TypeId::of::() } From 552774f5ccf2316236d3d4cf234251525ec074db Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 13 May 2019 17:30:14 +0200 Subject: [PATCH 2/3] add release notes for rust 1.34.2 --- RELEASES.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 3b4f4182702d1..48bd13105bbea 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,11 @@ +Version 1.34.2 (2019-05-14) +=========================== + +* [Destabilize the `Error::type_id` function due to a security + vulnerability][60785] + +[60785]: https://github.com/rust-lang/rust/pull/60785 + Version 1.34.1 (2019-04-25) =========================== From bc8787c998d8c4f411193733086954fb884e8470 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 13 May 2019 17:33:22 +0200 Subject: [PATCH 3/3] bump rust to 1.34.2 --- src/bootstrap/channel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/channel.rs b/src/bootstrap/channel.rs index d12094867b20b..89cc99728c54f 100644 --- a/src/bootstrap/channel.rs +++ b/src/bootstrap/channel.rs @@ -14,7 +14,7 @@ use crate::Build; use crate::config::Config; // The version number -pub const CFG_RELEASE_NUM: &str = "1.34.1"; +pub const CFG_RELEASE_NUM: &str = "1.34.2"; pub struct GitInfo { inner: Option,