Commit graph

326 commits

Author SHA1 Message Date
BaaRai
7c3aacc9da
Merge pull request #839 from BaaRai/sec/webfetch-redirect-egress
agent: check WebFetch redirect hops against the sandbox egress policy
2026-12-02 16:55:35 +01:00
BaaRai
09e1d8384a docs: correct the sandbox dialer comment about proxy redirects
The dialer sees each hop on a direct connection only. Through a proxy it sees
the proxy, and sandboxRedirectCheck checks the hop. The old comment claimed all
hops and redirects, which contradicted the redirect check added in this branch.
2026-12-02 16:39:41 +01:00
BaaRai
cc4e536a32
Merge pull request #828 from renaesop/codex/sandbox-cancel-pause-fix
fix(sandbox): preserve run cancellation and persist failure pauses
2026-12-02 16:24:40 +01:00
BaaRai
de1ec144f1
Merge pull request #835 from hakarrr/fix-sandbox-missing-context
fix(sandbox): report a missing sandbox context apart from a runner outage
2026-12-02 16:23:52 +01:00
renaesop
e64d6a66fe fix(sandbox): distinguish run cancellation and persist safety pauses 2026-12-02 21:47:08 +08:00
BaaRai
44644b075e agent: check WebFetch redirect hops against the sandbox egress policy
In ARTEX_SANDBOX=required mode the WebFetch tool checked only the first
URL of a call against the task's egress policy. Every later connection
goes through the sandbox dialer, but with an operator or recording proxy
configured that dialer only ever sees the proxy address, so a redirect
from an allowed URL to 169.254.169.254, a loopback or private address,
or a domain outside the task scope was requested from the proxy and
followed.

The WebFetch CheckRedirect is now wrapped in required mode: each hop is
checked with EgressPolicy.CheckURL first, and only a hop the policy
allows goes on to intercept.RedirectCheck, which keeps its target gate
and its redirect limit. A nil policy refuses every hop. Outside required
mode the redirect check is unchanged.
2026-12-02 14:31:07 +01:00
simple-minded
01a0ce9fbb
fix(agent): keep the no-MCP system prompt cacheable
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
2026-12-02 18:26:27 +05:30
simple-minded
d80b85ae0d
fix(agent): keep the no-MCP system prompt cacheable
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
2026-12-02 18:26:01 +05:30
simple-minded
df8fd0267d
fix(agent): keep the no-MCP system prompt cacheable
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
2026-12-02 18:25:40 +05:30
simple-minded
140f3b28f6
fix(sandbox): report a missing sandbox context apart from a runner outage
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
2026-12-02 17:48:14 +05:30
simple-minded
04366cbb41
fix(sandbox): report a missing sandbox context apart from a runner outage
Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com>
2026-12-02 17:47:53 +05:30
BaaRai
e736474085
Merge pull request #785 from BaaRai/sec/custom-http-egress-gate
security: enforce the task egress policy on custom HTTP tools
2026-12-01 22:17:27 +01:00
Lenin Mookiah
d4fc42eb96
fix(llm): default openai-responses to gpt-6.2-sol before gpt-5 shuts down
OpenAI shuts gpt-5 down on 2026-12-11 and lists gpt-6.2-sol as its
replacement. Use it as the openai-responses default in FromEnv and
ConfigFrom; an explicitly set model is kept.

Fixes #787
2026-12-01 12:41:54 -08:00
BaaRai
c8f057a039 security: enforce the task egress policy on custom HTTP tools
A custom tool with Kind "http" bound to the worker ran its request from
the panel process with no sandbox check: under ARTEX_SANDBOX=required a
worker could reach a URL outside the task scope (a loopback service, an
internal address, another host) and follow a redirect anywhere, because
runHTTPTool and httpToolTransport never looked at SandboxRequired or at
the task's egress policy.

Decision: option 1, enforce the policy in the panel, as WebFetch does.
WebFetch already has a usable path for the same situation (a request made
by the panel, outside the worker container): the task's policy from
SandboxRunInfo (sandbox.NewEgressPolicy), CheckURL on the input, and
sandboxScopeDialContext on every connection, which resolves once, checks
every address against the scope and the default deny list, and dials the
pinned IP. Routing the tool through the per-task egress proxy is not
needed for that, and WebFetch does not do it either.

Under ARTEX_SANDBOX=required the http tool now:
- checks the rendered URL with the task policy before any approval or
  request (scheme, scope domain or CIDR, names resolving only to private,
  loopback, metadata or IPv6 addresses);
- checks every redirect hop with the same policy; a hop outside the scope
  fails the call instead of being followed;
- dials through the WebFetch sandbox dialer: the target for a direct call
  (environment proxy dropped, pinned dialer of a gated scope kept
  underneath), the proxy for a call with a proxy, so a proxy outside the
  scope is not dialed.

The policy resolution moves to agent.SandboxEgressPolicy, used by WebFetch
and the http tool, and the dialer is exported as
agent.SandboxScopeDialContext with a label; WebFetch keeps its messages.

Sandbox off: nothing changes, the new code is skipped. The planner still
does not receive a Kind "http" tool bound to the worker.
2026-12-01 21:31:54 +01:00
BaaRai
ed70ea3220 security: promote company scope egress only when approved by the operator
An operator company approval froze the company's whole inventory into
task_scope_egress: every company_scope domain and IP/CIDR row plus the
root_domain, domain and ip of every asset attributed to the company. The
agent writes both (insert_assets, add_company_scope), so the next operator
selection or re-approval promoted worker-chosen hosts into the sandbox
egress allowlist for the life of the task.

The snapshot now reads only company_scope domain and IP/CIDR rules with
approved_by_operator = TRUE; the asset branches are gone. Migration 0025
adds the column and backfills existing rows as approved. The flag is an
explicit parameter of insertScopeRulesTx and the CompanyStore scope
writers: the operator company API passes true, add_company_scope and the
ScopeSentry sync pass false. An operator write of a rule the agent stored
first approves the existing row.

AddOperatorScope outside a transaction now commits the task_scope row and
the egress snapshot together.

Existing task_scope_egress rows are not purged.
2026-12-01 20:44:37 +01:00
BaaRai
cb5c3334d1 security: keep model credentials on their origin and pin shipped inputs
Model clients built from a config without an explicit redirect policy followed
any redirect, so a 30x could replay the request body and credential headers
(API key, Anthropic credential header) at another host. They now refuse a hop
that changes scheme or host and keep same-origin redirects.

Supply-chain hardening from the same report: docker-compose.ghcr.yml defaults
to the released 0.7.1 images instead of latest, the Playwright skill installs
the pinned 0.1.22 CLI instead of @latest, and the API-recon skill uses npm ci
with its lockfile instead of a floating npm install.
2026-12-01 02:55:22 +01:00
BaaRai
1cbccd657d merge: sec/agent-scope-install into the 0.7.1 advisory batch 2026-11-30 23:56:54 +01:00
BaaRai
d48a3a74e8 fix(server): send the LLM connection test through the model URL guard
GHSA-39w9: POST /api/llm/test accepted any base_url and proxy, made a real
request with them, returned the reply and the provider error text, and
followed redirects without an address check, while POST /api/llm/models was
already guarded. The test now validates the base URL and the proxy through the
same guard, dials and revalidates every redirect through it, and never reads
the *_PROXY environment. Only public addresses are accepted. The code-owned
default Ollama endpoint keeps working; an exact host:port in
ARTEX_LLM_PRIVATE_ENDPOINTS is the documented way to test a local model
server. The test button refuses SOCKS5 proxies because the guard cannot see
the destination behind them.
2026-11-30 23:54:02 +01:00
BaaRai
dccb066169 fix(server): scope update_finding_report writes to the caller's task
The node-id write path (GHSA-ph8r) resolved the finding and wrote its
report/verification with no task check, so any agent holding the tool
could overwrite another task's finding. Refuse unless the caller's task
owns the finding; inherited findings stay read-only and an unknown caller
fails closed. Triggered chat runs carry their source task(s) as a
server-owned context value (RunInfo is empty for ChatAgent turns), never
from tool arguments.
2026-11-30 23:20:40 +01:00
Brixton Pham
9b5fa4b6d6 fix(server,agent): enforce planner run budgets and stop revive loops (#705) 2026-11-30 22:38:54 +01:00
BaaRai
643e814ad6 security: isolate task execution in per-task sandbox worker and egress proxy
Introduce the sandbox MVP architecture separating panel credentials and
PostgreSQL access from model-controlled tool execution:

- Runner service (cmd/artex-runner, sandbox/) owning /var/run/docker.sock
  behind bearer-token auth (ARTEX_RUNNER_TOKEN) with POST /v1/tasks/{id}/exec,
  POST /v1/tasks/{id}/kill, DELETE /v1/tasks/{id}, and GET /v1/health.
- Strict input and env validation (400 on forbidden secret/DB/cloud env
  patterns or values > 8192 bytes, strict task ID and /workspace workdir).
- Hardened per-task worker containers (Dockerfile.worker, artex-worker:local,
  cmd/artex-exec-wrap): uid/gid 10001, artex-exec-wrap --init PID 1 zombie
  reaper, read-only rootfs, cap-drop ALL, no-new-privileges, pids/mem/cpu
  limits, tmpfs /tmp and /home/exec, only /app/data/tasks/<id>:/workspace:rw,
  only verified internal=true runner-labeled network artex-task-<id>.
- Kernel-backed kill-switch (zero agent-writable state): Kill executes
  artex-exec-wrap --kill-uid 10001 as uid 10001 scanning /proc directly
  (defeating setsid, nohup, nested double-forked trap-TERM daemons, and /tmp
  tampering), verifies zero non-PID-1 uid-10001 processes remain, and falls
  back to force-removing the worker container if any check fails. Dead
  workers/proxies are recreated automatically when startContainer fails.
- Operator-only scope approval (migration 0023_task_scope_operator_approval.sql):
  adds task_scope.approved_by_operator BOOLEAN NOT NULL DEFAULT FALSE, set
  true exclusively by operator API/UI (AddOperatorScope) and operator-selected
  TaskCreateOptions.CompanyIDs (insertTaskCompanies). AddAgentScope and
  AddAutoScope leave it false (coverage-only). taskSandboxRunInfo reads only
  approved, non-expanded rows (and expands company scope only for approved
  company rows); tasks with no approved scope deny all egress.
- Per-task egress proxy (cmd/artex-egress-proxy, Dockerfile.egress-proxy,
  artex-egress-proxy:local): HTTP/HTTPS CONNECT (:3128) and SOCKS5 (:1080),
  deny-by-default allowlist with strict domain suffix enforcement, blocks
  RFC1918/loopback/link-local/IMDS and IPv6 unless in scope CIDRs, DNS
  pinning, and tamper-proof JSONL audit logging to a proxy-only mount
  (/app/data/egress-audit/<id>:/audit:rw) never mounted into the worker.
- Panel integration (agent/sandbox.go, agent/webfetch.go, server/sandbox.go,
  server/sharedbrowser_guard.go, server/assembly.go, server/customtool.go,
  docker-compose.sandbox.yml): ARTEX_SANDBOX defaults to required (fail closed,
  no local fallback), WebFetch and opt-in shared browser inherit the
  operator-approved sandbox.EgressPolicy (with target_gate or explicit proxy
  required for shared browser), custom script tools staged via symlink-confined
  workspace files (avoiding argv E2BIG), Pause/Stop/Delete wired to runner
  Kill/Delete.
- Documented breaking change and hardening details in docs/SANDBOX.md,
  README.md, and CHANGELOG.md.
2026-11-30 19:09:32 +01:00
BaaRai
c54f7045bb fix(planner): bound retries with backoff, expose state, resume planning, and migrate 0021 (#676)
- B1: count retrying rounds toward MaxPlanningFailures with exponential backoff
- B2: exclude planner-authored writes from fingerprint; capture start snapshot
  and include non-agent task_scope and linked assets
- B3: expose planner recovery state in task API DTO and task detail UI
- B4: clear recovery state again when Engine.Resume lands mid-round and add
  dedicated resume_planning control action + UI button
- B5: skip stale time.Ticker heartbeats fired during a long planning round
- B6: move planner_progress DDL from db/schema.sql to migration 0021
  (0020 reserved for security batch chat_type backfill)
- i18n: add matching vi.json translations alongside tr.json and zh-CN.json
- tests: initialize secrets-at-rest key in TestPlanningCredentialUpdateReopensPlanning
2026-11-30 03:16:35 +01:00
renaesop
4d03d3412b fix: recover empty planning rounds in large graphs (#676) 2026-11-30 03:16:35 +01:00
BaaRai
b130cff602
Merge pull request #694 from BaaRai/land/ghidra-sidecar-2026-11-29
agent: optional hardened Ghidra static-analysis sidecar
2026-11-29 22:19:46 +01:00
tifo234123
c0b6d4f29b feat(agent): add optional hardened Ghidra static-analysis sidecar tools (#591)
Adds optional ghidra_* worker tools, ghidra skill, and hardened opt-in
docker-compose.ghidra.yml overlay:
- dedicated internal: true Compose network (ghidra-internal) with zero
  egress for ghidra and dual-homed artex (default + ghidra-internal)
- container hardening: digest pin, no host ports, cap_drop ALL,
  no-new-privileges, read_only + tmpfs + writable projects volume,
  pids_limit/mem_limit/cpus
- client guards: Proxy: nil, http/https schemes only, cross-host redirect
  refusal, 512 MiB client-side upload cap, 8 MiB response cap, strict
  job_id and addr path-traversal validation
- tool guards: run-dir path confinement, bounded filters/outputs, no shell
- compose config test verifying internal network and hardening.
2026-11-29 21:47:40 +01:00
BaaRai
677c10d62a test(agent): restore approval lifecycle coverage (#663)
Rebased on top of #662 (post-#655) with inherited #655/#662 changes stripped.

Co-authored-by: AseemPrasad <aseemprasad0520@gmail.com>
2026-11-29 01:02:27 +01:00
BaaRai
0d26f224dc test(agent): restore company scope coverage (#662)
Rebased onto post-#655 main with inherited #655 web changes stripped.

Co-authored-by: AseemPrasad <aseemprasad0520@gmail.com>
2026-11-29 01:02:27 +01:00
Dukotah
24f40c48a2 web: add a neutral "Custom OpenAI-compatible" preset for LLM profiles
Closes #648.

A self-hosted or relayed OpenAI-compatible endpoint has to be configured
today by picking the generic "openai" format and knowing the base-URL
convention, which the README documents but the form does not guide. The
common failures are a base URL that stops short of /v1 or one with
/chat/completions pasted on the end.

The preset is UI-only: it selects the existing openai format and shows
the expected base-URL shape and a one-line hint. No wire format, no
schema change, no vendor host, and nothing is prefilled into the value,
so an empty base URL still saves as empty and existing profiles are
untouched. Because the preset is not stored, it is re-derived when a
profile reopens: an openai profile pointing somewhere other than
api.openai.com shows the preset.

Tests, written before the change:

- agent: regression tests pinning the base-URL normalization the preset
  relies on (bare /v1, trailing slash, a pasted /chat/completions
  endpoint, whitespace, a path-prefixed gateway, host:port) and pinning
  that an empty base URL still resolves to the public endpoint.
- web: unit tests for the derivation helper, following the
  src/lib/*.test.mjs convention, wired into package.json and CI.
2026-11-29 00:01:51 +01:00
BaaRai
c1a1ca4dcd fix(trigger): frame untrusted finding, goal, and tool payloads (#659)
Applies #659 cleanly on b8cd251: wraps finding, goal, and tool-trigger
untrusted payloads in nonce-tagged ARTEX_DATA markers via FrameTriggerData.

Co-authored-by: Coff0xc <184964491+Coff0xc@users.noreply.github.com>
2026-11-28 23:07:45 +01:00
BaaRai
b530669908 fix(agent): wire enrichment trigger in insert_assets (#638)
Rebased CHANGELOG.md on top of #647.

Co-authored-by: shuhuNB515 <shuhuNB515@users.noreply.github.com>
2026-11-28 19:24:53 +01:00
BaaRai
d32f5689ec
Merge pull request #637 from zOrg1331/fix/bedrock-chat-completions
fix(llm): support Bedrock gateways that speak OpenAI chat completions
2026-11-28 19:24:27 +01:00
BaaRai
d477c118fd fix(agent,db): isolate fact capture provenance and tighten prove_goal (#602)
Rebased onto main (5f5ec32), keeping migration 0017_legacy_fact_capture_provenance.sql, cross-task shared-capture isolation, repair_legacy_fact_captures, and digest retirement.

Addresses review findings:
- prove_goal resolves evidence strictly within this task (GetNode, not GetNodeWithSources), blocking linked-task facts/findings from closing this task's goals.
- Facts with missing, empty, unverified, retired (captured_traffic), or non-matching provenance fail closed in prove_goal.
- Preserves a task-scoped tool_output proof path for TCP/DNS/non-HTTP goals by tying tool_output facts strictly to this task's recorded tool_result activity (ToolResultActivityContainingEvidence + ActivityMatchesProvenance) without ever reading the shared proxy store.
- For source=operator_input, prove_goal requires the whitespace/case-normalized summary to be contained in the verified operator evidence quote, preventing a benign real operator quote from smuggling an unrelated summary claim (tested in TestProveGoalOperatorInputSummaryMustMatchEvidencePG).
Co-authored-by: James K <jamesKhor@users.noreply.github.com>
2026-11-28 10:00:55 +01:00
Pavel Nakonechnyi
97c2d38526 fix(llm): retry Bedrock chat requests as chat completions
A tool-bearing Anthropic body is rejected with HTTP 400 by OpenAI-shaped InvokeModel endpoints. Retry that call once as a chat completion and keep the shape that succeeds.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-28 09:33:24 +01:00
Pavel Nakonechnyi
b2c7cc0275 fix(llm): accept Bedrock chat-completion replies
InvokeModel responses that use the OpenAI chat completion shape were parsed as empty Anthropic messages. Adapt them so connection tests and live sessions see the visible text, and name reasoning-only failures.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-28 09:33:24 +01:00
BaaRai
192ff94a24
Merge pull request #615 from sresarehumantoo/fix/595-anchor-summary-pattern
fix(agent): anchor the record_fact summary pattern for Ollama (#595)
2026-11-28 08:30:26 +01:00
BaaRai
91bf8bc00b fix(agent,server): scope discovery coverage by surface with >=50 entries and warn on JSON/all-404 CTF vhosts 2026-11-28 03:19:30 +01:00
BaaRai
3e1baf7a3f fix(agent): support curl -w status:size, expand Bash multi-URL loops, and widen gated-route block 2026-11-28 03:19:30 +01:00
BaaRai
c69ae37e78 feat(agent,intercept): add compact task_brief coordination and structured wait_for_lease active-lease dedup 2026-11-28 03:03:19 +01:00
BaaRai
e9f4c6e6e2 feat(agent,server,web): expose planner budget countdown, cap seed intents, wake on assets/findings, and add POST /extend 2026-11-28 03:03:19 +01:00
BaaRai
9fd5d695f0 feat(skills,agent,server): add API wordlist, 5-part discovery gate, and opt-in target fingerprint 2026-11-28 03:03:19 +01:00
BaaRai
437284f711 feat(agent,traffic,server): add constant-gate detector, gate_constant intent guard, and sweep handoff 2026-11-28 03:03:19 +01:00
BaaRai
4147b7abb9 fix(intercept,agent): add wait_for_lease tool, 900s TTL margin, worker-safe conflict text, and env validation 2026-11-28 03:03:19 +01:00
BaaRai
929f9bdc8a feat(intercept,guard,agent,server): add lease heartbeat TTL, lease_status, planner policy, and toggle flag 2026-11-28 03:03:19 +01:00
BaaRai
20042ed2cf Merge remote-tracking branch 'origin/main' into feat/exploitation-ledgers 2026-11-27 22:37:26 +01:00
BaaRai
b90474f1e7 docs(agent): state that capabilities are exploitation capabilities, not agent permissions (#613) 2026-11-27 22:20:09 +01:00
BaaRai
771c241831 feat(agent,db): add planner capability ledger (#613) 2026-11-27 22:19:43 +01:00
BaaRai
e3a83d7c74 feat(agent,db): add planner hypothesis ledger with closed-variant guard 2026-11-27 22:19:43 +01:00
BaaRai
da7015f6e8 fix(engine,agent): emit ask_operator handoff with operator_handoff cause on poll-loop stop 2026-11-27 22:19:40 +01:00
BaaRai
82af66cdd8 feat(agent,db,server): add anti-poll escalation and RetargetTask helper 2026-11-27 22:19:40 +01:00
SREsAreHumanToo
5f5472d720 fix(agent): anchor the record_fact summary pattern for Ollama (#595) 2026-11-27 09:57:23 -05:00