Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The problem with macros in Rust is that they have full access to your computer. This is literally an invitation for exploitation. I think we will see the attacks based on this vulnerability once Rust becomes more popular.


`make myfile.mk` -> pwned

I do share the sentiment - and complain about this frequently - but any environment with build scripts can wreck your computer. Encrypt what you can, I guess, but software engineering is an extremely dangerous job wrt security.


Its slightly more insidious: merely opening it in a text editor (assuming it has some form of lsp) could pwn you. Rust definitely isn't alone in this. Quite a few of the editors I know will run in a dumbed down mode when opening an unknown repo.


It's even more insidious than that! Even navigating to a directory in a checkout of a hostile git repo can run arbitrary code if your shell displays git info (what branch you're on, etc).


Do other languages have a security model for this? I've always assumed that building arbitrary code could execute something in most languages.

I think using something like the pledge syscall from OpenBSD in the compiler could be useful. That way, it's controlled at the process level which things can be accessed on the system.


C macros and gcc do not allow to run arbitrary code during compilation.


The C standard is accomodating as always: https://feross.org/gcc-ownage/


In practice every C build system already does.


There’s already a runtime for sandboxing macros with wasm: https://github.com/dtolnay/watt


So you need to use hacks, like compiling code into a web-browser language and messing with config files instead of having security out-of-box?

But thank you for letting me learn something useful.


It’s a demonstration. wasm is a portable ISA more than a “language”. Surely it makes sense to build things incrementally, in layers? https://internals.rust-lang.org/t/pre-rfc-sandboxed-determin...

But go off, king.


Proc macros. Declarative macros do not.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: