secureblue: Flatpak Electron App Throws Error With `libhardened_malloc.so`
I have tested several flatpak electron apps, including Signal, Slack, Freetube, all of them seems to give the following error:
ERROR: ld.so: object '/var/run/host/usr/lib64/libhardened_malloc.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
This error does not appear in app in other framework, like fsearch, syncthingy, or gnome core app. Native apps like codium and chormium also don’t have this issue.
Example command:
flatpak run org.signal.Signal --filesystem=host-os:ro
My signal is running xwayland and slack is running in wayland, yet both of them raise the same error, so I don’t think it is a wayland issue.
I don’t know if this can be reproduced on other systems.
Deployment info (rpm-ostree status):
ostree-image-signed:docker://ghcr.io/secureblue/silverblue-main-laptop-userns-hardened:latest
Digest: ...
Version: 39.20240130.0 (2024-01-30T18:19:08Z)
LayeredPackages: ...
Initramfs: regenerate
... represents unrelated information.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 21
@trytomakeyouprivate Since Android provides a standard OS WebView that’s kept up-to-date, very few apps bundle their own web browser engine. That means they get an updated one that the OS is able to harden. On GrapheneOS, that allows us to use CFI, MTE, etc. for the web rendering engine used by all these apps. Chromium doesn’t really use the system malloc in practice so hardened_malloc doesn’t really do much for it. Android WebView currently doesn’t have fine-grained isolation but it does at least provide an overall content sandbox separate from the app itself comparable to the browser sandbox. It doesn’t currently sandbox separate content used simultaneously by the app in separate OS sandboxes but it’s planned upstream and we can enable it early.
Windows has WebView2 based on Edge (Chromium) but it’s relatively new and would mainly be used by new Windows-only applications. Most of these desktop apps are using web content to be cross-platform across Windows, macOS and desktop Linux so they aren’t going to use an OS specific WebView API. There’s not going to be cooperation on this between Windows and macOS or even across desktop Linux distributions. Desktop Linux alone has a bunch of fragmented options, mostly badly maintained and they repeatedly get replaced in backwards incompatible ways. Android has always had the same WebView API evolving and gaining new features which became based on proper Chromium shipped with the OS browser over a decade ago.
Electron massively rolls back Chromium security, breaks the sandbox and is a regularly backwards incompatible library used by applications so there’s a huge mess created by it. Android WebView preserves compatibility to the same extent as Chromium does for the web, which is to say that essentially nothing breaks even after a decade if you don’t do anything stupid. Rare apps do stupid enough stuff to break on Chromium updates, but it’s generally easy for them to fix it. It’s essentially just the same as the web since the Android WebView adds very minimal API surface beyond standard Chromium. It has a tiny set of APIs for configuring it, executing JS, adding JavaScript interfaces from Java/Kotlin, intercepting network requests to replace them and do content filtering along with interoperability with APK assets (asset:), content providers (content:) and direct file access (file:). It’s dramatically simpler than Electron since it makes no attempt to provide a full application API. It’s only a sandboxed web content renderer with interoperability with the rest of the app code. Electron is for writing a whole application while the WebView is for putting web content in an app, although you can provide all the APIs you need to the WebView and write your whole app in it. Still, that avoids the WebView having complex APIs since the developer and the libraries they use would be defining any of that. Electron is a huge mess, as are most alternatives. WebView2 on Windows is reasonable, if only it wasn’t Windows-specific and stuff actually used it.
You could eliminate some of these issues by building hardened_malloc into glibc as the default allocator with an extended attribute set on the executable for disabling it which is read inside libc and used to select the standard glibc allocator instead. That’s essentially the approach we use ourselves, although we hard-wire the few rare cases of exceptions of the base OS and apps are handled more dynamically via a user-facing toggle integrated into the UI.
LD_PRELOAD adds some complexity and glibc’s implementation of replacing the allocator isn’t 100% complete and has some rare edge cases where applications do weird things with dynamic linking where it won’t properly work and will cause a crash.
Electron also breaks Content-Security-Policy and other things. Signal being an Electron app without Trusted Types turns it into a huge mess of XSS vulnerabilities. It was way less bad when it was still a Chrome app and moving to Electron to keep it alive with the end of Chrome apps while not turning it into a web app (due to E2EE) was a massive security regression for them.
strange…
using hardened_malloc:
not using hardened_malloc:
So it looks like Electron apps are going to be fun…
To be honest I think this is an Electron issue. On Android its is a single webview which is hardened, on Linux it is not even hardened. I guess it would be best to make flatpaks for those commonly used apps including hardened_malloc and a hardened Electron. This sounds like quite some work though.
Those Flatpaks would work anywhere though, and follow the idea of not depending on the OS for libraries.
again this is not true and comes back to reproducible builds. you only know that native apps are only running native code if you can reproduce the build.
I’m going to lock this post shortly as it’s wildly offtopic.
Telegram desktop is QT
@trytomakeyouprivate I tried an xdg-host-os override and it didn’t change anything.