Live data from Hacker News

Flatpak – a security nightmare – 2 years later (2020)

flatkill.org

281–290 of 296 posts

Re: Flatpak – a security nightmare – 2 years later (2020)

#281

Earlier quoted context omitted.

Because distributions don't need flatpak. There are already methods to do sandboxing like systemd and firejail.

Ah sure, I was referring to the: > Passing responsibility of not distributing evil software from the gatekeepers to the user. As in, we can have gatekeepers but also force software to define explicit access policies. Like, maybe a program that needs regularly files will create a folder where they have access to files and any files placed there afterwards can be used by the program without asking for access. For all o…

What's the point though? Either the software is evil/has a bug that lets it steal all your data, or it doesn't.

Making each app have its own filesystem just forces a weird file structure where you don't have a folder for a project, but for an app. Whose projects only consist of one type of files?

If the app is a web browser then fair enough, but what other apps would that be useful for?

Re: Flatpak – a security nightmare – 2 years later (2020)

#282

Earlier quoted context omitted.

The upside of having the system draw file dialogs is that file dialogs from different apps look consistent, rather than getting out-of-place dialogs depending on what toolkit the app used. It might sound silly, but it's a real annoyance, and there are plenty of apps that don't implement any custom preview.

Oh sure, but it's hard to make a one-size-fits-all file chooser. The case in point: Gimp, not using GtkFileChooserNative, even though Gtk started off as the "Gimp ToolKit". Otherwise, Gimp does not get image previews. Even if you do build support for previews in the file chooser, you lose the sandboxing since that preview-generating app now has access to any file a user simply previews. Unless you start introducing a…

Thumbnail rendering on GNOME is already sandboxed with bubblewrap, even when you're outside Flatpak: [0] for docs and [1] for code on how they accomplish it.

I don't think it's possible yet to ship thumbnailers in Flatpak - I'll try poking someone to see if there are plans for that.

[0]: https://gitlab.gnome.org/GNOME/gnome-desktop/-/blob/master/R... [1]: https://gitlab.gnome.org/GNOME/gnome-desktop/-/blob/master/l...

Re: Flatpak – a security nightmare – 2 years later (2020)

#283
post #207

Earlier quoted context omitted.

I've long argued for applications to use file choosers they do not control, but not for security reasons. I've wanted it for UI reasons. Somewhere I've got a screenshot of a Linux system I had with half a dozen applications trying to open a file. Each used a different GUI framework or widget toolkit, each of which had its own file dialogs, and so the user gets presented with half a dozen different file choosing UIs.…

Major GUI frameworks agree with you and have already adopted this approach and it is already used by many applications, and this has already been the case for years.

[deleted]

Re: Flatpak – a security nightmare – 2 years later (2020)

#284

Earlier quoted context omitted.

Can it? If my application invokes syscalls directly, that wouldn't hit anything interposed using LD_PRELOAD.

It will certainly work for the vast majority that are using #include and more importantly for the various GUI apps that are using GTK/Qt dialogs.

This is for security, though - you can't just assume it's good enough because it will work for most benign applications - you need to be sure it will work for all applications - benign or malicious!

There are other solutions such as seccomp (as siblings of your post have pointed out) that solve this securely, but LD_PRELOAD won't.

Re: Flatpak – a security nightmare – 2 years later (2020)

#285
post #182

Earlier quoted context omitted.

Basically, nix (and guix, which is based on it) is the only package manager that actually solves the dependency hell problem properly. It makes builds reproducible, and basically a package will depend on it’s inputs’ hashes. So you can not only install multiple versions of the same package that is solved by some package managers although in hacky ways, you can install multiple ones that only differ in eg which libc v…

Nix doesn’t guarantee binary reproducibility. It does help with reproducing build inputs and the build process, as do the tools used to create Flatpak applications and runtimes—flatpak-builder and BuildStream. Nix can build packages in a sandbox, but the same is true of flatpak-builder and BuildStream. The Freedesktop SDK has a CI pipeline (run on schedule, not on every change, because it is expensive) that tests rep…

Thank you for the detailed and informative answer. Sorry for my cocky style, I am by no means knowledgeable on flatpak and I passed judgement prematurely.

Nonetheless, I have some questions, comments:

> Nix doesn’t guarantee binary reproducibility

Yeah, it’s true, but no general build tool can, since language build tools themselves are usually non-deterministic.

> For example, Flatpak guarantees atomic updates with restarting merely the updated application. NixOS only guarantees atomic updates with a reboot

That latter is only true of NixOS; for an ordinary package you can just start up actually both the old and updated version at the same time without any trouble. And in the OS config case, it is more of a linux deficiency - it does restart services when possible, but that is orthogonal to this discussion as I believe flatpak doesn’t do anything similar.

> Evaluating Nix expressions is quite inefficient

You are right, but the results can be cached. With the experimental flakes it is quite fast.

> Worse is the cascading rebuilds that come with the Nix approach

Well, it is sort of a tradeoff of reproducibility. Also, there is work in progress to minimize rebuilds to only truly necessary changes.

> Also, Nix’s languages lacks domain abstractions for building packages

The language lacks them. The repo has a great deal of abstractions for many use cases, and so a trivial to build package will look almost the same as a JSON. And as you note, it is a tradeoff, but there are plenty of hard to package apps that benefit greatly from the more expressive language. Also, there is plenty of auto-updaters that can automatically create PRs for eg new python packages, since it is more often then not just a version and hash change away, so package description manipulation is possible this way as well.

> OSTree uses a content-addressable store for all files, giving Flatpak deduplication for free

Correct me if I’m wrong, but it is necessary because flatpak uses the docker-like model, in that the same shared dependency is “theoretically” copied in each package, even if it is the same version. So in a way they solve a self-created problem. nix on the other hand simply links the same shared library, no duplicated data. You can optionally deduplicate when you install multiple versions of eg. libc. Nix can’t really prove whether the two “versions” are the same, and sometimes they may be identical, or identical in part (eg the man pages are the same, but the exe is not), in which case imo really elegantly, it can hard-link one to the other. But the base state with only one version of a nix channel installed, you simply have no need for deduplication as opposed to the flatpak model, because you only get every package once.

One last point, a nix package may have less overhead, although it is I believe negligible in most cases since vms are quite light nowadays.

So I agree with you on the tradeoffs part, and I again apologize for dismissing the project - I really dislike the same uninformed attitude towards for example systemd or wayland. But I still believe that nix is the one doing something revolutionary.

(Also, maybe not-possible but nix could perhaps be used as a tool to create flatpak images similarly to how it can create smaller docker images: https://yann.hodique.info/blog/using-nix-to-build-docker-ima... )

Re: Flatpak – a security nightmare – 2 years later (2020)

#286
post #281

Earlier quoted context omitted.

Ah sure, I was referring to the: > Passing responsibility of not distributing evil software from the gatekeepers to the user. As in, we can have gatekeepers but also force software to define explicit access policies. Like, maybe a program that needs regularly files will create a folder where they have access to files and any files placed there afterwards can be used by the program without asking for access. For all o…

What's the point though? Either the software is evil/has a bug that lets it steal all your data, or it doesn't. Making each app have its own filesystem just forces a weird file structure where you don't have a folder for a project, but for an app. Whose projects only consist of one type of files? If the app is a web browser then fair enough, but what other apps would that be useful for?

I was trying to address multiple points that sometimes are made here and else where regarding stricter access patterns. This would probably involve a more complex (as in with more options) permission system, or perhaps can be achieved under linux with groups.

> What's the point though? Either the software is evil/has a bug that lets it steal all your data, or it doesn't.

The program itself might be updated to a compromised version, where the gatekeepers are compliant or by a change that passes review, or you might want to test a program and not have to worry about running a vm or a docker container. For package managed programs this is not so much an issue with linux where you usually will update it yourself, but anything using auto-updates can fall prey to it. The same with npm et al.

> Making each app have its own filesystem just forces a weird file structure where you don't have a folder for a project, but for an app. Whose projects only consist of one type of files?

The app wouldn't have any specific filesystem, it would be given a role/group/wtv that could be used to assert permission when accessing files or system apis. Say I download chrome, chrome creates a folder named "chrome", it can only, by default, write to that folder and read from that folder.

For anything else it needs to ask the OS for permission and I can grant it, for a single usage (the file as is in that point in time is read and passed to the app), for a single session (until the app is exited it can re-access that specific file without prompting) or until I revoke it (it can access that file without prompting until I revoke the access). When it needs to access a file or api, outside of those currently allowed it needs to ask again.

The folder was in terms of one of the complains of permissions making the UX worse when you need to give permissions to the app. So in this case, chrome could store its downloads inside that folder, the save Page as, download image as, etc.

Ideally it would have enough granularity to distinguish between modes of access, so I could give it permission to save on my "docs", but it wouldn't have permission to read other files in the folder that weren't granted permission - it would be able to read though the files it saved by default, because those would default to be readable as well (since the program was the one writing them there's no point in changing that).

The permission could be changed as well and changing the file from one "folder" to another could/would automatically reset the permissions (perhaps the permission would be an hash of the current directory + an app key). When upgrading versions the OS would have an easy way to migrate current permissions, generating a new copy of the current permissions from app key to a new set assigned to the new app key (the app key could be an hash of the current program folder as when installed). This would be something like a panel where you could see all app icons/or in text mode their names, and click one, and say, import to X, or do copy-permissions chromev12-xssdcfdsf to chromev13-shfghhjh. Or right-click the icon for the app and have one of the options be "import permissions from", etc.

If a program doesn't need to do any of these then it wouldn't need to have a folder but most programs will have some sort of necessary file storage, be it config, etc.

This same permission model would then work for OS api/hardware/wtv access. Open zoom and it needs mic and cam, you can give it permission just until you quit it.

This is also true when it comes to programs that have sudo requirements to be run. I'm not saying that you can't take precautions to mitigate any of this if you're paranoid, I just think it should be the baseline. There shouldn't (ideally) be any need for me to run jails, VMs or anything to try a program or installed libraries to be used.

If I on a phone use an app that can send, for instance images or any other files, but also store them, I should only need to give it write access to a folder but not read. Because unless it's going to do reading by itself without me instantiating the action, whenever I want to send a file, the OS can prompt me and I will pick the file, and this wouldn't even need to change the access level to that file, the os could just provide the file for that single interaction.

Re: Flatpak – a security nightmare – 2 years later (2020)

#287
post #281

Earlier quoted context omitted.

What's the point though? Either the software is evil/has a bug that lets it steal all your data, or it doesn't. Making each app have its own filesystem just forces a weird file structure where you don't have a folder for a project, but for an app. Whose projects only consist of one type of files? If the app is a web browser then fair enough, but what other apps would that be useful for?

I was trying to address multiple points that sometimes are made here and else where regarding stricter access patterns. This would probably involve a more complex (as in with more options) permission system, or perhaps can be achieved under linux with groups. > What's the point though? Either the software is evil/has a bug that lets it steal all your data, or it doesn't. The program itself might be updated to a compr…

Right, fix the permission system, every app has its own scratch space, but needs to talk to the os file protection layer to load/save, if you double click a file, it has permission to read it, if you save a file it has permission to write and read it.

Very few desktop apps need permission to read/write files you didn't select manually anyway.

Re: Flatpak – a security nightmare – 2 years later (2020)

#288

Earlier quoted context omitted.

And then have a barrage of users complaining that their app packaged in flatpak doesn't work.

Easy, show a pop-up informing the user that the application tried to access so and so file, and if this was intentional, please click allow and try again.

When the sandbox works as it should, the application has no idea that so and so file even exists.

The flatpak portals are trusted system components, that work outside the sandbox and can present some choosers, where the user picks what will eventually become accessible inside sandbox, if the user agrees (whether files via file choosers, microphones, cameras, desktop sharing, whatever). The sandboxed processes talks to the these portal via IPC (dbus, normally).

The thing is, that outside of standard gtk3 and qt5 apps, nothing else uses portals yet (and gtk3 with qt5 do that at framework level, so it's transparent for the apps). You cannot sandbox random electron app, for example, and expect that it will work just like it worked when it was installed via deb or rpm. And with files, it is just not single files (document apps are relatively easy), but imagine opening project file inside IDE or playlist inside media player: the project or playlist was picked by the user and can be opened by the app, but it contains references to other files, potentially hundreds of them. Can you imagine asking the user to confirm opening each and every one of the hundreds of files?

And then there were people complaining that their locally installed SDKs cannot be used from sandboxed IDEs. Sigh, that's kind of the point...

Re: Flatpak – a security nightmare – 2 years later (2020)

#289
post #216

Earlier quoted context omitted.

As an counterargument, see all the comments to this article. Most people here comment on something they have exactly zero idea about how the security model works, how the transition (i.e. holes in the sandbox and the reasoning behind them) works and what is the intended end-result (portals).

Imho not nearly the same thing.

Very similar. Either complaining about non problems, or complaining about some default they can change, or suggesting solutions that are over-complicated and simultaneously inadequate anyway.

Same underlying reason, except it is worse, because it is in the quadrant "they think they know, and they really don't".

Re: Flatpak – a security nightmare – 2 years later (2020)

#290

Earlier quoted context omitted.

It is... you can add/remove any paths you like. The default errs into what users are used to. See also threads bellow; people complaining that the Signal client can save only into ~/Downloads.

Makes sense. I use flatpaks only very lightly, I apologize for not checking before opening my mouth :)

Opening the mouth is fine, nobody has fallen from the sky fully learned about everything ;).

If you learned something that is interesting or useful to you, then great.

Post reply on HN