Skip to content

/workloads: authorize caller-named PVCs per subject, and scope workload names #358

Closed

Description

@pdettori

Problem

POST /workloads forwards a caller-supplied workspace.claimName to Context Service (packages/knative-server/src/context-service.ts, createWorkload). Neither the harness nor Context Service checks that the caller may use that PVC. #350 binds a workload to the subject that created it (MI1 R7), but owning the workload says nothing about owning the volume it names. Without a guard, a user could create a workload over another user's claim, run on it, and read that user's workspace.

Workload names are also one namespace across subjects, first come, first served. Existence is probeable: re-creating another subject's live name answers 409, and deleting an unowned one answers 204.

Current state (after #350)

This is a stop-gap, not authorization: claimName is refused (400 claim_name_not_allowed) from any authenticated caller and always under MOCA_TENANCY=multi. Only the anonymous caller of an unauthenticated deployment may still name a claim. So multi-user deployments lose the "bring your own PVC" feature entirely.

What closing it needs

  • Claim authorization: a mapping from subject to the claims it may mount, held by the control plane or Context Service rather than asserted by the caller. The harness checks it before forwarding claimName. Alternatively, Context Service scopes claim names per subject (for example a subject-derived prefix or label) and refuses a claim outside the caller's scope.
  • Subject-scoped workload names, so one user's name neither collides with nor reveals another's (for example keying sh:workload:<subject>:<name>, or subject-prefixed pool names).
  • Once those exist, lift the claim_name_not_allowed stop-gap, with tests that Alice cannot name Bob's claim and can name her own.

Context

docs/context-service.md ("Security boundary") and docs/specs/2026-09-28-moca-multi-user-isolation-design.md §4.3 and §13 ("Per-subject PVC authorization and subject-scoped workload names") record this. It was found in round 2 of #350's review.

Assisted-By: Claude (Anthropic AI) [email protected]

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions