Skip to content

fix(security): validate redirect_uri in external token grant flow#212

Merged
LucHeart merged 4 commits into
developfrom
fix/token-redirect-uri-validation
Jun 19, 2026
Merged

fix(security): validate redirect_uri in external token grant flow#212
LucHeart merged 4 commits into
developfrom
fix/token-redirect-uri-validation

Conversation

@hhvrc

@hhvrc hhvrc commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

The external-application API-token grant page took redirect_uri verbatim from the query string and navigated window.location to it with the freshly minted token spliced in, allowing an attacker to exfiltrate a live token to an arbitrary origin via a crafted consent link.

Add isValidTokenRedirectUri() which allows custom application schemes and loopback http(s) targets but rejects remote origins and dangerous schemes (javascript:/data:/...). Validate redirect_uri at parse time and encodeURIComponent the token when building the redirect target.

The external-application API-token grant page took redirect_uri verbatim
from the query string and navigated window.location to it with the freshly
minted token spliced in, allowing an attacker to exfiltrate a live token to
an arbitrary origin via a crafted consent link.

Add isValidTokenRedirectUri() which allows custom application schemes and
loopback http(s) targets but rejects remote origins and dangerous schemes
(javascript:/data:/...). Validate redirect_uri at parse time and
encodeURIComponent the token when building the redirect target.
@hhvrc hhvrc requested a review from LucHeart June 18, 2026 10:59
@hhvrc hhvrc self-assigned this Jun 18, 2026
@LucHeart

Copy link
Copy Markdown
Member

why not, whitelist http* only? aren't we already doing that?

@LucHeart

Copy link
Copy Markdown
Member

nvm we need custom protos, but we need to allow any host for http, not just localhost

@LucHeart LucHeart left a comment

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.

allow any host, not just localhost

@hhvrc

hhvrc commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

We do allow any host, but it must be https to not be localhost

@LucHeart LucHeart merged commit 8b23780 into develop Jun 19, 2026
10 checks passed
@LucHeart LucHeart deleted the fix/token-redirect-uri-validation branch June 19, 2026 08:59
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