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

Address history back button security issue (full page loads) #1784

Open
wants to merge 1 commit into
base: v1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions packages/core/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,21 @@ export class Router {
}

protected handleBackForwardVisit(page: Page): void {
window.history.state.version = page.version
this.setPage(window.history.state, { preserveScroll: true, preserveState: true }).then(() => {
let currentState

/* This ensures we give precedence to a fresh state.
'page' here holds the props from the latest backend request.
This prevents user A logging out and user B seeing sensitive data
from user A by going back in the history (shared computer)
*/
if (page.props) {
currentState = page
} else {
window.history.state.version = page.version
currentState = window.history.state
}

this.setPage(currentState, { preserveScroll: true, preserveState: true }).then(() => {
this.restoreScrollPositions()
fireNavigateEvent(page)
})
Expand Down