Skip to content

fix: give workers a per-app key stored as a secret - #641

Closed
KAJdev wants to merge 6 commits into
mainfrom
zeke/con-1833-secp1-high-developer-rw-api-key-injected-into-every-deployed
Closed

KAJdev wants to merge 6 commits into
mainfrom
zeke/con-1833-secp1-high-developer-rw-api-key-injected-into-every-deployed

Conversation

@KAJdev

@KAJdev KAJdev commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Workers authenticate with a key minted for their app environment (or for the app's dev sessions), never with the developer's own key. The key is stored as a RunPod secret named flash-app-key.<app>.<env> (flash-dev-key.<app> for dev) and every endpoint template references it as {{ RUNPOD_SECRET_... }}, so the platform decrypts it at boot and the value never lands in a template, an env payload, or a log. A resource that sets its own RUNPOD_API_KEY in env keeps it.

The key is minted on the first deploy that needs it and reused after that. Its scopes cover what flash runtime does from a worker: calling and listing endpoints, launching and terminating task pods, resolving volumes, and resolving registry credentials and secrets for task pods. Deleting an environment or an app revokes its key and deletes the secret.

Secrets go through the v2 REST routes. API keys stay on GraphQL because REST has no key routes.

@KAJdev KAJdev changed the title fix: give workers a scoped per-app key only when they make remote calls fix: give workers a per-app key stored as a secret Oct 19, 2026
@KAJdev
KAJdev requested a review from deanq October 20, 2026 00:10
@deanq
deanq requested a balanced review from Copilot October 20, 2026 07:13

Copilot AI 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.

馃煛 Changes recommended

Credential-name collisions and incomplete failure recovery can disrupt other deployments or leave active keys behind.

4 open issues
What changed in this PR

Replaces developer credentials in Flash worker templates with per-app keys stored as RunPod secrets.

Changes:

  • Adds credential creation, reuse, and deletion for deployed environments and dev sessions.
  • Injects secret references while preserving explicit resource credentials.
  • Moves secret operations to REST and adds credential tests.
File Description
tests/鈥媡est_apps/鈥媡est_worker_credentials.py Tests credential lifecycle and worker authentication.
tests/鈥媡est_apps/鈥媡est_dev.py Verifies developer keys are not forwarded.
tests/鈥媡est_apps/鈥媡est_api_client.py Tests REST secret operations.
runpod/鈥媋pps/鈥媘anage.py Adds credential cleanup during deletion.
runpod/鈥媋pps/鈥媎ev.py Supplies dev workers with secret references.
runpod/鈥媋pps/鈥媎eploy.py Supplies deployed workers with secret references.
runpod/鈥媋pps/鈥媋pp_key.py Implements credential naming and lifecycle.
runpod/鈥媋pps/鈥媋pi.py Adds key operations and REST secret access.
runpod/鈥媋pi/鈥媞ueries/鈥媋pps.py Adds API-key listing query.
runpod/鈥媋pi/鈥媘utations/鈥媋pps.py Adds key creation and revocation mutations.

Review effort: Balanced

Comment thread runpod/apps/app_key.py Outdated
Comment thread runpod/apps/app_key.py Outdated
Comment thread runpod/apps/manage.py Outdated
Comment thread runpod/apps/manage.py Outdated
Comment thread runpod/apps/app_key.py Outdated
Comment thread runpod/apps/app_key.py Outdated
Comment thread runpod/apps/dev.py
Comment thread runpod/apps/app_key.py
# (serverless:read), launch and terminate task pods (pods), resolve
# task mounts (volumes), and resolve registry credentials and secret
# references for task pods (secrets:read)
APP_KEY_SCOPES = [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Previously workers ran on the deployer's own key. Now createApiKeyNew needs the caller to hold API key create permission, and the backend rejects any requested scope outside the caller's grantable set (scoped calling key or restricted org role) with "Scope(s) not grantable by the caller". A user deploying with a scoped key that lacks, for example, volumes:write or authentication:write would now fail every deploy that previously worked. Is that intended, and should the error tell them to set RUNPOD_API_KEY in the resource env instead?

Separately, have these six scopes been exercised end to end from a worker: deployCpuPod / podFindAndDeployOnDemand for task pods, GET /v2/registries for registry auth, DELETE /v2/pods/{id}, volume create, and endpoint resolution plus invocation through the sentinel? The unit tests mock the API, so a missing scope would only show up as a 401/403 inside a worker.

Comment thread runpod/apps/app_key.py
Comment thread runpod/apps/api.py
Comment thread runpod/apps/api.py Fixed
Comment thread runpod/apps/app_key.py Fixed
Comment thread runpod/apps/app_key.py Fixed
Comment thread runpod/apps/app_key.py Fixed
Comment thread runpod/apps/api.py Fixed
Comment thread runpod/apps/api.py Fixed
Comment thread runpod/apps/app_key.py Outdated
Comment thread runpod/apps/app_key.py
Comment thread runpod/apps/app_key.py Outdated
Comment thread runpod/apps/dev.py
Comment thread runpod/apps/app_key.py
Comment thread runpod/apps/app_key.py
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.

4 participants