-
Notifications
You must be signed in to change notification settings - Fork 10
add ssrf protection for saml metadata #256
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
Merged
+30
−8
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / CodeQL
Server-side request forgery Critical
Copilot Autofix
AI 1 day ago
To fix the problem, we should ensure that
fetchAndParseMetadatadoes not send requests to arbitrary user‑controlled endpoints. That typically means enforcing an allow‑list of acceptable destinations and/or rejecting private/loopback addresses after resolving the hostname. Since we must avoid changing existing functionality too much and stay within this snippet, the least invasive and clearest fix is to validate the hostname (and optionally IP) before callingaxios.get.Concretely, we can:
hostname.dnsand asynchronous code changes that might be more intrusive. Given the constraints, we’ll implement domain/suffix allow‑listing only, which is a standard and easily auditable mitigation and addresses the CodeQL concern.Implementation details in this file:
importfor Node’s built‑inurl/netis not strictly necessary since we already use the globalURLclass, and we don’t need external packages. We can implement hostname/domain checks inline.isAllowedMetadataHost(hostname: string): booleanor an inline check that:localhost,127.0.0.1,::1).const parsedUrl = new URL(url);, call this validation and throw if the hostname is not allowed. Keep the rest of the behavior intact.This preserves the function’s general behavior—fetching SAML metadata from a URL—but prevents it from being used to reach arbitrary or internal endpoints.