Repository navigation
fix(apps): give the account api key only to workers that call resources - #628
Draft
justinwlin wants to merge 1 commit into
Draft
justinwlin wants to merge 1 commit into
justinwlin wants to merge 1 commit into
Conversation
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.
This branch has not been deployed
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.
rp 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(...))Unreadable 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.
Verification
leafqueue plus acallerqueue that runsleaf.remote(). The templates showedcallerwithRUNPOD_API_KEYandleafwithout it. Callingcallerreturned{'has_key': True, 'nested': {'has_key': False, 'x': 42}}, so the nested call still works. The app was deleted afterward.runpod.Queueclient, an API class with only decorators, a local import, and a nested definition. They also check the deploy and dev payload env.pytest tests: 1484 passed, coverage 91.61%.