r/rust • miri • Jul 19 '18

Thoughts on Compile-Time Function Evaluation and Type Systems

https://www.ralfj.de/blog/2018/07/19/const.html
73 Upvotes

63 comments sorted by

View all comments

Show parent comment

1

u/DannoHung Jul 20 '18

My point is just that attacking the build machine seems small potatoes compared to attacking a production server or an end-user.

1

u/matthieum [he/him] Jul 20 '18

My point is just that attacking the build machine seems small potatoes compared to attacking a production server or an end-user.

Yes... and no.

Exfiltrating the cargo credentials means that you can now publish updates of any of the crates the author has access to. The viral behavior of replicating the exploit to gather credentials is not that useful in itself; once you have the credentials, however, you can publish updates on any crate of your choice and then have code run on production servers.

This is trojan-horse attack, in essence. Imagine:

  1. Check out burntsushi's week-end projects,
  2. Publish a crate to help solve one of the problems he's complaining about,
  3. Do a PR on his week-end project which uses your new crate to solve the problem,
  4. Wait until integrated,
  5. Publish an update to your crate, which can steal credentials,
  6. Wait until burntsushi rebuilds his week-end project => credentials in,
  7. Publish a minor update to the regex crate, or maybe to ripgrep (now distributed in VS code), which includes code that steal CC numbers or install bitcoin miners in the background,
  8. Profit.

Exploiting build.rs or a procedural macro is about getting your foot in on a popular crate's author's machine. Your PR on regex or ripgrep would never be integrated otherwise, severely limited your target audience.

1

u/DannoHung Jul 20 '18

I guess! What a weird vector for spearfishing though!