Compare commits

...
Author SHA1 Message Date
BaaRai 6c6b353dab docs(changelog): cover notable changes since 0.6.0
The 0.7.1 release notes now list the security, interception, workspace, traffic and data changes from the v0.6.0 window that were not already detailed in the 0.7.0 or 0.7.1 sections, with their pull request numbers.
2026-11-30 21:18:23 +01:00
BaaRai 518739be3b security(server): refuse stdio MCP discovery on the panel in sandbox mode
In ARTEX_SANDBOX=required the panel must not start agent-controlled local processes. discoverAndCacheMCP now refuses stdio before connectMCP, which covers startup auto-discovery, the operator add/refresh paths and ScopeSentry; the Auto agent's create_mcp and update_mcp reject stdio transports as well. HTTP and SSE MCP clients keep their existing checks. The canary test proves the command is not spawned.
2026-11-30 21:18:09 +01:00
BaaRai 2438d1f4c0 fix(docker): keep the worker's existing exec user
Dockerfile.worker already creates exec (10001:10001) with HOME=/home/exec; #708's artex-exec rename was unnecessary and would have changed the worker identity name. The panel image keeps the artex-exec entry it needed; the worker is unchanged. The changelog now says so.
2026-11-30 21:14:11 +01:00
KKhandBaaRai f7f097ec2c fix(isolation): verify secret reads under each probe identity with descriptor metadata
Rebase #700 onto P0's isolation changes in server/isolation_unix.go (preserving
LockDownKeyDir, keys/ dir checking, and fail-closed EnforceIsolation): probe
each protected path directly with O_RDONLY|O_NONBLOCK|O_NOCTTY under the file-
tool and Bash identities, report descriptor mode/uid/gid or unexpected open
errors, and add the 0.7.1 CHANGELOG entry.

Co-authored-by: BaaRai <130491490+BaaRai@users.noreply.github.com>
2026-11-30 21:13:50 +01:00
Jędrzej SierackiandBaaRai 2276a3a023 fix(docker): give the agent executor an artex-exec passwd entry in panel and worker images
Port #708 into the panel Dockerfile and Dockerfile.worker so uid/gid 10001
resolves to artex-exec in both images (fixing tools such as ssh that require
a passwd entry for the running UID) and add the 0.7.1 CHANGELOG entry.

Co-authored-by: BaaRai <130491490+BaaRai@users.noreply.github.com>
2026-11-30 21:13:50 +01:00
BaaRai 5bd3dd2c89 Merge pull request #718 from BaaRai/release/0.7.1
release: package the sandbox images for the 0.7.1 default
2026-11-30 21:13:30 +01:00
8 changed files with 191 additions and 20 deletions
+15 -1
View File
@@ -8,11 +8,12 @@ All notable changes to this project are documented in this file. The format is b
### 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.
- **Per-task execution sandbox is the default.** `Bash`, custom command and script tools run in a disposable `artex-worker` container created by `artex-runner`, never in the panel container. Stdio MCP servers are not started on the panel in required mode; HTTP and SSE MCP clients keep their existing checks. 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.
- **The panel does not start stdio MCP servers in sandbox mode.** Discovery, startup auto-discovery, the operator refresh path and the Auto agent's `create_mcp` / `update_mcp` tools reject stdio transports while `ARTEX_SANDBOX=required`; an agent-created stdio MCP cannot be launched on the panel at the next restart. HTTP and SSE MCP clients are unchanged. This closes the remaining panel-side local execution path.
- **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
@@ -45,6 +46,8 @@ The execution-scope gap and its remediation were tracked in public before the No
- **Go vulnerability scanning in CI**: every push and pull request runs the official `govulncheck` action against packages reachable from `./...`, using the Go version declared by `go.mod`. Run the same check locally with `./scripts/verify.sh --security`.
### Fixed
- **Startup isolation self-test verifies secret opens under each probe identity and reports file metadata**: `fileToolIsolationFailures` and `checkIsolationAsExecutor` now open every protected target directly with `O_RDONLY|O_NONBLOCK|O_NOCTTY` (avoiding a server-identity `os.Stat` pre-check and never blocking on FIFOs), report the opened descriptor's `mode`, `uid` and `gid`, and surface unexpected open errors such as symlink loops (#700).
- **The panel executor uid/gid 10001 has a named `artex-exec` passwd/group entry**: programs that look up their own user, such as ssh-based stdio MCP servers, refuse to start without one. The worker image already had `exec` (10001:10001) with `/home/exec` and `/bin/bash`; the panel image now defines `artex-exec` (`/app/data/exec-home`, `/usr/sbin/nologin`). A custom `-exec-uid` still needs its own entry (#708).
- **Attached curl body flags no longer bypass the stateful target guard**: `ClassifyHTTPAction` required a separator after `-d`, `-F` and `-T`, but curl takes the value fully attached, so `curl -dfoo=1`, `-Tshell.php` and `-Ffile=@payload` were classified read-only. That skipped the pre-mutation baseline gate and let `RecordStatefulReadOnly` store the mutation itself as the host's read-only baseline, a fail-open on a safety invariant. The attached forms are now mutating, including a spaced value (`-T shell.php`), while `-D` (dump headers), `-f`, `-o` and wget's `-T` timeout stay read-only. A body flag inside a multi-letter cluster (`-sSd...`) is still not detected.
- **The chat agent filter no longer keeps a thread from another agent open**: switching the filter left the previously selected conversation in place, so a thread started with one agent could still be read while the filter showed another, and the draft could pick the wrong agent. The selection is now cleared when it does not belong to the new filter, and the draft uses the filtered agent. `npm run test:chat-filter` covers both helpers and now runs in CI.
- **Session tokens are no longer accepted from a URL query string**: the SSE, log and browser endpoints accepted `?token=`, which put a console JWT into browser history, proxy logs and `Referer` headers. Those endpoints now require the same Bearer header as the rest of the API; the console uses a `fetch` based SSE reader, the client-written auth cookie is gone, and the same-origin CORS preflight allows `Authorization` and `Last-Event-ID`. Login and uploads no longer carry a token in the URL either (#660).
@@ -100,6 +103,17 @@ The execution-scope gap and its remediation were tracked in public before the No
- **Hardening follow-up for the upload and capture fixes**: existing spill blob directories and files are tightened on startup, hook `range` charges 32 bytes per pair, and uploads open with `O_NOFOLLOW` on Unix. The Windows upload path keeps the `Lstat` check.
- **Docker Compose database passwords with URL-special characters**: `docker-compose.yml` no longer pastes `POSTGRES_PASSWORD` into `ARTEX_PG_DSN`. The server builds the URL from `ARTEX_PG_HOST`, `ARTEX_PG_PORT`, `ARTEX_PG_USER`, `ARTEX_PG_PASSWORD`, `ARTEX_PG_DBNAME` and `ARTEX_PG_SSLMODE`, percent-encoding the user and password, so `/`, `?`, `%`, `@`, `:` and spaces connect. An explicit `ARTEX_PG_DSN` still wins and is not rewritten. `ARTEX_PG_PASSWORD` is removed from the environment with the other startup secrets (#450).
### Other changes since 0.6.0
The full commit list is in the compare view. The notable changes not already detailed above:
- **Sessions and authentication**: sessions issued before a password change are rejected (#301); password-change guesses are rate-limited (#343).
- **Interception and scope**: `insert_assets` is refused when the intercept rules cannot be loaded (#336); an allow is recorded only after the gate decides (#355); target pins stay name-only behind a proxy (#370); deny and ask argv rules match across compound commands (#377); always-allow is denied for git, cmake, ctest and cpack (#385); `ExecuteExtraTool` and `Monitor` are gated by default (#389).
- **Workspace, network and execution boundaries**: `ask_operator` image paths are confined to the task directory (#337); workspace and skill paths are confined against symlink escapes (#372); the capture CA and index stay out of the workspace file API (#387); the model-list endpoint blocks SSRF (#390); agent execution is contained with the executor UID drop (#395); the optional DNS-driven egress allowlist is available as a compose overlay (#418).
- **Traffic and evidence**: WebSocket and SSE messages are recorded and shown (#254, #255); an edited request can be replayed through the recording proxy (#258); rewrite rules apply in the capture proxy (#309); rewrite provenance is recorded on snapshots and archives (#392, #394, #399); HAR 1.2 import and export are available (#412); SOCKS5, transparent TCP, UDP recording and constrained tampering hooks are opt-in (#431, #432, #433, #434); `record_fact` ties evidence to recorded activity and captures (#441).
- **Data and export**: formula cells are neutralized in the findings CSV export (#340); asset DSL length and parenthesis depth are bounded (#353); keyword-value and query DSN passwords are masked (#354); CR and LF are rejected in ingested methods and headers (#344).
- **Third-party code and install**: acquiring third-party code can require explicit operator approval (#417); the runtime image adds more recon staples (#442); `install.sh` stops using get.docker.com on unsupported distributions such as Kali (#443).
## [0.7.0] - 2026-11-21
Agent-driven traffic capture (SOCKS5, transparent TCP and raw UDP), operator tampering hooks with their admin panel, the agentic injection and proof hardening from the #124 audit, LLM context telemetry and the worker cache-prefix split, capture-proxy rewrite rules, HAR import and export, and a large security batch across the interception gate, sessions, logs, the workspace file API and the model endpoint probe.
+8
View File
@@ -291,6 +291,14 @@ RUN npm install -g "@playwright/mcp@${PLAYWRIGHT_MCP_VERSION}" "@playwright/cli@
# cache, which /root's 0711 lets the executor reach.
ENV PLAYWRIGHT_BROWSERS_PATH=/root/.cache/ms-playwright
WORKDIR /app
# A passwd and group entry for the agent executor (the default -exec-uid and
# -exec-gid, 10001). Agent processes and stdio MCP servers run as that uid, and
# programs that look their own user up refuse to start without an entry: ssh
# exits with "No user exists for uid 10001". The home is the executor home the
# server prepares under the data directory. A custom -exec-uid needs its own entry.
RUN groupadd --gid 10001 artex-exec \
&& useradd --uid 10001 --gid 10001 --no-create-home --home-dir /app/data/exec-home \
--shell /usr/sbin/nologin artex-exec
# Binary compiled from source in the build stage above.
COPY --from=build /out/artex /app/artex
# Daemon startup script: relaunches the process after a crash and forwards SIGTERM
+30 -2
View File
@@ -10,6 +10,7 @@ import (
"strings"
"syscall"
"testing"
"time"
)
// isolationRootFixture is newExecRootFixture with the Bash shim installed, a key
@@ -73,9 +74,36 @@ func TestIsolationSelfTestDetectsReadableSecretAsRoot(t *testing.T) {
if err := os.Chmod(key, 0o644); err != nil {
t.Fatal(err)
}
var st syscall.Stat_t
if err := syscall.Stat(key, &st); err != nil {
t.Fatal(err)
}
err := IsolationSelfTest(f.priv, f.targets())
if err == nil || !strings.Contains(err.Error(), "Bash can read "+key) || !strings.Contains(err.Error(), "the file tools can read "+key) {
t.Fatalf("self-test with a world-readable key: %v", err)
if err == nil {
t.Fatal("self-test accepted a world-readable key")
}
for _, actor := range []string{"Bash", "the file tools"} {
if !strings.Contains(err.Error(), actor+" opened "+key+" for reading (mode=-rw-r--r-- uid=0 gid="+strconv.FormatUint(uint64(st.Gid), 10)+")") {
t.Errorf("self-test with a world-readable key did not report its metadata for %s: %v", actor, err)
}
}
}
func TestSecretOpenFailureOnFIFO(t *testing.T) {
path := filepath.Join(t.TempDir(), "key")
if err := syscall.Mkfifo(path, 0o600); err != nil {
t.Fatal(err)
}
// A FIFO with no writer must still be reported without waiting for bytes.
done := make(chan string, 1)
go func() { done <- secretOpenFailure("probe", path) }()
select {
case msg := <-done:
if !strings.Contains(msg, "opened "+path+" for reading (mode=p") {
t.Fatalf("unexpected FIFO diagnostic: %q", msg)
}
case <-time.After(5 * time.Second):
t.Fatal("probe blocked on a FIFO with no writer")
}
}
+29 -16
View File
@@ -258,30 +258,44 @@ func skillTreeFailures(root string, execUID, execGID uint32) []string {
return failures
}
// fileToolIsolationFailures opens each existing secret through the file tool
// identity (agent/filetools_identity.go): the open must be refused.
// secretOpenFailure checks the open under the caller's identity. Inspect the
// descriptor so the diagnostic describes the object at the time of the probe.
func secretOpenFailure(actor, path string) string {
f, err := os.OpenFile(path, os.O_RDONLY|syscall.O_NONBLOCK|syscall.O_NOCTTY, 0)
if errors.Is(err, fs.ErrNotExist) || errors.Is(err, fs.ErrPermission) {
return ""
}
if err != nil {
return fmt.Sprintf("%s could not check %s: %v", actor, path, err)
}
defer f.Close()
msg := fmt.Sprintf("%s opened %s for reading", actor, path)
info, err := f.Stat()
if err != nil {
return fmt.Sprintf("%s (stat failed: %v)", msg, err)
}
if st, ok := info.Sys().(*syscall.Stat_t); ok {
return fmt.Sprintf("%s (mode=%s uid=%d gid=%d)", msg, info.Mode(), st.Uid, st.Gid)
}
return fmt.Sprintf("%s (mode=%s)", msg, info.Mode())
}
// fileToolIsolationFailures checks each secret through the file tool identity.
func fileToolIsolationFailures(secrets []string) []string {
if !agent.FileToolIdentitySupported() {
return []string{"the agent's file tools run with the server's identity on this platform"}
}
var failures []string
for _, path := range secrets {
if _, err := os.Stat(path); err != nil {
continue
}
var openErr error
var failure string
if err := agent.RunAsFileToolIdentity(func() {
f, err := os.Open(path)
if err == nil {
f.Close()
}
openErr = err
failure = secretOpenFailure("the file tools", path)
}); err != nil {
failures = append(failures, fmt.Sprintf("the file tool identity cannot be applied: %v", err))
break
}
if openErr == nil {
failures = append(failures, fmt.Sprintf("the file tools can read %s", path))
if failure != "" {
failures = append(failures, failure)
}
}
return failures
@@ -350,9 +364,8 @@ func checkIsolationAsExecutor(spec isolationProbeSpec) []string {
fail("Bash has the supplementary groups %v, want only the executor gid %d", groups, spec.GID)
}
for _, path := range spec.Unreadable {
if f, err := os.Open(path); err == nil {
f.Close()
fail("Bash can read %s", path)
if failure := secretOpenFailure("Bash", path); failure != "" {
failures = append(failures, failure)
}
}
if spec.ServerPID > 0 {
+21 -1
View File
@@ -97,7 +97,7 @@ func TestCheckIsolationReportsEachExposure(t *testing.T) {
})
for _, want := range []string{
"not the executor uid 10001",
"Bash can read " + secret,
"Bash opened " + secret + " for reading (mode=-rw-------",
"Bash can create files in " + dir,
"ARTEX_ISOLATION_CANARY reached Bash",
`database session as "artex"`,
@@ -114,6 +114,26 @@ func TestCheckIsolationReportsEachExposure(t *testing.T) {
}
}
func TestSecretOpenFailureReportsUnexpectedError(t *testing.T) {
link := filepath.Join(t.TempDir(), "key")
if err := os.Symlink(link, link); err != nil {
t.Fatal(err)
}
if msg := secretOpenFailure("probe", link); !strings.HasPrefix(msg, "probe could not check "+link) {
t.Fatalf("unexpected diagnostic for a symlink loop: %q", msg)
}
}
func TestSecretOpenFailureDetectsReadableKeyDir(t *testing.T) {
dir := filepath.Join(t.TempDir(), "keys")
if err := os.MkdirAll(dir, 0o755); err != nil {
t.Fatal(err)
}
if msg := secretOpenFailure("Bash", dir); !strings.Contains(msg, "Bash opened "+dir+" for reading (mode=d") {
t.Fatalf("unexpected diagnostic for readable key dir: %q", msg)
}
}
// A database that asks for a password, or none listening, is not an exposure.
func TestConnectWithoutPasswordRefused(t *testing.T) {
ln, err := net.Listen("tcp", "127.0.0.1:0")
+13
View File
@@ -6,6 +6,7 @@ import (
"log"
"time"
"github.com/Autumn-27/artex/agent"
"github.com/Autumn-27/artex/db"
"github.com/Autumn-27/artex/mcphttp"
"github.com/Autumn-27/norma/mcp"
@@ -51,9 +52,21 @@ func connectMCP(ctx context.Context, m *db.MCPServer, priv ExecPrivilege) (mcpCl
}
}
// sandboxBlocksStdioMCP reports whether this stdio MCP must not run on the
// panel. In ARTEX_SANDBOX=required the panel never starts agent-controlled
// local processes: stdio MCP servers stay unavailable until the per-task
// runner hosts them. HTTP and SSE MCP clients are platform-owned transports and
// keep their existing checks.
func sandboxBlocksStdioMCP(m *db.MCPServer) bool {
return agent.SandboxRequired() && (m.Transport == "" || m.Transport == "stdio")
}
// discoverAndCacheMCP connects to one MCP, lists its tools, and persists the tool
// names to mcp_tools_cache so the UI shows them without a live connection.
func (s *Server) discoverAndCacheMCP(ctx context.Context, m *db.MCPServer) error {
if sandboxBlocksStdioMCP(m) {
return fmt.Errorf("stdio MCP servers are not started on the panel while ARTEX_SANDBOX=required; use an HTTP/SSE MCP server or set ARTEX_SANDBOX=off")
}
cl, err := connectMCP(ctx, m, s.execPriv)
if err != nil {
_ = s.m.pg.UpdateMCPHealth(m.ID, false, err.Error())
+69
View File
@@ -0,0 +1,69 @@
package server
import (
"context"
"encoding/json"
"os"
"path/filepath"
"strings"
"testing"
"github.com/Autumn-27/artex/agent"
"github.com/Autumn-27/artex/db"
"github.com/Autumn-27/artex/sandbox"
)
func withSandboxRequired(t *testing.T) {
t.Helper()
prev := agent.CurrentSandboxExecutor()
agent.SetSandboxExecutor(&agent.SandboxExecutor{Mode: sandbox.ModeRequired})
t.Cleanup(func() { agent.SetSandboxExecutor(prev) })
}
// The panel must never start a stdio MCP process in required mode. The canary
// command would create a file if connectMCP reached it; the guard returns before
// the process is spawned.
func TestSandboxSkipsStdioMCPDiscovery(t *testing.T) {
withSandboxRequired(t)
dir := t.TempDir()
canary := filepath.Join(dir, "stdio-mcp-ran")
args, _ := json.Marshal([]string{"-c", "touch " + canary})
m := &db.MCPServer{Name: "t-sandbox-stdio", Transport: "stdio", Command: "sh", Args: args, Enabled: true}
s := &Server{}
err := s.discoverAndCacheMCP(context.Background(), m)
if err == nil || !strings.Contains(err.Error(), "ARTEX_SANDBOX=required") {
t.Fatalf("discovery error = %v, want the sandbox refusal", err)
}
if _, statErr := os.Stat(canary); statErr == nil {
t.Fatal("stdio MCP command ran on the panel in required mode")
}
}
func TestSandboxMCPToolGuardsStdioOnly(t *testing.T) {
withSandboxRequired(t)
for _, tc := range []struct {
transport string
blocked bool
}{
{"", true},
{"stdio", true},
{"http", false},
{"sse", false},
} {
if got := sandboxBlocksStdioMCP(&db.MCPServer{Transport: tc.transport}); got != tc.blocked {
t.Errorf("transport %q blocked=%v, want %v", tc.transport, got, tc.blocked)
}
}
}
func TestSandboxCreateMCPRejectsStdio(t *testing.T) {
withSandboxRequired(t)
tool := (&Server{}).toolCreateMCP()
res, err := tool.Call(context.Background(), json.RawMessage(`{"name":"t-stdio","transport":"stdio","command":"sh"}`), nil)
if err != nil {
t.Fatal(err)
}
if !res.IsError || !strings.Contains(res.Flatten(), "ARTEX_SANDBOX=required") {
t.Fatalf("create_mcp result = %q, want the sandbox refusal", res.Flatten())
}
}
+6
View File
@@ -370,6 +370,9 @@ func (s *Server) toolCreateMCP() actool.CoreTool {
if strings.TrimSpace(a.Name) == "" || strings.TrimSpace(a.Transport) == "" {
return actool.Errorf("name / transport are required"), nil
}
if sandboxBlocksStdioMCP(a.toDB()) {
return actool.Errorf("stdio MCP servers are unavailable while ARTEX_SANDBOX=required; use an HTTP/SSE MCP server or set ARTEX_SANDBOX=off"), nil
}
id, err := s.m.pg.SaveMCP(a.toDB())
if err != nil {
return actool.Errorf(err.Error()), nil
@@ -387,6 +390,9 @@ func (s *Server) toolUpdateMCP() actool.CoreTool {
if a.ID == 0 {
return actool.Errorf("id is required"), nil
}
if sandboxBlocksStdioMCP(a.toDB()) {
return actool.Errorf("stdio MCP servers are unavailable while ARTEX_SANDBOX=required; use an HTTP/SSE MCP server or set ARTEX_SANDBOX=off"), nil
}
if _, err := s.m.pg.SaveMCP(a.toDB()); err != nil {
return actool.Errorf(err.Error()), nil
}