Skip to content

fix(execution): resolve secrets against the acting principal, not the workflow owner - #6690

Merged
icecrasher321 merged 3 commits into
stagingfrom
fix/execution-secret-actor-identity
Aug 14, 2026
Merged

fix(execution): resolve secrets against the acting principal, not the workflow owner#6690
icecrasher321 merged 3 commits into
stagingfrom
fix/execution-secret-actor-identity

Conversation

@icecrasher321

@icecrasher321 icecrasher321 commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Workspace env vars now authorize against the execution actor rather than the workflow owner, so a run resolves only the secrets its caller is actually a credential member of
  • Personal env vars resolve as the caller whenever one is identifiable (session, personal API key, delegated, copilot)
  • Anonymous public-API runs resolve both slices as the workspace billing account. Nobody in the workspace triggered those and the endpoint is callable by anyone, so lending one human's personal namespace to it was never opted into
  • The workflow-owner fallback for personal vars now applies only to workspace API keys, schedules, and webhooks — each configured by someone in the workspace, and routinely authored against the owner's personal keys
  • Adds getExecutionEnvironment, which resolves the two slices from their own identities and collapses to the single existing query when they match. If the billing account can no longer reach the workspace (billedAccountUserId is a stored column, so an org ownership transfer can strand it), it falls back to the owner and logs rather than failing every background run
  • Threads enforceCredentialAccess and isPublicApiAccess through the streaming execution path and executeWorkflowService, which build their own metadata and would otherwise disagree with the JSON path and with v2
  • Marks workflow.userId deprecated as an execution identity in the schema, documenting the one fallback that remains. It stays the ownership column everywhere else

Intentional behavior changes: runs with an identifiable caller no longer resolve workspace secrets the caller lacks credential membership for, nor personal secrets that exist only in the owner's namespace; anonymous public-API runs no longer resolve the owner's personal vars.

Type of Change

  • Bug fix

Testing

Tested manually. type-check clean; 4,500 tests across lib/workflows, lib/environment, lib/execution, lib/copilot, app/api/workflows, and app/api/v2; lint; block-registry check; all 26 audits via check:audits. check:migrations reports no new migrations — the schema change is comment-only.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 14, 2026 1:50am

Request Review

@cursor

cursor Bot commented Aug 14, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Changes who can see which secrets at runtime across API, streaming, async, and public endpoints—incorrect wiring would leak owner personal keys or deny production workspace secrets.

Overview
Fixes secret resolution so runs use the acting principal, not workflow.userId, for authorization and personal-env fallback.

Workspace secrets are loaded with credential membership for the execution actor (ExecutionMetadata.userId), not the workflow owner. Personal secrets come from the identifiable caller when enforceCredentialAccess is set (session, personal API key, copilot); otherwise from the workflow owner (workspace API key, schedule, webhook). Anonymous public-API runs set isPublicApiAccess and resolve no personal secrets—workspace billing principal only.

Adds getExecutionEnvironment(personalUserId, workspaceUserId, workspaceId) to merge two slices (single query when identities match; logs and falls back to the owner if the billing actor cannot access the workspace).

Path consistency: enforceCredentialAccess and isPublicApiAccess are forwarded through async enqueue, the background worker, executeWorkflowService, streaming (executeWorkflow), and pause/resume snapshot serialization. Streaming fixes streamWorkflow.userId to the owner for workflowUserId fallback (was incorrectly the actor).

Docs (credentials.mdx) and schema comments deprecate using workflow.userId as execution identity except the personal-env fallback.

Reviewed by Cursor Bugbot for commit 3c4dd6b. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR separates personal-secret ownership from workspace-secret authorization so execution environments resolve against the appropriate principal across synchronous, streaming, queued, and resumed runs.

  • Adds a two-identity environment resolver with an explicit workspace-access fallback for stranded billing accounts.
  • Propagates caller and public-API identity decisions through execution metadata, queue payloads, and pause snapshots.
  • Updates tests, shared mocks, schema documentation, and user-facing credential documentation to match the new resolution policy.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/environment/utils.ts Introduces split-principal environment resolution and narrows the owner fallback to an explicit workspace-access denial.
apps/sim/lib/workflows/executor/execution-core.ts Selects personal and workspace environment identities from execution metadata and applies the combined environment snapshot.
apps/sim/app/api/workflows/[id]/execute/route.ts Propagates caller-authorization and anonymous-public-API decisions consistently across sync, stream, and async execution.
apps/sim/background/workflow-execution.ts Preserves identity decisions in queued execution payloads so workers resolve secrets consistently with request-bound paths.
apps/sim/executor/execution/snapshot-serializer.ts Persists both identity flags across human-in-the-loop pause and resume.
packages/testing/src/mocks/environment-utils.mock.ts Recomputes conflict and decryption-failure metadata from the retained personal and workspace slices, addressing the previous mock-divergence finding.
packages/db/schema.ts Adds documentation clarifying that workflow ownership is not generally an execution identity; no database shape changes are introduced.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Trigger[Execution trigger] --> Identity{Identifiable caller?}
  Identity -->|Yes| Caller[Caller identity]
  Identity -->|No| Billing[Workspace billing account]
  Caller --> Personal[Resolve personal secrets as caller]
  Caller --> Workspace[Authorize workspace secrets as caller]
  Billing --> Public{Anonymous public API?}
  Public -->|Yes| NoPersonal[No personal-secret slice]
  Public -->|No| Owner[Resolve personal secrets as workflow owner]
  Billing --> WorkspaceBilling[Authorize workspace secrets as billing account]
  WorkspaceBilling --> Access{Workspace access?}
  Access -->|Yes| Merge[Merge personal and workspace slices]
  Access -->|No| OwnerFallback[Resolve both slices as workflow owner]
  Personal --> Merge
  Workspace --> Merge
  NoPersonal --> Merge
  Owner --> Merge
  OwnerFallback --> Merge
Loading

Reviews (2): Last reviewed commit: "fix(execution): propagate run identity a..." | Re-trigger Greptile

Comment thread apps/sim/lib/environment/utils.ts Outdated
Comment thread packages/testing/src/mocks/environment-utils.mock.ts
Comment thread apps/sim/lib/workflows/executor/execute-service.ts
Comment thread apps/sim/lib/workflows/executor/execution-core.ts Outdated
Comment thread apps/sim/lib/workflows/executor/execution-core.ts Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3c4dd6b. Configure here.

@icecrasher321
icecrasher321 merged commit fa394e5 into staging Aug 14, 2026
30 checks passed
@icecrasher321
icecrasher321 deleted the fix/execution-secret-actor-identity branch August 14, 2026 01:50
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