Skip to content

fix(apps): prevent open redirect via backslash manipulation in Host header#3740

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
josephperrott:fix-open-redirect
Jun 5, 2026
Merged

fix(apps): prevent open redirect via backslash manipulation in Host header#3740
alan-agius4 merged 1 commit into
angular:mainfrom
josephperrott:fix-open-redirect

Conversation

@josephperrott
Copy link
Copy Markdown
Member

This PR fixes an Open Redirect vulnerability in the dns-redirecting Cloud Function. The fix implements strict hostname validation (isValidDomain) to ensure only alphanumeric characters, dots, and hyphens are allowed, securely preventing attackers from bypassing subdomain verification via backslashes.\n\nValidated that tests pass and the bypass via evil.com\\.material.angular.io is appropriately rejected with a 400 Bad Request.

@google-cla

This comment was marked as outdated.

@josephperrott josephperrott requested a review from alan-agius4 June 5, 2026 00:10
@josephperrott josephperrott added the action: merge The PR is ready for merge by the caretaker label Jun 5, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a domain validation helper function isValidDomain to sanitize the hostname in the DNS redirecting function, returning a 400 error for invalid hostnames. Feedback suggests improving this helper by adding runtime type safety checks and escaping the hyphen in the regular expression to prevent potential bypasses and ensure regex maintainability.

Comment thread apps/functions/dns-redirecting/index.ts
@alan-agius4 alan-agius4 merged commit 00ec31b into angular:main Jun 5, 2026
16 checks passed
@alan-agius4
Copy link
Copy Markdown
Contributor

This PR was merged into the repository. The changes were merged into the following branches:

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

Labels

action: merge The PR is ready for merge by the caretaker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants