fix(managed): guard dropped-UID queue ownership inspection
Require effective SYS_PTRACE only for native owned workers and distinguish denied FD inspection from foreign queue ownership. Keep inode proof authoritative and constrain deployment to its private PID namespace. Co-authored-by: GPT-6 <gpt-6@openai.com>
This commit is contained in:
1 parent
18038e4112
commit
0398e6fe28
5 files changed
+120
-15
No files matched your search
@@ -113,10 +113,20 @@ password before starting child processes.
|
||||
|
||||
The dedicated bridge is not shared with existing services. No host networking,
|
||||
Docker socket, existing mounts, host Lua/fakes or privileged mode; all
|
||||
capabilities are dropped except `NET_ADMIN`, `NET_RAW`, `SETUID`, `SETGID`, `KILL`.
|
||||
capabilities are dropped except `NET_ADMIN`, `NET_RAW`, `SETUID`, `SETGID`, `KILL`,
|
||||
`SYS_PTRACE`.
|
||||
`NET_ADMIN` covers nft/NFQUEUE; `NET_RAW` covers nfqws2 raw sends. Zapret2's
|
||||
`nfqws2 --user=tpws` needs `SETUID`/`SETGID` for UID/GID switching.
|
||||
`KILL` allows bounded cleanup of workers that have dropped their UID.
|
||||
`SYS_PTRACE` permits inspecting socket FD symlinks of privilege-dropped,
|
||||
nondumpable nfqws workers to prove NFQUEUE ownership by inode. The native owned
|
||||
worker path fails fast without effective `KILL`, `NET_ADMIN` and `SYS_PTRACE`;
|
||||
legacy modes do not gain this requirement. Permission denial is an inspection
|
||||
failure, not evidence that another process owns the queue.
|
||||
This capability is confined to the target's **private PID namespace**: never
|
||||
use host or shared/container PID namespaces. It does not grant inspection of
|
||||
broader host processes. The full service/adaptive hardware gate remains
|
||||
**pending**, not PASS; this ownership fix alone does not qualify it.
|
||||
|
||||
Startup order: ss-server/ss-local → listener 1080 → guarded managed init on
|
||||
fresh state → `managed reconcile` on every startup → target-local `zapret2 start`
|
||||
|
||||
@@ -13,7 +13,8 @@ readme = (directory / "README.md").read_text()
|
||||
assert " privileged: false\n" in compose
|
||||
assert " image: ${ZAPRET_AUTOTUNE_IMAGE:-zapret-autotune-managed-target:local}\n" in compose
|
||||
assert " cap_drop: [ALL]\n" in compose
|
||||
assert " cap_add: [NET_ADMIN, NET_RAW, SETUID, SETGID, KILL]\n" in compose
|
||||
assert " cap_add: [NET_ADMIN, NET_RAW, SETUID, SETGID, KILL, SYS_PTRACE]\n" in compose
|
||||
assert "pid:" not in compose # Keep inspection confined to the private PID namespace.
|
||||
assert compose.count(" - type: bind\n") == 1
|
||||
assert " source: ./target-state\n" in compose
|
||||
assert " target: /var/lib/zapret-autotune/target\n" in compose
|
||||
|
||||
@@ -7,8 +7,9 @@ services:
|
||||
dockerfile: Dockerfile.target
|
||||
privileged: false
|
||||
cap_drop: [ALL]
|
||||
# nft/NFQUEUE, raw sends, UID/GID switching, cleanup of dropped-UID workers.
|
||||
cap_add: [NET_ADMIN, NET_RAW, SETUID, SETGID, KILL]
|
||||
# SYS_PTRACE permits /proc/<worker>/fd ownership checks after nfqws drops UID.
|
||||
# Confined to this target's private PID namespace; never share host processes.
|
||||
cap_add: [NET_ADMIN, NET_RAW, SETUID, SETGID, KILL, SYS_PTRACE]
|
||||
environment:
|
||||
SS_PASSWORD: ${SS_PASSWORD:?Set SS_PASSWORD in the deployment environment}
|
||||
SS_DNS_SERVER: ${SS_DNS_SERVER-}
|
||||
|
||||
Reference in new issue
Block a user