Flatpak - Linux Sandbox Isolation
מאת שי מרדכי | 29 במרץ 2026
בפוסטים הקודמים שלי דיברנו על בידוד ברמת ריצת ה-process בזכרון (V8) וברמת השפה (JNI). היום נדבר על מערכת ההפעלה עצמה. Flatpak זוהי סביבת sandboxes מאובטחת עבור מערכות הפעלה ממודרניות (כמו Fedora Kinoite שאני עובד עליה). היא לא מסתפקת ב-sandboxes שכל דפדפן פותח לכל כרטיסייה, אלא עוטפת את כל התהליך הראשי ב-sandbox מאובטח מאוד.
הבעיה מתעוררת כשמנסים להשתמש ב-extensions ותיקים שלא עדכנו את הדרך בה ה-desktop app מדברת עם הדפדפן (IPC). בעידן הקודם, הדפדפן יכל לגשת ישירות למערכת ההפעלה. כיום, דפדפן מבודד שמבקש לגשת למצלמה או למיקרופון כבר לא דורש ש"נקדח לו חורים" באבטחה, אלא מבקש גישה בצורה מבוקרת דרך מערכת ה-Portals.
במחקר החדש שלי, יצאתי לחקור מדוע ה-LibreWolf Browser שלי לא תואם ל-KeePassXC ששומר לי את הסיסמאות במחשב, ובנוסף מדוע הוא חוסם לי שימוש במפתחות אבטחה פיזיים (USB Security Keys / WebAuthn). גיליתי שהדרך המודרנית בה Flatpak מצפה שידברו איתו, זו לא הדרך בה האפליקציות האלו מדברות. כדי לגרום לתקשורת לעבוד, הייתי צריך לחקור את מרחב ה-Mount Namespaces, לאתר את ה-Unix Domain Socket של האפליקציה ב-Host, ולבצע הגדרת override נקודתית שחוסכת "קידוח חורים" רחב ומסוכן במערכת.
מתן הרשאת הרצה על מערכת ההפעלה (כמו דרישת Legacy Native Messaging המבוססת על stdio) דורשת מאיתנו להעניק הרשאה מסוג flatpak-spawn --host שמפעילה קבצים בינאריים ישירות על המארח (ה-Fedora Kinoite). הרשאה כזו הופכת את ה-Sandbox לשקוף לחלוטין – כל חולשת RCE בדפדפן תהפוך מיד להשתלטות מלאה על המחשב. תקשורת מודרנית חייבת להיות מבוססת הודעות טקסט בלבד (כמו DBus Portals).
עוד תובנה שהרווחתי, היא לראות את רמת הבידוד אצל דפדפנים אחרים המותקנים כ-flatpak, כגון Chrome ו-Brave. סריקת ה-Manifests שלהם הראתה שהמפתחים שלהם מראש קדחו הרבה יותר "חורים" ב-sandbox של flatpak (לתיקיית מסמכים, תמונות ומשטחי DBus רחבים), מאשר LibreWolf שמכיל כברירת מחדל חור אחד בלבד (לתיקיית Downloads).
Investigating IPC Boundaries and Sandboxing in Flatpak: The LibreWolf & KeePassXC Case
Executive Summary (TL;DR)
Problem: Strict OS-level isolation (Flatpak/bubblewrap) breaks essential browser functionality, specifically Native Messaging IPC (KeePassXC) and hardware-based authentication (WebAuthn/USB Security Keys).
Action: Investigated Flatpak mount namespaces, Unix Domain Sockets, and hardware permissions. Engineered granular sandbox overrides and analyzed browser engine configurations (about:config) to restore functionality.
Result: Successfully mapped the trade-off between OS-level sandboxing, functionality, and browser fingerprinting. Demonstrated that exposing hardware for WebAuthn fundamentally breaks fingerprinting resistance (RFP), highlighting a critical attack/detection surface.
1. Theoretical Background
Modern Linux systems increasingly rely on containerized application formats like Flatpak to enhance security. Flatpak uses features like namespaces and bubblewrap to isolate applications into separate sandboxes.
However, this strict isolation breaks traditional Inter-Process Communication (IPC). Legacy mechanisms relying on stdio execution or shared directories often fail under mount namespace boundaries.
2. The Investigation: Locating the IPC Socket
To understand why the LibreWolf browser extension cannot communicate with the KeePassXC desktop app, we first locate the active Unix Domain Socket on the host operating system:
shay0129@fedora:~$ ls -l /run/user/1000/app/org.keepassxc.KeePassXC/
srwx------. 1 shay0129 shay0129 0 Mar 28 21:21 org.keepassxc.KeePassXC.BrowserServer
3. Proving the Sandbox Isolation
To verify the boundary, we inject an installation diagnostic command directly into the LibreWolf runtime container to query the socket path:
shay0129@fedora:~$ flatpak run --command=ls io.gitlab.librewolf-community -l /run/user/1000/app/org.keepassxc.KeePassXC/
F: Not sharing "/dev/bus/usb" with sandbox: Path "/dev" is reserved by Flatpak
ls: cannot access '/run/user/1000/app/org.keepassxc.KeePassXC/': No such file or directory
Mount Namespaces (IPC Blocked): The sandbox environment receives an isolated, restricted view of the filesystem. The target socket directory simply does not exist within the container's namespace.
Device Isolation (Hardware Blocked): The warning warning shows that raw hardware access (/dev/bus/usb) is strictly denied by default.
4. Architectural Solutions
To resolve the isolation barriers without exposing the global filesystem, granular overrides are enforced to map only the necessary socket path into the container layout:
flatpak override --user --filesystem=/run/user/1000/app/org.keepassxc.KeePassXC io.gitlab.librewolf-community
5. Resolving the Hardware Token (USB Key) & The Fingerprinting Trade-off
Modern FIDO2/WebAuthn tokens rely on direct USB HID communication. Restoring functionality requires a multi-stage configuration:
Step 1: Sandbox Hardware Override
flatpak override --user --device=all io.gitlab.librewolf-community
Step 2: Browser Engine Configuration
LibreWolf's strict anti-fingerprinting mechanism (RFP) actively suppresses USB token probes. We modified internal Javascript engine flags (about:config) to bypass the block:
// Enable underlying WebAuthn processing layers
security.webauth.webauthn = true
security.webauth.u2f = true
security.webauth.webauthn_enable_usbtoken = true
The Privacy Conflict: Overriding the sandbox to communicate with local USB subsystems exposes unique hardware configurations to web scripts, creating a traceable fingerprinting signature.
6. Comparative Attack Surface Analysis: LibreWolf vs. Chrome & Brave
We extracted active application profiles (flatpak info --show-permissions) to assess the threat profile if a Remote Code Execution (RCE) occurs inside the sandbox layout:
- Google Chrome (Data Exposure): Requests extensive filesystem permissions (xdg-documents, xdg-download). RCE grants immediate access to local file boundaries.
- Brave Browser (System Integration Risk): Requests extensive DBus session access, expanding the attack surface toward host system services.
- LibreWolf (Strict Least Privilege): Restricts filesystem access solely to xdg-download and limits the DBus surface to an absolute minimum.
Conclusion
Legacy IPC mechanisms relying on host binary execution via stdio are fundamentally incompatible with modern secure sandboxes. To balance both system integrity and user privacy, applications must transition to modern isolation-aware communication models, such as DBus WebExtensions Portals.