Live data from Hacker News

Arbitrary code execution during compilation – rust

github.com

1–10 of 58 posts

Re: Arbitrary code execution during compilation – rust

#3
We must start systematically sandboxing developer tools. It's scary how sensitive dev workspaces are, and how much random crap we run. After decades of training the world's parents and grandparents not to download and run programs from untrusted sources we now routinely do it ourselves.

Re: Arbitrary code execution during compilation – rust

#5
Afaik you don’t even need to use macros for this, can’t you just put a build.rs file in the crate and it will execute on build?

Almost all build/project systems I know have this functionality simply because execution of arbitrary programs is too useful to go without. Any C# project (.csproj) for example can include a task that eats your homework.

It’s scary but I don’t see a solution like sandboxing being very easy to retrofit either.

Re: Arbitrary code execution during compilation – rust

#7
Old, it's not new that macro expansions, build files and build tooling can do that. (And if we sandboxed that, you still get infected release builds, check your deps..)

See NPM installations and "please sponsor this project" messages, which can also give you a virus.

Re: Arbitrary code execution during compilation – rust

#8
post #6

I would expect any sufficiently powerful macro system would have to be this way. Don't most editors ask you whether or not you want to trust some code before opening it with full privileges anyway?

Yes, which was kind of a result of people making a fuss about this a year or two ago iirc.

Re: Arbitrary code execution during compilation – rust

#9

I filed a issue on `rust-analyzer` and apparently it is by design - https://github.com/rust-lang/rust-analyzer/issues/14375

I mean it’s fairly obvious. You can do this through build.rs files as well.

There was talk about trying to compile proc macros to WASM and run them sandboxed in the compiler. Not sure what happened to that RFC (by dtolnay?)

Re: Arbitrary code execution during compilation – rust

#10
post #5

Afaik you don’t even need to use macros for this, can’t you just put a build.rs file in the crate and it will execute on build? Almost all build/project systems I know have this functionality simply because execution of arbitrary programs is too useful to go without. Any C# project (.csproj) for example can include a task that eats your homework. It’s scary but I don’t see a solution like sandboxing being very easy t…

The mistake is that arbitrary transformations != arbitrary code.

I want the build process to be able to generate arbitrary code based on the inputs given to it from the source control — but nothing else. No reaching out to HTTP command and control endpoints, making database calls, or deleting my home directory.

It’s not just because of security. Security is a side-benefit here.

The real benefit is that unrestricted build processes cannot be versioned with source control. If the build process can “reach out” and pull in data from external sources, then it will always use the “latest” version, not the version in that branch or commit.

It’s about being hygienic.

Post reply on HN