Skip to content

Validate navigate URLs and exec timeouts on the Bot computer - #429

Merged
davidmckayv merged 2 commits into
CopilotKit:mainfrom
Ayush7614:fix/agent-computer-navigate-exec-validation
Sep 8, 2026
Merged

Validate navigate URLs and exec timeouts on the Bot computer#429
davidmckayv merged 2 commits into
CopilotKit:mainfrom
Ayush7614:fix/agent-computer-navigate-exec-validation

Conversation

@Ayush7614

Copy link
Copy Markdown
Contributor

What

Two shape checks on the Bot computer itself (agent-computer), which holds no policy engine — so a malformed call should be a 400 naming the field, not a 502 that reads as a broken computer:

  • POST /navigate accepted any string into page.goto: an empty string came back 502 Navigation failed, and javascript:/file:///data:/ftp: URLs were never refused up front. New parseNavigateUrl trims, requires a parseable URL, and allows only http:/https:.
  • POST /exec forwarded NaN/Infinity into the shell, where Math.max(NaN, 1000) stays NaN and setTimeout(NaN) fires at once — the command reported timed out before doing anything. New parseExecTimeout enforces whole milliseconds in 1000..600000 (matching the server gateway), and shell.run falls back to its default on a non-finite value so a direct caller gets a run rather than a lie.

Why it matters

The computer is the Bot's SSRF surface (/navigate) and its most expensive action (/exec). Both previously failed in ways that pointed at the computer instead of the caller. The shared validation module (agent-computer/src/request-validation.ts) is pure and unit-tested without a browser.

Verification

  • agent-computer/tests/request-validation.test.ts (new): 11 invalid navigate inputs rejected, 10 invalid timeouts rejected, valid inputs pass — 24 pass.
  • agent-computer/tests/shell.test.ts (+2 NaN/Infinity cases): a non-finite timeout now runs the command with the default instead of reporting an instant timeout — 23 pass.
  • bun run --filter server typecheck — clean (agent-computer's pre-existing missing playwright/spiffe deps in this env are untouched). Biome format + lint — clean.

/navigate accepted any string and handed it to page.goto, so an empty
string came back as a 502 Navigation failed that reads as a broken
computer, and a javascript: or file:// URL was never refused up front.
/exec forwarded NaN and Infinity into the shell, where Math.max(NaN)
stayed NaN and setTimeout fired at once: the command was reported as
timed out before it did anything.

Check both shapes before the browser or the shell is reached and answer
400 naming the field, matching the server gateway's validation of the
same timeout. The shell itself falls back to its default on a
non-finite value, so a direct caller gets a run rather than a lie.

@davidmckayv davidmckayv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

navigate-URL + exec-timeout validation. Deep-reviewed clean (no SSRF/over-block). CI failure was pre-existing handoff-integration flakiness (baselined 3/5 on clean main); rerun green.

@davidmckayv
davidmckayv merged commit 436e50f into CopilotKit:main Sep 8, 2026
26 of 28 checks passed
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.

2 participants