Potential fix for code scanning alert no. 33: Client-side cross-site scripting#39
Merged
Potential fix for code scanning alert no. 33: Client-side cross-site scripting#39
Conversation
…scripting Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: AU_gdev_19 <64915515+Dargon789@users.noreply.github.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR fixes a client-side XSS vulnerability in handleDemoRedirect by ensuring the redirection URL uses only a whitelisted path entry instead of the untrusted params.next value. Sequence diagram for secure redirect in handleDemoRedirectsequenceDiagram
participant User
participant "handleDemoRedirect()"
participant "window.location.replace()"
User->>"handleDemoRedirect()": Triggers redirect with params.next
"handleDemoRedirect()"->>"handleDemoRedirect()": Validate params.next against whitelist (path[])
alt params.next is in whitelist
"handleDemoRedirect()"->>"window.location.replace()": Redirect to whitelisted path[index]?next=nextPath
else params.next is not in whitelist
"handleDemoRedirect()"->>User: No redirect (or error)
end
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Potential fix for https://github.com/Dargon789/mempool/security/code-scanning/33
To fix the problem, ensure only permitted paths are ever used in
window.location.replace. Rather than interpolating the user-providedparams.nextin the resulting URL, use the whitelisted version from thepatharray after validation. Refuse to use any value not in the allowed list. Specifically, inhandleDemoRedirect, change the redirect line to use the validated value (params.nextmust be inpath, so use the whitelisted entry directly for redirection) and never trust user input for the base URL. This prevents injection of a malicious value.Edit file
frontend/src/app/shared/common.utils.ts:window.location.replace(`${params.next}?next=${nextPath}`)to use the whitelisted value (window.location.replace(${path[index]}?next=${nextPath}))Suggested fixes powered by Copilot Autofix. Review carefully before merging.
Summary by Sourcery
Bug Fixes: