Posts Bubblewrap y Firefox
Post
Cancel

Bubblewrap y Firefox

Si hay algo que está presente en todos los ordenadores personales es el navegador. Un programa normalmente gigantesco, lleno de fallos, que recibe y ejecuta código igualmente grande y no auditado. ¿Hacen falta mas razones para ejecutarlo en un entorno lo mas reducido posible?


$ bwrap [OPTION...] [COMMAND]

Importante, las opciones se interpretan de izquierda a derecha!

Ejecutar Firefox en la sandbox es tan sencillo como:

  • Crear bind mounts como read-only a los binarios, librerias…etc
1
2
3
  --ro-bind /usr /usr
  --ro-bind /bin /bin
  --ro-bind /lib64 /lib64
  • Crear bind mounts como read-only a la configuración DNS, fuentes y la cache de ld.
1
2
3
  --ro-bind /etc/resolv.conf /etc/resolv.conf
  --ro-bind /etc/fonts /etc/fonts
  --ro-bind /etc/ld.so.cache /etc/ld.so.cache
  • Crear bind mounts al profile existente y al directorio Downloads.
1
2
3
  --bind ~/.cache/mozilla ~/.cache/mozilla
  --bind ~/.mozilla ~/.mozilla
  --bind ~/Downloads ~/Downloads
  • PulseAudio
1
2
3
  --ro-bind ~/.config/pulse ~/.config/pulse
  --bind /run/user/$UID/pulse /run/user/$UID/pulse
  --setenv XDG_RUNTIME_DIR "/run/user/$UID"
  • Montar procfs, un nuevo devtmpfs y un tmpfs en /tmp.
1
2
3
  --proc /proc
  --dev /dev
  --tmpfs /tmp
  • Crear nuevos namespaces y mantener unicamente el de red.
1
2
  --unshare-all
  --share-net
  • CVE-2017-5226 1
1
  --new-session

>$ bwrap \ --ro-bind /usr /usr \ --ro-bind /bin /bin \ --ro-bind /lib64 /lib64 \ --ro-bind /etc/resolv.conf /etc/resolv.conf \ --ro-bind /etc/fonts /etc/fonts \ --ro-bind /etc/ld.so.cache /etc/ld.so.cache \ --bind ~/.cache/mozilla ~/.cache/mozilla \ --bind ~/.mozilla ~/.mozilla \ --bind ~/Downloads ~/Downloads \ --ro-bind ~/.config/pulse ~/.config/pulse \ --bind /run/user/$UID/pulse /run/user/$UID/pulse \ --setenv XDG_RUNTIME_DIR "/run/user/$UID" \ --proc /proc \ --dev /dev \ --tmpfs /tmp \ --unshare-all \ --share-net \ --new-session \ firefox

xdg-open

La extensión perl-matcher de urxvt (y otros programas que usen XDG) no funciona a no ser que tengamos un MIME registrado. Lo primero es crear un script para abrir Firefox.

>#!/bin/bash bwrap \ --ro-bind /usr /usr \ --ro-bind /bin /bin \ --ro-bind /lib64 /lib64 \ --ro-bind /etc/resolv.conf /etc/resolv.conf \ --ro-bind /etc/fonts /etc/fonts \ --ro-bind /etc/ld.so.cache /etc/ld.so.cache \ --bind ~/.cache/mozilla ~/.cache/mozilla \ --bind ~/.mozilla ~/.mozilla \ --bind ~/Downloads ~/Downloads \ --ro-bind ~/.config/pulse ~/.config/pulse \ --bind /run/user/$UID/pulse /run/user/$UID/pulse \ --setenv XDG_RUNTIME_DIR "/run/user/$UID" \ --proc /proc \ --dev /dev \ --tmpfs /tmp \ --unshare-all \ --share-net \ --new-session \ firefox "${@}"

Copiamos el fichero firefox.desktop a ~/.local/share/applications y modificamos Exec= para que apunte al script anterior.

>$ cp /usr/share/applications/firefox.desktop ~/.local/share/applications/sanfox.desktop $ vim ~/.local/share/applications/sandfox.desktop
>Exec=/path/to/firefox/script %u

Añadimos sandfox.desktop como navegador por defecto.2

>$ vim .local/share/applications/mimeapps.list [Default Applications] text/html=sandfox.desktop x-scheme-handler/http=sandfox.desktop x-scheme-handler/https=sandfox.desktop

Fuentes:

Bubblewrap – Unprivileged sandboxing tool

OLDER POST NEWER POST

Comments powered by Disqus.

Search Results