unarr/internal/agent
Deivid Soto 060a3e48db fix(security): CORS allowlist, URL scheme guard, state perms, ZIP slip, mirror docs
Phase 3 security audit follow-up. Medium and low-severity hardenings
plus a deferred-work plan for the cross-repo stream-token rollout.

Stream server CORS: replace the wildcard Access-Control-Allow-Origin
with an allowlist that echoes back only torrentclaw.com,
app.torrentclaw.com, the local Next dev port (3030 — matches the web
repo package.json) and any extras the operator adds via the new
downloads.cors_extra_origins TOML key. A Vary: Origin header is now
emitted whenever the request carries an Origin header so an
intermediate cache cannot serve a stale ACAO to a different origin.

URL scheme guard: openBrowser and OpenPlayer refuse any URL that is
not http(s). Combined with passing the URL after "--" wherever the
launched helper supports it (open, mpv, vlc, cvlc), this stops a
leading "-" from being parsed as a switch by the spawned process.

State file permissions: WriteState now writes 0o600 so the agent ID,
PID and counters cannot be enumerated by another local user on a
shared host. Matches the existing config file mode.

ZIP slip defense-in-depth: extractZip extracts the safety check into
safeZipPath, which canonicalises the entry name (normalising
backslashes to "/"), rejects "..", "../" prefix and "/../" interior
components, and verifies the final destination stays inside destDir
before opening any file.

Mirror fallback: documented the design for multi-provider
mirrors.json hosting in the comment block on DefaultStaticFallbackURLs
and added a follow-up note about signing it with the same ed25519
release key. The list is kept at one provider until the second host
is provisioned and added to torrentclaw-web's STATIC_FALLBACKS.

Deferred work: a new plan document Docs/plans/security-stream-token.md
covers the per-task stream token (Phase 2.2 of the original audit)
which requires coordinated web + CLI work and ships separately.
2026-05-15 18:48:59 +02:00
..
client.go feat(agent): add mirror failover, agent client refactor, status 401 detection 2026-05-15 16:26:43 +02:00
client_test.go feat(agent): add mirror failover, agent client refactor, status 401 detection 2026-05-15 16:26:43 +02:00
daemon.go feat(transcode): dynamic H.264 level + HW probe + capability reporting 2026-05-08 15:57:02 +02:00
disk.go feat(cli): add login command and refactor shared helpers 2026-04-01 12:20:51 +02:00
disk_test.go test(coverage): raise engine+agent coverage above 50% 2026-05-12 11:21:59 +02:00
disk_unix.go feat: initial commit — unarr CLI 2026-03-28 11:29:42 +01:00
disk_windows.go feat: initial commit — unarr CLI 2026-03-28 11:29:42 +01:00
mirror_client.go fix(security): CORS allowlist, URL scheme guard, state perms, ZIP slip, mirror docs 2026-05-15 18:48:59 +02:00
mirror_pool.go feat(agent): add mirror failover, agent client refactor, status 401 detection 2026-05-15 16:26:43 +02:00
process_unix.go feat: add clean command to remove temp files, logs, and cached data 2026-03-29 11:04:51 +02:00
process_unix_test.go test(coverage): raise engine+agent coverage above 50% 2026-05-12 11:21:59 +02:00
process_windows.go fix(build): unused variable in Windows process check 2026-03-30 13:11:55 +02:00
signal_client.go fix(security): UPnP opt-in, bounded SSE reader, signed self-update 2026-05-15 17:29:22 +02:00
signal_client_test.go fix(security): UPnP opt-in, bounded SSE reader, signed self-update 2026-05-15 17:29:22 +02:00
state.go fix(security): CORS allowlist, URL scheme guard, state perms, ZIP slip, mirror docs 2026-05-15 18:48:59 +02:00
state_test.go feat: improve daemon resilience, streaming, and usenet downloads 2026-03-28 21:36:12 +01:00
sync.go feat(stream): pion-based WebRTC byte streamer for browser playback 2026-05-06 23:12:38 +02:00
sync_test.go test: add comprehensive test suite for engine, agent and cmd packages 2026-04-08 23:36:00 +02:00
taskstate.go feat(sync): replace WS+DO transport with unified HTTP sync 2026-04-08 18:50:59 +02:00
taskstate_test.go test(coverage): raise engine+agent coverage above 50% 2026-05-12 11:21:59 +02:00
types.go feat(transcode): dynamic H.264 level + HW probe + capability reporting 2026-05-08 15:57:02 +02:00