Repository navigation
Description
Summary
Service.CreateTeam accepts a client-supplied filesystem workspace and builds an osfs workspace + root-bound command runner on it without consulting workspace authority. On a server-assigned deployment (the deployment ADR 0237 exists to protect), an authenticated caller can root an agent team at any absolute path — the identical hole ADR 0237 closed on CreateSession, surviving on a verb the ADR's route list never enumerated.
Found during panel review of the listener-scoped-workspace-authority branch. This is pre-existing and out of scope for that branch's own fix, hence a separate issue.
Affected code
internal/adapter/server/team.go:120—CreateTeamguards onlyworkspace == "", thens.cfg.Workspaces(workspace)ands.cfg.CommandRunnerFactory(workspace).grep WorkspaceAuthority internal/adapter/server/team.go→ 0 matches.- Wire entries pass the request workspace straight through:
internal/adapter/server/grpc_team.go:23,internal/adapter/server/http.go:1044(POST /v1/teams). - Every forked member derives from this base
Environment.
Preconditions
- Server-assigned deployment (any non-loopback API listener). Loopback-only/embedded is client-selected and unaffected.
- Teams enabled —
mecateddefaults--enable-teams=true(cmd/mecated/main.go:1573).mecak8sdefaults it off and is no-FS, so mecak8s is not exposed. - Authenticated caller. This is authenticated-principal privilege escalation: per ADR 0237, authentication does not authorize selecting a host/container path.
Buildwires the realosfsWorkspaceFactory(internal/app/build.go:1722), which opens any non-empty absolute root.
Impact (CWE-284 / OWASP A01:2021)
- Read surface: a member rooted at
/runs Read/Grep/Glob over the daemon's filesystem — mounted secret volumes, cloud-credential files, TLS keys, and (in k8s) the pod service-account token → lateral movement per that SA's RBAC. - Shell escalation: a
mutating:truemember gets Edit/Write/Bash viaCommandRunnerFactory(workspace)— a shell bound to the attacker-chosen root — so on atrusted/autoposture deployment, command execution in a directory the operator never vouched for. - Blast radius is bounded by the daemon process's own uid/mounts; env-var provider secrets are scrubbed by
envscrub, but on-disk secret files are not.CreateTeamstamps the caller as owner, so the action is attributable in the session store.
Minimal repro
Against a server-assigned mecated with teams on, an authenticated caller:
POST /v1/teamswithworkspace:"/"and one lead member whoseinitial_promptreads a secret path.POST /v1/teams/{id}/run.
The member executes file reads against /. Adding mutating:true to the member grants a shell bound to /.
Fix
Route CreateTeam through the same single predicate as every other creation path — root-cause fix, not a per-callsite patch. As the first statement after the MemberEngine nil check, replacing the bare workspace == "" guard:
workspace, _, err := s.workspaceForCreate(workspace, ProfileDefault)
if err != nil { return "", nil, err }Under client-selected this yields the same ErrInvalidArgument: workspace is required for an empty value (byte-identical local behaviour); under server-assigned it demands empty and substitutes the deployment root.
Also:
- Drop the emptiness pre-checks in the gRPC (
grpc_team.go:20) and HTTP (http.go) handlers so an empty workspace reaches the service gate on a server-assigned deployment (theCreateSessionprecedent: the wire workspace field stays a request field for compatibility, empty = "assign the operator root"). Existing clients that send a workspace to a server-assigned deployment will start receivingInvalidArgument— the same intentional breakCreateSessiontook. - Add a scenario test mirroring
TestListenerScopedWorkspaceAuthority_Scenario5_AllCreationPathsRespectAuthority:CreateTeam("/client/root")against a server-assigned Service backed by a countingWorkspacesfactory; assertErrInvalidArgumentand zero factory calls (rejection precedes construction). - Add agent-team creation to ADR 0237's enumerated route list ("persisted-session run entry and rehydration, scheduled-fire creation, legacy adoption, composition-created environment overrides, direct API creation").
Notes
SpawnTeammate / spawnTeammate (POST /v1/teams/{id}/members) inherit the team's base environment, so fixing CreateTeam closes the member path too — but worth a glance during the fix to confirm no member route re-derives a workspace independently.
Activity