The privileges gate mirrors the controller's security-review fixes (image-bound entry, more classes, drive-namespace roots)
gates / gates (push) Successful in 5s
gates / gates (push) Successful in 5s
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
d5a443dbd1
commit
6b7d40d80b
4 files changed
+48
-11
No files matched your search
@@ -13,6 +13,9 @@
|
||||
- Standard library only (CI has no PyYAML): a small compose reader; the decoy suite checks it equals PyYAML on all 123
|
||||
catalog files. Decoys in `test_gate_decoys.py` (`privileges`): 6 genuine/decoy passes, 11 facts refused, rc 3 on no
|
||||
templates; red-proved (with the allow-list check disabled, the 10 refusal cases fail).
|
||||
- After the controller's security review (same day): an allowed entry holds only for its `image` repository and the
|
||||
image's own entrypoint/command; the classes gained `cgroup_parent`, `runtime`, `isolation`, `gpus`, deploy device
|
||||
reservations, `provider`, `post_start`/`pre_stop`; a data root must be under `/mnt/felhom-drives/`. Four new decoys.
|
||||
- Survey: all 123 files, nothing in any class except homepage's socket (felhom.eu
|
||||
`audits/agent-allowlist-rotation-2026-10-17/P2/survey.md`).
|
||||
|
||||
|
||||
@@ -12,11 +12,13 @@ classes below unless that app's service has exactly that setting on the allow-li
|
||||
fails here before it is pushed instead of being refused on every box and alarming the operator.
|
||||
|
||||
THE CLASSES (the same setting strings as the controller's — a mismatch makes this gate and the box disagree):
|
||||
privileged, cap_add, device, device_cgroup_rule, network_mode, pid, ipc, uts, userns_mode, cgroup, security_opt
|
||||
(except no-new-privileges), sysctl, volumes_from, build, extends_file, env_file outside the stack dir, bind (a host
|
||||
path outside ${HDD_PATH} / ${USERDATA_PATH} / ${IMPORT_PATH}, the Docker socket anywhere, mount propagation), volume
|
||||
privileged, cap_add, device, device_cgroup_rule, network_mode, pid, ipc, uts, userns_mode, cgroup, cgroup_parent,
|
||||
runtime, isolation, security_opt (except no-new-privileges), sysctl, volumes_from, gpus, device_request (deploy
|
||||
reservations), provider, post_start / pre_stop, build, extends_file, env_file outside the stack dir, bind (a host path
|
||||
outside ${HDD_PATH} / ${USERDATA_PATH} / ${IMPORT_PATH}, the Docker socket anywhere, mount propagation), volume
|
||||
(driver / driver_opts / external / name), config_file / secret_file outside the stack dir, include, and
|
||||
`interpolated <key>` for a ${VAR} inside any of the privileged keys.
|
||||
`interpolated <key>` for a ${VAR} inside any of the privileged keys. An allowed setting holds only while its service
|
||||
runs the entry's image repository with the image's own entrypoint and command.
|
||||
|
||||
THE LIST: scripts/privilege-allowlist.json, a BYTE-IDENTICAL copy of the controller's
|
||||
internal/privpolicy/allowlist.json (pinned there by TestAllowList_CatalogCopyIsIdentical, and here by this gate when the
|
||||
@@ -46,9 +48,11 @@ PLACEHOLDER_ENV = {
|
||||
"SUBDOMAIN": "check",
|
||||
}
|
||||
ROOT_VARS = ("HDD_PATH", "USERDATA_PATH", "IMPORT_PATH")
|
||||
SCALAR_KEYS = ("network_mode", "pid", "ipc", "uts", "userns_mode", "cgroup")
|
||||
SCALAR_KEYS = ("network_mode", "pid", "ipc", "uts", "userns_mode", "cgroup", "cgroup_parent", "runtime", "isolation")
|
||||
PRIVILEGED_KEYS = ("privileged", "cap_add", "devices", "device_cgroup_rules", "network_mode", "pid", "ipc", "uts",
|
||||
"userns_mode", "cgroup", "security_opt", "sysctls", "volumes_from")
|
||||
"userns_mode", "cgroup", "cgroup_parent", "runtime", "isolation", "security_opt", "sysctls",
|
||||
"volumes_from", "gpus", "provider", "post_start", "pre_stop")
|
||||
DRIVE_NAMESPACE = "/mnt/felhom-drives/"
|
||||
|
||||
|
||||
# ---------- a small YAML reader for compose files ----------
|
||||
@@ -336,7 +340,7 @@ def valid_roots(env):
|
||||
out = []
|
||||
for r in ROOT_VARS:
|
||||
v = env.get(r, "")
|
||||
if v and v.startswith("/") and os.path.normpath(v) == v and v != "/" and not has_dotdot(v) and v.startswith("/mnt/"):
|
||||
if v and v.startswith("/") and os.path.normpath(v) == v and v != "/" and not has_dotdot(v) and v.startswith(DRIVE_NAMESPACE):
|
||||
out.append(v)
|
||||
return out
|
||||
|
||||
@@ -394,6 +398,17 @@ def violations(doc, env):
|
||||
add(name, "volumes_from " + render(v, env))
|
||||
if "build" in sd:
|
||||
add(name, "build")
|
||||
if "gpus" in sd:
|
||||
add(name, "gpus " + canon(sd["gpus"], env))
|
||||
res = ((sd.get("deploy") or {}).get("resources") or {}) if isinstance(sd.get("deploy"), dict) else {}
|
||||
rv = res.get("reservations") if isinstance(res, dict) else None
|
||||
if isinstance(rv, dict) and "devices" in rv:
|
||||
add(name, "device_request " + canon(rv["devices"], env))
|
||||
if "provider" in sd:
|
||||
add(name, "provider " + canon(sd["provider"], env))
|
||||
for hook in ("post_start", "pre_stop"):
|
||||
if hook in sd:
|
||||
add(name, hook + " " + canon(sd[hook], env))
|
||||
ex = sd.get("extends")
|
||||
if isinstance(ex, dict) and "file" in ex:
|
||||
add(name, "extends_file " + shown(ex["file"], env))
|
||||
@@ -450,6 +465,12 @@ def volume(v, env, roots):
|
||||
return None
|
||||
|
||||
|
||||
def image_repo(ref):
|
||||
ref = ref.strip().split("@", 1)[0]
|
||||
i = ref.rfind(":")
|
||||
return ref[:i] if i > ref.rfind("/") else ref
|
||||
|
||||
|
||||
def judge_files(root):
|
||||
tdir = os.path.join(root, "templates")
|
||||
files = []
|
||||
@@ -468,7 +489,7 @@ def main(argv):
|
||||
root = a.split("=", 1)[1]
|
||||
with io.open(os.path.join(root, ALLOWLIST), encoding="utf-8") as f:
|
||||
raw_list = f.read()
|
||||
allowed = {(e["app"], e["service"], e["setting"]) for e in json.loads(raw_list)["entries"]}
|
||||
allowed = {(e["app"], e["service"], e["setting"]): e["image"] for e in json.loads(raw_list)["entries"]}
|
||||
sibling = os.path.join(root, CONTROLLER_COPY)
|
||||
if os.path.exists(sibling):
|
||||
with io.open(sibling, encoding="utf-8") as f:
|
||||
@@ -493,8 +514,16 @@ def main(argv):
|
||||
bad.append("%s: cannot be read (%s) — the box refuses a definition it cannot check" % (rel, e))
|
||||
continue
|
||||
for svc, setting in violations(doc, PLACEHOLDER_ENV):
|
||||
where = "%s: %s%s" % (rel, (svc + ": ") if svc else "", setting)
|
||||
if (app, svc, setting) not in allowed:
|
||||
bad.append("%s: %s%s — not on the allow-list (scripts/privilege-allowlist.json)" % (rel, (svc + ": ") if svc else "", setting))
|
||||
bad.append(where + " — not on the allow-list (scripts/privilege-allowlist.json)")
|
||||
continue
|
||||
# the entry holds only for its image repository and the image's own start (security review 2026-10-17)
|
||||
sd = (doc.get("services") or {}).get(svc) or {}
|
||||
if image_repo(render(sd.get("image"), PLACEHOLDER_ENV)) != allowed[(app, svc, setting)]:
|
||||
bad.append(where + " — allowed only for image " + allowed[(app, svc, setting)])
|
||||
elif "entrypoint" in sd or "command" in sd:
|
||||
bad.append(where + " — allowed only with the image's own entrypoint and command")
|
||||
for b in bad:
|
||||
print("REFUSED " + b)
|
||||
if bad:
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"version": 1,
|
||||
"note": "R-971 (operator decision D2 = A, 2026-10-17). The box's catalog allow-list, compiled into the controller. Each entry allows ONE exact setting for ONE service of ONE app; a changed setting is a different one and is refused. The catalog's scripts/privilege-allowlist.json is a byte-identical copy for its CI gate. Survey: felhom.eu documentation/audits/agent-allowlist-rotation-2026-10-17/P2/survey.md",
|
||||
"note": "R-971 (operator decision D2 = A, 2026-10-17). The box's catalog allow-list, compiled into the controller. Each entry allows ONE exact setting for ONE service of ONE app, only while that service runs the entry's image repository with the image's own entrypoint and command; a changed setting is a different one and is refused. The catalog's scripts/privilege-allowlist.json is a byte-identical copy for its CI gate. Survey: felhom.eu documentation/audits/agent-allowlist-rotation-2026-10-17/P2/survey.md",
|
||||
"entries": [
|
||||
{
|
||||
"app": "homepage",
|
||||
"service": "homepage",
|
||||
"setting": "bind /var/run/docker.sock -> /var/run/docker.sock ro",
|
||||
"image": "ghcr.io/gethomepage/homepage",
|
||||
"why": "the Docker widget and the docker service discovery list the household's containers and their state",
|
||||
"doc": "https://gethomepage.dev/configs/docker/"
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ COVERS = {
|
||||
"login-kind": "login_kind written only in a COMMENT, only inside the English i18n: block, or under ANOTHER mapping (resources:) - none is the field, each passes; vs the facts: an unknown value (`magic`), a wrong case (`EMAIL`), the key twice, and no templates/ at all (rc 3, never a pass); the three known values pass (controller 0.320.0)",
|
||||
"copy-i18n": "Hungarian edited in a COMMENT/README/display_name (label, not copy) vs a real frozen string changed; an English block that is not English, is not matched to a Hungarian twin, or rewrites a credential (R-560). A retrieval promise REGISTERED in ALLOWLIST_EN passes only for its own app+path+sentence with a real reason; an entry for another app, a rewritten sentence, a stale entry or a two-word reason convicts (R-594). Also the DEGRADED mode CI actually runs — PyYAML shadowed out, freeze only (R-595). THE USER GUIDE (2026-10-15): a download-source name only in a COMMENT or in docs_url passes; vs the facts - guide strings not frozen, checked_version in the English block, an empty steps list, an FAQ entry with no answer, an unquoted version, an English guide with no Hungarian one, more English sections than Hungarian, a different step count, and a source name in either language",
|
||||
"redis-persistence": "`--appendonly yes` only in a COMMENT, or only in a steps/ file (a tested step definition, not judged on purpose) - each passes; vs the facts: AOF in string form, in a flow list, in a block list, on a valkey image - each refused naming the app; image default (no command) and `--appendonly no` pass; no templates/ is rc 3 (R-1096)",
|
||||
"privileges": "a dangerous key only in a COMMENT, `privileged: false`, `no-new-privileges:true`, a ${HDD_PATH} bind, the docker socket only in a comment, homepage's own allow-listed read-only socket - each passes; vs the facts: privileged true, cap_add, a host-root bind, a ${OTHER} bind, homepage's socket READ-WRITE, the same socket in ANOTHER app, network_mode host, a driver_opts bind volume, a ${VAR} in a privileged key, the same in a steps/ file, an allow-list copy that differs from the controller's - each refused naming the setting; no templates/ is rc 3; and the stdlib reader equals PyYAML on every catalog file (R-971)",
|
||||
"privileges": "a dangerous key only in a COMMENT, `privileged: false`, `no-new-privileges:true`, a ${HDD_PATH} bind, the docker socket only in a comment, homepage's own allow-listed read-only socket - each passes; vs the facts: privileged true, cap_add, a host-root bind, a ${OTHER} bind, homepage's socket READ-WRITE, the same socket in ANOTHER app or under ANOTHER image or with an added entrypoint, gpus / provider / a privileged post_start, network_mode host, a driver_opts bind volume, a ${VAR} in a privileged key, the same in a steps/ file, an allow-list copy that differs from the controller's - each refused naming the setting; no templates/ is rc 3; and the stdlib reader equals PyYAML on every catalog file (R-971)",
|
||||
"gate-decoys": "this suite, run as a gate of the full run (R-1115): every case above is a decoy of its own gate, and ONE case that stops convicting turns the whole run red - measured 2026-10-17, when the credential-token case had lost its premise (gokapi's login line removed by 326f846) the suite printed FAIL and exited 1; the copy-i18n credential cases now edit an EXISTING line, so a removed premise stops the suite (`edit` raises) instead of passing",
|
||||
}
|
||||
|
||||
@@ -875,6 +875,10 @@ def privileges_cases():
|
||||
run("FACT: a driver_opts bind volume", {"a/docker-compose.yml": compose().replace("volumes:\n app_data:\n", "volumes:\n app_data:\n driver_opts:\n type: none\n o: bind\n device: /\n")}, 1, ("volume app_data driver_opts",))
|
||||
run("FACT: a ${VAR} in a privileged key", {"a/docker-compose.yml": compose(" privileged: ${PRIV}\n")}, 1, ("interpolated privileged",))
|
||||
run("FACT: privileged in a steps/ file", {"a/docker-compose.yml": compose(), "a/steps/0123456789abcdef.yml": compose(" privileged: true\n")}, 1, ("a/steps/0123456789abcdef.yml",))
|
||||
run("FACT: homepage's socket under ANOTHER image", {"homepage/docker-compose.yml": homepage.replace("ghcr.io/gethomepage/homepage", "docker.io/evil/homepage")}, 1, ("allowed only for image",))
|
||||
run("FACT: homepage's socket with an added entrypoint", {"homepage/docker-compose.yml": homepage.replace(" volumes:", " entrypoint: [sh, -c, id]\n volumes:", 1)}, 1, ("own entrypoint",))
|
||||
run("FACT: gpus / a provider service / a privileged post_start", {"a/docker-compose.yml": compose(" gpus: all\n provider:\n type: model\n post_start:\n - command: id\n privileged: true\n")}, 1, ("gpus all", "provider", "post_start"))
|
||||
run("GENUINE: homepage bumped to a new tag of the same image", {"homepage/docker-compose.yml": homepage.replace("homepage:v1.13.2", "homepage:v1.14.0")}, 0)
|
||||
run("FACT: the list copy differs from the controller's", {"a/docker-compose.yml": compose()}, 1, ("differs",), controller_copy=allow.replace("homepage", "glance"))
|
||||
run("FACT: no templates/ at all (nothing to judge)", {}, 3, ("nothing to judge",), no_templates=True)
|
||||
# The stdlib reader against PyYAML on every catalog file (this suite needs PyYAML anyway).
|
||||
|
||||
Reference in new issue
Block a user