Files
ARTEX-chixuweihu/Dockerfile.sandbox
T
ji ruo d786de90af feat(traffic,sandbox): add TUN/netstack transparent gateway, egress controls, CAP_NET_RAW hardening, and i18n fixes
- Implement full-traffic transparent gateway (cmd/artex-gateway, traffic/netstack.go, traffic/transparent.go) using Linux TUN + gVisor netstack deferred TCP handshakes (eliminating nmap/nc false-positive open ports), real ICMPv4 Echo proxying, UDP/DNS interception, and per-container upstream proxy overrides.
- Add egress blacklist + asset-intercept sync, non-HTTP flow/DNS SQLite persistence and APIs, and /system/proxy & /function/traffic TCP/UDP/DNS UI panels.
- Fix sandbox Playwright MCP browser loopback --proxy-server rewrite and NODE_EXTRA_CA_CERTS override in server/mcpstdio.go.
- Strip all SUID/SGID binaries in Dockerfile.sandbox, grant minimal cap_net_raw+ep to nmap/nping/ping with ARTEX_SANDBOX_ALLOW_NET_RAW toggle, and enforce IPv4/IPv6 anti-spoofing in iptables and netstack.
- Remove hardcoded Chinese "(全局)" from GET /api/proxy/routes, localize ContainerRoutesTab / NonHTTPTrafficPanel labels, and expose reactive locale/isEn from useLiveTranslation for React Compiler compatibility.
2026-12-02 02:51:36 +08:00

65 lines
3.5 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# syntax=docker/dockerfile:1
#
# ARTEX Worker / Chat Sandbox 镜像:
# 承载所有不受信任的工具执行(Bash / Python 脚本 / 扫描工具 / Playwright 浏览器),
# 不含 ARTEX 主服务、不含 LLM Key、不含数据库凭据,以非 root 用户运行。
#
# 本地构建:
# docker build -f Dockerfile.sandbox -t ruoji6/artex-sandbox:latest .
FROM python:3.12-slim-bookworm
ENV TZ=Asia/Shanghai \
DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates ripgrep curl wget vim git jq unzip \
tzdata procps libcap2-bin \
dnsutils iputils-ping netcat-openbsd inetutils-telnet whois nmap \
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*
# 预装 Playwright MCP 与 CLI 及 Chromium(直接装到全局路径供非 root 用户运行,
# 浏览器访问目标站点完全隔离在沙箱容器内)。
# 国内构建可传 --build-arg PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright 加速。
ARG PLAYWRIGHT_DOWNLOAD_HOST=""
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
PLAYWRIGHT_DOWNLOAD_HOST=${PLAYWRIGHT_DOWNLOAD_HOST} \
SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt \
CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt \
REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt \
NODE_EXTRA_CA_CERTS=/etc/artex/ca.crt \
NMAP_PRIVILEGED=1
RUN mkdir -p /ms-playwright /workspace /etc/artex /usr/local/share/ca-certificates \
&& npm install -g @playwright/mcp@latest @playwright/cli@latest \
&& playwright-mcp --version \
&& playwright-cli --help \
&& playwright-mcp install-browser --with-deps chromium \
&& playwright-cli install-browser chromium \
&& chmod -R a+rX /ms-playwright \
&& rm -rf /var/lib/apt/lists/*
# 常用渗透/脚本 Python 依赖
RUN pip install --no-cache-dir requests httpx beautifulsoup4 pyyaml
# 可选系统 CA 刷新辅助脚本(默认运行模式下由主服务直接只读挂载合并后的
# /etc/ssl/certs/ca-certificates.crt,无需容器内 root 权限;若以 root 调试
# 或自定义镜像启动,可运行此脚本通过 update-ca-certificates 注入 /etc/artex/ca.crt)。
RUN printf '#!/bin/sh\nif [ -f /etc/artex/ca.crt ] && [ -w /usr/local/share/ca-certificates ]; then\n cp /etc/artex/ca.crt /usr/local/share/ca-certificates/artex-mitm-ca.crt\n update-ca-certificates >/dev/null 2>&1 || true\nfi\n' > /usr/local/bin/artex-update-ca.sh \
&& chmod +x /usr/local/bin/artex-update-ca.sh
# 非 root 运行用户(UID/GID 1000,与 ARTEX_SANDBOX_USER 默认值对齐)。
RUN groupadd -g 1000 sandbox \
&& useradd -u 1000 -g 1000 -m -s /bin/bash sandbox \
&& chown -R 1000:1000 /workspace
# 剥离所有 SUID/SGID 位防止提权,仅授予 nmap / nping / ping 最小必需的 cap_net_raw+ep
# 文件能力(注意仅 +ep 而非 +eip,确保子进程/NSE os.execute 不继承任何 capability),
# 使非 root 沙箱用户(uid 1000)无需 sudo 即可执行 nmap -sU/-sS、nping 与 ping,
# 同时普通脚本与进程依然保持 CapEff=0。
RUN find / -xdev -perm /6000 -type f -exec chmod a-s {} + 2>/dev/null || true \
&& setcap cap_net_raw+ep /usr/bin/nmap \
&& (setcap cap_net_raw+ep /usr/bin/nping 2>/dev/null || true) \
&& (setcap cap_net_raw+ep /usr/bin/ping 2>/dev/null || setcap cap_net_raw+ep /bin/ping 2>/dev/null || true)
USER 1000:1000
WORKDIR /workspace
CMD ["sleep", "infinity"]