News for hackers. Stuff that matters.
Re:Using Rust Macros to exfiltrate secrets by db48x on Friday May 14, 2021 @11:56AM (#27155616)
Also, it’s not a new problem; a Makefile or configure script can run arbitrary code as well.
Re:Using Rust Macros to exfiltrate secrets by mprovost on Friday May 14, 2021 @11:59AM (#27155678)
Yes this has always made me wonder about the pushback you see with the recent move towards curl | sh installers. In the past you'd download a random tarball and then run ./configure which could do anything.
Re:Using Rust Macros to exfiltrate secrets by db48x on Friday May 14, 2021 @12:24PM (#27156042)
There are three main problems with curl | sh: the file one the web server could be replaced without modifying the source in version control (and unlike a git checkout, the hash of the file is not verified), you can’t read the code before it runs, and curl could fail to download the whole file.

Of course, I bet a lot of people don’t bother to read any of the source code of a program that they’ve downloaded anyway.

Re:Using Rust Macros to exfiltrate secrets by slimsag on Friday May 14, 2021 @01:11PM (#27156748)
Downloading a tarball and running ./configure from it (pretty dang common) also does not have the changes checked into version control, nor the hash verified.

Same is true of `npm install`, deb/rpm/etc packages, etc: you don't have proof what was distributed to you matches up with what was in VCS.

You can read the code before it runs and solve the "curl could fail" theoretical arguments by just.. removing `| sh` and examining + running yourself.

Re:Using Rust Macros to exfiltrate secrets by db48x on Friday May 14, 2021 @05:21PM (#27159845)
I agree; distribution via git is better in many ways than distribution via tarball. I believe that npm and similar package managers mostly pull code from git repositories. Of course, even then you might want to double check that the package name hasn’t been hijacked or sold off.

Of course you can break the curl|sh into separate steps and check that the script isn’t malicious before you run it, but the fact that you have to do that makes it a bad idea to distribute software this way. If you were told to download an installation script, inspect it, and only then to run it then there would be less of a problem. curl|sh is yet another sign that we so often prefer convenience over reliability and safety.

Re:Using Rust Macros to exfiltrate secrets by deadbunny on Sunday May 16, 2021 @02:46AM (#27171726)
Debian are working on reproduceable builds for apt. Not there yet but going in the right direction.

https://wiki.debian.org/ReproducibleBuilds

Re:Using Rust Macros to exfiltrate secrets by fiddlerwoaroof on Friday May 14, 2021 @01:08PM (#27156717)
You can solve the third problem by declaring a shell function `install` that is run at the send of the script. The first problem is a problem but, as far as I know, most language package managers don’t verify provenance anyway: yarn install foo can perform arbitrary side-effects either directly or through its transitive dependencies.
Re:Using Rust Macros to exfiltrate secrets by mprovost on Friday May 14, 2021 @01:09PM (#27156723)
You can break the pipe and curl the file first, read it, and then run it. But I doubt that anyone ever reads through the thousands of lines of m4 that come with a typical program that uses autoconf either.
Re:Using Rust Macros to exfiltrate secrets by db48x on Friday May 14, 2021 @05:11PM (#27159759)
If the project uses Autoconf/Automake, then you can just read the .in files instead. If they include anything unexpected, then it will be pretty obvious (since anything unexpected will be a lot more complicated–looking than anything normal). But if they do include a bunch of custom m4 files, then you’re going to be spending more time on it than you would want.
Re:Using Rust Macros to exfiltrate secrets by parhamn on Friday May 14, 2021 @12:44PM (#27156357)
Citation needed. Show me a Makefile + IDE combination that executed code by simply opening a file. I think you’re missing the language server part of this.
Re:Using Rust Macros to exfiltrate secrets by efaref on Friday May 14, 2021 @01:15PM (#27156830)
IntelliJ with "Build in background" enabled?

https://www.jetbrains.com/help/idea/executing-build-file-in-...

Re:Using Rust Macros to exfiltrate secrets by remram on Friday May 14, 2021 @01:25PM (#27157018)
bash autocompletion will run arbitrary code from a Makefile. I wouldn't be surprised if many editors do too.
Re:Using Rust Macros to exfiltrate secrets by mjw1007 on Friday May 14, 2021 @01:53PM (#27157424)
I think programmers' editors in general have treated "automatically run arbitrary code supplied by files you're editing" seriously as a security vulnerability since sometime around 2000.

(For example, Emacs realised that 'local eval' wasn't a good thing to have enabled globally in Emacs 19, in 1994, and spent the next decade or more closing many other loopholes involving local variables specified directly in files.)

If modern editors and IDEs are no longer thinking that way, I think that's a mistake.

Re:Using Rust Macros to exfiltrate secrets by VWWHFSfQ on Friday May 14, 2021 @01:17PM (#27156851)
Does opening an android project in android studio implicitly run any of the code in the project? I'm guessing it does, because the ide seems to be very busy all the time, even when idle
Re:Using Rust Macros to exfiltrate secrets by Nullabillity on Friday May 14, 2021 @01:43PM (#27157292)
build.gradle can contain arbitrary Groovy code with full system access, and needs to be executed to figure out the project structure.
Re:Using Rust Macros to exfiltrate secrets by j4yav on Friday May 14, 2021 @01:07PM (#27156679)
Apart from running make which of course runs the makefile, under what scenario does viewing a makefile run it?
Re:Using Rust Macros to exfiltrate secrets by remram on Friday May 14, 2021 @01:22PM (#27156951)
Makefiles can actually be quite dynamic, so a program merely trying to figure out the list of target has to execute code. For example put this in a Makefile and do `make <TAB>`, the file will be created (no need to press enter):

    VALUE := $(shell touch /tmp/something)
Re:Using Rust Macros to exfiltrate secrets by JNRowe on Saturday May 15, 2021 @06:02AM (#27163884)
FWIW, while both bash and fish completion execute "make -n" for tab completion that isn't the case for zsh. zsh uses an internal parser for makefiles¹, and as such won't execute the shell function or recipes that use the + prefix.

¹ https://github.com/zsh-users/zsh/blob/master/Completion/Unix...

Re:Using Rust Macros to exfiltrate secrets by efaref on Friday May 14, 2021 @01:12PM (#27156769)
You're not just viewing it. You're opening it in an IDE which compiles it behind the scenes for you.

Many IDEs also do this for other languages (e.g. by running make), and the same problem applies.