24 security pagination follows nextlink urls without origin validation#48
Open
24 security pagination follows nextlink urls without origin validation#48
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Improves the security posture of Invoke-AzPagedRequest by validating nextLink pagination URLs before following them, reducing the risk of forwarding ARM bearer tokens to untrusted endpoints.
Changes:
- Introduces an allowlist of trusted hosts for pagination (
management.azure.com). - Validates that
nextLinkuseshttpsand an allowed host; otherwise stops pagination. - Ensures pagination terminates cleanly by setting
$nextUri = $nullwhennextLinkis absent.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace Write-Error + break with throw when encountering an untrusted nextLink host in Invoke-AzPagedRequest. This ensures the pipeline stops immediately and the error is propagated to callers instead of silently continuing, allowing higher-level code to handle the exception.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Related Issue
Fixes #24
Type of Change
Changes Made
This pull request enhances the security of the
Invoke-AzPagedRequestfunction by validating thenextLinkURLs during pagination. The main improvement is to ensure that only trusted hosts over HTTPS are followed, preventing potential security risks from untrusted pagination links.Security improvements to pagination:
$allowedHostslist (currently allowing only"management.azure.com") to restrict which hosts can be followed in paginated responses.nextLinkURL uses the HTTPS scheme and its host is in the$allowedHostslist; if not, an error is logged and pagination stops.$nextUrito$nullwhen there is nonextLink, ensuring proper termination of pagination.Testing
Checklist
Additional Notes