New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Headers): don't forward secure headers to 3th party #1449
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,3 +56,20 @@ export const isAbortSignal = object => { | |
) | ||
); | ||
}; | ||
|
||
/** | ||
* isDomainOrSubdomain reports whether sub is a subdomain (or exact match) of | ||
* the parent domain. | ||
* | ||
* Both domains must already be in canonical form. | ||
* @param {string|URL} original | ||
* @param {string|URL} destination | ||
*/ | ||
export const isDomainOrSubdomain = (destination, original) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The names of the variables here don't see to match the values passed in?
Surely locationURL is the destination and request.url is the original? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you are right. it works as intended and how it is suppose to protect you, But the variable names are mixed up There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No rush to get fixed, can create a issue about it if needed |
||
const orig = new URL(original).hostname; | ||
const dest = new URL(destination).hostname; | ||
|
||
return orig === dest || ( | ||
orig[orig.length - dest.length - 1] === '.' && orig.endsWith(dest) | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this use the public suffix list instead? https://publicsuffix.org/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that would be necessary.