|
diff --git a/src/tools/cargo/src/cargo/util/toml/mod.rs b/src/tools/cargo/src/cargo/util/toml/mod.rs |
|
--- a/src/tools/cargo/src/cargo/util/toml/mod.rs |
|
+++ b/src/tools/cargo/src/cargo/util/toml/mod.rs |
|
@@ -169,7 +169,15 @@ impl<'de> de::Deserialize<'de> for TomlDependency { |
|
where V: de::MapAccess<'de> |
|
{ |
|
let mvd = de::value::MapAccessDeserializer::new(map); |
|
- DetailedTomlDependency::deserialize(mvd).map(TomlDependency::Detailed) |
|
+ let dep = DetailedTomlDependency::deserialize(mvd).map(TomlDependency::Detailed); |
|
+ if let Ok(&TomlDependency::Detailed(ref dep)) = dep.as_ref() { |
|
+ if dep.package.is_some() { |
|
+ return Err(<V::Error as de::Error>::custom( |
|
+ "the package subkey is not allowed due to CVE-2019-16760" |
|
+ )); |
|
+ } |
|
+ } |
|
+ dep |
|
} |
|
} |
|
|
|
@@ -187,6 +195,7 @@ pub struct DetailedTomlDependency { |
|
git: Option<String>, |
|
branch: Option<String>, |
|
tag: Option<String>, |
|
+ package: Option<String>, |
|
rev: Option<String>, |
|
features: Option<Vec<String>>, |
|
optional: Option<bool>, |
|
diff --git a/src/tools/cargo/tests/cve_2019_16760.rs b/src/tools/cargo/tests/cve_2019_16760.rs |
|
new file mode 100644 |
|
--- /dev/null |
|
+++ b/src/tools/cargo/tests/cve_2019_16760.rs |
|
@@ -0,0 +1,28 @@ |
|
+extern crate cargotest; |
|
+extern crate hamcrest; |
|
+ |
|
+use cargotest::support::{project, execs}; |
|
+use hamcrest::assert_that; |
|
+ |
|
+#[test] |
|
+fn test_cve_2019_16760() { |
|
+ let pb = project("foo") |
|
+ .file("Cargo.toml", r#" |
|
+ [package] |
|
+ name = "foo" |
|
+ version = "0.0.0" |
|
+ authors = [] |
|
+ |
|
+ [dependencies] |
|
+ lazy_static1 = { version = "1", package = "lazy_static" } |
|
+ "#) |
|
+ .file("src/lib.rs", ""); |
|
+ let p = pb.build(); |
|
+ |
|
+ assert_that(p.cargo("check"), execs().with_status(101).with_stderr("\ |
|
+error: failed to parse manifest at `[..]` |
|
+ |
|
+Caused by: |
|
+ the package subkey is not allowed due to CVE-2019-16760 for key `dependencies.lazy_static1` |
|
+")); |
|
+} |
|
|