Skip to content
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

JS: Add New XSS sink - Next.js router.push/replace #12787

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tyage
Copy link
Contributor

@tyage tyage commented Apr 8, 2023

Made Next.js router's push/replace methods as XSS sink.
They should be XSS sink because XSS occurs when their argument is javascript:alert(1).

https://nextjs.org/docs/api-reference/next/router#routerpush
https://nextjs.org/docs/api-reference/next/router#routerreplace

BTW, those methods are considered as XSS sink in the test code of ClientSideUrlRedirect but they are not actually treated as XSS sink.

export function nextRouter() {
const router = useRouter();
return <span onClick={() => router.push(document.location.hash.substr(1))}>Click to XSS 1</span>
}
import { withRouter } from 'next/router'
function Page({ router }) {
return <span onClick={() => router.push(document.location.hash.substr(1))}>Click to XSS 2</span>
}

@tyage tyage requested a review from a team as a code owner April 8, 2023 09:33
@github-actions github-actions bot added the JS label Apr 8, 2023
@tyage tyage changed the title Add New XSS sink: Next.js router.push/replace JS: Add New XSS sink - Next.js router.push/replace Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant