Repository navigation
fix(apps): give the account api key only to workers that call resources - #628
Closed
justinwlin wants to merge 4 commits into
Closed
justinwlin wants to merge 4 commits into
justinwlin wants to merge 4 commits into
Conversation
This was referenced Oct 19, 2026
Deploy and dev copied the client's account API key into every endpoint's template env, so any endpoint's workers (and anyone who can read its template) held full account credentials, including endpoints that never call another resource. runpod-flash injected the key only for endpoints whose functions make remote calls. Analyze each resource's module source: the resource body (not its decorators) and the module-level helpers it reaches. The key is added when that code references another resource, calls .remote or .spawn, uses anything imported from runpod, or uses a project-local import the analysis cannot follow. Unreadable source and nested definitions also get the key, so a worker that needs it never goes without.
…andles the analysis missed four ways a worker reaches another resource: an import inside the resource body, a package import resolved from inside the package, a queue init hook, and a handle from another app in the module. each now gives the key.
justinwlin
force-pushed
the
fix/scope-worker-api-key
branch
from
October 20, 2026 15:48
8953786 to
3e3a16c
Compare
justinwlin
marked this pull request as ready for review
October 20, 2026 15:48
Contributor
|
this is a duplicate of #641 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Flash → SDK 2.0 fix stack
PRs 1–9 are independent PRs off
main, and 10 is stacked on 9. Merge in this order. Hover a link for its status.mainpeft/accelerategets bundledrp flash devleaks endpoints when stopped by a signalvol.pathsays "not mounted" on deployed workersrunpod2.0.0rc2 with 1–6rp flash deployandrp flash devcopy the account API key into every endpoint's template env. Workers that never call another resource still hold full account credentials, and so does anyone who can read the template. runpod-flash injected the key only for endpoints that make remote calls.Change
New
runpod/apps/remote_calls.py. For each resource it parses the module source, walks the resource body (skipping decorators, so@runpod.postdoesn't count) and the module-level helpers it reaches. It gives the key when that code:.remote/.spawnrunpod(for examplerunpod.Queue(...))@handle.inithookUnreadable source and nested definitions also get the key. Every uncertain case gives the key, so a worker that needs it never goes without. Deploy and dev payloads both use the analysis. Redeploying rewrites the template env, which drops a key left by an earlier deploy.
Testing
mainleafhas_key: Falsecallerleaf.remote()has_key: True; nested call returnsvia_helperfrom helpers import call_leafinside the body; the helper usesrunpod.Queue(...)has_key: True; nested call returns{'has_key': False, 'x': 10}warm@warm.inithook callsleaf.remote()has_key: True; the init call returned{'has_key': False, 'x': 2}How we tested and compared
bool(os.environ.get("RUNPOD_API_KEY"))and the nested result.mainwith the other fixes: the results in the table.leafhad no key (correct),via_helperfailed withno api key configured. run rp login or set RUNPOD_API_KEY., andwarmnever served a job (IN_QUEUEfor 240 s, one workerUNHEALTHY). These are the cases the review found.leaf/callerdeploy:{'has_key': True, 'nested': {'has_key': False, 'x': 42}}.runpod.Queueclient, an API class with only decorators, a local import, a nested definition, an import inside the body (plus stdlib and client-absent packages, which don't count), a package import from inside the package, a queue init hook, and another app's handle. Deploy and dev payload env are also checked.pytest tests: 1488 passed, coverage 91.54%.Review (Codex, two rounds)
runpodor project modules give the key.from mypkg.helpers import ...insidemypkg/resolved against the wrong directory@handle.inithooks weren't analyzed