Files
2025-10-27 16:49:06 +00:00

72 lines
6.0 KiB
JSON

[
{
"id": "CVE-2018-1000622",
"modified": "2020-10-02T01:29:11Z",
"published": "2018-07-05T12:00:00Z",
"aliases": [],
"related": [],
"summary": "Uncontrolled search path element vulnerability in rustdoc plugins",
"details": "Rustdoc, if not passed the `--plugin-path` argument, defaults to\n`/tmp/rustdoc/plugins`. `/tmp` is world-writable on many systems, and so an\nattacker could craft a malicious plugin, place it in that directory, and the\nvictim would end up executing their code. This only occurs when the\n`--plugin` argument is also passed. If you're not using that argument, then\nthe loading, and therefore the bug, will not happen.\n\nBecause this feature is very difficult to use, and has been deprecated for\nalmost a year[2] with no comments on its usage, we don't expect this to\naffect many users. For more details, read on.\n\n## Background\n\nRustdoc has a \"plugins\" feature that lets you extend rustdoc. To write a\nplugin, you create a library with a specific exposed symbol. You instruct\nrustdoc to use this plugin, and it will load it, and execute the function as\na callback to modify rustdoc's AST.\n\nThis feature is quite hard to use, because the function needs to take as\ninput and return as output Rustdoc's AST type. The Rust project does not ship\na copy of `librustdoc` to end users, and so they would have to synthesize\nthis type on their own. Furthermore, Rust's ABI is unstable, and so\ndynamically loading a plugin is only guaranteed to work if the plugin is\ncompiled with the same compiler revision as the rustdoc that you're using.\nBeyond that, the feature and how to use it are completely undocumented.\n\nGiven all of this, we're not aware of any usage of plugins in the wild,\nthough the functionality still exists in the codebase.\n\n## Description of the attack\n\nIf you pass the `--plugins` parameter, let's say with \"foo\", and *do not*\npass the `--plugin-path` parameter, rustdoc will look for the \"foo\" plugin\nin /tmp/rustdoc/plugins. Given that /tmp is world-writable on many systems,\nan attacker with access to your machine could place a maliciously crafted\nplugin into /tmp/rustdoc/plugins, and rustdoc would then load the plugin,\nand execute the attacker's callback, running arbitrary Rust code as your\nuser instead of theirs.\n\n## Affected Versions\n\nThis functionality was introduced into rustdoc on December 31, 2013, in commit\n14f59e890207f3b7a70bcfffaea7ad8865604111 [3]. That change was to rename\n`/tmp/rustdoc_ng/plugins` to `/tmp/rustdoc/plugins`; The addition of this\nsearch path generally came with the first commit to this iteration of rustdoc,\non September 22, 2013, in commit 7b24efd6f333620ed2559d70b32da8f6f9957385 [4].\n\n## Mitigations\n\nTo prevent this bug from happening on any version of Rust, you can always\npass the `--plugin-path` flag to control the path. This only applies if\nyou use the `--plugin` flag in the first place.\n\nFor Rust 1.27, we'll be releasing a 1.27.1 on Tuesday with the fix, which\nconsists of requiring `--plugin-path` to be passed whenever `--plugin`\nis passed.\n\nWe will not be releasing our own fixes for previous versions of Rust, given\nthe low severity and impact of this bug. The patch to fix 1.27 should be\ntrivially applicable to previous versions, as this code has not changed in\na very long time. The patch is included at the end of this email. If you\nneed assistance patching an older version of Rust on your own, please reach\nout to Steve Klabnik, st...@steveklabnik.com, and he'll be happy to help.\n\nOn beta and nightly we will be removing plugins entirely.\n\n## Timeline of events\n\n* Tue, Jul 3, 2018 at 11:57 PM UTC - Bug reported to security@rust-lang.org\n* Tue, Jul 3, 2018 at 12:13 PM UTC - Steve responds, confirming the bug\n* Weds, Jul 4, 2018 - Steve works up an initial patch\n* Thu, Jul 5, 2018 at 6:00 PM UTC - Rust team decides to not embargo this bug\n* Fri, Jul 6, 2018 at 12:38 AM - Final patch created after feedback from Red Hat\n\n## Acknowledgements\n\nThanks to Red Hat Product Security, which found this bug. And specifically to\nJosh Stone, who took their findings and reported it to us in accordance with\nour security policy https://www.rust-lang.org/security.html, as well as providing\nfeedback on the patch itself. You can find their bug at [5].\n\n[1]: https://cwe.mitre.org/data/definitions/427.html\n[2]: https://github.com/rust-lang/rust/issues/44136\n[3]: https://github.com/rust-lang/rust/commit/14f59e890207f3b7a70bcfffaea7ad8865604111\n[4]: https://github.com/rust-lang/rust/commit/7b24efd6f333620ed2559d70b32da8f6f9957385\n[5]: https://bugzilla.redhat.com/show_bug.cgi?id=1597063",
"severity": [
{
"type": "CVSS_V3",
"score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
}
],
"affected": [
{
"package": {
"ecosystem": "crates.io",
"name": "rustdoc",
"purl": "pkg:cargo/rustdoc"
},
"ecosystem_specific": {
"affects": {
"arch": [],
"os": [],
"functions": []
},
"affected_functions": null
},
"database_specific": {
"categories": [
"code-execution"
],
"cvss": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H",
"informational": null
},
"ranges": [
{
"type": "SEMVER",
"events": [
{
"introduced": "0.0.0-0"
},
{
"fixed": "1.27.1-0"
}
]
}
],
"versions": []
}
],
"references": [
{
"type": "PACKAGE",
"url": "https://crates.io/crates/rustdoc"
},
{
"type": "ADVISORY",
"url": "https://rustsec.org/advisories/CVE-2018-1000622.html"
},
{
"type": "WEB",
"url": "https://groups.google.com/forum/#!topic/rustlang-security-announcements/4ybxYLTtXuM"
}
],
"database_specific": {
"license": "CC0-1.0"
}
}
]