mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-12-03 13:11:05 +00:00
security: flow spawn company inheritance only through the caller's approved set
Review 6154399166 on #841: spawn_task inherited standing company consent for any LLM-selected fully approved company, never checking that the calling task was allowed to reach it. A task scoped to customer A, or a chat with no scope, could start a child on customer B with B's whole frozen egress and no operator decision - reversing the consent invariant the drift test pins. CreateTaskWithOptions now carries CompanyScopeCallerID, the id of the task running spawn_task (0 = chat session or direct API). Inheritance requires the company to be the caller's own: an operator-approved task_scope link on the caller, on top of the company's fully approved inventory. With no task caller nothing is auto-approved: the child stays coverage-only until the operator confirms, restoring the pre-#830 posture for unanchored spawns. The handler reads the caller id from the target scope whether or not the gate is on. Probes: TestSpawnWithoutTaskCallerDoesNotAutoApprove proven RED on the reviewed head; caller-boundary teeth shown by removing only the caller EXISTS clause (3 boundary assertions fail, guard case unaffected); drift case 4 now flows consent through an operator caller and a no-caller child task denies on proxy, WebFetch and browser. Verified in-container on real Postgres: ok db, ok intercept; ./server carries only the six known AsRoot container-noise failures. Related: #830, #833.
This commit is contained in:
parent
1dac5c87ee
commit
e2edea0369
5 changed files with 191 additions and 45 deletions
|
|
@ -6,7 +6,7 @@ All notable changes to this project are documented in this file. The format is b
|
|||
|
||||
### Security
|
||||
|
||||
- **Chat-spawned tasks inherit fully operator-approved companies (#830).** Migration `0025_company_scope_approved.sql` made company scope an explicit operator decision, but `spawn_task` still stamped the whole company link `approved_by_operator=false`, so a chat-spawned task started with an empty egress allowlist and every connection was denied until an operator approved scope again per task (the trap #833 warns about). `CreateTaskWithOptions` now checks each LLM-selected company: one whose scope inventory exists and is entirely operator-approved carries standing consent, so its task link is inserted approved and its grant frozen into `task_scope_egress`, exactly as an operator selection does; a company holding any agent-written (unapproved) row, and one with no scope rows, stay coverage-only, so `add_company_scope`, the ScopeSentry sync and invented ids still grant nothing without a fresh operator decision. Provenance is preserved: `source` stays `agent` and the approval column records the inherited consent row by row. Related: #830, #833.
|
||||
- **Chat-spawned tasks inherit fully operator-approved companies (#830).** Migration `0025_company_scope_approved.sql` made company scope an explicit operator decision, but `spawn_task` still stamped the whole company link `approved_by_operator=false`, so a chat-spawned task started with an empty egress allowlist and every connection was denied until an operator approved scope again per task (the trap #833 warns about). `CreateTaskWithOptions` now checks each LLM-selected company: one whose scope inventory exists and is entirely operator-approved and to which the calling task itself holds an operator-approved link carries standing consent, so its task link is inserted approved (a spawn with no task caller - chat session or direct API - inherits nothing, per review on #841) and its grant frozen into `task_scope_egress`, exactly as an operator selection does; a company holding any agent-written (unapproved) row, and one with no scope rows, stay coverage-only, so `add_company_scope`, the ScopeSentry sync and invented ids still grant nothing without a fresh operator decision. Provenance is preserved: `source` stays `agent` and the approval column records the inherited consent row by row. Related: #830, #833.
|
||||
|
||||
- **Company egress is promoted only from operator-approved company scope.** A sandboxed worker could register assets with `insert_assets` (an attacker IP or domain attributed to the company through its domain or ICP rule), and the agent could add rules with `add_company_scope`; the next operator selection or re-approval of the company copied those hosts into `task_scope_egress`, persistently widening the approved sandbox egress. The approval snapshot now copies only `company_scope` domain and IP/CIDR rules with the new `approved_by_operator` flag (migration `0025_company_scope_approved.sql`), which only the operator company API sets; `add_company_scope` and the ScopeSentry sync store rules with the flag off. Existing rules are backfilled as approved. Behaviour change: a domain or IP discovered only in assets is no longer reachable from the sandbox until it is added explicitly to the company scope (operator) or to the task scope. Egress rows already frozen by earlier approvals are not purged by this change, and re-approving the company does not remove them (the snapshot only adds rows); removing the company from the task scope drops its rows, and approving it again rebuilds them from approved rules only.
|
||||
- **Session tokens accept only HS256 and carry an issuer and audience.** Token checks accepted any HMAC algorithm (HS384, HS512) signed with the session key; they now accept only HS256. New tokens have `iss: artex` and `aud: artex-api`, and a token that has either claim with another value is rejected. Tokens issued by earlier releases have neither claim and stay valid until they expire, so upgrading does not sign anyone out.
|
||||
|
|
|
|||
|
|
@ -64,12 +64,15 @@ RETURNING approved_by_operator`, companyID).Scan(&fresh); err != nil {
|
|||
}
|
||||
}
|
||||
|
||||
// TestSpawnInheritsFullyApprovedCompany (#830): a task created by the LLM
|
||||
// (CompanyScopeByAgent=true) stamps the company link operator-approved and
|
||||
// TestSpawnInheritsFullyApprovedCompany (#830, #841): a task created by the
|
||||
// LLM (CompanyScopeByAgent=true) stamps the company link operator-approved and
|
||||
// freezes the egress grant for a company whose entire scope inventory the
|
||||
// operator approved. A company holding any unapproved row, and one with no
|
||||
// scope rows at all, stay coverage-only, so add_company_scope and invented ids
|
||||
// still grant nothing without a fresh operator decision.
|
||||
// operator approved - but only within the caller's trust boundary (review
|
||||
// 6154399166): the caller task must itself hold an operator-approved link to
|
||||
// that company. A company holding any unapproved row, one with no scope rows
|
||||
// at all, and one the caller cannot reach stay coverage-only, so
|
||||
// add_company_scope and invented ids still grant nothing without a fresh
|
||||
// operator decision.
|
||||
func TestSpawnInheritsFullyApprovedCompany(t *testing.T) {
|
||||
dsn := scratchDSN(t, "spawn_inherit_830")
|
||||
d, err := Open(dsn)
|
||||
|
|
@ -97,15 +100,26 @@ func TestSpawnInheritsFullyApprovedCompany(t *testing.T) {
|
|||
exec(`INSERT INTO company_scope(company_id, kind, domain, raw, approved_by_operator) VALUES ($1, 'domain', 'half830.test', 'half830.test', TRUE)`, halfID)
|
||||
exec(`INSERT INTO company_scope(company_id, kind, domain, raw, approved_by_operator) VALUES ($1, 'domain', 'agent830.test', 'agent830.test', FALSE)`, halfID)
|
||||
emptyID := mk("SpawnEmpty Co")
|
||||
|
||||
// A second fully approved company the caller cannot reach: inheritance must
|
||||
// stop at the trust boundary (#841, review 6154399166).
|
||||
otherID := mk("SpawnOther Co")
|
||||
exec(`INSERT INTO company_scope(company_id, kind, domain, raw, approved_by_operator) VALUES ($1, 'domain', 'other841.test', 'other841.test', TRUE)`, otherID)
|
||||
// Operator caller: linked, approved, to the full company only.
|
||||
caller, err := d.CreateTaskWithOptions("caller841", "goal", TaskCreateOptions{
|
||||
CompanyIDs: []int64{fullID},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateTaskWithOptions caller: %v", err)
|
||||
}
|
||||
task, err := d.CreateTaskWithOptions("spawn830", "goal", TaskCreateOptions{
|
||||
CompanyIDs: []int64{fullID, halfID, emptyID},
|
||||
CompanyScopeByAgent: true,
|
||||
CompanyIDs: []int64{fullID, halfID, emptyID, otherID},
|
||||
CompanyScopeByAgent: true,
|
||||
CompanyScopeCallerID: caller.ID,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateTaskWithOptions: %v", err)
|
||||
}
|
||||
want := map[int64]bool{fullID: true, halfID: false, emptyID: false}
|
||||
want := map[int64]bool{fullID: true, halfID: false, emptyID: false, otherID: false}
|
||||
rows, err := d.Query(`SELECT company_id, approved_by_operator, source FROM task_scope WHERE task_id=$1 AND kind='company'`, task.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("read task_scope: %v", err)
|
||||
|
|
@ -150,6 +164,11 @@ func TestSpawnInheritsFullyApprovedCompany(t *testing.T) {
|
|||
if halfGrants, err := d.CompanyEgressForTask(task.ID, halfID); err != nil || len(halfGrants) != 0 {
|
||||
t.Errorf("half company egress %v (%v), want none", halfGrants, err)
|
||||
}
|
||||
// The unreachable-but-fully-approved company crossed no trust boundary: it
|
||||
// froze nothing.
|
||||
if otherGrants, err := d.CompanyEgressForTask(task.ID, otherID); err != nil || len(otherGrants) != 0 {
|
||||
t.Errorf("unreachable company egress %v (%v), want none", otherGrants, err)
|
||||
}
|
||||
if _, err := d.Exec(`DELETE FROM task_scope_egress WHERE task_id=$1 AND company_id IS NULL`, task.ID); err != nil {
|
||||
t.Fatalf("cleanup probe: %v", err)
|
||||
}
|
||||
|
|
@ -161,3 +180,50 @@ func TestSpawnInheritsFullyApprovedCompany(t *testing.T) {
|
|||
t.Errorf("task holds %d egress rows, want only the two inherited ones", stray)
|
||||
}
|
||||
}
|
||||
|
||||
// TestSpawnWithoutTaskCallerDoesNotAutoApprove (review 6154399166): a
|
||||
// CompanyScopeByAgent spawn with no task caller - a chat session or direct API
|
||||
// use - must not silently auto-approve even a fully operator-approved company.
|
||||
// The trust boundary between caller and child has nothing to inherit through,
|
||||
// so the link stays coverage-only until the operator confirms it on the task
|
||||
// scope; the child starts with an empty allowlist, as before #830.
|
||||
func TestSpawnWithoutTaskCallerDoesNotAutoApprove(t *testing.T) {
|
||||
dsn := scratchDSN(t, "spawn_nocaller_841")
|
||||
d, err := Open(dsn)
|
||||
if err != nil {
|
||||
t.Fatalf("initial Open: %v", err)
|
||||
}
|
||||
defer d.Close()
|
||||
var fullID int64
|
||||
if err := d.QueryRow(`INSERT INTO companies(name, nkey) VALUES ('NoCaller Co', 'nocaller co') RETURNING id`).Scan(&fullID); err != nil {
|
||||
t.Fatalf("insert company: %v", err)
|
||||
}
|
||||
if _, err := d.Exec(`INSERT INTO company_scope(company_id, kind, domain, raw, approved_by_operator) VALUES ($1, 'domain', 'nocaller841.test', 'nocaller841.test', TRUE)`, fullID); err != nil {
|
||||
t.Fatalf("seed approved company_scope row: %v", err)
|
||||
}
|
||||
task, err := d.CreateTaskWithOptions("nocaller841", "goal", TaskCreateOptions{
|
||||
CompanyIDs: []int64{fullID},
|
||||
CompanyScopeByAgent: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateTaskWithOptions: %v", err)
|
||||
}
|
||||
var approved bool
|
||||
var source string
|
||||
if err := d.QueryRow(`SELECT approved_by_operator, source FROM task_scope WHERE task_id=$1 AND kind='company' AND company_id=$2`, task.ID, fullID).Scan(&approved, &source); err != nil {
|
||||
t.Fatalf("read task_scope link: %v", err)
|
||||
}
|
||||
if approved {
|
||||
t.Error("spawn with no task caller auto-approved the company link; want coverage-only pending operator confirmation")
|
||||
}
|
||||
if source != "agent" {
|
||||
t.Errorf("source=%q, want agent (provenance must survive either way)", source)
|
||||
}
|
||||
grants, err := d.CompanyEgressForTask(task.ID, fullID)
|
||||
if err != nil {
|
||||
t.Fatalf("CompanyEgressForTask: %v", err)
|
||||
}
|
||||
if len(grants) != 0 {
|
||||
t.Errorf("no-caller spawn inherited grants %v, want none", grants)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
57
db/tasks.go
57
db/tasks.go
|
|
@ -182,9 +182,21 @@ type TaskCreateOptions struct {
|
|||
// OFF for unscoped tasks; pass an explicit false pointer to opt out.
|
||||
TargetGate *bool
|
||||
// CompanyScopeByAgent marks CompanyIDs supplied by an LLM orchestration tool
|
||||
// (spawn_task) rather than an authenticated operator, leaving task_scope
|
||||
// approved_by_operator=false (coverage-only) to prevent scope drift.
|
||||
// (spawn_task) rather than an authenticated operator. The link is inserted
|
||||
// approved_by_operator=false (coverage-only), except for a company whose
|
||||
// whole scope inventory the operator approved AND to which the calling
|
||||
// task itself holds an operator-approved link (CompanyScopeCallerID): that
|
||||
// standing consent is inherited, so chat-spawned tasks stop starting with
|
||||
// an empty allowlist against companies the operator configured (#830)
|
||||
// while the caller boundary keeps the agent from self-widening reach
|
||||
// (#841).
|
||||
CompanyScopeByAgent bool
|
||||
// CompanyScopeCallerID is the id of the task running spawn_task when
|
||||
// CompanyScopeByAgent is set (0 = no task caller: chat session or direct
|
||||
// API use). Standing company consent is inherited only for companies the
|
||||
// caller task itself holds operator-approved links to; with no task caller
|
||||
// nothing is auto-approved (#841, review 6154399166).
|
||||
CompanyScopeCallerID int64
|
||||
}
|
||||
|
||||
// CreateTaskWithOptions creates an exploration, task, direct source relations,
|
||||
|
|
@ -281,7 +293,7 @@ RETURNING id, status, paused, created_at`, opts.Name, opts.CategoryID, descripti
|
|||
if err := insertTaskRelations(tx, t.ID, opts.SourceTaskIDs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := insertTaskCompanies(tx, t.ID, opts.CompanyIDs, !opts.CompanyScopeByAgent); err != nil {
|
||||
if err := insertTaskCompanies(tx, t.ID, opts.CompanyIDs, !opts.CompanyScopeByAgent, opts.CompanyScopeCallerID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := insertTaskLLMProfiles(tx, t.ID, opts.LLMProfileIDs); err != nil {
|
||||
|
|
@ -298,7 +310,7 @@ RETURNING id, status, paused, created_at`, opts.Name, opts.CategoryID, descripti
|
|||
return t, tx.Commit()
|
||||
}
|
||||
|
||||
func insertTaskCompanies(tx *sql.Tx, taskID int64, companyIDs []int64, approvedByOperator bool) error {
|
||||
func insertTaskCompanies(tx *sql.Tx, taskID int64, companyIDs []int64, approvedByOperator bool, callerTaskID int64) error {
|
||||
if len(companyIDs) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -321,10 +333,15 @@ func insertTaskCompanies(tx *sql.Tx, taskID int64, companyIDs []int64, approvedB
|
|||
// no scope rows at all, stays coverage-only: add_company_scope and invented
|
||||
// ids still cannot self-grant. Provenance is kept either way: source stays
|
||||
// agent, the approval column records who consented.
|
||||
// #841 review 6154399166 adds the trust boundary: that consent only flows
|
||||
// to a child through a caller that already reaches the company, so an
|
||||
// agent spawn inherits only within the calling task's operator-approved
|
||||
// companies, and a spawn with no task caller (chat session, direct API)
|
||||
// inherits nothing silently.
|
||||
var inherited []int64
|
||||
if !approvedByOperator {
|
||||
var err error
|
||||
inherited, err = companiesWithFullyApprovedScopeTx(tx, companyIDs)
|
||||
inherited, err = companiesInheritableByCallerTx(tx, companyIDs, callerTaskID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -395,15 +412,20 @@ SET source=EXCLUDED.source,
|
|||
return nil
|
||||
}
|
||||
|
||||
// companiesWithFullyApprovedScopeTx returns the requested companies whose
|
||||
// company_scope inventory exists and is entirely operator-approved (the
|
||||
// company-level consent migration 0025 introduced). Selecting such a company
|
||||
// at spawn introduces no address the operator has not already approved for it;
|
||||
// companies without scope rows (an id the LLM invented, or an empty inventory)
|
||||
// and companies holding any unapproved row are excluded, because promoting
|
||||
// those rows would be the agent granting itself coverage.
|
||||
func companiesWithFullyApprovedScopeTx(tx *sql.Tx, companyIDs []int64) ([]int64, error) {
|
||||
if len(companyIDs) == 0 {
|
||||
// companiesInheritableByCallerTx returns the requested companies whose egress
|
||||
// inheritance is consented twice over: the company's company_scope inventory
|
||||
// exists and is entirely operator-approved (the company-level consent
|
||||
// migration 0025 introduced), AND the calling task holds its own
|
||||
// operator-approved link to that company (#841, review 6154399166). Selecting
|
||||
// such a company at spawn introduces no address the operator has not already
|
||||
// approved for it and no reach the caller did not already have; companies
|
||||
// without scope rows (an id the LLM invented, or an empty inventory),
|
||||
// companies holding any unapproved row, and companies the caller cannot reach
|
||||
// are excluded - promoting those would let the agent widen its own sandbox. A
|
||||
// callerTaskID of 0 (chat session, direct API) inherits nothing: the child
|
||||
// starts coverage-only until the operator confirms the link on the task scope.
|
||||
func companiesInheritableByCallerTx(tx *sql.Tx, companyIDs []int64, callerTaskID int64) ([]int64, error) {
|
||||
if len(companyIDs) == 0 || callerTaskID <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
rows, err := tx.Query(`
|
||||
|
|
@ -413,7 +435,12 @@ WHERE EXISTS (SELECT 1 FROM company_scope cs WHERE cs.company_id = ids.id)
|
|||
AND NOT EXISTS (SELECT 1 FROM company_scope cs
|
||||
WHERE cs.company_id = ids.id
|
||||
AND cs.approved_by_operator IS DISTINCT FROM TRUE)
|
||||
ORDER BY ids.id`, companyIDs)
|
||||
AND EXISTS (SELECT 1 FROM task_scope ts
|
||||
WHERE ts.task_id = $2
|
||||
AND ts.kind = 'company'
|
||||
AND ts.company_id = ids.id
|
||||
AND ts.approved_by_operator IS TRUE)
|
||||
ORDER BY ids.id`, companyIDs, callerTaskID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,18 +341,28 @@ func (s *Server) toolSpawnTask() actool.CoreTool {
|
|||
// the block rules of the calling task. Read from the caller's scope, never
|
||||
// from parent_ref (optional and written by the model). Pins and allow rules
|
||||
// are never copied. Gate-off caller or no scope: created as before.
|
||||
// The caller id is read whether or not the gate is on (#841, review
|
||||
// 6154399166): it is the trust boundary for company-grant inheritance,
|
||||
// and a chat session (ConversationID, no TaskID) leaves it 0 so nothing
|
||||
// is auto-approved for the child.
|
||||
var gate *bool
|
||||
var blockRules []db.TaskInterceptRuleInput
|
||||
if scope, ok := intercept.TargetScopeFromContext(ctx); ok && scope.Enabled != nil && scope.Enabled() {
|
||||
on := true
|
||||
gate = &on
|
||||
if callerID, err := strconv.ParseInt(scope.TaskID, 10, 64); err == nil && callerID > 0 {
|
||||
block, _, err := s.m.Assets().TaskInterceptRulesSplit(callerID)
|
||||
if err != nil {
|
||||
return actool.Errorf("read the block rules of the calling task: " + err.Error()), nil
|
||||
}
|
||||
for _, r := range block {
|
||||
blockRules = append(blockRules, db.TaskInterceptRuleInput{Enabled: r.Enabled, Action: r.Action, Kind: r.Kind, Pattern: r.Pattern, Note: r.Note})
|
||||
var callerID int64
|
||||
if scope, ok := intercept.TargetScopeFromContext(ctx); ok {
|
||||
if id, err := strconv.ParseInt(scope.TaskID, 10, 64); err == nil && id > 0 {
|
||||
callerID = id
|
||||
}
|
||||
if scope.Enabled != nil && scope.Enabled() {
|
||||
on := true
|
||||
gate = &on
|
||||
if callerID > 0 {
|
||||
block, _, err := s.m.Assets().TaskInterceptRulesSplit(callerID)
|
||||
if err != nil {
|
||||
return actool.Errorf("read the block rules of the calling task: " + err.Error()), nil
|
||||
}
|
||||
for _, r := range block {
|
||||
blockRules = append(blockRules, db.TaskInterceptRuleInput{Enabled: r.Enabled, Action: r.Action, Kind: r.Kind, Pattern: r.Pattern, Note: r.Note})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -360,6 +370,7 @@ func (s *Server) toolSpawnTask() actool.CoreTool {
|
|||
SourceTaskIDs: sourceIDs,
|
||||
CompanyIDs: companyIDs,
|
||||
CompanyScopeByAgent: true,
|
||||
CompanyScopeCallerID: callerID,
|
||||
LLMProfileIDs: llmIDs,
|
||||
TimeoutSeconds: a.TimeoutSeconds,
|
||||
PlanHeartbeatSeconds: a.PlanHeartbeatSeconds,
|
||||
|
|
|
|||
|
|
@ -334,13 +334,22 @@ func TestSandboxScopeDriftBlockedAcrossProxyWebFetchAndBrowser(t *testing.T) {
|
|||
|
||||
// Agent-spawned task (spawn_task sets CompanyScopeByAgent=true) inherits a
|
||||
// company whose whole inventory the operator approved (#830, on top of
|
||||
// migration 0025): opComp's domain and canary IP are operator-entered, so
|
||||
// the spawn carries them instead of the empty allowlist that made every
|
||||
// connection from a chat-spawned task 403. Provenance stays agent; the
|
||||
// approval column records that the consent predates the spawn.
|
||||
// migration 0025) through the caller's trust boundary (#841, review
|
||||
// 6154399166): tCaller holds the operator-approved link to opComp, so its
|
||||
// spawn carries opComp's operator-entered domain and canary IP instead of
|
||||
// the empty allowlist that made every connection from a chat-spawned task
|
||||
// 403. Provenance stays agent; the approval column records that the
|
||||
// consent predates the spawn.
|
||||
tCaller, err := pg.CreateTaskWithOptions("caller-"+suffix, "goal", db.TaskCreateOptions{
|
||||
CompanyIDs: []int64{opCompID},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateTaskWithOptions caller: %v", err)
|
||||
}
|
||||
tAgentSpawn, err := pg.CreateTaskWithOptions("agent-spawn-"+suffix, "goal", db.TaskCreateOptions{
|
||||
CompanyIDs: []int64{opCompID},
|
||||
CompanyScopeByAgent: true,
|
||||
CompanyIDs: []int64{opCompID},
|
||||
CompanyScopeByAgent: true,
|
||||
CompanyScopeCallerID: tCaller.ID,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateTaskWithOptions agent-spawn: %v", err)
|
||||
|
|
@ -370,9 +379,18 @@ func TestSandboxScopeDriftBlockedAcrossProxyWebFetchAndBrowser(t *testing.T) {
|
|||
VALUES ($1, 'domain', $2, $2, false)`, halfID, "agent-row-"+suffix+".test"); err != nil {
|
||||
t.Fatalf("seed agent company_scope row: %v", err)
|
||||
}
|
||||
// Keep the trust boundary satisfied here, so this case tests the
|
||||
// half-approved inventory itself and not an unreachable company.
|
||||
tHalfCaller, err := pg.CreateTaskWithOptions("half-caller-"+suffix, "goal", db.TaskCreateOptions{
|
||||
CompanyIDs: []int64{halfID},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateTaskWithOptions half-caller: %v", err)
|
||||
}
|
||||
tHalf, err := pg.CreateTaskWithOptions("half-spawn-"+suffix, "goal", db.TaskCreateOptions{
|
||||
CompanyIDs: []int64{halfID},
|
||||
CompanyScopeByAgent: true,
|
||||
CompanyIDs: []int64{halfID},
|
||||
CompanyScopeByAgent: true,
|
||||
CompanyScopeCallerID: tHalfCaller.ID,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateTaskWithOptions half-spawn: %v", err)
|
||||
|
|
@ -388,9 +406,16 @@ VALUES ($1, 'domain', $2, $2, false)`, halfID, "agent-row-"+suffix+".test"); err
|
|||
if err != nil {
|
||||
t.Fatalf("CreateCompanyWithScope emptyComp: %v", err)
|
||||
}
|
||||
tEmptyCaller, err := pg.CreateTaskWithOptions("empty-caller-"+suffix, "goal", db.TaskCreateOptions{
|
||||
CompanyIDs: []int64{emptyID},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateTaskWithOptions empty-caller: %v", err)
|
||||
}
|
||||
tEmpty, err := pg.CreateTaskWithOptions("empty-spawn-"+suffix, "goal", db.TaskCreateOptions{
|
||||
CompanyIDs: []int64{emptyID},
|
||||
CompanyScopeByAgent: true,
|
||||
CompanyIDs: []int64{emptyID},
|
||||
CompanyScopeByAgent: true,
|
||||
CompanyScopeCallerID: tEmptyCaller.ID,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateTaskWithOptions empty-spawn: %v", err)
|
||||
|
|
@ -399,6 +424,23 @@ VALUES ($1, 'domain', $2, $2, false)`, halfID, "agent-row-"+suffix+".test"); err
|
|||
if len(info7.ScopeDomains) != 0 || len(info7.ScopeCIDRs) != 0 {
|
||||
t.Fatalf("company without scope rows must grant no egress: domains=%v cidrs=%v", info7.ScopeDomains, info7.ScopeCIDRs)
|
||||
}
|
||||
// Same fully approved company as case 4, spawn with no task caller (chat
|
||||
// session or direct API): the trust boundary has nothing to inherit
|
||||
// through, so nothing is auto-approved silently - the child keeps the
|
||||
// empty allowlist until the operator confirms the link (#841, review
|
||||
// 6154399166).
|
||||
tNoCaller, err := pg.CreateTaskWithOptions("nocaller-"+suffix, "goal", db.TaskCreateOptions{
|
||||
CompanyIDs: []int64{opCompID},
|
||||
CompanyScopeByAgent: true,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("CreateTaskWithOptions nocaller-spawn: %v", err)
|
||||
}
|
||||
info8, proxy8, wf8, br8 := buildEnforcers(t, tNoCaller.ID)
|
||||
if len(info8.ScopeDomains) != 0 || len(info8.ScopeCIDRs) != 0 {
|
||||
t.Fatalf("spawn without a task caller must stay coverage-only: domains=%v cidrs=%v", info8.ScopeDomains, info8.ScopeCIDRs)
|
||||
}
|
||||
assertAllDenied(t, "no-caller-spawn", "http://api."+opCompDom+"/v1", proxy8, wf8, br8)
|
||||
}
|
||||
|
||||
func containsStr(list []string, want string) bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue