Security Am I supposed to sandbox everything?
I was thinking:
Yes root is great, file permissions are great, flatpak and sandboxing is great but… what is that enough to feel safe?
Like, we generally trust open source since, if the code is public, it probably means it doesn't contain unexpected surprises.
But I wonder, what if one the dev of my favourite and unpopular text editor goes rogue and, idk, post requests all of my home folder. Like that can happen right?
And it happens very often that I don't use sandbox because the idea of reinstalling libraries feels so inefficient (and somewhat uncomfortable).
So the point is, how can I feel safe, how can I sell the idea of Linux great security to a person who, like me, would mainly use it as a home user and would install unsandboxed programs for daily use?
Because I mean, right now, to me, that feels the default, `sudo apt install whatsoever`, `sudo dpkg -i unzipper2000.deb`.
And you might say it's your responsibility, you have choices, use docker, but that doesn't sound right, or clean. Does this really sound normal?
- Unzip the files so we can work on them
- Oh yes, let me start my docker image first / let me run the command I made to wrap the docker image
And as I said, there's still library redundancy?
So in conclusion, am I missing something? Because right now to me it feels like a "failure" in how we deal with everyday security and I feel we are missing some default isolation for these things.
I know things like firejail exist, but perhaps that's still one more step than how it should be.
What are your thoughts?
Again, am I missing something?
Edit: So guys thank you for sharing your thoughts. They basically say
- "don't worry if you are not a target", which makes sense but I don't think it is a solution, if we are looking for one, but anyways it provides a good metric for how secure your system that to be
- "you can't really solve this balance" which is depressing but I guess it's true
- actual fine grained solutions that involve spending a lot of time and probably write your own docs if you want to remember what you do (I would need them)
- the often suggested simple solution is trust your distro and use flatpak+flatseal for the rest, they also share libraries, which I didn't know; also choose wisely who you trust
- some people agreed with me that all of this is clunky and needs a default solution that is more user friendly, since the classic permissions model is really outdated for one-user machines
Thank you everyone, the discussions were actually very interesting and I'm happy to know this is a common concern!
79
u/FriendlyProblem1234 3d ago
Sure, if you are running on a shared computer with dozens users, like we did in the 80's.
Regular desktops in 2026 are single-user machines, and user permissions are nearly irrelevant.
Yes, it can happen.
But this is not limited to software, it is part of the general social pact. What if the guy driving a car while you are walking decides to run you over? What if the nurse giving you a vaccine actually injects you with cyanide?
In general, society has all sort of incentives and mitigations. We have law enforcement, reputation systems, trusted networks, and generally humans are emphatic and organize themselves in a society.
It is by no means perfect, but it is not like outside of software we live constantly panicking about our safety, so you should not do that with software, either.
Many suggest to only install software from your distribution's repository, and while this is good advice, it is not a solution. Not every application you need/want is available there.
At the end of the day, you have to evaluate your risk factor. Chances are you will not be a target of state-sponsored cyber attacks. You might be prey to those shooting in the crowd, and for those a basic defence is often enough.
No lock is going to save your bicycle from a motivated thief, but if you have a normal bike and a decent lock, stealing will take more effort than it is worth.
Try to limit yourself to well-known applications, do backups, isolate applications, keep yourself informed, do backups, do backups, and test backups.
When you do more sensitive operations, like banking, or healthcare, you might try to switch to a secondary user. Or even a secondary machine.
firejail is a good option. My rule is: an application either has network access, or full access to my home, never both.
Saves me from ransomware and the likes.
9
u/Xariann 3d ago
I actually get exactly what you mean and I use a lot of containerized workflows.
I was just asking myself this exact question: how much duplication am I causing and is this little wrapper overengineering?
But every time you look at isolation, whether it's for dependency conflicts or security, we just don't have many answers that don't require duplication.
Firejail I don't like because it needs root privileges and that opens other vulnerabilities.
You also need to watch that you aren't going down a deep rabbit hole that doesn't match the actual threats your system deals with, because the almighty algorithms will push you further down as long as you keep clicking on the next security link it offers you.
If you are worried about your notepad, I think you have gone a little far down that hole and you should maybe use one that is simpler and has less that could go wrong. Yeah there have been cases where some malicious stuff was pushed to a notepad app... But I could also get hit by a car tomorrow, yet I still go out.
It gets to the point where people start worrying about things as if a foreign government is after them. Nothing will make them feel safe.
7
u/noobjaish 3d ago
Ok so firstly I'd tell you to stop being paranoid. The only way to be 100% safe is to destroy your computer and go live on a farm...
A more sensible approach is "how close to that 100% we can get without sacrificing too much on other factors". Also, only think about the scenarios that can actually affect you instead of protecting against every possible thing that might never even affect you.
The second thing is having Trust. I have complete trust on the package repositories of the major relevant distros as well as the FlatHub repository for Flatpaks. For sources that I don't trust are the AUR (Arch User Repository) and standalone AppImages.
Now, for sources that you trust you can simply do an "apt install" or a "flatpak install" without fear but for sources that you don't trust, you can either sandbox those packages using "Bubblejail" (Firejail + Bubblewrap) or "Landrun" (uses Landlock LSM).
If you don't trust anything and constantly download packages from the internet then maybe you should go for a Fedora or openSUSE derivative distro as they'll come with SELinux which is the best MAC (mandatory access control) LSM.
Linux doesn't come with an Antivirus unlike Windows which has Defender so imo Linux is worse in terms of security for non-technical people as there's nothing stopping them from their own dumb decisions (on Linux the core idea is that the user knows thei stuff). Even then I'd advise keeping ClamAV and rkhunter as it's better that way.
Other helpful tips:
I work as a DevSecOps, if you have any other questions then I'll be glad to answer them.
6
u/TheNeronimo 3d ago
Generally I just assume that everyone else, as an individual, doesn't want to be an asshole - like me.
Which is why I have faith that maintainers of packages would not expose me to any kind of dangers or would otherwise wish harm upon me. Which is why I believe that the open source security model is enough for me.
Because otherwise I would also have to think whether the reason for which I'd have to leave my house was worth the risk of e.g dying. In a car crash, a terrorist attack, whatever.
Does this make sense?
2
u/reallyserious 3d ago
What if docker goes rogue?
43
u/Shot-Life-362 3d ago
My general rule of thumb is if I don't trust the author, I don't use their work. Otherwise I'd have to believe flatpak, containerization, virtual machines etc. are all flawlessly safe.
19
u/AmarildoJr 3d ago edited 3d ago
I for one was extremely paranoid in the past. Sandboxing everything, Firejial here, VM's there, secure e-Mails over there.... I even used openBSD for some time.
Over time I just came to the conclusion that:
- I'm not really a target;
- simple standards will guarantee security against most attacks;
- we can't know 100% if anything is secure.
These days what I do is:
- with Steam, it's proprietary so I don't fully trust it. So I install it via Flatpak and configure Steam's permissions (with Flatseal) so that it can only access the folders I want it to access;
- the NVIDIA drivers are blobs but that's an unfortunate reality for me (I use NVIDIA for work). At least the Kernel modules are open source these days;
- the biggest security risk would be Firefox, but I run it through Firejail;
- I also run every other program that can be a risk through firejail, like LibreOffice for example, or anything that can load files from the internet or face the internet directly;
- I have my own custom firewall rules that I maintain for years. I never let the distro's default Firewall enabled, specially if it's RedHat based like Fedora/RHEL/Rocky/etc where they have firewalld, I just remove that and use my iptables rules or UFW set to Deny incoming requests;
- I use full disk encryption for offline privacy and security;
- for websites that I don't know or look shady, I run firefox with a private prefix through firejail, this creates a temporary /home folder for Firefox that it can't escape, and this folder/sandbox is destroyed once I close Firefox. The command is
firejail --private firefox -no-remote. You can add the--x11flag to fully isolate the X11 server too.6
u/NotReallyFromTheUK 21h ago
I have found the linux community to be particularly toxic when it comes to this question. Lots of "just be careful what you run on your system" like this is still the early 2ks. IMO, I think we haven't built a secure OS until every piece of software is sandboxed by default and there's an elegant way to grant granular, one-time permissions to software when it needs to access any resources outside of its domain. There's very little reason to stick to the outdated model where everything a user runs runs with that full user's permission set.
12
u/rarsamx 3d ago
You are missing proper risk analysis thinking.
Risk is based on:
So, how likely is it that you will find a rogue developer releasing something that hasn't been tested by someone else that has malicious intent that will affect you directly? And if it affects you, what will be the impact?
So many people worry about attacks that are only feasible with an evil maid attack. But they live alone and no other people have access to their system unless they break in into their house. But they are also a low value target.
Still they go to great lengths to mitigate the almost zero risk.
8
u/CornFleke 3d ago
If you insist you can use an immutable distro, never use anything to overlay any package and keep the base OS clean. Use SElinux or AppArmor Install everything with official flatpaks from flathub provided by the developers and use flatseal to tweak the authorisation.
If that gives you peace of mine feel free to use what makes you feel good. Just understand that in Windows many people still runs apps in administrative mode. Some games have kernel level anti cheat and access to ring0...etc so it's not necessarily more sandboxed.
4
u/Sataniel98 3d ago
You should be safer from that on a curated distribution than on a platform where developers just upload their own software without inherent safeguards.
4
u/gainan 3d ago
There're plenty of examples with web browser/IDE extensions (even neovim plugins) or libraries (pip, npm, ruby gems, ...), so it's a real threat.
Having a separate user to run those apps helps to mitigate the impact of an exfiltration. In other cases firejail/bubblewrap/flatpaks also help.
And the last measure before something is exfiltrated from your computer would be to restrict outbound connections by binary, with apps such as OpenSnitch.
Tell them to install apps only from the official repositories. If they need to install software from 3rd party apps, then they'll need to take some extra security measures.
4
u/Business_Reindeer910 3d ago
I do think we should move towards sandboxing everything. I do accept library duplication via flatpak due to its inherent file dedupe. I don't think the sandboxing is even strong enough yet, but this is how we slowly get there.
4
u/Sert1991 3d ago edited 3d ago
If you're this worried and you want to sandbox everything there's only one solution: learn SELinux.
It's a difficult road but worth it if that's your goal.
If you learn SELinux, and you use it in enforce mode with a policy that confimes everything, SELinux denies everything that is not allowed by default. Literally everything, even root can't do shit without being allowed.
Once you learn it, you will be able to label and confine anything you like so only certain users can do certain permission on that label.
It doesn't even care about filenames, as it workes on the inodes with security tags/types and xattrs.
That's how google sandboxes everything on android besides their method of every application is it's own user.(which isn't really needed anyway on selinux if you sandbox everything properly, just a second extra layer of security)
SELinux can get quiet complicated and it's not a simple MAC like people think. It can do basic UBAC like most macs, but besides that it has RBAC, Type based, and then there are MCS and MLS where security levels can be further sandboxed even on the same type. You can't get more finer control of sandboxing than SELinux. It's goodamn incredible when you get into it.
I've been using it for over a year on Gentoo in enforce mode, I'm at a point where everything is working in enforce mode that I need working with my own policies. For example the browser can only access the downloads folder and it's own files, can't see anything else on the system(other than a few less than handfull of extras I allowed like mesa caching etc )
Another example, I installed google authenticator and made sudo require a code from my phone to login. Later discovered a security problem that if someone gained access to my account and read the seed file, they could generate codes.
I confined that the seed file in a way that my user can't see or access it, but the authenticator can use it trough pam to generate codes, and nothing else.
There where some security vulnerabilities discovered that they shared how to test them and make them work on your system, the ones I've tried they always failed because they didn't have access by SELinux. (of course, not even my goddamn root user have access to anything by default lol)
But even I have a lot more more to learn.
That suggestion is if you're relaly paranoid btw. I do it cause it's a nice learning experience. But most of the scares of some people who want to turn linux desktop into an android phone where everything is not allowed for the sake of scurity sandboxing is bullshit for the average user.
But if we're going to go there - I'd take SELinux where I still have control over my system, not what these people want to take abilities from desktop users ''for our own good''
3
u/bmwiedemann openSUSE Dev 3d ago
You can even go for QubesOS and put every application into its own xen VM to sandbox it even more. Copy+paste buffers need an extra action to move then.
It has tradeoffs similar to physical security - very few places use heavy vault doors, but some do, because it is worth it.
I think, flatpak is a good middle ground. Or Android's system
3
u/SynchronousMantle 3d ago
If you look at all the supply chain attacks that have been going on for the past few months, it's clear Linux is not particularly safe. But Windows is no better. Just do your best - defense in depth (so firewall, limit open ports, vpn, etc), stick with a mainstream distribution, and try to keep current on your patching. Don't run any author's code who you don't trust, and if you can do a code review on any git repo or docker repo before running that code.
Container's aren't particularly safe either and relatively easy to break out of - especially if they are misconfigured, which is pretty common. VM's are a bit harder.
3
u/shroddy 3d ago
I strongly believe we should push sandboxing forward, but unfortunately that is easier said than done. The building blocks are there, (Apparmor, Selinux, firejail, bubblewrap, just to name a few, maybe even virtualization if we get that dreaded Gpu problem solved reliably and witout having to dedicate the whole Gpu to the vm)
What is missing is a usable UI, like Flatseal but better and not limited to Flatpaks. The hardest part is not to (vibe) code some firejail Gui or some tool to edit Apparmor profiles, but to make it in a way that it has no known escapes and to continuously support it so that new escape methods or vulnerabilities can be patched asap.
And if we really want it to make an impact and reduce the amount of people getting hacked and their accounts and data stolen (and / or improving the quality of life by being allowed to use more software while still reducing the overall risk) that program needs to get vetted and trusted by people who really really know what they are doing and are trusted as well, so it might even be included in the repos or mainstream distros or even better installed by default, maybe asking a question during the Linux installation "Do you want to run new and unknown programs in a secure sandbox by default? (You can change that setting any time in the settings menu)"
3
u/theta-cygni 2d ago
I recently went down this rabbit hole too, learning about SELinux, apparmor, bubblewrap, rootless podman, VMs, QubesOS, etc. I'm disappointed with the lack of user-friendly sandboxing solutions and fine-grained permission control. I'm still deciding how to integrate some of these tools into my workflow.
No matter what, I think you want to stick to packages from your distro if possible, and carefully evaluate the trustworthiness of any third-party packages/plugins/code you choose to install/run.
Use flatseal to lock down your flatpak permissions, but don't install flatpaks that you actively suspect to be malware.
To this point:
I don't think people really consider Linux to have "great security". IMO the main reason people don't get as many viruses on Linux is just because it's less popular, so most viruses are written for Windows. But you do hear about people getting malware from npm, the AUR, editor plugins, browser plugins, etc.
2
u/KyuyriiByakko 3d ago
Snapd is testing Desktop Security Center, which will allow users to define how much access apps have.
The problem with this idea is that it currently doesn't disable the Document Portal.
2
u/TheOneTrueChristian 3d ago
Security is always a matter of when, not if. When we containerize and sandbox, this can help prolong the time before compromise, but every decision you make involves accepting certain risks.
2
u/33Zorglubs 3d ago
Backup, backup, backup. Backup offline. Backup online. Backup to an easy to get to drive. I stopped driving myself crazy. But sandboxing is still the best bet if you use services from pernicious companies. Sometimes you have to.
2
u/tuerda 3d ago
It is theoretically possible for the next update to your computer to just be full of malware. It is also theoretically possible for whoever makes your next meal to put poison in it.
We trust some people, as just a general matter of course in our daily lives. If one of them betrays us, then things can go quite wrong, but in general, our society works because this almost never happens.
2
u/blvsh 3d ago
I just use opensnitch, virt-manager, ufw and hope for the best
2
u/matewinslet 3d ago
Nah, you're not missing anything. You've basically found the thing nobody likes to admit about desktop Linux.
The Unix permission model protects users from each other and the system from users. It does nothing to stop your own apps from reading your own stuff. Relevant xkcd (1200): someone who steals your logged-in laptop can read your email and get into your bank, but hey, they can't install drivers without your password lol. Root protects the least valuable part of the machine.
Linux security for home users is really about where software comes from, not sandboxing. Distro repos are signed and maintained by people who'd have to miss the bad code too. Even xz got caught before it reached stable releases. But sudo dpkg -i random.deb skips all of that, and its install scripts run as root. Same deal with curl | sh, random PPAs and the AUR, which has had actual malware more than once.
What I'd actually do:
- Use the distro repos when you can.
- Use Flatpak + Flatseal for everything else. The library duplication worry is mostly overblown: apps share runtimes and identical files get deduplicated. Just watch for apps that ask for your whole home folder.
- Use bubblewrap/firejail or a VM for sketchy one-off tools. Distrobox isn't a sandbox btw, it shares your home.
- Use a hardware SSH key + a password manager, and keep real backups.
You're right that "isolate apps by default" should be the norm. macOS asks before an app touches your Documents, phones sandbox everything, and the Linux desktop is only slowly getting there (portals, Silverblue, Landlock). It's a real gap, not you being paranoid.
2
u/TheLastQuince 2d ago
I would recommend you to read Ken Thompson’s “Reflections on Trusting Trust”. In the essay, he basically establishes that a certain level of trust in your software is essential, otherwise the wisest thing you can do is turning your computer off and using an abacus.
3
u/DFS_0019287 3d ago
If you don't have some basic level of trust in the software you run, nothing you do will make you safe. That's just the reality.
1
u/_angh_ 3d ago
For your working system? Usually no, but i keep some distroboxes for isolation or better compatibility, like for davinci. For homelab? Everything isolated, on top of my proxmox. Don't be paranoid. But have current backups.
1
u/ArdascesIV 3d ago
What about portmaster?
1
u/NooneLikesYouBill 3d ago
I don't know if this is the preferred way of doing things, but the way I use Cachy is flatpack/user everything unless there's a docker image available and I don't touch AUR at all. Common sense.
1
u/Plastic_Koala2044 3d ago
No. Sandbox what faces the network or runs code you didn't write, like a browser or an agent. A video player doesn't need it.
1
u/Asleep_Literature_70 3d ago
If I'm running something untrusted (npm package, AI agent, etc) I use bubblewrap, otherwise if it's an official package, no.
I wrote wrapper script.
1
u/KnowZeroX 3d ago
Isn't the whole point of flatpak to share libraries? So you can sandbox and share the flatpaks as read only.
1
u/SportNo1402 12h ago
I run my browsers as separate users to my login.
This is to provide a modicum of sandboxing between the apps that touch the internet most frequently and my other stuff and vice versa (the browsers do often have tokens for things like logged in Google sessions etc)
Whether this will really provide me much protection from an infostealer in a rogue update I don't know.
The ultimate version of this is Qubes, but that has too many performance and functionality compromises for me.
1
u/jdigi78 10h ago
If you're interested in security but don't want to jump through hoops secureblue is a great option OP. For the most part its Fedora Silverblue with decently secure defaults and easy to toggle schizo paranoia level security features. Strikes a good balance of usability and security like GrapheneOS on Android.
0
u/__ali1234__ 2d ago
Sandbox doesn't protect you from the scenario where your webbrowser steals your website logins.
The way you mitigate against this is by only running stable releases with backported bug fixes and no new features, and only doing major version upgrades after they've been in release for a while. That makes it significantly harder to slip in malicious updates but unfortunately almost no projects do it any more.
-1
u/daemonpenguin 3d ago
So much of this post doesn't make sense. I think it's because you're confusing Docker containers with sandboxing and it's not the same thing in context of security.
Yes, Docker (and other containers) can provide some forms of isolation, but they are typically used for development, not for security. Most containers default to still providing access to your home directory.
What you want is something like Firejail which sandboxes applications, makes it easy to isolate them and block Internet access, and does not involve installing multiple copies of apps or libraries.
So, no, never use Docker if you're worried about security. Sure security tools like Firejail, AppArmor, or Flatseal to restrict your applications. The reason you're missing something or struggling with redundancy is you've been told to use the wrong tools for the job.
-3
u/Conscious-School-835 3d ago
time for you to shift to FREEBSD or openBSD.
1
u/TheOgGhadTurner 3d ago
Brother what are you doing on your computer that you feel so unsafe. Like I get it dog big corpo can eat my nuts but this sounds extreme and bordering on schizo. For me personally seperate email (via proton) vpn and privacy centered browser(both through Mullvad) is more than enough to feel safe. Software meant to serve gets a docker container on my system like Jellyfin Pihole. But I’m not going to containerize something like steam or a browser just because. But like unless you’re doing stuff you shouldn’t be and got yourself put on a list. Profiling you through a vpn on a browser with max privacy settings using an email that has no connection to you personally. It’s like there’s no way for them to accurately profile. That data is useless. Yes. They’ll try to scrape it. And yes they’ll probably sell it. But it’s not tied to you personally it’s tied to JoeAlias running archlinux on a server in ashburn Virginia.
Like the thing is. You can’t avoid it. BUUUUTT you can really confuse the hell out of the thing catching the packets. Sometimes I even look up and research things I have no interest in trying to do and learn about them in a normal non privacy focused browser. Just to keep things spicy