Security advisory: malicious crate rustdecimal

853 views
Skip to first unread message

Pietro Albini

unread,
May 10, 2022, 12:00:10 PM5/10/22
to rustlang-securi...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

The Rust Security Response WG and the crates.io team [were notified][1] on
2022-05-02 of the existence of the malicious crate `rustdecimal`, which
contained malware. The crate name was intentionally similar to the name of the
popular [`rust_decimal`][2] crate, hoping that potential victims would misspell
its name (an attack called "typosquatting").

To protect the security of the ecosystem, the crates.io team permanently
removed the crate from the registry as soon as it was made aware of the
malware. An analysis of all the crates on crates.io was also performed, and no
other crate with similar code patterns was found.

Keep in mind that the [`rust_decimal`][2] crate was **not** compromised, and it
is still safe to use.

## Analysis of the crate

The crate had less than 500 downloads since its first release on 2022-03-25,
and no crates on the crates.io registry depended on it.

The crate contained identical source code and functionality as the legit
`rust_decimal` crate, except for the `Decimal::new` function.

When the function was called, it checked whether the `GITLAB_CI` environment
variable was set, and if so it downloaded a binary payload into
`/tmp/git-updater.bin` and executed it. The binary payload supported both Linux
and macOS, but not for Windows.

An analysis of the binary payload was not possible, as the download URL didn't
work anymore when the analysis was performed.

## Recommendations

If your project or organization is running GitLab CI, we strongly recommend
checking whether your project or one of its dependencies depended on the
`rustdecimal` crate, starting from 2022-03-25. If you notice a dependency on
that crate, you should consider your CI environment to be compromised.

In general, we recommend regularly auditing your dependencies, and only
depending on crates whose author you trust. If you notice any suspicious
behavior in a crate's source code please follow [the Rust security
policy][3] and report it to the Rust Security Response WG.

## Acknowledgements

We want to thank GitHub user [`@safinaskar`][4] for identifying the
malicious crate in [this GitHub issue][1].

[1]: https://github.com/paupino/rust-decimal/issues/514#issuecomment-1115408888
[2]: https://crates.io/crates/rust_decimal
[3]: https://www.rust-lang.org/policies/security
[4]: https://github.com/safinaskar
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEV2nIi/XdPRSiNKes77mGCudSDawFAmJ6YBUACgkQ77mGCudS
DawfUw/+IKjWavAL1HdXJLgMTQCJKEbzQ8y9z44Alhqt20JiGBLpsdsQgHqh2iPC
mu8w4DZ6u3/VLQ5uGFTk11q2QA/oGAJVJARzFH9wbvjDB0hUY/c5I61uHLZqVf1I
2vnWUNNt20eDS5Ojy3pTPG2WecdkGPIrUUL1LJ13up8Dn2a/pfrN88D+O5oZcuyC
aHTIwWnSzCtOxVVBzAa/ti7DzddkQ6flGb64j+3YrBTsztwgmvEJMGhffoiQIFa5
4fxtoQ5xRJYOwbG9J4DCEI7w0o+F5eiIq/shAfQ8k5gEdleOG4x3vwJha53wredg
oYoEm/nVO4QNQmjCUvOUyrn9P4L0btfMwKWUZdiH8i416upZCNMDMfdD/cx63+94
Gz5Pn5++btTd5Gps8MQJy01kZIDJ3tL3KXrDYoK5go+MStuWSek5QLL4XCpnW3HS
jj1MXiEeGX9HpRBmCmHsDiiLsEbkqR4CMAB7heyd2ektnmc0B2veYHmCqhYLhVUp
LnzfyOeftxpIEioYVg5XlDwBIsVYD87dEnfhdLR9OoGup4rmhEVYj6C+N/WeWNzk
fJ2rPZZDN3n2oNSztTJ2N8LwCgGbpMgpaQh2ZyO5/Fs4mbZcRA0PzPj1y17CBXB9
iM9XuypjiyoI2DdP+pRlMD7jFmqa/Ek+V/KtdfEdg1YTcBRtnOc=
=xyNH
-----END PGP SIGNATURE-----
announcement.txt.asc
Reply all
Reply to author
Forward
0 new messages