Potential fix for code scanning alert no. 33: Client-side cross-site scripting#30
Merged
Potential fix for code scanning alert no. 33: Client-side cross-site scripting#30
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 GuideReplaces direct use of unsanitized Sequence diagram for safe redirection in handleDemoRedirectsequenceDiagram
participant User as actor User
participant Route as ActivatedRoute
participant Router as Router
participant Utils as common.utils.ts
User->>Route: Navigates with next param
Route->>Utils: handleDemoRedirect(route, router)
Utils->>Utils: Validate params.next against path array
alt params.next is valid
Utils->>Utils: Compute nextPath
Utils->>Browser: window.location.replace(`${path[index]}?next=${nextPath}`) after 15s
else params.next is invalid
Utils->>Utils: No redirect
end
File-Level Changes
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 cross-site scripting vulnerability, ensure that only safe, expected values for the redirection target are used, and never directly interpolate unsanitized user input (such as
params.next) into URLs or location changes. Since only known path strings are acceptable, we should always use the trusted value from thepatharray rather than the rawparams.next. Specifically, in the linewindow.location.replace(${params.next}?next=${nextPath}), we should replaceparams.nextwith the trustedpath[index]value that was matched from the array (or, to be extra safe, usenextPath). This avoids using raw user input and prevents injection vulnerabilities.Changes should be made in
frontend/src/app/shared/common.utils.ts, by editing the implementation ofhandleDemoRedirectso that only safe, trusted strings from the predefined array are used in the location replacement.No new methods or external dependencies are required.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.
Summary by Sourcery
Bug Fixes: