|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: crates.io security advisory |
| 4 | +author: Rust Security Response WG |
| 5 | +--- |
| 6 | + |
| 7 | +This is a cross-post of [the official security advisory][ml]. The official post |
| 8 | +contains a signed version with our PGP key, as well. |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +The Rust Security Response Working Group was recently notified of a security |
| 13 | +issue affecting token generation in the [crates.io] web application, and while |
| 14 | +investigated that issue we discovered an additional vulnerability affecting |
| 15 | +crates.io API tokens. |
| 16 | + |
| 17 | +We have no evidence of this being exploited in the wild, but out of an |
| 18 | +abundance of caution we opted to revoke all existing API keys. You can generate |
| 19 | +a new one at [crates.io/me]. |
| 20 | + |
| 21 | +## Overview |
| 22 | + |
| 23 | +Until recently, API keys for [crates.io] were generated using the PostgreSQL |
| 24 | +random function, which is not a cryptographically secure random number |
| 25 | +generator. This means that in theory, an attacker could observe enough random |
| 26 | +values to determine the internal state of the random number generator, and use |
| 27 | +this information to determine previously created API keys up to the last |
| 28 | +database server reboot. |
| 29 | + |
| 30 | +As part of the investigation for this, we also found that API keys were being |
| 31 | +stored in plain text. This would mean if our database were somehow compromised |
| 32 | +the attacker would be have API access for all current tokens. |
| 33 | + |
| 34 | +## Mitigations |
| 35 | + |
| 36 | +We deployed a code change to production to use a cryptographically secure |
| 37 | +random number generator, and we implemented hashing for storing tokens in the |
| 38 | +database. |
| 39 | + |
| 40 | +Exploiting either issue would be incredibly impractical in practice, and we've |
| 41 | +found no evidence of this being exploited in the wild. However, out of an |
| 42 | +abundance of caution, we've opted to revoke all existing API keys. You can |
| 43 | +generate a new API key by visiting [crates.io/me]. We apologize for any |
| 44 | +inconvenience this causes. |
| 45 | + |
| 46 | +## Acknowledgements |
| 47 | + |
| 48 | +Thanks to [Jacob Hoffman-Andrews] for responsibly disclosing the random number |
| 49 | +generator issue according to [our security policy][policy]. Thanks to [Siân |
| 50 | +Griffin] and [Justin Geibel] from the crates.io team for helping the Security |
| 51 | +Response WG addressing both of the issues. Thanks to [Pietro Albini] from the |
| 52 | +Security Response WG for coordinating the work on this vulnerability. |
| 53 | + |
| 54 | +## Timeline of events |
| 55 | + |
| 56 | +All times are listed in UTC. |
| 57 | + |
| 58 | +- 2020-07-11 17:43 - The issue is reported to [security@rust-lang.org] |
| 59 | +- 2020-07-11 20:56 - The issue is acknowledged, the leads of the crates.io team |
| 60 | + are looped in |
| 61 | +- 2020-07-11 23:48 - The issue is confirmed and a planned fix is agreed on |
| 62 | +- 2020-07-13 08:00 - The development of the fix is started |
| 63 | +- 2020-07-14 12:53 - The fix is tested on the staging environment |
| 64 | +- 2020-07-14 19:03 - The fix is deployed, existing tokens are revoked, and the |
| 65 | + issue is disclosed publicly |
| 66 | + |
| 67 | +[ml]: https://groups.google.com/forum/?oldui=1#!topic/rustlang-security-announcements/wc5d_Qq35RA |
| 68 | +[policy]: https://www.rust-lang.org/policies/security |
| 69 | +[security@rust-lang.org]: mailto:security@rust-lang.org |
| 70 | +[crates.io]: https://crates.io |
| 71 | +[crates.io/me]: https://crates.io/me |
| 72 | +[Jacob Hoffman-Andrews]: https://github.com/jsha |
| 73 | +[Siân Griffin]: https://github.com/sgrif |
| 74 | +[Justin Geibel]: https://github.com/jtgeibel |
| 75 | +[Pietro Albini]: https://github.com/pietroalbini |
0 commit comments