Harden review agent job launch endpoints#533
Open
Aeg1sx wants to merge 1 commit intobacknotprop:mainfrom
Open
Conversation
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.
Summary
/api/diffinto the review UI and add Bun/Pi regression coverageWhy this patch
The vulnerable behavior is not just that review agent jobs can be reached over the network. The core issue is that the review server exposes a process-launching API to a browser client. Tightening bind addresses helps with remote reachability, but it does not stop other local processes or same-host browser contexts from hitting the endpoint.
I did not change this into a provider-wide command allowlist because that would be brittle for this product. The review flow intentionally supports provider-specific wrappers and future command shapes, so hard-coding a narrow set of accepted argv patterns would likely break valid review-agent integrations.
Instead, this patch makes job launch and kill operations session-bound:
/api/diffreturns that token only to the active review UI/api/agents/jobsrequests are rejected unless they include the matching tokenThat keeps the existing provider flexibility, while preventing blind unauthenticated requests from launching or killing jobs.
The loopback-only bind is kept as a second layer of defense. It removes direct LAN exposure by default while still allowing SSH/devcontainer port-forwarded workflows.
Testing
/tmp/bun/bin/bun test packages/server/remote.test.ts packages/server/agent-jobs.test.ts apps/pi-extension/server/network.test.ts apps/pi-extension/server.test.ts