Skip to content

fix(runs): scope project-less run controls to the responsible user - #1120

Open
vastStage wants to merge 1 commit into
Tencent:mainfrom
vastStage:fix/run-projectless-authz
Open

vastStage wants to merge 1 commit into
Tencent:mainfrom
vastStage:fix/run-projectless-authz

Conversation

@vastStage

Copy link
Copy Markdown

What changed

A shared workflow can be started with an empty projectId. In that case runWriteGuard authorized run lifecycle writes through requireProjectWriter(c, ""), and an empty project is treated as writable by every authenticated user. As a result, any signed-in account could approve/reject/retry/pause/resume/pass/cancel a project-less run and inject HumanDecision.Context into another user's agent invocation; the run could also be deleted.

This change scopes project-less runs to their responsible user:

  • If the run has a project (or a linked issue project), the existing project-writer check is unchanged.
  • If it has no project, only run.ExecutionContext.ResponsibleUserID (or a platform admin) may write/control it.
  • Unknown ownership fails closed instead of falling back to the empty-project rule.
  • Personal workspaces keep their existing owner check.

Scope

  • Platform core / API / runner
  • Public adapter / deployment
  • Classic
  • Portable
  • Shared behavior contract
  • Installer / CLI
  • Documentation only

Compatibility

No API or schema change. Project-backed runs and platform admins keep their current authorization. Owners of existing project-less runs with ResponsibleUserID set keep access; runs with no recorded owner now require an admin, which is the intended fail-closed behavior.

Validation

Commands actually run:

GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build ./...        # pass
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go test -c ./internal/httpapi
# targeted tests run in WSL Ubuntu 24.04:
TestRunWriteGuardRequiresResponsibleUserWithoutProject       # pass
TestRunWriteGuardRejectsProjectlessRunWithoutOwner           # pass

New tests cover the responsible user (200), an unrelated account (403) and an ownerless run (403).

Not run: the full go test -p=2 ./... suite and browser acceptance in this environment.

Safety

  • I did not include credentials, internal endpoints, production data, or organization-specific infrastructure.
  • I preserved user files and unrelated changes.
  • I updated generated Classic host bundles when applicable. (Not applicable.)
  • I documented third-party content and licensing changes when applicable. (Not applicable.)

Shared workflows can start without a project. requireProjectWriter treats an empty project as writable by every authenticated user, so runWriteGuard let any signed-in account approve, reject, cancel, pause, retry, pass or delete another user's project-less run and inject HumanDecision context into it.

For a run without a project (and without a linked issue project), authorize lifecycle writes against ExecutionContext.ResponsibleUserID. Unknown ownership fails closed; platform admins and project-backed runs keep their existing checks.

Adds tests for the responsible user, an unrelated account and an ownerless run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant