From fc93846b2c0ccd3f2ef132ab68d1abec23df46c4 Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Sat, 17 Oct 2026 23:22:47 +0200 Subject: [PATCH] privileges gate: a template named like another app's appdata folder gets no root; one folder for two apps fails (security review 2026-10-18) --- CHANGELOG.md | 2 ++ scripts/check-privileges.py | 9 ++++++++- scripts/test_gate_decoys.py | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e771d2b..ea90a39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ new cases; the homepage-entry cases now run on a test list carrying the old entry, and the homepage socket on the REAL list is a FACT (refused). Red-proof: root back at `${HDD_PATH}/appdata` → four R-1142 decoys convict the gate (felhom.eu `audits/night-2026-10-18/P1/redproof-catalog-gate-r1142.txt`). +- **Security review 2026-10-18 (same night):** a template NAMED like a folder the list gives to another app (`paperless`) + gets no `${HDD_PATH}` root, and one folder given to two apps fails the gate — two more decoys, as the box. - **Order:** this commit is pushed BEFORE controller v0.329.0 (which refuses the old homepage template); an older controller accepts this one. diff --git a/scripts/check-privileges.py b/scripts/check-privileges.py index 8e84e88..841c9ea 100644 --- a/scripts/check-privileges.py +++ b/scripts/check-privileges.py @@ -354,7 +354,11 @@ def appdata_folder(app, folders): """The app's own folder under ${HDD_PATH}/appdata/ (R-1142) — as the box's privpolicy.AppdataFolder.""" if app in folders: return folders[app] - return app if one_segment(app) else "" + # a folder the list gives to ANOTHER app is not this app's, even when it is named like it (security review + # 2026-10-18: a template called "paperless" must not get paperless-ngx's files) + if not one_segment(app) or app in folders.values(): + return "" + return app def valid_roots(env, app="", folders=None): @@ -531,6 +535,9 @@ def main(argv): if not one_segment(f): print("FAIL: %s: the appdata folder of %s is not one folder name: %r" % (ALLOWLIST, a, f)) return 1 + if len(set(folders.values())) != len(folders): + print("FAIL: %s: one appdata folder is given to two apps" % ALLOWLIST) + return 1 sibling = os.path.join(root, CONTROLLER_COPY) if os.path.exists(sibling): with io.open(sibling, encoding="utf-8") as f: diff --git a/scripts/test_gate_decoys.py b/scripts/test_gate_decoys.py index cafa9b8..bb28e8b 100644 --- a/scripts/test_gate_decoys.py +++ b/scripts/test_gate_decoys.py @@ -903,6 +903,8 @@ def privileges_cases(): run("FACT: the whole appdata/ (R-1142)", {"a/docker-compose.yml": compose(vol=" - ${HDD_PATH}/appdata:/all\n")}, 1, ("appdata -> /all",)) run("GENUINE: paperless-ngx's listed folder appdata/paperless (R-1142)", {"paperless-ngx/docker-compose.yml": compose(vol=" - ${HDD_PATH}/appdata/paperless/media:/m\n")}, 0) run("FACT: paperless-ngx binds appdata/paperless-ngx (the slug, where a folder is listed)", {"paperless-ngx/docker-compose.yml": compose(vol=" - ${HDD_PATH}/appdata/paperless-ngx:/m\n")}, 1, ("appdata/paperless-ngx",)) + run("FACT: a template NAMED like paperless-ngx's folder binds it (security review 2026-10-18)", {"paperless/docker-compose.yml": compose(vol=" - ${HDD_PATH}/appdata/paperless/media:/m\n")}, 1, ("appdata/paperless/media",)) + run("FACT: one appdata folder given to two apps", {"a/docker-compose.yml": compose()}, 1, ("given to two apps",), list_body=allow.replace('"paperless-ngx": "paperless"', '"paperless-ngx": "paperless", "x": "paperless"')) run("FACT: an appdata folder that is a path (R-1142)", {"a/docker-compose.yml": compose()}, 1, ("not one folder name",), list_body=allow.replace('"paperless-ngx": "paperless"', '"paperless-ngx": "../backups"')) # The stdlib reader against PyYAML on every catalog file (this suite needs PyYAML anyway). import importlib.util