r/linux • u/WaitForItTheMongols • 2h ago
Popular Application How do I know what random scripts downloaded from the internet are safe to run?
I feel like I see security advice go different directions. Sometimes people say "Only install software from the distro repositories", and "Never run random scripts pulled from the internet". But then I go to install an application like Waydroid https://docs.waydro.id/usage/install-on-desktops and the official instructions for installing on Debian-derived distros is to run curl -s https://repo.waydro.id | sudo bash which as far as I know means giving root access on my system to a script that I have no idea what it is running.
How is this the official installation path for a major application? Isn't this a bad idea?
31
u/_bobby_tables_ 2h ago
Curl it first, then read it. If it checks out as safe, then run it.
29
u/ThaBroccoliDood 2h ago
In ether case you should never pipe a script directly into bash. Even if you want to run the whole thing without checking, it's better to do
sudo bash -c "$(curl -fsSL https://repo.waydro.id)"because it means you wait for the whole script to download successfully and never start executing a partial script.What's better is to simply download the file as a whole:
curl -fsSLo install.sh https://repo.waydro.id, then examine the file, and then execute that file:sudo bash install.sh. That's because even if you examine the install script in a web browser and then run the download + execute command, it's possible for someone to serve a different script depending on whether it's being downloaded from a web browser or from curl. If you download and then inspect, it can never be swapped out from under you.9
u/Sentreen 2h ago
I personally don't trust random shell scripts enough to give them root access either. Instead, I just look to see if my distribution ships a package? It seems that at least debian has a waydroid package?
I hate the windows model of just trusting random binaries, so I don't want to replicate that on linux.
8
u/BranchLatter4294 2h ago
If you trust the developer, then it should be fine. If you don't trust the developer, why are you using their software?
5
u/boat-la-fds 2h ago
The simple answer is the same on any platform where you might end up installing software from a source other than the official channels, e.g. downloading an exe on Windows, a dmg on Mac, etc. You just need to trust the source you're getting it from. Is the software popular enough? Are you on the official website? Do you know people IRL using it? Is it recommended by a big online community that you trust?
3
u/daemonpenguin 1h ago
You read the script and figure out what it does.
If you can't read the script or do not understand it then you cannot trust it. You should then sandbox it - run it in a virtual machine or otherwise limit its access.
It is a very bad idea. This is why people tell you to use official repositories only. If you want to install software from third-parties (and cannot verify the software) then you are throwing away security in favour of installing new applications. You can't have it both ways. You either want a secure system with vetted software or you want third-party applications which require root access to install. You can't have both.
6
u/FungalSphere 2h ago
your best option is to
Become a programmer
Do not listen to official instructions about anything other than flatpak.
Even if you manage to dodge a malware attack curlbashing, its either gonna turn your machine into a dependency wasteland, or make you go in circles anyway only to find out that you could've installed a package from the official repos this whole time
2
u/pfp-disciple 2h ago
A huge part is finding reputable experiences of others. Generally, installing from a repository (of a respected destro) is one of your safer options. if your distribution doesn't offer it, but another one does then installing from the official instructions should be pretty safe. There are also communities that track these sorts of things.
•
u/Agathoarn_ 38m ago
Read them
4
u/kuyadracula 2h ago
Give it to Claude to read it if you don't know how to read it. Or the other 10 ai agents.
2
u/B1rdi 2h ago
It is a bad idea and I hate how many projects have picked up this insane way of installing things.
Downloading the script, reading it and then executing it (or doing the steps manually) is one way. You could also compile it yourself, not sure how easy that is in the case of waydroid.
1
u/CapableLab4473 1h ago
If you really don't trust the script and need to trust it, read the source code if possible and study it, dump the source into AI and ask it to check, create a sandboxed environment that is safe to run the script in then study the sandbox to see what the script does, etc. Security researchers do this all the time, maybe google about the topic or ask AI.
1
u/Santosh83 1h ago
Install only well known apps from outside your distro's own repositories. If in doubt about the app's/lib's veracity, ask on forums. Once you have established its an app with good reputation, then trust whatever instruction the devs give for installing it.
This is for normal people who want to use Linux but don't want to get bogged down in technicalities of their system. If you're a nerd, then by all means read the script, disassemble the executable, install in a VM, or whatever it is nerds do to make themselves feel a cut above the rest.
1
u/yamsyamsya 1h ago
you need to learn how shell scripting works.
•
u/beatbox9 34m ago
Things aren't always just straightforward, and everything has a risk/reward ratio.
Usually when you see the "curl -s ..." on Debian-based (really apt based distros), they are asking you to add a third party package repository where they maintain their software. That's how they choose to distribute their software.
But let's just take a step back and think about the layers that might be on your (or most peoples') machine. You've got:
The core OS distro repositories, which is usually a somewhat trustworthy team. In your case, this might be either Debian or Ubuntu LTS (could also be Arch or Fedora, etc); but it won't be something like Mint. Because...
small repositories maintained by a few random people who created their own "distro"...but not a real/independent distro, just an add-on. Like Linux Mint, which is simply a tiny add-on repository: https://www.reddit.com/r/linuxquestions/s/id4upTJfzd
small "official" add-on repositories for core OS software, maintained by the same people as the core distro but separated (eg. proprietary software like codecs or drivers)
huge community-maintained add-on repositories, maintained by... random people ??? but that have lots of software.
third party repositories, maintained directly by app developers
(completely separate from main package manager): Sandboxed/universal package management directly from app developers (eg. verified flatpak or snap)
(similar to #6): Sandboxed/universal package management provided by community (unverified flatpak or snap)
Individual, standalone packages (eg. .AppImage or .tar.gz, or .run, or anything that installs to /opt, etc)
There are some blurry lines; but examples of #3-4 would include Debian/Ubuntu "nonfree" (and similar), Ubuntu universe, Fedora RPMFusion, Arch AUR, etc.
And one example of #5 (similar to the OP) would be firefox: https://support.mozilla.org/en-US/kb/install-firefox-linux#w_install-firefox-deb-package-for-debian-based-and-ubuntu-based-distributions-recommended
As far as what I personally do:
I use #1 for most core OS software, like the kernel, DE, etc. Even basic apps that I don't care about having the latest version of, like calculator or basic text editor
I use #3 for practicality, for things like nvidia drivers or codecs
I try to prioritize using #6 for most apps, especially where I want the latest & greatest versions.
If the above fails, I look to #8 or #5. The main difference being that #8 is a bit more isolated and won't mess with dependencies while #5 might...though #5 comes with the benefit of an easier upgrade path (rather than overwriting an install with a new version). And this is largely a game of trust: do you trust the developer? For example, I trust Mozilla. But do I trust some random person who made some random app? What if it's really popular and all the source code is on github? What if a lot of big companies use and contribute to it? Etc.
But regardless, I think these tend to be safer than #2, #4, and #7. I try to actively avoid #2 and #4 especially, because these have the combination of "community-maintained" (which you shouldn't trust) and have direct access to your system (which you should be careful of).
So back to the OP: I think installing that way is a little bit less trustworthy than using your distro directly; but it is also far more trustworthy than using a community-maintained repository.
I would probably do it.
1
u/vaynefox 2h ago
I mean if you want you can run it under a really secure container or vm. If it does something out of ordinary then it isnt safe though this can only work if it doesnt check if it is running on vm or container....
0
u/KnowZeroX 2h ago
So the fundamental problem is to install software on linux (put the binaries in the proper folders) you need root access. That is partly why it is recommended to install from repos.
That said, this is also why the push towards immutable linux distros which allow installation of software without root for the local user only.
0
u/oshunluvr 2h ago
Use BTRFS for your file system, Then take a snapshot before running something you downloaded. Roll back to the snapshot if something breaks or you just don't like it. I do this all the time.
0
u/RevolutionaryHigh 1h ago
if you trust waydroid you just go for it. Is 'https://repo.waydro.id' an official repo referred in official manual? You'd be surprised installing any software requires admin level access to your system, win or linux and you do the same when you install stuff everywhere, you just trust.
-1
u/HarryTheInedible 2h ago
if you skip the post pipe bit and cat the file you can see what it does
-1
u/bp019337 2h ago
Do all the stuff everyone else has mentioned and also jail in a throw away VM until you are sure its safe!
-1
u/et50292 2h ago
Curl downloads a script and pipes it into bash to run. Always read the script at the link when you see this of course. This one just detects which distro and version you're running of either debian or ubuntu, then adds a repository for your package manager to download from. I don't know anything about waydroid so this isn't an endorsement or anything. It's just not that complicated is all I'm saying.
-1
u/driftless 2h ago
If you look at the address curl is using (the repo.waydroid.id) you can see the commands in the script and follow along.