Commit Graph
7 Commits
Author SHA1 Message Date
BaaRai 4fa45eb449 security(agent): ask_operator staging refuses symlinks and never overwrites
The staged copy of an ask_operator image was written by the server with
os.Create under a name built from the second, in an uploads directory made
with MkdirAll. An agent that can write in uploads/ (a task directory from
before the run-directory layout) could prepare that name as a symlink, and a
symlinked uploads/ was followed.

- uploads/ is created with Mkdir and checked with Lstat: a symlink or a
  file in its place is refused.
- The name is ask-operator-<unixnano>-<8 random hex>.<ext>, created with
  O_CREATE|O_EXCL, mode 0640. A taken name is never opened: another name is
  tried, five at most.
- The source is opened only when it is still the regular file Lstat saw
  (os.SameFile on the Lstat and the Stat of the open file), which refuses a
  file swapped for a symlink between the EvalSymlinks check and the open.
  The run-directory confinement is unchanged.

Not closed: a directory inside the run directory swapped for a symlink
between the check and the open still leads both Lstat and the open to the
same file elsewhere.
2026-11-20 05:35:56 +01:00
BaaRai 7be765bff2 security(agent): restore group sharing for legacy task entries; resolve ask_operator paths from the run dir
The layout commit made tasks/<id> root:root 0755 and shared only the run
directories. Entries that sat directly in a task directory before it
(uploads/, files the main agent wrote there) were left as found and
nothing shared them any more: after an archive restore, which keeps
neither owners nor modes, the executor could not use them. ask_operator
still resolved a relative image_path from tasks/<id>, not from the
directory the agent works in.

- shareTaskDir: after the task directory is set root:root 0755, each
  direct entry that is not a run directory (main, i<N>) is shared with
  the executor group again (shareWithExecGroup: group owner, group
  read/write, traverse and setgid on directories). Run directories are
  handled as before. The task directory stays root-only, so the executor
  works inside an old entry and cannot rename, remove or add one. A
  symlink among the entries is not followed. The pass runs at start-up
  and on archive restore (installTaskArchiveFiles calls
  shareRestoredTaskDir and rolls back on failure), with no operator step.
- ask_operator: image_path is resolved inside the run directory of the
  agent that asks (agent.EnsureRunDir: tasks/<id>/i<N> for a worker,
  tasks/<id>/main without an intent). An absolute path outside it, "..",
  and a symlink leading out are refused as before. The copy is still
  staged in tasks/<id>/uploads. The tool description says so.

Tests: root-only TestShareTaskDirLegacyEntriesAsRoot (owners and modes,
an executor probe, links to a root-only directory and file left alone);
TestRunDirLayoutOnExistingTreeAsRoot now expects the old file shared;
TestTaskArchiveRestoreRunDirOwnershipAsRoot restores an entry of the task
directory; TestStageAskOperatorImage uses the i<N> and main leaves.
SECURITY.md states the sharing of the old entries and the empty main/.
2026-11-20 05:35:56 +01:00
Coff0xc 203103360e fix(server): confine ask_operator image_path to the task directory
image_path was opened as a raw filesystem path, so any readable
png/jpg/jpeg/webp/gif on the host could be copied into the operator
transcript. The path is now resolved from the task working directory
and refused when it contains .. or EvalSymlinks outside that tree.
2026-11-18 17:22:42 +01:00
BaaRai a7e91c81e6 fix(ask_operator): seed the goal targets with bare goal domains (F12)
The goal gate accepts a goal that names its target as a bare domain (goalDomainRE), but the in-goal set was built only with commandTargets, which does not read bare hosts. A question citing the operator's own target as a URL was then tagged target-derived. goalTargets adds the goalDomainRE matches, widened to the whole dotted name, lowercased, port and path dropped. The question-side parser is unchanged.
2026-11-12 11:51:38 +01:00
BaaRai 6dbcd33552 feat(ask_operator): tag requests that name hosts outside the goal (F12)
An ask_operator question that names a host or URL not among the task's
goal targets is tagged "contains target-derived text": the hosts go into
the transcript activity's Detail payload as target_derived_hosts, and the
transcript shows the tag on the request card when the field is set.

Hosts are read with intercept.ExtractTargets (the target gate's
command-string rules) from both the question and the task goal, and
compared without the port. The text the model reads, the pause, and the
operator's decision are unchanged: the tag is a visible hint only.

Audit F12, 0.7.0.
2026-11-12 11:12:22 +01:00
BaaRai 4b815d5ee0 feat: ask_operator environmental handoff discipline
When a worker hits an environmental failure (sandboxed or filtered
network path, missing binary or key, TLS or proxy interception, missing
runtime permission), nothing today tells it how to stop: transcripts
show turn after turn of retries with different flags, equivalent tools,
or fallback transports, all burning budget against a wall the agent
cannot move.

Changes:

- the ask_operator tool description now covers environmental blocks
  explicitly: do not retry or work around; include the exact single
  command the operator should run in their own terminal as one
  copy-pastable line, plus what to paste back, then wait. The question
  parameter description gains the same guidance.
- worker and pentest seeds gain an "Operator handoff on environmental
  blocks" block: stop after the first environmental failure, no
  flag-hopping, no bypass hunting, one command per ask_operator request,
  never batch.
- tests: the tool description must keep the handoff markers
  (TestAskOperatorEnvHandoffGuidance) and the executor seeds must keep
  the block (TestPromptSeedsCarryOperatorHandoff).

Pattern adapted from bug-bounty-hunting-prompts (MIT), whose operator
handoff rule produced exactly this single-command format.
2026-10-12 06:45:21 +02:00
BaaRai d54e468763 feat: ask_operator tool - workers can request operator input (captcha/OTP) with a screenshot and pause
A worker hitting a wall only a human can clear (captcha, email/SMS OTP, 2FA,
a decision) calls ask_operator with a precise question and an optional
screenshot. The question lands in the intent's transcript as a user-role turn
with an attachment card (the same {text, attachments} shape chat uploads use,
so the existing transcript UI renders it natively), and the intent pauses. The
operator replies through the existing message-to-worker flow; the reply resumes
the run with the answer as the next input. Images are whitelisted (png/jpg/
jpeg/webp/gif), capped at 10MB, and copied into the task uploads dir.

Closes #41
2026-10-11 23:06:39 +02:00