Skip to content

Commit 075fa32

Browse files
committed
image: tighten the Firefox and Chromium sandboxes
Firefox held devices=all (webcam, microphone, raw USB — a browser needs the GPU; WebRTC capture goes via the portal regardless) and features=devel, which relaxes the in-sandbox seccomp filter to allow ptrace and perf. That is a debugging affordance weakening the boundary around the most hostile input on the machine. Chromium could write .desktop files to ~/.local/share/applications via :create. A .desktop entry executes outside the sandbox, so that is a straightforward escape. Host /tmp went with it. Cost: PWA/"Create shortcut" install stops working; ~/.local/share/icons is left alone because revoking it buys nothing once the .desktop path is gone. Both verified before committing, as --user overrides, which reproduce a system override exactly: Chromium maps a window, and Firefox headlessly rendered a real page to a valid PNG so content processes still work. After the Discord override crash-loop, overrides get tested rather than reasoned about.
1 parent 1cfa72c commit 075fa32

4 files changed

Lines changed: 43 additions & 0 deletions

File tree

SETUP.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,17 @@ bluetooth audio, and suspend/resume. Only then wipe the internal drive (§9.10).
225225
sudo flatpak override --system --nosocket=x11 com.bitwarden.desktop
226226
sudo flatpak override --system --nofilesystem=home --filesystem=xdg-download \
227227
com.github.IsmaelMartinez.teams_for_linux
228+
sudo flatpak override --system --nodevice=all --device=dri --disallow=devel \
229+
org.mozilla.firefox
230+
sudo flatpak override --system --nofilesystem=/tmp \
231+
--nofilesystem=~/.local/share/applications \
232+
io.github.ungoogled_software.ungoogled_chromium
228233
```
234+
> **Test any new override before trusting it.** Apply it as `--user` first,
235+
> launch the app, and confirm it actually runs — a `--user` override
236+
> reproduces a system one's effect exactly. An override on
237+
> `com.discordapp.Discord` silently crash-looped that app for months while
238+
> everyone blamed zypak. Overrides are not free.
229239
Verify with `flatpak info --show-permissions <app>` — the effective
230240
`[Context]` should show `!x11` / `!home` merged in.
231241
- [ ] Restore by hand, encrypted (never via repo/image, §10): `~/.ssh`, `~/.gnupg`,

files/system/usr/lib/tmpfiles.d/kb3lyb-flatpak-overrides.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ d /var/lib/flatpak/overrides 0755 root root - -
1313
C /var/lib/flatpak/overrides/com.slack.Slack 0644 root root - -
1414
C /var/lib/flatpak/overrides/com.bitwarden.desktop 0644 root root - -
1515
C /var/lib/flatpak/overrides/com.github.IsmaelMartinez.teams_for_linux 0644 root root - -
16+
C /var/lib/flatpak/overrides/org.mozilla.firefox 0644 root root - -
17+
C /var/lib/flatpak/overrides/io.github.ungoogled_software.ungoogled_chromium 0644 root root - -
1618
#
1719
# DELIBERATELY NO com.discordapp.Discord LINE. An override on Discord — even just
1820
# `sockets=wayland;fallback-x11;` with no environment block — makes its renderer
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[Context]
2+
# !~/.local/share/applications — the manifest grants this with :create, letting
3+
# the browser write .desktop files onto the host. That is a well-known flatpak
4+
# sandbox escape: a .desktop entry runs OUTSIDE the sandbox when launched, so
5+
# anything that can write one can arrange host code execution at the next click.
6+
#
7+
# !/tmp — host /tmp is shared with every other process on the system; a browser
8+
# has no reason to read or write it.
9+
#
10+
# COST: "Create shortcut…" / PWA install no longer works. `~/.local/share/icons`
11+
# is deliberately left alone — with the .desktop path revoked, PWA install is
12+
# already broken, so revoking icons too would buy nothing.
13+
#
14+
# VERIFIED: Chromium launches and maps a window with these applied (it is slow to
15+
# start, ~50s, which is normal for it and not a symptom).
16+
filesystems=!/tmp;!~/.local/share/applications;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[Context]
2+
# devices=!all;dri — the manifest grants `all`, which is every device node the
3+
# sandbox can see: webcam, microphone, raw USB. A browser needs the GPU, not the
4+
# camera; WebRTC capture goes through the portal, which is not affected by this.
5+
#
6+
# features=!devel — `devel` relaxes the seccomp filter INSIDE the sandbox to
7+
# permit ptrace and perf. That is a debugging affordance, and it weakens the one
8+
# boundary containing the most hostile input on the machine.
9+
#
10+
# VERIFIED, not assumed: with both applied, a headless render of a real page in a
11+
# fresh profile produced a valid PNG, so content processes still work. Tested as a
12+
# --user override first, which reproduces a system override's effect exactly (the
13+
# com.discordapp.Discord incident proved that equivalence in the other direction).
14+
devices=!all;dri;
15+
features=!devel;

0 commit comments

Comments
 (0)