fix(security): изоляция агент-контейнера Фаза-0 (пентест AGENT-EXFIL)

--cap-drop=ALL + --security-opt no-new-privileges + --pids-limit=512 (+memory-swap)
во всех 4 точках docker-run (claude_bridge/sonnet/sandbox/canary, лок-степ). Worker
уже non-root → кэпы не нужны; режет пост-эксплуатацию + fork-bomb. Сеть/креды —
следующими фазами (главный фикс exfil). Проверка канарейкой на dev.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
anor
2026-07-19 13:52:34 +10:00
co-authored by Claude Opus 4.8
parent 8b9cc93315
commit a9f4523e69
5 changed files with 15 additions and 1 deletions
+6
View File
@@ -271,7 +271,13 @@ async def stream_claude(
"docker", "run", "--rm",
# Resource limits — bumped for xlsm parsing
"--memory=2g",
"--memory-swap=2g", # не уходить в своп
"--cpus=2",
# Изоляция контейнера (пентест AGENT-EXFIL Фаза-0): worker уже non-root,
# кэпы/новые привилегии не нужны; pids-limit — анти-fork-bomb из инъекции.
"--pids-limit=512",
"--security-opt", "no-new-privileges",
"--cap-drop=ALL",
"--network=host", # access xray on host
# Mount work directory as /data
"-v", f"{work_dir.resolve()}:/data",
+4
View File
@@ -167,6 +167,10 @@ async def stream_claude(
"docker", "run", "--rm",
"--memory=512m",
"--cpus=1",
# Изоляция контейнера (пентест AGENT-EXFIL Фаза-0, лок-степ с claude_bridge)
"--pids-limit=512",
"--security-opt", "no-new-privileges",
"--cap-drop=ALL",
"--network=host",
"-v", f"{CLAUDE_CONFIG_DIR}:/home/worker/.claude",
"-v", f"{os.path.expanduser('~')}/.claude.json:/home/worker/.claude.json",
+1 -1
View File
@@ -151,7 +151,7 @@ MAX_MESSAGE_LEN = 10_000
# ⚠️ Версия UI — единый источник. БАМПАТЬ ПРИ КАЖДОМ ДЕПЛОЕ (формат: YYYY-MM-DD + буква).
# Фронт берёт её через GET /api/version (chat.html + admin.html, элемент .app-version).
APP_VERSION = "2026-07-19h"
APP_VERSION = "2026-07-19i"
# Audit: path → action name mapping
_AUDIT_MAP = [
+3
View File
@@ -82,6 +82,9 @@ async def stream_claude(
# Docker command
cmd = [
"docker", "run", "--rm",
"--pids-limit=512",
"--security-opt", "no-new-privileges",
"--cap-drop=ALL",
# Resource limits
"--memory=512m",
"--cpus=1",
+1
View File
@@ -32,6 +32,7 @@ if [ -n "${CANARY_PROBE_OVERRIDE:-}" ]; then
OUT="$(eval "$CANARY_PROBE_OVERRIDE" 2>&1)"; RC=$?
else
OUT="$(timeout "$CANARY_TIMEOUT" docker run --rm --network=host \
--pids-limit=512 --security-opt no-new-privileges --cap-drop=ALL \
-e HOME=/home/worker \
-e "HTTPS_PROXY=http://${DOCKER_HOST_GW}:${XRAY_PORT}" \
-e "HTTP_PROXY=http://${DOCKER_HOST_GW}:${XRAY_PORT}" \