-
Notifications
You must be signed in to change notification settings - Fork 0
fix(security): isolate NIM proposer from shell execution #366
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
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8a5c70a
test(security): require shell-free NIM proposer
seonghobae d79cb4e
fix(security): deny shell to credential-bearing NIM proposer
seonghobae 8efa209
Merge protected main into NIM proposer shell-isolation lane
seonghobae 8550b87
test(security): align workflow shell-isolation contract
seonghobae 07febd1
test(security): forbid proposer-side proposal execution
seonghobae 866f8f3
fix(security): execute proposals only in uncredentialed verifier
seonghobae 9553239
style(test): terminate proposer isolation contract cleanly
seonghobae f84cfeb
Merge protected main into NIM proposer isolation
seonghobae 23f97bc
test(security): require exact uncredentialed verifier command
seonghobae 3d75c69
fix(security): require exact verifier command without proposer execution
seonghobae 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
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
84 changes: 84 additions & 0 deletions
84
test/hourly-product-development-nim-shell-isolation.test.ts
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 |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import { readFileSync } from "node:fs"; | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| const workflow = readFileSync( | ||
| ".github/workflows/hourly-product-development.yml", | ||
| "utf8", | ||
| ); | ||
|
|
||
| function sliceBetween(startMarker: string, endMarker: string): string { | ||
| const start = workflow.indexOf(startMarker); | ||
| const end = workflow.indexOf(endMarker, start + startMarker.length); | ||
| expect(start).toBeGreaterThan(-1); | ||
| expect(end).toBeGreaterThan(start); | ||
| return workflow.slice(start, end); | ||
| } | ||
|
|
||
| describe("NVIDIA NIM proposer shell isolation", () => { | ||
| it("denies shell execution in the credential-bearing OpenCode policy", () => { | ||
| const config = sliceBetween( | ||
| " - name: Configure OpenCode for NVIDIA NIM only", | ||
| " - name: Run bounded NVIDIA NIM model fallback", | ||
| ); | ||
|
|
||
| expect(config).toContain('"bash": "deny"'); | ||
| expect(config).not.toContain('"bash": {'); | ||
| expect(config).not.toContain('"*": "allow",\n "curl *"'); | ||
| }); | ||
|
|
||
| it("requires exact verifier instructions without granting proposer execution authority", () => { | ||
| const prompt = sliceBetween( | ||
| " - name: Prepare bounded commercial-quality task", | ||
| " - name: Record dry-run task contract", | ||
| ); | ||
|
|
||
| expect(prompt).toContain( | ||
| "The credential-bearing proposer has no shell execution authority.", | ||
| ); | ||
| expect(prompt).toContain( | ||
| "A separate uncredentialed verifier will execute the proposal on a fresh runner.", | ||
| ); | ||
| expect(prompt).toContain( | ||
| "The separate uncredentialed verifier must execute `npm run release:verify`", | ||
| ); | ||
| expect(prompt).toContain( | ||
| "Do not execute that command or claim its result in the credential-bearing proposer.", | ||
| ); | ||
| expect(prompt).not.toContain("run it, and record the expected failure"); | ||
| expect(prompt).not.toContain("Run focused tests and npm run release:verify"); | ||
| expect(prompt).not.toContain("complete verification commands and\n results"); | ||
| }); | ||
|
|
||
| it("never executes proposed repository code on the credential-bearing proposer runner", () => { | ||
| const proposer = sliceBetween( | ||
| " propose_product_increment:", | ||
| " package_product_increment:", | ||
| ); | ||
| const releaseVerifyCommands = workflow.match( | ||
| /^\s+npm run release:verify\s*$/gm, | ||
| ) ?? []; | ||
|
|
||
| expect(proposer).toContain( | ||
| " - name: Bound and export proposal without executing it", | ||
| ); | ||
| expect(proposer).not.toContain( | ||
| " - name: Verify, bound, and export the uncredentialed proposal", | ||
| ); | ||
| expect(proposer).not.toMatch(/^\s+npm run /m); | ||
| expect(releaseVerifyCommands).toHaveLength(1); | ||
| }); | ||
|
|
||
| it("retains executable verification in the fresh uncredentialed job", () => { | ||
| const verifier = sliceBetween( | ||
| " package_product_increment:", | ||
| " publish_product_increment:", | ||
| ); | ||
|
|
||
| expect(verifier).toContain( | ||
| "Re-run complete release verification on the fresh runner", | ||
| ); | ||
| expect(verifier).toContain("npm run release:verify"); | ||
| expect(verifier).not.toContain("NVIDIA_API_KEY"); | ||
| expect(verifier).not.toContain("NOEMA_MAINTAINER_APP_PRIVATE_KEY"); | ||
| }); | ||
| }); | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.