Skip to content

fix: Treat a scheme-less endpoint host as invalid - #1014

Merged
razor-x merged 1 commit into
mainfrom
claude/js-sdk-audit-6x115l-l1d-url-prefix
Aug 24, 2026
Merged

fix: Treat a scheme-less endpoint host as invalid#1014
razor-x merged 1 commit into
mainfrom
claude/js-sdk-audit-6x115l-l1d-url-prefix

Conversation

@razor-x

@razor-x razor-x commented Aug 24, 2026

Copy link
Copy Markdown
Member

Problem

SDK audit finding L1d (low): getUrlPrefix accepted any string the URL constructor could parse. localhost:3000 parses with localhost: as the scheme (and 3000 as the path), so the request url getter built garbage like localhost:3000/devices/get?x=1 instead of failing.

Fix

Only http:/https: URLs are treated as absolute endpoints. Anything else takes the existing fallback path: resolved against the browser origin, or the existing Cannot resolve origin error in a non-browser environment.

Tests

  • endpoint: 'localhost:3000'request.url throws Cannot resolve origin (fails on reverted source, which builds the garbage URL)
  • endpoint: 'http://localhost:3000' → builds the correct URL

Full suite (127 tests), lint, typecheck green.

Part of applying the rev-3 SDK audit (one PR per finding). Related: #1002#1013.

🤖 Generated with Claude Code

https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2


Generated by Claude Code

getUrlPrefix accepted any string the URL constructor could parse, so an
endpoint like localhost:3000 parsed with localhost: as the scheme and
built a garbage request URL. Only http and https URLs are absolute
endpoints now; anything else resolves against the browser origin or
raises the existing cannot-resolve-origin error.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B8xeJm2Hd923k8uo6eoFd2
@razor-x
razor-x requested a review from a team as a code owner August 24, 2026 19:54
@razor-x
razor-x merged commit fd53013 into main Aug 24, 2026
16 checks passed
@razor-x
razor-x deleted the claude/js-sdk-audit-6x115l-l1d-url-prefix branch August 24, 2026 22:06
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