Skip to content

eBPF-based security platform

image: refuse the library variables that name a file on a target

Daniel Borkmann5fd48e9d84da
diff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rst
index 0d7ad975..c435d443 100644
--- a/Documentation/contribute/testing/test-coverage.rst
+++ b/Documentation/contribute/testing/test-coverage.rst
@@ -358,7 +358,8 @@ signed config image.
* - ``t6135-task-descriptors``
- Descriptors through ``/proc`` and ``pidfd_getfd``
* - ``t6136-secure-exec``
- - Secure-exec mode and no program interpreter
+ - Secure-exec mode, no program interpreter, and the library
+ variables a target refuses
* - ``t6137-traced-exec``
- A traced task cannot exec shirudo
* - ``t6138-upatch-integrity``
diff --git a/Documentation/reference/environment.rst b/Documentation/reference/environment.rst
index 6347f740..6ab89c2e 100644
--- a/Documentation/reference/environment.rst
+++ b/Documentation/reference/environment.rst
@@ -51,6 +51,10 @@ forbidden`` and fails with ``EPERM`` and exit status 1.
``SHIRUDO_KEYS_DIR`` also serves operator hosts. The others serve
development and tests.
+``TSS2_LOGFILE`` and ``SSLKEYLOGFILE`` are refused on a target the same
+way. tpm2-tss and libcurl open the file they name with the process's
+authority, sealed state included, and neither has a use on a target.
+
shirudo and shirudo-build
-------------------------
diff --git a/Documentation/security/threat-model.rst b/Documentation/security/threat-model.rst
index d3a451aa..ba33c460 100644
--- a/Documentation/security/threat-model.rst
+++ b/Documentation/security/threat-model.rst
@@ -1520,12 +1520,14 @@ U3 The environment reaches authorized processes
:Consequence: ``BPM_OCI_SCHEME=http`` turns TLS off,
``BPM_OCI_CA_FILE`` adds a trust anchor, proxy variables redirect
the traffic, and credentials come from the environment and auth
- files. Libraries in the process honor ``SSLKEYLOGFILE`` (libcurl)
- and ``TSS2_LOGFILE`` (tpm2-tss), which open a file root names
- with the process's authority, sealed state included. The
- environment files of the shipped units are writable by root.
+ files. The environment files of the shipped units are writable
+ by root. ``TSS2_LOGFILE`` (tpm2-tss) and ``SSLKEYLOGFILE``
+ (libcurl), which open a file root names with the process's
+ authority, are refused on a target like shirudo's own overrides
+ (``t6136``): with the first set, ``shirudo status`` wrote the
+ library's log into a sealed file.
:Status: Confirmed in code for shirudo's own variables; the library
- variables are a code-path reading, not reproduced.
+ log file was reproduced on a test VM and is refused now.
:Meanwhile: Keep ``/etc/shirudo/bpm/environment``,
``/etc/shirudo/map-export.env`` and ``/etc/shirudo/init.env``
absent or empty and owned by root, and watch who runs runtime
diff --git a/testing/functional/tamperproof/t6136-secure-exec.sh b/testing/functional/tamperproof/t6136-secure-exec.sh
index 4659e775..63603931 100755
--- a/testing/functional/tamperproof/t6136-secure-exec.sh
+++ b/testing/functional/tamperproof/t6136-secure-exec.sh
@@ -56,4 +56,12 @@ test_expect_success 'its copy outside the image runs without' '
[ "$("$W/probe" secure)" = 0 ]
'
+test_expect_success 'a library variable that names a file is refused' '
+ for v in TSS2_LOGFILE SSLKEYLOGFILE; do
+ ! env "$v=$W/$v" "$BIN" status >"$W/out" 2>&1 &&
+ grep -q "bootstrap override $v is forbidden" "$W/out" &&
+ [ ! -e "$W/$v" ] || exit 1
+ done
+'
+
test_done
diff --git a/util/image_runtime.c b/util/image_runtime.c
index f2f3d0f0..6351f51e 100644
--- a/util/image_runtime.c
+++ b/util/image_runtime.c
@@ -91,6 +91,8 @@ static int reject_overrides(void)
"SHIRUDO_EVENTLOG_PENDING_PATH",
"SHIRUDO_INITRD_RELEASE",
"SHIRUDO_SYSROOT",
+ "TSS2_LOGFILE",
+ "SSLKEYLOGFILE",
};
size_t i;