Skip to content

Allow same-origin redirects - #227

Merged
lsd-cat merged 2 commits into
mainfrom
issue-220
Aug 19, 2026
Merged

Allow same-origin redirects#227
lsd-cat merged 2 commits into
mainfrom
issue-220

Conversation

@jupenur

@jupenur jupenur commented Aug 19, 2026

Copy link
Copy Markdown
Member

Fixes #220.

It's worth noting that the URL constructor used in this PR and Firefox's internal URL parsing for Location headers don't behave exactly the same way: specifically, the URL constructor strips ASCII whitespace throughout the URL, while Firefox's internal handling only trims whitespace from the start of the URL. That means a URL like https\t://example.com/ appears absolute to the URL constructor but actually triggers a relative redirect. This PR doesn't address that issue, because the failure mode is safe.

@jupenur
jupenur requested review from a team and lsd-cat August 19, 2026 12:17
Comment thread extension/src/webcat/response.ts Outdated
);
export function isSameOriginURL(target: string, base: string) {
const baseURL = new URL(base);
const targetURL = new URL(target, baseURL);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

new URL can throw on malformed URLs, and I don't think we catch that anywhere. Without #178 I think that could result in a WEBCAT bypass?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good catch, thanks! Fixed in 73f7d5c.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great! I wonder if an alternative to #178 could be instead to lint for uncaught throws or errors in CI instead, I'm gonna investigate a bit! Thanks for the patch here :)

@jupenur
jupenur requested a review from lsd-cat August 19, 2026 14:56
@lsd-cat
lsd-cat merged commit 22ed6f9 into main Aug 19, 2026
8 checks passed
@lsd-cat
lsd-cat deleted the issue-220 branch August 19, 2026 15: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.

Allow frame redirections to same-origin absolute URLs

2 participants