Commit Graph
458 Commits
Author SHA1 Message Date
Phantom-IN 2efc2aca68 fix(server): seed a goal URL that is followed by punctuation
parseTarget pulls the first URL out of the goal with https?://[^\s'"]+,
which keeps any punctuation that follows it. "Assess http://juiceshop:3000."
matches "http://juiceshop:3000.", url.Parse rejects the port, and the seed
logs "could not parse a target host/IP" even though goalGateCheck accepted
the same goal. A dotted host only survived through the domain fallback,
which takes the scheme from the port, and a sentence-final period stayed
in the host.

Trim trailing punctuation before parsing the URL, including full-width
punctuation from pasted text. A closing bracket is trimmed only when the
URL has no matching opener, so a bracketed IPv6 host like http://[::1]
still parses.
2026-11-23 20:09:03 +05:30
BaaRai 6ec01e007e Merge remote-tracking branch 'origin/main' into pr507b
# Conflicts:
#	CHANGELOG.md
2026-11-23 15:10:58 +01:00
BaaRai 410d8fa7f2 Merge remote-tracking branch 'origin/main' into pr507b
# Conflicts:
#	CHANGELOG.md
2026-11-23 14:55:14 +01:00
BaaRai 8040e38faf Merge remote-tracking branch 'origin/main' into pr503b
# Conflicts:
#	CHANGELOG.md
2026-11-23 14:54:03 +01:00
BaaRai ab2a0262b5 Merge pull request #509 from jamesKhor/feat/assessment-identification
Add a per-task scanner User-Agent for approved sites
2026-11-23 14:53:06 +01:00
BaaRai 164e2388ed Merge pull request #480 from jamesKhor/feat/bedrock-gateway
Add bearer-authenticated Bedrock gateway profiles
2026-11-23 14:52:58 +01:00
BaaRai a4276b490f Merge pull request #478 from BaaRai/feat/agent-uid-isolation-rebased
Run agent processes under the executor identity with a sealed environment
2026-11-23 12:59:10 +01:00
BaaRai 60a1ffca62 server: keep only the fixed locale names in the executor environment
The executor environment kept every name starting with LC_, so a secret supplied under an LC_ name crossed the allowlist even though the comment promised a fixed set of names. The POSIX locale categories are now enumerated and the prefix rule is gone.

Found by jamesKhor in the review of #478.
2026-11-23 12:42:43 +01:00
James Khor 1725a44543 Clarify scanner User-Agent settings and verify recorded redirects 2026-11-23 18:29:58 +08:00
James Khor f90db65430 Limit generated assessment labels to configured HTTP origins 2026-11-23 17:55:39 +08:00
James Khor fdd0041529 Verify assessment labels on the wire and document SOC triage 2026-11-23 17:46:27 +08:00
James Khor 6ef25b22b1 Identify approved assessment tasks in native HTTP requests 2026-11-23 17:45:26 +08:00
thejesh23 1aaa7a479b fix(scheduler): fire on_task_timeout for tasks that time out out of id order
The timeout trigger used the task id as a watermark, but tasks time out
in deadline order. When a newer task timed out first, the watermark moved
past every older running task, so their later timeouts were never fired.

Keep fired timeouts in a persisted set, the same way met goals are
tracked. On first start the set is seeded with the tasks already timed
out, so nothing replays.
2026-11-23 01:33:19 -08:00
James Khor c1e17ad934 server: secure executor run-directory sharing 2026-11-23 12:39:32 +08:00
Leo Camus b7e766ffe4 fix(server): skip named pipes and sockets when packing a task archive
writeTaskArchivePackage opened every entry of the staged workspace that is
not a directory. Opening a FIFO blocks until a writer appears, so a named
pipe left by a command (mkfifo backpipe for an nc relay) stopped the single
archive worker in openat for good, with the task files already moved to
staging and every later archive, restore and delete job queued behind it.
A Unix socket failed the archive instead, and a device file was packed but
refused by extractTaskArchivePackage on restore.

Skip every entry that is neither a directory nor a regular file, as is
already done for symlinks.
2026-11-23 04:34:29 +00:00
James Khor 8f16794a97 fix: scrub Bedrock gateway credentials at startup 2026-11-23 11:13:40 +08:00
APZN 7e555e86d7 fix(web): reset stream filters and exclude warning rows from counts
Reset the stream panel's filter and request state when the exchange changes.
Keep recording-limit warnings visible while reporting only actual messages
in the header, including first-page and warning-only counts.

Add message_total to the stream page without changing raw pagination totals
or existing Go paging signatures. Cover the count and pagination boundaries
in the stream and HTTP route tests.
2026-11-23 10:26:56 +09:00
BaaRai 303acd7587 server: probe every database host of the DSN; compose: SCRAM for TCP
The self-test probe tried only the first host of the DSN. It now tries
each host and port the DSN lists, fallbacks included, and nothing else,
and a DSN it cannot parse fails the self-test instead of skipping the
database check.

docker-compose.yml sets POSTGRES_HOST_AUTH_METHOD=scram-sha-256: a TCP
connection from another container, artex's included, needs the
password. It takes effect when a new pgdata volume is initialised.
2026-11-22 23:00:41 +01:00
BaaRai 9a8234f71e server: start degraded where agent isolation cannot be built
The isolation self-test stopped every start it failed, so a non-root
server (the systemd unit), dev.sh, Windows and macOS no longer started
without -dev-insecure-no-isolation.

EnforceIsolation now decides from the platform and the privilege drop:

- self-test passed: isolated;
- Linux with the privilege drop on (root, the Docker image): a failure
  stops the start, unless -dev-insecure-no-isolation is set;
- elsewhere (not Linux, not root, -exec-uid=-1): the server starts
  degraded, without a flag.

A degraded start logs a banner with the self-test failure and what is
exposed, and GET /api/health reports the isolation status to a
signed-in caller; the web UI shows a red banner on every page while it
is degraded. The systemd deployment guide and dev.sh describe the mode.
2026-11-22 23:00:41 +01:00
BaaRai 7172738da1 server: fail the isolation self-test on a skill tree the agent can write
The six platform tools that durably change skills, custom tools and MCP
servers already need operator approval (intercept/persistence.go, the
built-in ask rules of db/intercept_persistence_seed.go, guard.go). Custom
tools and MCP servers live in the database, which the agent's shell
cannot reach. Skills live on disk: an agent process that can write the
skill directory adds or changes a skill without create_skill or
update_skill_file, and every agent then loads it as instructions.

The startup self-test now checks the skill directory: the probe, as the
executor, must not be able to create an entry in it, its parent must not
let the executor replace it, and no file or directory below it may be
owned by the executor uid or writable by the executor gid or by others
(judged from owners and mode bits, symlinks by their target, nothing
written).
2026-11-22 23:00:41 +01:00
BaaRai fd781dcdab server: keep the keys, config and data out of the executor's reach
PrepareExecPrivilege chmodded jwt.key, secret.key and the config file to
0600 but left their owner as it was: a file owned by the executor uid
(created by an agent process, or on the host under the uid the executor
has in the container) stayed readable by the agent. It now makes root
their owner first.

The startup self-test also checks the directories: the probe, as the
executor, must not be able to create an entry in the data directory, the
key directory or the config file's directory (it could plant a key, a
config or a data tree for the next start), and none of their parents may
let the executor replace them (owned by it, or writable by it without the
sticky bit). For the database, a test against PostgreSQL shows the
server's role refused without its password (SQLSTATE 28P01); the probe
already fails the start when the database lets that role in.

No Unix socket is introduced: in the compose deployment PostgreSQL runs
in its own container and is reached over TCP with a password that the
executor cannot read (sealed environment, root-only config).
2026-11-22 23:00:41 +01:00
BaaRai 0a3dd44404 server: self-test agent isolation at startup, fail closed
When the privilege drop could not be applied (the server not root, or
-exec-uid negative), the start went on with one log line, and nothing
checked that an applied drop really isolated the agent. Before the stores
open, the server now runs a self-test: a probe started the way the
agent's Bash starts ("bash" on PATH, so through the shim) checks from
inside the executor process that it runs as the executor uid, gid and
only group, cannot read jwt.key, secret.key, the config file or the MITM
CA key, cannot read the server's /proc environ or memory, sees only the
allowlisted environment, and cannot open a session on the server's
database with the server's user and no password (only host, port, user
and database name reach the probe). The file tools are checked too: the
secrets must not open through their identity.

A failed or impossible self-test stops the start. The development escape
-dev-insecure-no-isolation, off by default, lets the start go on and logs
a banner that says what is exposed. This changes the behaviour of a
non-root start (go run, the systemd example unit, Windows, macOS): it now
needs that flag.
2026-11-22 23:00:41 +01:00
BaaRai 2e8f4fea38 server: give agent processes a fixed allowlisted environment
An agent process inherited the server's environment minus the names that
ScrubSecretEnv removes: a deny list, so a credential under any other name
(one an operator or an image adds) reached the agent's shell, its custom
tools and its MCP stdio servers. When a process crosses from the server's
identity to the executor's, its environment is now rebuilt from a fixed
allowlist: the search path and locale, the temp directory, the
non-interactive defaults, the proxy and CA trust variables the agents pass
to their shells, PLAYWRIGHT_BROWSERS_PATH and the shim's own variables.
The Bash shim and the MCP drop shim rebuild it before the drop; a custom
tool starts from it. What the caller passes on purpose still crosses: the
agent's Bash env, the TOOL_* parameters, and the configured env of an MCP
server, which the drop shim keeps because connectMCP names it in
ARTEX_EXEC_KEEP. A nested shell is not filtered again.

The startup scrub and the environment seal stay as they are; they are no
longer the boundary for agent processes. With the drop disabled nothing
changes.
2026-11-22 23:00:41 +01:00
BaaRai 2b7739aaf5 agent: run the file tools as the executor identity
The confined file tools (Read, Write, Edit, MultiEdit, LS, Glob, Grep) and
the opens of ingest_bbot and ingest_scan_output ran inside the server, as
root, and relied on the os.Root path confinement alone. With the executor
privilege drop active, PrepareExecPrivilege now gives them the executor
uid and gid: each call runs on a thread of its own whose file system uid,
file system gid and supplementary groups are the executor's (setfsuid,
setfsgid and the per-thread setgroups of x/sys/unix). The thread is never
unlocked, so the runtime ends it with the call and no other goroutine
runs with those ids. The kernel then checks every open, create and
directory read against the rights of the agent's shell, on top of the
path confinement. Output over the cap is still spilled, after the call,
with the server's identity.

Linux only. Elsewhere the identity is not set and a log line says the
file tools keep the server's identity. golang.org/x/sys becomes a direct
dependency (already in the module graph at the same version).
2026-11-22 23:00:41 +01:00
BaaRai f7fc2b02fb merge origin/main into security/response-headers 2026-11-22 22:45:48 +01:00
BaaRai 0a794647ef Merge pull request #404 from Lusitaniae/pr/webui-caching
web: add ETag, gzip and immutable caching to the embedded SPA handler
2026-11-22 22:44:06 +01:00
BaaRai 76bd0abeb1 Merge pull request #425 from joanrodriguez/feat/company-switcher
feat(web): global company switcher in the sidebar
2026-11-22 22:43:32 +01:00
Pedro Gomes 48d46e8d41 webui: give the raw and gzip bodies one strong ETag each
serveWebAsset digested the raw bytes and then served either the raw or the gzip
body under that single ETag. ServeContent validates Range/If-Range and
If-None-Match against that header, so a request validated with the ETag of one
representation could be answered from the other: a client that held the gzip
entity and sent `If-Range: <etag>` got raw bytes back as a 206, and the 304 path
had the same shape. Vary: Accept-Encoding does not help — it tells caches that
the representations differ, it does not make one validator describe both.

Digest the compressed bytes as well and publish `"<hash>-gzip"` for that
representation. The two validators are now distinct strong ETags over what is
actually on the wire, selected together with the body.

Tests: TestServeWebAssetPerRepresentationETag asserts the validators differ, that
a range with If-Range from its own representation gets 206 + 10 bytes, and that
a range with If-Range from the other representation comes back 200 with the full
self-consistent body. TestServeWebAssetConditionalIsPerRepresentation covers the
same for If-None-Match (304 vs 200). Both fail against the shared-validator code
(304 where 200 is required). The existing stability check now pins the ETag per
representation rather than per file.
2026-11-22 14:41:07 +00:00
James Khor 3b367c1433 fix: bind Bedrock headers to gateway and redact errors 2026-11-22 22:31:06 +08:00
lizhuhui f70930bdf2 security(server): send security headers on every response
The console route set a framing CSP, X-Frame-Options and a referrer
policy; the JSON API set none, so an API error page could be framed and
referrer information leaked from any response. Move the headers that are
safe everywhere into one wrapper around the whole handler tree and keep
only the document headers on the console route, adding a
Permissions-Policy and COOP/CORP there.

Send HSTS when the request is known to be HTTPS: directly over TLS, or
via X-Forwarded-Proto from a peer in ARTEX_TRUSTED_PROXIES. Believing the
header from any peer would let a direct client claim HTTPS on its own.
The README proxy recipe now starts with an 80 to 443 redirect and the
same trusted-proxy list enables the header.
2026-11-22 20:48:49 +08:00
James Khor b1e419ba2c feat: add bearer-authenticated Bedrock gateway profiles 2026-11-22 18:27:43 +08:00
BaaRai ead1a126ae Merge pull request #457 from NikolayGusev-astra/feat/skill-index-in-prompt
agent: list available skills in the system prompt
2026-11-22 10:46:26 +01:00
Joan RodriguezandClaude Opus 5.5 9734b4b743 fix(company-switcher): address review on #425
- Findings with no live asset belong to a company only through their
  task's company scope; unknown or non-numeric ids match nothing.
- Filter tasks by company on the server (GET /api/tasks?company=).
- Scope the grouped findings view, the asset tree and the stat cards.
- AND company_id outside the compiled asset DSL so OR cannot escape it.
- Add the 7 company switcher keys to tr.json and zh-CN.json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BWbhPFZifkVU75uaD5NYj5
2026-11-22 09:44:37 +00:00
Joan RodriguezandClaude Code c3c8d1093e feat(web): global company switcher in the sidebar
The panel had no way to scope it to one target. Companies exist as the
ownership layer, but only the task form offered one, so a second engagement
mixed into every list.

Sidebar header, under the logo: a company picker that defaults to
"All companies" and persists per browser. Every asset-backed view follows
it — findings (all three views plus the asset tree and export), the
dashboard's finding panels, the task list, the traffic list and the assets
tabs.

Server side the switch rides on the existing ownership column: findings and
traffic take a company, and the assets list takes company_id on both the
plain and the DSL path. Findings with no live asset anchor stay visible
under their company, because they belong to no other one; the strict
subtree filter would hide them from every view.

Tests: TestFindingCompanyScopeFilter (own assets, another company, a
company with none, a nonexistent id) and TestPageHostsAllowlist. Full
./db/ ./traffic/ ./server/ pass.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BWbhPDnkSEFNzBXG4wDvTj
2026-11-22 09:29:50 +00:00
BaaRai 90cd290d42 security: follow-up hardening for the upload and capture fixes
Tighten existing spill blob permissions on startup, charge 32 bytes per hook range pair, and open uploads with O_NOFOLLOW on Unix. Tests cover the startup walk, the 32-byte charge and the no-follow open.
2026-11-22 09:10:59 +01:00
BaaRai 5df46e22c1 Merge remote-tracking branch 'origin/main' into pr465
# Conflicts:
#	CHANGELOG.md
#	server/chatupload.go
2026-11-22 08:55:15 +01:00
BaaRai 9d7983f1a2 Merge remote-tracking branch 'origin/main' into pr459
# Conflicts:
#	CHANGELOG.md
2026-11-22 08:40:44 +01:00
Coff0xc f4c7184dcc fix(server): refuse to upload through a symlink
os.Create follows a symlink, and Stat treats a dangling link as missing, so a
name planted in the uploads directory could redirect the server's write.
Destinations are now Lstat'd, a symlink is rejected, and the chat name search
treats a link as taken.
2026-11-21 19:53:50 +00:00
Coff0xc 0eb66f4c44 fix(server): stop the chat upload name search when the path cannot be created
uniqueUploadPath treated every Stat error except "not exist" as "try the next
suffix". A name the filesystem rejects never becomes "not exist", so the
handler looped. The search now returns that error, and it also stops after
10000 existing suffixes.
2026-11-21 19:33:22 +00:00
Coff0xc 9a8f366574 fix(server): do not send a log line to a closed subscriber
Unsubscribing closes the channel after dropping it from the map. The fan-out
copied the channel and sent after releasing the lock, so the close could land
first and panic the process. The send now happens while the lock is still held.
2026-11-21 19:32:38 +00:00
Николай Гусев 6ef6d0dbdb agent: list available skills in the system prompt
The Skill tool's description carries the skill listing, but a description is
only read once the model decides to open the tool: on a live run with 36 skills
assigned the agent invoked Skill zero times across 485 trace records, hunting
every class with raw Bash. Put the names where every turn already looks, with
the rule to invoke the matching skill before hunting a class.

Names-only, bounded at 1200 bytes, empty for skill-less agents (prompt stays
byte-identical). The index rides the same seam as FindingGuidance, so the
cached-prefix path keeps its two segments byte-identical to the unsplit prompt.
2026-11-21 22:00:22 +03:00
Coff0xc 8b4f890e61 fix(server): seal ARTEX_PG_PASSWORD with the other startup secrets
The Linux handoff test reports every name in secretEnv. The new password
variable was scrubbed but not included in that fixture, so CI reported it
unset after sealing.
2026-11-21 17:49:22 +00:00
Coff0xc ff287467aa fix(config): encode the Compose database password instead of pasting it into the URL
docker-compose.yml built ARTEX_PG_DSN by interpolating POSTGRES_PASSWORD, so
/, ?, %, @, : and spaces made the URL invalid. The server now assembles that
URL from ARTEX_PG_HOST, ARTEX_PG_PORT, ARTEX_PG_USER, ARTEX_PG_PASSWORD,
ARTEX_PG_DBNAME and ARTEX_PG_SSLMODE. An explicit ARTEX_PG_DSN still wins.
ARTEX_PG_PASSWORD is scrubbed with the other startup secrets.
2026-11-21 17:25:20 +00:00
BaaRai b56ad38b43 feat(agent,web): explain that traffic capture is off and required for provable findings 2026-11-21 16:35:31 +01:00
dach-a c92c784987 Tie fact evidence to recorded activity and proxy captures
record_fact trusted a model-written source, so target text labelled
tool_output could prove a goal. The server now matches the fact's evidence
against the intent's recorded activity and pins the activity id. If the same
bytes were captured coming back from the target through the proxy, the fact is
stored as target_response with the traffic id, whatever the model declared,
and prove_goal refuses it (#124 row 1). An untied claim downgrades to
inference/inferred and is refused instead of silently trusted.
2026-11-21 09:50:45 +00:00
BaaRai 6bb2fe199e fix(server): judge NAT64 and 6to4 addresses by their embedded IPv4
POST /api/llm/models refused 64:ff9b::/96 and 2002::/16 as a whole. A
DNS64 resolver answers with a 64:ff9b::/96 address for every IPv4-only
name, so on a NAT64 network every public provider was refused and no
setting brought it back.

An address in 64:ff9b::/96 (the IPv4 address in the low 32 bits) or in
2002::/16 (the IPv4 address in bits 16 to 47) is now judged as the
IPv4 address it embeds, by the rule a bare IPv4 address gets: private,
loopback, link-local, metadata, reserved, carrier-grade NAT and
unspecified addresses stay refused, a public one is accepted. The rule
is the same for literal hosts, resolved names, redirects and at dial
time, and an endpoint listed in ARTEX_LLM_PRIVATE_ENDPOINTS gets behind
such an address what it gets as a bare IPv4 address.
2026-11-21 07:34:30 +01:00
BaaRai a1998685f9 fix(server): block carrier-grade NAT and reserved ranges; stop echoing upstream model errors
POST /api/llm/models treated every address outside RFC 1918, loopback,
link-local, multicast and the metadata addresses as public. It now
also refuses 100.64.0.0/10, 198.18.0.0/15, 192.0.0.0/24, 240.0.0.0/4,
NAT64 64:ff9b::/96 and 6to4 2002::/16, for literal hosts, resolved
names, redirects and at dial time. An endpoint listed in
ARTEX_LLM_PRIVATE_ENDPOINTS may still sit in 100.64.0.0/10 or
198.18.0.0/15, as it may in RFC 1918 space; the other ranges are never
allowed.

A non-200 answer was returned with the first 512 bytes of its body,
which let a caller read what any reachable host answers. The answer
now carries the status only.
2026-11-21 07:34:30 +01:00
BaaRai 6765d01b94 fix(server): keep the capture CA, index and blob store out of workspace deletes
The workspace file manager refused traffic/_ca and traffic/_index by
path, but DELETE /api/workspace/delete on their parent, traffic,
removed the whole tree: the capture CA private key, the exchange index
and the blobs went with it. The blob store, traffic/_blobs, was not
denied at all and could be listed, read and downloaded.

traffic/_blobs joins the denied prefixes, and a delete is refused with
400 when a denied prefix lies beneath the entry it would remove. A
symlink to such a directory is still removed as a link.
2026-11-21 07:34:30 +01:00
BaaRai 8eff7b907c fix(server): keep the setup token and proxy credentials out of the log sink
The log sink keeps every standard-logger line in a ring, persists it to
server_logs and serves it through /api/logs, /api/logs/history and
/api/logs/stream to any session. Two secrets went through it.

The one-time setup token was logged with log.Printf. It is now printed
on stderr directly, with the same wording, so `docker compose logs` and
the journal still show it; the sink gets a line that says where it was
printed.

A global proxy with user:password was logged in full when the browser
MCP was synced and when a stored value failed validation at startup,
and was written with its credentials into the --proxy-server argument
of the browser MCP row, which GET /api/mcp lists. The log lines and the
row now carry the proxy without its userinfo. A stored address that
does not parse is not written to the row at all.

As a second line of defence the sink masks the password of any
scheme://user:password@ it is given, in the ring and on stderr, and
rows persisted earlier are masked when they are read back.
2026-11-21 07:34:30 +01:00
BaaRai ee35fb4b29 fix(server): refuse cookie-authenticated state changes from a foreign origin
requireAuth accepted the artex_token cookie on its own for every method
and checked neither Origin nor Sec-Fetch-Site. The handlers decode a
JSON body whatever its Content-Type, so a page on another origin of the
same site (another port of the host, a sibling subdomain) could send a
text/plain POST that the browser sends without a preflight and with the
cookie: POST /api/mcp stored a server entry with a command.

A POST, PUT, PATCH or DELETE whose session comes from the cookie must
now be same-origin: Sec-Fetch-Site is same-origin, or Origin names the
scheme, host and port the request was sent to. Anything else, including
a request with neither header, is answered 403. Requests that carry a
bearer token are not checked, nor are GET and HEAD. The /api/auth/*
routes stay outside requireAuth, so setup and login are unchanged. The
web console sends the bearer token on every state-changing request.
2026-11-21 07:34:30 +01:00