aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_local
diff options
context:
space:
mode:
Diffstat (limited to 'dot_local')
-rw-r--r--dot_local/bin/executable__sandbox-net-parser58
-rw-r--r--dot_local/bin/executable_mpv4
-rw-r--r--dot_local/bin/executable_streamlink5
-rw-r--r--dot_local/bin/executable_yt-dlp4
4 files changed, 71 insertions, 0 deletions
diff --git a/dot_local/bin/executable__sandbox-net-parser b/dot_local/bin/executable__sandbox-net-parser
new file mode 100644
index 0000000..648ad0f
--- /dev/null
+++ b/dot_local/bin/executable__sandbox-net-parser
@@ -0,0 +1,58 @@
+#!/usr/bin/env sh
+# Sandbox wrapper for tools that parse data from untrusted network
+# sources (mpv, yt-dlp, streamlink). The threat model is RCE in a
+# subtitle / muxer / extractor that walks the user's home directory
+# looking for SSH/GPG keys, password store, cloud tokens, etc.
+#
+# Compromise: most of the system is still reachable (--bind / /), so
+# Wayland, PipeWire, DBus, GPU, hardware accel and config files all
+# work transparently; the sandbox only tmpfs-shadows known-sensitive
+# directories so a compromised parser cannot read them.
+#
+# Set SANDBOX=0 to bypass entirely for a single invocation:
+# SANDBOX=0 mpv weird-codec-file.mkv
+#
+# Usage (called by the per-tool wrappers): _sandbox-net-parser /usr/bin/mpv "$@"
+
+set -eu
+
+if [ "${SANDBOX:-1}" = "0" ]; then
+ bin=$1
+ shift
+ exec "$bin" "$@"
+fi
+
+if ! command -v bwrap >/dev/null 2>&1; then
+ printf '%s: bwrap not installed; falling back to direct exec\n' "$0" >&2
+ bin=$1
+ shift
+ exec "$bin" "$@"
+fi
+
+bin=$1
+shift
+
+# Prevent re-entry: any tool spawned inside the sandbox that resolves
+# `mpv`/`yt-dlp`/`streamlink` via PATH (e.g. streamlink launching mpv)
+# must find the real binary, not another wrapper that would try to
+# nest a second bwrap and fail. Strip ~/.local/bin and nix-profile/bin
+# from PATH inside the namespace.
+inner_path='/usr/local/sbin:/usr/local/bin:/usr/bin'
+
+exec bwrap \
+ --bind / / \
+ --dev-bind /dev /dev \
+ --proc /proc \
+ --tmpfs /root \
+ --tmpfs "$HOME/.ssh" \
+ --tmpfs "$HOME/.gnupg" \
+ --tmpfs "$HOME/.password-store" \
+ --tmpfs "$HOME/.config/gh" \
+ --tmpfs "$HOME/.config/op" \
+ --tmpfs "$HOME/.aws" \
+ --tmpfs "$HOME/.local/share/keyrings" \
+ --tmpfs "$HOME/.local/share/pass" \
+ --setenv PATH "$inner_path" \
+ --die-with-parent \
+ --new-session \
+ -- "$bin" "$@"
diff --git a/dot_local/bin/executable_mpv b/dot_local/bin/executable_mpv
new file mode 100644
index 0000000..ba6787b
--- /dev/null
+++ b/dot_local/bin/executable_mpv
@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+# Thin wrapper: run /usr/bin/mpv inside _sandbox-net-parser. See that
+# script for the threat model and the SANDBOX=0 escape hatch.
+exec _sandbox-net-parser /usr/bin/mpv "$@"
diff --git a/dot_local/bin/executable_streamlink b/dot_local/bin/executable_streamlink
new file mode 100644
index 0000000..86ab12a
--- /dev/null
+++ b/dot_local/bin/executable_streamlink
@@ -0,0 +1,5 @@
+#!/usr/bin/env sh
+# Thin wrapper: run /usr/bin/streamlink inside _sandbox-net-parser. The
+# sandbox strips ~/.local/bin from PATH so streamlink's internal launch
+# of `mpv` resolves to /usr/bin/mpv (avoids nested bwrap).
+exec _sandbox-net-parser /usr/bin/streamlink "$@"
diff --git a/dot_local/bin/executable_yt-dlp b/dot_local/bin/executable_yt-dlp
new file mode 100644
index 0000000..3298e3f
--- /dev/null
+++ b/dot_local/bin/executable_yt-dlp
@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+# Thin wrapper: run /usr/bin/yt-dlp inside _sandbox-net-parser. See that
+# script for the threat model and the SANDBOX=0 escape hatch.
+exec _sandbox-net-parser /usr/bin/yt-dlp "$@"