Skip to content

fix(server): restrict browser route URLs to HTTP(S) protocols - #229

Open
aymanmali wants to merge 1 commit into
CopilotKit:mainfrom
aymanmali:fix/browser-url-protocol-validation
Open

aymanmali wants to merge 1 commit into
CopilotKit:mainfrom
aymanmali:fix/browser-url-protocol-validation

Conversation

@aymanmali

Copy link
Copy Markdown

Summary

POST /api/browsers, POST /api/browsers/:id/navigate, and POST /api/browsers/:id/reopen validated url with z.url().max(4096), which accepts non-web schemes such as javascript:, file:, and data:. As a result, browser.create() persisted non-HTTP(S) URLs into the browsers table before forwarding them to the worker.

Changes

  • Updated the url schema on POST /api/browsers, POST /api/browsers/:id/navigate, and POST /api/browsers/:id/reopen in apps/server/src/app.ts to z.url({ protocol: /^https?$/ }).max(4096) (matching apps/server/src/search.ts and apps/mobile/src/search-tool-card.tsx).
  • Added regression test tests/browser-url-validation.test.ts verifying non-HTTP(S) URLs are rejected with 422 without persisting browser records or contacting the worker.

Verification

  • pnpm format
  • pnpm lint
  • pnpm typecheck
  • pnpm test (524/524 passed)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant