You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PR correctly hardens the balance banner redirect by removing the server-action echo of creditsUrl and switching to a locally constructed client-side router.push, fully resolving the open redirect vector (CodeQL alert 268).
Root cause fixed: The original code passed creditsUrl as a parameter to the server action and received it back in the return value — a pattern CodeQL correctly flagged because client code was trusting a server-action return value to construct a redirect target. The fix moves creditsUrl construction entirely to the client side (where it was already derived) and uses router.push(creditsUrl) directly, breaking the trust-chain that caused the alert.
returnUrl (pathname) validation:usePathname() always returns an internal Next.js route path. setPaymentReturnUrl validates it server-side via isValidReturnUrl, which only accepts relative paths starting with / (not //). This chain is safe.
encodeURIComponent(organizationId): Correct defensive improvement; organization IDs in this codebase appear to be UUIDs, so this is harmless and appropriate.
router.push vs window.location.href: The switch from window.location.href to Next.js router.push is correct — it keeps navigation within the SPA, avoids a full page reload, and is the idiomatic approach for client components.
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.
Summary
Verification
Not manually verified; this is a non-visual redirect hardening and no local app session was started.
Visual Changes
N/A
Reviewer Notes
CodeQL alert: https://github.com/Kilo-Org/cloud/security/code-scanning/268