Skip to content

security: close the 0.7.1 advisory batch (14 fixes) - #727

Merged
BaaRai merged 20 commits into
mainfrom
sec/advisory-batch-071
Nov 30, 2026
Merged

BaaRai merged 20 commits into
mainfrom
sec/advisory-batch-071

Conversation

@BaaRai

@BaaRai BaaRai commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Summary

Closes the 14 open advisories that are fixable now, on top of the sandbox, the scope-ownership change and the CORS proof checks already on main. Each fix has a test that fails without it. Credit to the reporters is in the changelog.

Triage of the 26 advisories in triage: 7 fixed before this batch (GHSA-67c6, GHSA-prm8, GHSA-86r5, GHSA-fcx3, GHSA-3gwj, GHSA-3558, GHSA-3rm5), 14 fixed here, 3 duplicates, 2 invalid. Two remain: GHSA-4rcx is an intended admin capability (its reported PoC is closed by the sandbox), and GHSA-fgq3 is a 41-byte "test".

What this batch fixes

Advisory Severity Fix
GHSA-r7q2 + GHSA-7h5v medium Chat uploads create and write through os.OpenRoot on the data dir, every component Lstat-verified, O_CREATE|O_EXCL; a symlinked uploads/ is refused
GHSA-fqvh high Archive staging/restore journals validated (ids, files/ relatives, server-derived sources) before MkdirAll/Rename; archives denied in the workspace API
GHSA-3p3q high wsWrite/wsMkdir/wsUpload go through os.OpenRoot, closing the resolve-then-write race
GHSA-39w9 high /api/llm/test validates base URL and proxy, re-checks every dial and redirect, ignores *_PROXY; ARTEX_LLM_PRIVATE_ENDPOINTS for local servers
GHSA-589f high Target fingerprint uses its own transport, no env proxy, dials through the pinned target gate
GHSA-663x medium 0.0.0.0/8 is non-public in the exemption and model guards
GHSA-q37j medium The recording proxy opens a separate upstream for a plain-HTTP request naming another host
GHSA-ph8r high update_finding_report is scoped to the caller's task; inherited findings read-only; no task context fails closed
GHSA-f7fv medium ExecuteExtraTool is unwrapped and rules/persistence are evaluated on the inner tool, stricter decision wins
GHSA-m27c critical The custom-tool test endpoint evaluates the built-in and operator rules on what it runs and writes the audit
GHSA-8g8c (script) high runScriptTool passes the target gate before the interpreter starts
GHSA-8g8c (install) high config.json is 0600 from the installer and from the start path even without the exec drop
GHSA-2crf medium The rm rules match -r -f, -R -f, -f -r; a v4 seed rewrites the old pattern without touching operator edits
GHSA-53wc low Asset/company/lesson reads require approved_by_operator; the coverage ledger still counts every row
GHSA-3vq4 + GHSA-v6j2 medium Asset block rules canonicalize both sides (IPv4/IPv6, case, trailing dot, IDNA) and normalize at save

Verification

  • go build ./..., go vet ./...: PASS on the merged tree.
  • go test -count=1 ./db ./server ./agent ./guard ./intercept ./traffic on disposable PostgreSQL 16: db 94.9s, server 141.5s, agent 42.8s, guard 4.3s, intercept 12.4s, traffic 59.8s, all PASS.
  • gofmt clean on all 51 committed Go blobs (checked on LF blobs extracted from the commit, not the CRLF worktree).
  • Each fix was verified red before and green after in its branch: TestChatUploadRejectsSymlinkedUploadsDir, TestTaskArchiveStageJournalRejectsHostilePaths, TestWorkspaceWritePathTOCTOUSymlinkSwap, TestLLMTestRefusesNonPublicTargetsBeforeDial, TestFingerprintRefusesReboundTargetAtDial, TestThisNetworkIsNonPublic, TestPlainHTTPKeepAliveDoesNotCrossHosts, TestUpdateFindingReportScopedToOwningTask, TestAgentScopeDoesNotGrantReadsUntilOperatorApproved, TestPrepareExecPrivilegeTightensConfigFileWithoutExecDrop, TestMatchAssetInterceptRules canonical cases, TestExecuteExtraToolDenyAppliesToInnerTool, TestCustomToolTestEndpointAppliesRules, TestRecursiveForceDeleteSeparateFlags, TestCustomScriptRenderedTargetGated.

Behavior changes to know

  • A local model server must be listed by exact host:port in ARTEX_LLM_PRIVATE_ENDPOINTS to use the Test button, and SOCKS5 proxies are refused there.
  • A manual chat with no task context can no longer call update_finding_report; task-triggered and merged runs are scoped.
  • Agent-written task_scope rows no longer grant asset/company/lesson reads; operators approve scope once (migration 0023 already backfills manual rows).

Known limits

  • Workspace reads and deletes (wsRead, wsDownload, wsList, wsDelete) still resolve before use; only the write paths were in scope.
  • The archive moves still Rename host paths after validation; moving them onto os.Root is a follow-up.
  • The script and custom-command target gates use the same static scan as commands, so a destination computed at runtime is not detected.

Ships in 0.7.1. The advisory metadata update and publication comes after the tag.

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.
The hook sees ExecuteExtraTool for every deferred custom tool and every MCP
tool, so a deny/ask rule keyed on the real tool name never matched. Unwrap
the wrapper input (the same unwrap the target gate already uses) and
evaluate IsToolEnabled, MatchPersistence and Match on the inner name and
input, keeping the stricter of the wrapper and inner decisions.
The panel's test endpoint dispatched the rendered command, script or URL
without evaluating the intercept rules or writing the audit, so a call a
worker would be blocked from running could be run from the panel. Evaluate
the built-in deny rules and the rule set on the rendered text before the
dispatch, refuse on deny/ask, and record the decision as the agent path
does. The admin-only route and its sandbox behaviour are unchanged.
Agent/auto scope rows are coverage-only (approved_by_operator=false):
sandbox egress already filtered them, but the scoped asset reads
(scopeTargetCTE behind QueryDSLInScope/GetByIDsInScope), the task's
company list, and the lesson read scope still honoured them, so an agent
could widen what it reads by calling add_task_scope (GHSA-53wc).

Require approved_by_operator=true on those read paths. The coverage
ledger keeps counting every scope row unchanged: only authorization
reads are filtered, not the coverage denominator.
The recursive-force-delete rules required the recursive and the force flag
in one token, so rm -r -f /, rm -R -f / and rm -f -r / passed while the
combined rm -rf / was denied. The v1 and v2 seed patterns now read the short
flags combined or separate, and a v4 seed rewrites the rows an upgraded
install already has (leaving operator-edited patterns alone).
install.sh wrote config.json, which carries the database password, under the
ambient umask and never chmodded it. Write it 0600.

PrepareExecPrivilege returned before its 0600 tightening whenever the executor
drop was disabled, so a non-root local start never restricted the file either.
Tighten it on every start and only force root ownership when the drop is
enabled (which implies a root server).
…part 3)

runScriptTool only ran the stateful check: unlike the command tool it never
called GateRenderedCommand, and the hook reads the call's parameters, not the
script's stored code. A gated task could therefore run a script that reaches
any destination. Run the same destination gate on the script text before the
interpreter starts and refuse when its targets are not approved.
Block rules compared raw strings: exact_ip was a literal compare, exact
domain was case-folded only, and fuzzy_ip was case-sensitive. Targets are
canonical, so a rule written as 0:0:0:0:0:0:0:1, with a trailing dot or in
upper case never matched and the block silently failed open
(GHSA-3vq4 / GHSA-v6j2).

Canonicalize both sides in matchOne (netip Unmap/zone-strip for IPs;
lower-case, one trailing dot removed, IDNA for domains; lower-case
fuzzy_ip) and canonicalize or reject the same variants at save time.
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.
GHSA-589f: FingerprintTarget checked the target before the request but built
its client on http.DefaultTransport, so the environment proxy and a fresh DNS
resolution could reach loopback, private or instance-metadata addresses after
the check. The client now uses its own transport, never the *_PROXY
environment, and dials through the gate's pinned dialer, which resolves again
and refuses an address the pin does not cover. The probe requests reuse the
same transport.
GHSA-663x: ValidateExemptionHost and IsNonPublicAddr accepted 0.0.0.0/8 as
public, so 0.0.0.1 could be exempted from the target gate or used as a model
endpoint. The range is rejected now, and the model reserved-prefix test covers
it.
…ction

GHSA-q37j: with capture enabled, go-mitmproxy dials one upstream per client
connection and reuses it for later plain-HTTP requests, so a request for host
B, with B's Cookie and Authorization headers, was delivered to host A. The
sink now sets UseSeparateClient when the request names another host:port than
the connection's upstream, so each host gets its own connection. Intercepted
TLS tunnels are unchanged.
…capes

Fixes GHSA-r7q2 and GHSA-7h5v: chatUpload previously joined base/uploads
and ran os.MkdirAll + saveUpload outside an os.Root handle, allowing an
exec process that owns the workspace to replace uploads/ with a symlink
and make the root panel process write files outside s.m.dir.

Anchor every chat upload under os.OpenRoot(s.m.dir), verify each directory
component via root.Mkdir + root.Lstat (rejecting symlinks), choose free
names via root.Lstat, and write via root.OpenFile(..., O_WRONLY|O_CREATE|
O_EXCL, 0644).
…space API

Fixes GHSA-fqvh: stageTaskArchiveFiles, applyMoves, rollbackFiles, and
recoverTaskArchiveStages trusted paths unmarshalled from
.staging/<id>/journal.json, and workspaceDeniedPrefixes only blocked
traffic/_* so the workspace API could write to archives/.

Validate staging and restore journals before any MkdirAll or Rename
(matching ArchiveID/TaskID, clean relative paths under files/ with no
absolutes or "..", and exact server-derived Source paths under dataDir)
and add "archives" to workspaceDeniedPrefixes.
Eliminate the TOCTOU check-then-use window between wsResolveConfined and
filesystem writes in wsWrite, wsMkdir and wsUpload (GHSA-3p3q).

After wsResolveConfined canonicalizes the path within s.m.dir, open the
workspace root via os.OpenRoot(cp.realRoot) and perform all directory
creation, symlink verification and file writes using root-relative paths
and root.OpenFile instead of host-path os.MkdirAll, os.WriteFile and
saveUpload. Walking components with root.Lstat also blocks post-resolution
symlink swaps targeting denied platform subtrees such as traffic/_ca or
archives.
Adds one entry per advisory fixed by this batch, moves the 0.7.1 date to
2026-12-01, credits the reporters, and documents that the model list and the
connection test reach only public addresses unless the exact host:port is in
ARTEX_LLM_PRIVATE_ENDPOINTS.
@BaaRai
BaaRai merged commit 7bfe3fa into main Nov 30, 2026
8 checks passed
esp0xdeadbeef pushed a commit to esp0xdeadbeef/ARTEX that referenced this pull request Nov 30, 2026
upstream: Merge pull request BaaRai#727 from BaaRai/sec/advisory-batch-071
overlay:  sync-upstream: re-sync once instead of failing on a rejected push

files: flake.nix flake.lock nix .github/workflows/update-flake-lock.yml .github/workflows/sync-upstream.yml scripts/sync-upstream.sh
esp0xdeadbeef pushed a commit to esp0xdeadbeef/ARTEX that referenced this pull request Nov 30, 2026
upstream: Merge pull request BaaRai#727 from BaaRai/sec/advisory-batch-071
overlay:  sync-upstream: parent the result on main, not on upstream

files: flake.nix flake.lock nix .github/workflows/update-flake-lock.yml .github/workflows/sync-upstream.yml scripts/sync-upstream.sh
github-actions Bot pushed a commit to esp0xdeadbeef/ARTEX that referenced this pull request Nov 30, 2026
upstream: Merge pull request BaaRai#727 from BaaRai/sec/advisory-batch-071
overlay:  nix overlay: record the upstream commit the loop was proven against

files: flake.nix flake.lock nix .github/workflows/update-flake-lock.yml .github/workflows/sync-upstream.yml scripts/sync-upstream.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant