-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(security): stop passing NVIDIA_API_KEY into sandbox and command lines #675
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+92
−11
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -224,4 +224,72 @@ describe("regression guards", () => { | |
| expect(src.includes("validateName(SANDBOX")).toBeTruthy(); | ||
| expect(src.includes("execSync")).toBeFalsy(); | ||
| }); | ||
|
|
||
| describe("credential exposure guards (#429)", () => { | ||
| it("onboard createSandbox does not pass NVIDIA_API_KEY to sandbox env", () => { | ||
| const fs = require("fs"); | ||
| const src = fs.readFileSync(path.join(__dirname, "..", "bin", "lib", "onboard.js"), "utf-8"); | ||
| // Find the envArgs block in createSandbox — it should not contain NVIDIA_API_KEY | ||
| const envArgsMatch = src.match(/const envArgs = \[[\s\S]*?\];/); | ||
| expect(envArgsMatch).toBeTruthy(); | ||
| expect(envArgsMatch[0].includes("NVIDIA_API_KEY")).toBe(false); | ||
| }); | ||
|
|
||
| it("onboard clears NVIDIA_API_KEY from process.env after setupInference", () => { | ||
| const fs = require("fs"); | ||
| const src = fs.readFileSync(path.join(__dirname, "..", "bin", "lib", "onboard.js"), "utf-8"); | ||
| expect(src.includes("delete process.env.NVIDIA_API_KEY")).toBeTruthy(); | ||
| }); | ||
|
|
||
| it("setup.sh uses env-name-only form for nvidia-nim credential", () => { | ||
| const fs = require("fs"); | ||
| const src = fs.readFileSync(path.join(__dirname, "..", "scripts", "setup.sh"), "utf-8"); | ||
| // Should use "NVIDIA_API_KEY" (name only), not "NVIDIA_API_KEY=$NVIDIA_API_KEY" (value) | ||
| const lines = src.split("\n"); | ||
| for (const line of lines) { | ||
| if (line.includes("upsert_provider") || line.includes("--credential")) continue; | ||
| if (line.trim().startsWith("#")) continue; | ||
| // Check credential argument lines passed to upsert_provider | ||
| if (line.includes('"NVIDIA_API_KEY=')) { | ||
| // Allow "NVIDIA_API_KEY" alone but not "NVIDIA_API_KEY=$..." | ||
| expect(line.includes("NVIDIA_API_KEY=$")).toBe(false); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| it("setup.sh does not pass NVIDIA_API_KEY in sandbox create env args", () => { | ||
| const fs = require("fs"); | ||
| const src = fs.readFileSync(path.join(__dirname, "..", "scripts", "setup.sh"), "utf-8"); | ||
| // Find sandbox create command — should not have env NVIDIA_API_KEY | ||
| const createLines = src.split("\n").filter((l) => l.includes("sandbox create")); | ||
| for (const line of createLines) { | ||
| expect(line.includes("NVIDIA_API_KEY")).toBe(false); | ||
| } | ||
| }); | ||
|
|
||
| it("setupSpark does not pass NVIDIA_API_KEY to sudo", () => { | ||
| const fs = require("fs"); | ||
| const src = fs.readFileSync(path.join(__dirname, "..", "bin", "nemoclaw.js"), "utf-8"); | ||
| // Find the run() call inside setupSpark — it should not contain the key | ||
| const sparkLines = src.split("\n").filter( | ||
| (l) => l.includes("setup-spark") && l.includes("run(") | ||
| ); | ||
| for (const line of sparkLines) { | ||
| expect(line.includes("NVIDIA_API_KEY")).toBe(false); | ||
| } | ||
| }); | ||
|
|
||
| it("walkthrough.sh does not embed NVIDIA_API_KEY in tmux or sandbox commands", () => { | ||
| const fs = require("fs"); | ||
| const src = fs.readFileSync(path.join(__dirname, "..", "scripts", "walkthrough.sh"), "utf-8"); | ||
| // Check only executable lines (tmux spawn, openshell connect) — not comments/docs | ||
| const cmdLines = src.split("\n").filter( | ||
| (l) => !l.trim().startsWith("#") && !l.trim().startsWith("echo") && | ||
| (l.includes("tmux") || l.includes("openshell sandbox connect")) | ||
| ); | ||
| for (const line of cmdLines) { | ||
| expect(line.includes("NVIDIA_API_KEY")).toBe(false); | ||
| } | ||
| }); | ||
|
Comment on lines
+282
to
+293
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Credential regression guard is too narrow for walkthrough script. This check only inspects tmux/connect command lines, so a direct env dependency/exposure path can slip through undetected. 🧪 Proposed test hardening it("walkthrough.sh does not embed NVIDIA_API_KEY in tmux or sandbox commands", () => {
const fs = require("fs");
const src = fs.readFileSync(path.join(__dirname, "..", "scripts", "walkthrough.sh"), "utf-8");
+ // Guard against runtime env preconditions that force secret presence.
+ expect(src.includes('[ -n "${NVIDIA_API_KEY:-}" ]')).toBe(false);
// Check only executable lines (tmux spawn, openshell connect) — not comments/docs
const cmdLines = src.split("\n").filter(
(l) => !l.trim().startsWith("#") && !l.trim().startsWith("echo") &&
(l.includes("tmux") || l.includes("openshell sandbox connect"))
);
for (const line of cmdLines) {
expect(line.includes("NVIDIA_API_KEY")).toBe(false);
}
});🤖 Prompt for AI Agents |
||
| }); | ||
| }); | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: NVIDIA/NemoClaw
Length of output: 101
🏁 Script executed:
Repository: NVIDIA/NemoClaw
Length of output: 3759
Unset or scrub
NVIDIA_API_KEYbefore sandbox creation to prevent child-process environment inheritance.Although the command no longer explicitly passes
-- env, the variable remains in the shell's exported environment and will be inherited by the sandbox process. Add eitherunset NVIDIA_API_KEYbefore the sandbox creation call, or useenv -u NVIDIA_API_KEYas a prefix to the command.Suggested patch
🤖 Prompt for AI Agents