Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ POSTGRES_USER=artex
# because Compose reads this file that way.
POSTGRES_PASSWORD=change-me-please
POSTGRES_DB=artex
# Shared secret between the panel and artex-runner for the internal execution
# API. install.sh and update.sh generate it when empty. Keep it private.
ARTEX_RUNNER_TOKEN=
# Agent execution isolation: required (default, one worker per task) or off
# (explicit degraded mode, loud warning). docker-compose.yml includes the runner.
# ARTEX_SANDBOX=required
# Prebuilt GHCR image tag for docker-compose.ghcr.yml. Unset uses latest.
# ARTEX_IMAGE_TAG=latest
# Build identity shown in the UI and the startup banner. update.sh refreshes both
Expand Down
65 changes: 63 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:

# ③ Collect all zips → create the GitHub Release
release:
needs: binaries
needs: [binaries, sandbox-images]
runs-on: ubuntu-latest
permissions:
contents: write # create the Release (softprops/action-gh-release)
Expand Down Expand Up @@ -152,7 +152,68 @@ jobs:
generate_release_notes: false
body_path: ${{ runner.temp }}/release-body.md

# ④ Multi-arch image → push to GitHub Container Registry (and optionally Docker Hub
# ④ Sandbox images: the runner, the per-task worker and the egress proxy.
# The panel image above is useless for agent execution without them when
# ARTEX_SANDBOX=required, so they are published from the same tag.
sandbox-images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- { name: runner, dockerfile: Dockerfile.runner }
- { name: worker, dockerfile: Dockerfile.worker }
- { name: egress-proxy, dockerfile: Dockerfile.egress-proxy }
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Log in to GitHub Container Registry
if: github.event_name == 'push'
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
id: meta
with:
images: ghcr.io/baarai/artex-${{ matrix.name }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=raw,value=latest
- uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
ARTEX_VERSION=${{ github.ref_name }}
ARTEX_REVISION=${{ github.sha }}
provenance: true
sbom: true
- name: Verify the image pulls anonymously
if: github.event_name == 'push'
run: |
tag="${GITHUB_REF_NAME}"
image="ghcr.io/baarai/artex-${{ matrix.name }}:${tag}"
cfg="$(mktemp -d)"
for attempt in 1 2 3; do
if DOCKER_CONFIG="$cfg" docker manifest inspect "$image" >/dev/null; then
exit 0
fi
sleep 10
done
echo "anonymous pull of $image is denied; set the package visibility to Public" >&2
exit 1

# ⑤ Multi-arch image → push to GitHub Container Registry (and optionally Docker Hub
# when DOCKERHUB_ENABLED is set to 'true' alongside DOCKERHUB_IMAGE and
# DOCKERHUB_USERNAME / DOCKERHUB_TOKEN secrets). Dry runs (workflow_dispatch)
# build both platforms without logging in or pushing.
Expand Down
27 changes: 21 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
# Changelog

All notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

## [0.7.1] - 2026-11-30

### Security

- **Per-task execution sandbox is the default.** `Bash`, custom command and script tools, and stdio MCP servers run in a disposable `artex-worker` container created by `artex-runner`, never in the panel container. The worker has uid/gid 10001, a read-only rootfs, `cap-drop ALL`, no key or database mount, only its task workspace, and only an internal task network. A per-task `artex-egress-proxy` enforces a deny-by-default domain and CIDR allowlist with DNS pinning, HTTP/HTTPS CONNECT and SOCKS5, blocks IMDS, RFC1918, loopback, link-local and IPv6 unless explicitly approved, and writes its audit log outside the worker workspace. The runner and the three images are part of `docker-compose.yml`, `docker-compose.ghcr.yml`, `install.sh` and `update.sh`; the release publishes the runner, worker and egress-proxy images beside the panel. `ARTEX_SANDBOX=off` is the explicit, loud degraded mode.
- **The sandbox egress allowlist is operator-owned, not agent-writable.** Migration `0023_task_scope_operator_approval.sql` adds `task_scope.approved_by_operator`. Only operator-approved rows (Task Scope UI, operator-selected companies, operator retarget) grant egress; `add_task_scope`, `insert_assets`, agent-spawned company scope and expanded rows are coverage-only. `WebFetch` and the shared browser use the same policy. Existing `source='manual'` rows are backfilled; goal-derived (`source='agent'`) and auto (`source='auto'`) scopes must be re-approved once in Task Scope. Target-gate approval clears only the tool-call gate, and the denial message says so.
- **Startup is fail-closed and key permissions are enforced.** The isolation self-test stops the server on every platform unless `ARTEX_ALLOW_UNISOLATED=1` is explicitly set. The key directory is tightened to 0700 and existing key files to 0600 at startup, so a host bind mount cannot mask the image permissions.
- **Secret rotation is atomic.** `db.RotateSecretKey`, `artex -rotate-secrets` and `scripts/rotate-secrets.sh` re-encrypt every sealed database value and bump `auth.password_version` in one transaction before the new key is moved into place. Existing sessions are invalidated.
- **Target gate backfill and a real kill switch.** Migration `0022_target_gate_backfill.sql` enables the gate on active scoped tasks that did not opt out, with `tasks.target_gate_opt_out` for the explicit opt-out. `Engine.Pause` and `Engine.BeginDelete` set `PR_SET_CHILD_SUBREAPER` and terminate the executor UID or task descendants from `/proc`; the sandbox kill scans `/proc` for uid 10001 and never trusts agent-writable state, with a container-removal fallback.
- **Chat bridge approval buttons recheck access.** A member removed, a chat unlisted or the bridge disabled while a batch was queued can no longer spend a valid button. The handler re-reads the bridge, refuses when access or the enabled state changed, and the consume statement requires the current `config_version`. Reported privately by @jamesKhor.

### Breaking Changes
- **Upgrade note (migration `0023_task_scope_operator_approval.sql`)**: Existing `source = 'manual'` `task_scope` rows are backfilled to `approved_by_operator = TRUE`, while goal-derived/agent (`source = 'agent'`) and auto (`source = 'auto'`) scopes remain `FALSE` and must be re-approved once via the Task Scope UI to grant sandbox egress. Target-gate approval clears only the tool gate; worker egress still requires operator-approved Task Scope.
- **Container sandbox required by default (`ARTEX_SANDBOX=required`)**: agent execution (`Bash`, custom command/script tools) now routes to disposable per-task `artex-worker` containers via `artex-runner` (`docker-compose.sandbox.yml`) with an `internal: true` per-task network and DNS-pinning HTTP/SOCKS5 egress allowlist proxy (`artex-egress-proxy`). Tasks refuse to start or pause when the runner is unavailable (no silent local fallback). Pass `ARTEX_SANDBOX=off` for explicit degraded local mode (logs a loud startup warning and records `sandbox=off` in every task event log).

# Changelog
- **`ARTEX_SANDBOX=required` by default.** If `artex-runner` is unavailable, ARTEX refuses to start tasks and pauses running tasks, with no local fallback. `ARTEX_SANDBOX=off` is the explicit degraded mode and writes `sandbox=off` into each task event log. The runner needs access to the Docker socket; `install.sh` and `update.sh` generate `ARTEX_RUNNER_TOKEN` and build the runner, worker and egress-proxy images. GHCR users pull the sandbox profile from the same release tag.
- **Existing task scopes need one re-approval.** Operator-entered `source='manual'` scopes are backfilled by migration 0023. Goal-derived and auto-discovered scopes remain coverage-only and must be re-approved once in Task Scope before sandbox egress is granted.

All notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
### Credits

## [Unreleased]
The execution-scope gap and its remediation were tracked in public before the November 2026 writeup: #421 and #423 by @youssefmedhatl, #554, #555 and #553 by @renaesop, with the two-sources-of-truth analysis by @Dukotah in #421. The chat bridge advisory was reported by @jamesKhor. The public writeup is by Kevin Joensen. Thank you.

### Added

Expand Down Expand Up @@ -1285,7 +1299,8 @@ First release of this fork. The engine underneath is still upstream's, but this
- [@Autumn-27](https://github.com/Autumn-27)
- [@neouks](https://github.com/neouks)

[Unreleased]: https://github.com/BaaRai/ARTEX/compare/v0.7.0...HEAD
[Unreleased]: https://github.com/BaaRai/ARTEX/compare/v0.7.1...HEAD
[0.7.1]: https://github.com/BaaRai/ARTEX/compare/v0.7.0...v0.7.1
[0.7.0]: https://github.com/BaaRai/ARTEX/compare/v0.6.0...v0.7.0
[0.6.0]: https://github.com/BaaRai/ARTEX/compare/v0.5.1...v0.6.0
[0.5.1]: https://github.com/BaaRai/ARTEX/compare/v0.5.0...v0.5.1
Expand Down
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1178,12 +1178,34 @@ using this project means you have read, understood and agreed to all of the abov
> development, set `ARTEX_SANDBOX=off` (logs a loud startup banner and writes
> `sandbox=off` into each task's event log).

Launch with the sandbox overlay:
The runner, worker and proxy services are part of `docker-compose.yml` and the
GHCR compose file. `install.sh` and `update.sh` generate `ARTEX_RUNNER_TOKEN` and
build the three images:

```bash
docker compose -f docker-compose.yml -f docker-compose.sandbox.yml --profile build-only build
docker compose -f docker-compose.yml -f docker-compose.sandbox.yml up -d
./install.sh # first install
./update.sh # existing checkout
```

Manual, from a source checkout:

```bash
# Put ARTEX_RUNNER_TOKEN=$(openssl rand -hex 32) in .env once.
docker compose build artex artex-runner
docker compose --profile build-only build artex-worker artex-egress-proxy
docker compose up -d
```

From the published images:

```bash
# ARTEX_RUNNER_TOKEN must be set in .env.
docker compose -f docker-compose.ghcr.yml --profile build-only pull
docker compose -f docker-compose.ghcr.yml up -d
```

`docker-compose.sandbox.yml` remains as a compatibility overlay for existing
commands; it is no longer required.

See [`docs/SANDBOX.md`](docs/SANDBOX.md) for the runner API, per-task internal
network, HTTP/SOCKS5 egress allowlist proxy, and security boundary.
52 changes: 52 additions & 0 deletions docker-compose.ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ services:
depends_on:
postgres:
condition: service_healthy
artex-runner:
condition: service_healthy
networks:
- default
- runner-net
environment:
# Parts, not a pasted URL. PostgresDSN percent-encodes the password, so a
# value with / ? % @ : or a space still connects.
Expand Down Expand Up @@ -71,6 +76,11 @@ services:
ARTEX_TASK_BUDGET_TURNS: ${ARTEX_TASK_BUDGET_TURNS:-}
ARTEX_INTENT_BUDGET_TOKENS: ${ARTEX_INTENT_BUDGET_TOKENS:-}
ARTEX_INTENT_BUDGET_TURNS: ${ARTEX_INTENT_BUDGET_TURNS:-}
# Agent execution runs in disposable per-task worker containers. The
# sandbox images are published beside the panel image.
ARTEX_SANDBOX: ${ARTEX_SANDBOX:-required}
ARTEX_RUNNER_URL: ${ARTEX_RUNNER_URL:-http://artex-runner:8789}
ARTEX_RUNNER_TOKEN: ${ARTEX_RUNNER_TOKEN:?Please set ARTEX_RUNNER_TOKEN in .env}
ports:
- "${ARTEX_BIND_ADDR:-127.0.0.1}:8787:8787"
- "127.0.0.1:8788:8788"
Expand All @@ -79,5 +89,47 @@ services:
- ./keys:/app/keys
restart: unless-stopped

artex-runner:
image: ghcr.io/baarai/artex-runner:${ARTEX_IMAGE_TAG:-latest}
networks:
- runner-net
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data/tasks:/app/data/tasks
- ./data/egress-audit:/app/data/egress-audit
environment:
ARTEX_RUNNER_TOKEN: ${ARTEX_RUNNER_TOKEN:?Please set ARTEX_RUNNER_TOKEN in .env}
ARTEX_WORKER_IMAGE: ${ARTEX_WORKER_IMAGE:-ghcr.io/baarai/artex-worker:${ARTEX_IMAGE_TAG:-latest}}
ARTEX_EGRESS_PROXY_IMAGE: ${ARTEX_EGRESS_PROXY_IMAGE:-ghcr.io/baarai/artex-egress-proxy:${ARTEX_IMAGE_TAG:-latest}}
ARTEX_WORKSPACE_ROOT: /app/data/tasks
ARTEX_HOST_WORKSPACE_ROOT: ${ARTEX_HOST_WORKSPACE_ROOT:-./data/tasks}
ARTEX_AUDIT_ROOT: /app/data/egress-audit
ARTEX_HOST_AUDIT_ROOT: ${ARTEX_HOST_AUDIT_ROOT:-./data/egress-audit}
ARTEX_TASK_NET_PREFIX: ${ARTEX_TASK_NET_PREFIX:-artex-task-}
ARTEX_EGRESS_NET: ${ARTEX_EGRESS_NET:-egress-net}
healthcheck:
test: ["CMD-SHELL", "curl -fsS -H \"Authorization: Bearer $$ARTEX_RUNNER_TOKEN\" http://127.0.0.1:8789/v1/health"]
interval: 5s
timeout: 3s
retries: 10
restart: unless-stopped

# Images the runner instantiates per task. They are pulled with
# `docker compose -f docker-compose.ghcr.yml --profile build-only pull`.
artex-worker:
image: ghcr.io/baarai/artex-worker:${ARTEX_IMAGE_TAG:-latest}
profiles: ["build-only"]

artex-egress-proxy:
image: ghcr.io/baarai/artex-egress-proxy:${ARTEX_IMAGE_TAG:-latest}
profiles: ["build-only"]

networks:
runner-net:
internal: true
egress-net:
name: ${ARTEX_EGRESS_NET:-egress-net}
driver: bridge

volumes:
pgdata:
11 changes: 7 additions & 4 deletions docker-compose.sandbox.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# ARTEX Sandbox MVP overlay (CONTRACT.md §§1-6).
# Usage:
# docker compose -f docker-compose.yml -f docker-compose.sandbox.yml build
# docker compose -f docker-compose.yml -f docker-compose.sandbox.yml up -d
# ARTEX sandbox compatibility overlay.
#
# Since 0.7.1 the runner, worker and egress proxy are part of
# docker-compose.yml and docker-compose.ghcr.yml, so a plain
# `docker compose up -d` runs the sandbox. This file is kept so existing
# `-f docker-compose.yml -f docker-compose.sandbox.yml` commands keep working;
# it is no longer required.
#
# Security boundary:
# - artex (panel): holds DB credentials, keys, LLM keys; never mounts docker.sock;
Expand Down
59 changes: 59 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ services:
depends_on:
postgres:
condition: service_healthy
artex-runner:
condition: service_healthy
networks:
- default
- runner-net
environment:
# Parts, not a pasted URL. PostgresDSN percent-encodes the password, so a
# value with / ? % @ : or a space still connects. ARTEX_PG_DSN, when set,
Expand Down Expand Up @@ -73,6 +78,11 @@ services:
ARTEX_TASK_BUDGET_TURNS: ${ARTEX_TASK_BUDGET_TURNS:-}
ARTEX_INTENT_BUDGET_TOKENS: ${ARTEX_INTENT_BUDGET_TOKENS:-}
ARTEX_INTENT_BUDGET_TURNS: ${ARTEX_INTENT_BUDGET_TURNS:-}
# Agent execution runs in disposable per-task worker containers. The
# runner is part of this compose file; its token must be set in .env.
ARTEX_SANDBOX: ${ARTEX_SANDBOX:-required}
ARTEX_RUNNER_URL: ${ARTEX_RUNNER_URL:-http://artex-runner:8789}
ARTEX_RUNNER_TOKEN: ${ARTEX_RUNNER_TOKEN:?Please set ARTEX_RUNNER_TOKEN in .env}
ports:
- "${ARTEX_BIND_ADDR:-127.0.0.1}:8787:8787"
- "127.0.0.1:8788:8788"
Expand All @@ -88,5 +98,54 @@ services:
- ./skills:/app/skills
restart: unless-stopped

artex-runner:
build:
context: .
dockerfile: Dockerfile.runner
image: artex-runner:local
networks:
- runner-net
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data/tasks:/app/data/tasks
- ./data/egress-audit:/app/data/egress-audit
environment:
ARTEX_RUNNER_TOKEN: ${ARTEX_RUNNER_TOKEN:?Please set ARTEX_RUNNER_TOKEN in .env}
ARTEX_WORKER_IMAGE: ${ARTEX_WORKER_IMAGE:-artex-worker:local}
ARTEX_EGRESS_PROXY_IMAGE: ${ARTEX_EGRESS_PROXY_IMAGE:-artex-egress-proxy:local}
ARTEX_WORKSPACE_ROOT: /app/data/tasks
ARTEX_HOST_WORKSPACE_ROOT: ${ARTEX_HOST_WORKSPACE_ROOT:-./data/tasks}
ARTEX_AUDIT_ROOT: /app/data/egress-audit
ARTEX_HOST_AUDIT_ROOT: ${ARTEX_HOST_AUDIT_ROOT:-./data/egress-audit}
ARTEX_TASK_NET_PREFIX: ${ARTEX_TASK_NET_PREFIX:-artex-task-}
ARTEX_EGRESS_NET: ${ARTEX_EGRESS_NET:-egress-net}
healthcheck:
test: ["CMD-SHELL", "curl -fsS -H \"Authorization: Bearer $$ARTEX_RUNNER_TOKEN\" http://127.0.0.1:8789/v1/health"]
interval: 5s
timeout: 3s
retries: 10
restart: unless-stopped

artex-worker:
build:
context: .
dockerfile: Dockerfile.worker
image: artex-worker:local
profiles: ["build-only"]

artex-egress-proxy:
build:
context: .
dockerfile: Dockerfile.egress-proxy
image: artex-egress-proxy:local
profiles: ["build-only"]

networks:
runner-net:
internal: true
egress-net:
name: ${ARTEX_EGRESS_NET:-egress-net}
driver: bridge

volumes:
pgdata:
28 changes: 24 additions & 4 deletions docs/SANDBOX.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,33 @@ from disposable per-task **worker** containers (`artex-worker:local`).

## Running with the sandbox

The runner, worker and proxy are part of `docker-compose.yml` and
`docker-compose.ghcr.yml`. `install.sh` and `update.sh` generate
`ARTEX_RUNNER_TOKEN` and build the three images:

```bash
./install.sh # first install
./update.sh # existing checkout
```

Manual, from a source checkout (put `ARTEX_RUNNER_TOKEN` in `.env` once):

```bash
export ARTEX_RUNNER_TOKEN="$(openssl rand -hex 32)"
docker compose -f docker-compose.yml -f docker-compose.sandbox.yml --profile build-only build
docker compose -f docker-compose.yml -f docker-compose.sandbox.yml build
docker compose -f docker-compose.yml -f docker-compose.sandbox.yml up -d
docker compose build artex artex-runner
docker compose --profile build-only build artex-worker artex-egress-proxy
docker compose up -d
```

From the published images:

```bash
docker compose -f docker-compose.ghcr.yml --profile build-only pull
docker compose -f docker-compose.ghcr.yml up -d
```

`docker-compose.sandbox.yml` is kept as a compatibility overlay; it is no longer
required.

## Breaking change: `ARTEX_SANDBOX=required` by default

Starting with this release, `ARTEX_SANDBOX` defaults to **`required`**. If
Expand Down
2 changes: 1 addition & 1 deletion ghidra/compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestComposeOverlayConfigHasInternalNetworkAndHardening(t *testing.T) {
t.Skip("docker CLI not available; static overlay assertions passed")
}
cmd := exec.Command("docker", "compose", "-f", baseFile, "-f", overlayFile, "config", "--format", "json")
cmd.Env = append(os.Environ(), "POSTGRES_PASSWORD=test")
cmd.Env = append(os.Environ(), "POSTGRES_PASSWORD=test", "ARTEX_RUNNER_TOKEN=testtoken")
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("docker compose config failed: %v\n%s", err, out)
Expand Down
Loading
Loading