Skip to content

Chat-spawned tasks inherit company link but zero egress: spawn_task stamps approved_by_operator=false, proxy starts with cidrs=0 #830

Backlog

Description

@c4nc

Version/commit: local build of main (checkout 6479ed7, backend reports version=dev; runner healthy)

What I ran:

  1. Created a company (ICrash2) and gave it scope cidr 100.85.186.124/32 (the lab target).
  2. Deleted the previous company that held the same scope.
  3. Started a new chat with the auto orchestration agent while the sidebar company switcher was set to ICrash2.
  4. Asked the chat to spawn two assessment tasks against the target.
  5. Workers ran curl http://100.85.186.124:8095/ → every request 403 from the per-task egress proxy.

What I expected: a task spawned from a chat that the operator opened with an explicit company selection to inherit that company's egress (the company row is linked at creation, the target is inside the company's declared CIDR).

What happens: the company link lands in task_scope with source='agent', approved_by_operator=false, and the sandbox allowlist query only honours approved rows — so the proxy starts with an empty allowlist and denies everything, silently.

Evidence from a live incident (task_ids 8/9):

-- task_scope (company row written inside the creation transaction, microsecond-identical created_at)
 task_id |  kind   | comp |        net        | source | approved_by_operator
       8 | company |    4 |                   | agent  | f
       8 | ip      |    0 | 100.85.186.124/32 | agent  | f
       9 | company |    4 |                   | agent  | f
-- task_scope_egress: 0 rows (no freeze ever happened for any task)

-- egress proxy startup logs
task=3 domains=0 cidrs=1   → audit decision:"allow"  (operator-approved rows existed at spawn)
task=8 domains=0 cidrs=0   → audit decision:"deny"   (all four rows unapproved/expanded)

-- agent self-repair attempt (task 8, ~2 min after its own spawn)
task=8 ip 100.85.186.124/32 source=agent approved=f expanded=t   → still filtered out

Root cause:

  • server/orchestration.go:362 — spawn_task unconditionally passes CompanyScopeByAgent: true, so every company link from any chat is stamped coverage-only (db/tasks.go:184-186: "rather than an authenticated operator, leaving task_scope approved_by_operator=false (coverage-only) to prevent scope drift").
  • server/sandbox.go:99 — the sandbox allowlist is built from task_scope WHERE approved_by_operator=true AND COALESCE(expanded,false)=false → empty → cmd/artex-egress-proxy + sandbox/policy.go:250 deny-by-default for literal IPs → 403 on every connect.
  • The chat itself carries no company binding server-side: conversations has no company column; the sidebar switcher is a client-side view filter (web/src/stores/company/). So the operator's deliberate company selection is lost at the one hop where it would matter — only the LLM's tool argument survives, and by design the LLM's word carries no consent.

For contrast, the HTTP path POST /api/tasks (server/server.go:1930) leaves CompanyScopeByAgent=false → rows land source='manual', approved_by_operator=TRUE → the same company selection grants egress. So two operator surfaces, one grants and one silently doesn't.

Why it feels like a trap:

  • The task looks linked (it appears in company-filtered views, prompts show the company), so "no egress at all" is not visible anywhere in the UI.
  • The agent notices the 403 and calls add_task_scope/add_company_scope to self-repair — those are the unapproved paths, and even if approved, the allowlist is frozen at proxy creation (documented in server/sandbox.go:128-130), so the repair cannot help the running task. The only exit is an out-of-band operator approval + task respawn.
  • A closed predecessor, spawn_task orchestration tool cannot link companies at creation #626, added company_ids to spawn_task to restore creation-time linking, but the approval semantics mean the linked company still confers zero egress for chat-dispatched tasks — so the unattended-dispatch motivation of spawn_task orchestration tool cannot link companies at creation #626 ("a human has to edit the task afterwards, which breaks unattended dispatch flows") is only half solved: visibility is back, privileges are not.

Suggested fix (pick one or combine):

  1. Bind conversations to companies server-side (e.g. conversations.company_id, set from the authenticated operator when the switcher is applied at chat start). spawn_task then passes approvedByOperator=true for company ids that are a subset of the conversation's bound companies; LLM-only ids keep the current coverage-only stamp. Operator intent is captured where it actually exists (a human clicked the selector), and the self-grant invariant is preserved for ids the model invents.
  2. Minimum alternative: make the gap loud instead of silent — when a task has an empty approved allowlist (cidrs=0 and domains=0 at proxy start) while it has company links, surface a banner/warning on the task ("company linked, egress pending operator approval") instead of letting workers 403 in a loop.

Bonus doc note: the freeze-at-spawn behaviour means "approve scope, then the already-running task still 403s until respawn" — worth stating next to the scope-approval UI.

Activity

  1. github-actions commented on Dec 2, 2026

    @github-actions

    Thanks, this is a detailed bug report. The expected/actual split is clear, but a few things are missing to confirm and fix it: (1) whether the cidr 100.85.186.124/32 row on ICrash2 was explicitly approved by an operator before the chat spawn; (2) the exact spawn_task tool arguments and server log lines around creation of tasks 8/9, including whether company_ids was passed; (3) full artex-egress-proxy startup logs/env for a denied task and an approved task; (4) output of task_scope and task_scope_egress for both; (5) whether auth/operator identity was enabled and which DB/migration version and backend you used; (6) whether POST /api/tasks with the same company produces approved rows in that environment. Also confirm whether you respawned after approval, since the documented freeze-at-proxy-creation means later approval cannot affect a running task. The linked-company/no-egress mismatch looks like a real core-functionality bug rather than a security bypass.


    🤖 automated reply from the repo bot. A human maintainer reads everything. Ping me in any comment with @artex-bot.

  2. added
    bug
    on Dec 2, 2026
  3. c4nc commented on Dec 2, 2026

    @c4nc
    Author

    Answers to (1)-(6), all from the live host (Docker Compose deploy, PostgreSQL backend, schema_migrations head = 24, backend version=dev, runner healthy):

    (1) Was the CIDR row on ICrash2 operator-approved before the chat spawn?
    company_scope has no approval column at all (full DDL checked: id, company_id, kind, domain, net, value, raw, reason, created_at; approval semantics exist only on task_scope). So "approved company scope before spawn" is not representable — a company's CIDR is inert by construction until task-level approval freezes it. Timeline detail that matters: companies.id=4 (ICrash2) created_at 2026-12-02 09:53:42, but both company_scope rows (cidr 100.85.186.124/32, one keyword) carry created_at 2026-12-02 10:24:23.832343 — microsecond-identical, the signature of a single scope-rebuild transaction (the edit path deletes+reinserts rows, DEFAULT now()). That is ~5 min after tasks 8/9 were spawned (10:19:40/46) and after their first audit denies (10:21:03). So at spawn time the company's current scope rows did not exist as they are now; whether the CIDR was originally present at 09:53 and rewritten at 10:24 cannot be recovered from the row alone — there is no scope history table. Either way the approved_by_operator=false mechanism below fully explains the denies independent of this timing.

    (2) Exact spawn_task arguments + server log lines
    From conversation_activities (ids 644/645, conversation 4 = the operator's auto chat started 10:18:30 with the sidebar switcher on ICrash2). Both calls pass company ids explicitly:

    id 633: add_company_scope {"company":"ICrash2","reason":"Operator-provided sandbox target: iCrash CRM app on 100.85.186.124:8095..."}
    id 644: spawn_task {"description":"iCrash CRM — BLACK-BOX assessment (fresh instance)","goal":"...","company_ids":[4],...}
    id 645: spawn_task {"description":"iCrash CRM — GRAY-box assessment + register verdicts (fresh instance)","goal":"...","company_ids":[4],...}
    

    Server log, creation window:

    10:19:40 [seed] task 8: target site http://100.85.186.124:8095
    10:19:44 [fingerprint] task 8 ("http://100.85.186.124:8095/"): target_fingerprint gated (TARGET_APPROVAL_PENDING)
    10:19:46 [seed] task 9: target site http://100.85.186.124:8095
    10:20:37 [worker work#1] task 8 claimed intent #214
    

    Target-gate approval was performed; these 403s are the egress proxy, a different gate — which is exactly the confusion the issue is about.

    (3) Egress-proxy startup logs + env, denied vs allowed task (both containers still running)

    # denied (task 8)
    docker exec artex-egress-8 env | grep ARTEX_SCOPE
    ARTEX_SCOPE_DOMAINS=
    ARTEX_SCOPE_CIDRS=
    log: 2026-12-02 10:20:53 [egress-proxy] task=8 http=:3128 socks5=:1080 domains=0 cidrs=0
    
    # allowed (task 4, operator-approved rows existed at its spawn)
    docker exec artex-egress-4 env | grep ARTEX_SCOPE
    ARTEX_SCOPE_DOMAINS=
    ARTEX_SCOPE_CIDRS=100.85.186.124/32
    log: 2026-12-02 08:51:09 [egress-proxy] task=4 http=:3128 socks5=:1080 domains=0 cidrs=1
    

    Audit JSONL: task 8 → {"host":"100.85.186.124","port":8095,"decision":"deny","bytes":0} (recurring); task 4 → {"host":"100.85.186.124","port":8095,"decision":"allow","bytes":30304} plus :8096 allow bytes 2579.

    (4) task_scope / task_scope_egress

     task_id |  kind   | comp |        net        | source | approved_by_operator | expanded
           8 | company |    4 |                   | agent  | f                    | f
           8 | ip      |    0 | 100.85.186.124/32 | agent  | f                    | t
           9 | company |    4 |                   | agent  | f                    | f
           9 | ip      |    0 | 100.85.186.124/32 | agent  | f                    | t
    task_scope_egress: 0 rows (all tasks).
    

    For the approved task 4 the task_scope table now returns 0 rows — coverage rows for tasks 2–7 have aged out / were removed when the old company was deleted; the surviving proof of its approved state is the ARTEX_SCOPE_CIDRS=100.85.186.124/32 env and the allow audit entries above. Caveat stated rather than papered over.
    Note the ip rows' created_at (task 8: 10:20:02, ~22 s after its own creation): the worker/planner self-repaired via add_task_scope after seeing denies — source='agent', approved=f, expanded=t, still invisible to server/sandbox.go:99.

    (5) Auth / operator identity, DB, backend
    Operator auth is enabled (JWT: ARTEX_JWT_KEY_DIR, ARTEX_SECRET_KEY, ARTEX_RUNNER_TOKEN set; values redacted). PostgreSQL via artex-postgres container, migration head 24 (previous 23, 22). Single-user local install — the chat that spawned 8/9 was an authenticated operator session; the stamping does not depend on the session identity because server/orchestration.go:362 hardcodes CompanyScopeByAgent: true for every spawn_task call, authenticated operator chat or not. That is the crux: the human intent exists and is authenticated, but the transport discards it.

    (6) Does POST /api/tasks with the same company produce approved rows here?
    Not yet exercised empirically in this environment (it would create a live task + planner load on this shared runtime; happy to run it with a ZZ-probe description and delete it afterwards on request). From the code it is deterministic: the HTTP create path (server/server.go:1930) does not set CompanyScopeByAgent, so insertTaskCompanies(tx, id, companyIDs, true) writes source='manual', approved_by_operator=TRUE — the contrast is precisely why the chat path is a core-functionality mismatch rather than an environment quirk.

    Respawn-after-approval question: for tasks 8/9 no operator approval had happened at all when the deny loop ran (the company had no current scope rows either, see (1)), so the freeze-at-proxy-creation behaviour was not the operative cause for them; it is operative for the agent's self-repair attempt (approved or not, a row added after proxy start cannot reach the running allowlist). The earlier allow-cycle (tasks 3/4/5, ~08:44–08:51) was approval before spawn, hence cidrs=1 — consistent with the documented freeze semantics.

    Happy to add the empirical (6) run or any other capture.

  4. advokat11 commented on Dec 2, 2026

    @advokat11

    Same problem. Wonder how you guys use it before, scope mechanic is literally not working and egrees giving me 403 even to in-scope targets.

  5. advokat11 commented on Dec 2, 2026

    @advokat11

    Works with ARTEX_SANDBOX=off

  6. c4nc commented on Dec 2, 2026

    @c4nc
    Author

    Supplement (2026-12-02): after the evidence comment above was posted, upstream landed ed70ea3 ("security: promote company scope egress only when approved by the operator", migration 0025): company_scope now carries approved_by_operator (existing rows backfilled approved), and the task egress snapshot reads only operator-approved company scope rows. The evidence comment's "company-level approval is not representable" point was true of our build (6479ed7) and is superseded by that commit.

    The reported gap itself still reproduces on current origin/main (e38f58d), re-verified today:

    • server/orchestration.go:362 still hardcodes CompanyScopeByAgent: true for chat spawn_task;
    • db/tasks.go (insertTaskCompanies, called at :284) still stamps every task company/ip row approved_by_operator=false whenever that flag is set, regardless of whether every scope row of the selected company is now operator-approved under 0025;
    • so a chat-spawned task still starts with an empty allowlist (cidrs=0) and the proxy denies every connect — the original repro is unchanged.

    With 0025 in place the natural fix is narrower than option 1 in the body: derive the per-company spawn approval flag from the company's scope approval state. At spawn, a selected company whose scope rows are all approved_by_operator=true inserts its task_scope rows as operator-approved and freezes the task_scope_egress snapshot in the same transaction, mirroring AddOperatorScope's 0025 semantics; a company holding any agent-written unapproved row, and LLM-invented company ids, keep the coverage-only stamp. Operator intent is then captured where 0025 says it lives (the company-level approval), and the self-grant invariant is preserved per row.

    We plan to prepare this as a PR from a fork, alongside a companion PR for the mirror bug — operator-approved egress grants satisfying zero target-gate approvals (the gate reads target_pins only, intercept/ never consults task_scope; CIDR-granted targets still raise per-port and bare-host approval prompts). Companion issue to follow with its own evidence trail.

  7. c4nc commented on Dec 2, 2026

    @c4nc
    Author

    Works with ARTEX_SANDBOX=off

    @advokat11 yeah, but not looking to be swatted just because artex may have gone rogue and berserk against a .mil domain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions