by superjared on 5/14/21, 2:12 PM with 75 comments
by the_duke on 5/14/21, 3:50 PM
This can be done even easier without users having to use a macro: with `build.rs` build scripts, which are run by default. So all you'd need is to compromise some popular dependency with a custom build.rs
Many other languages have the same (or at least similar) problem (Makefiles, npm hooks, ...)
There is an interesting proposal and prototype for compiling proc macros to WASM so they can be run in a sandbox: https://github.com/dtolnay/watt
But in the end it doesn't make that much difference: nothing prevents a random library from just reading your secrets and calling curl to send it to a server at runtime.
Build time execution is definitely an additional attack vector.
But if you use a third party dependency, you have to trust it or review all it's code for every version. There is no way around this, and it's true for any language.
by terseus on 5/14/21, 4:55 PM
The PoC doesn't even open a file, it just opens the directory. It's a pretty big difference, when you execute a build script you _expect_ to run code, when you open a directory in your editor you don't expect any side effect _at all_.
My guess is that since the proc_macros returns a TokenStream, rust-analyzer have no way to know what it provides except running it.
I'm not sure there's a solution for this that doesn't cripple macros in Rust, apart from being able to configure rust-analyzer to ignore the macros, which clearly limit its usefulness.
by kam on 5/14/21, 6:00 PM
by ngalstyan4 on 5/14/21, 4:08 PM
[1]: http://users.ece.cmu.edu/~ganger/712.fall02/papers/p761-thom...
by Jaygles on 5/14/21, 3:53 PM
by vlovich123 on 5/14/21, 6:15 PM
by mike-cardwell on 5/14/21, 5:06 PM
by greenshackle2 on 5/14/21, 3:57 PM
by duped on 5/14/21, 4:00 PM
by not2b on 5/14/21, 6:46 PM
by juancampa on 5/14/21, 6:14 PM
Just installing a relatively popular crate (say Hyper) makes you realize that all of your secret could have been stolen by any of the myriad of dependencies.
by rhooke on 5/14/21, 6:53 PM
I can't see a robust solution to this, though.
by akkartik on 5/15/21, 1:40 AM
by cryptonector on 5/14/21, 6:22 PM
by yannoninator on 5/14/21, 5:10 PM