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

Fix CSRF vulnerability in opt-out when setCookieInNewWindow=1 #14400

Merged
merged 2 commits into from May 3, 2019
Merged

Conversation

katebutler
Copy link

Fixes #12540

@katebutler katebutler added the Needs Review PRs that need a code review label May 2, 2019
@katebutler katebutler added this to the 3.10.0 milestone May 2, 2019
@Findus23
Copy link
Member

Findus23 commented May 2, 2019

Just FYI: As this only solves the CSRF-part of #12540 and not the unneeded-cookie-part I have created #14402 as a followup for that issue.

@tsteur
Copy link
Member

tsteur commented May 2, 2019

image

just tested it and actually didn't work for me. Instead seeing above error in chrome.

In https://github.com/matomo-org/matomo/blob/3.10.0-b1/plugins/CoreAdminHome/javascripts/optOut.js#L6-L7 it actually does a GET request to the form action. You would think the form does a regular post but it opens the <form action=""> URL in a new window totally ignoring the hidden nonce input field etc.

That's why previously the nonce was before added in the redirect URL and caused the CSRF problem.

To fix it, we need to add the nonce to the form action url in https://github.com/matomo-org/matomo/blob/3.10.0-b1/plugins/CoreAdminHome/OptOutManager.php#L195-L200 . It should be totally fine to send the nonce through GET parameter.

@tsteur
Copy link
Member

tsteur commented May 2, 2019

Tested using the URL: https://$DOMAIN/index.php?module=CoreAdminHome&action=optOut&idSite=1&period=day&date=yesterday

@tsteur
Copy link
Member

tsteur commented May 3, 2019

Works 👍

@tsteur tsteur merged commit 72df150 into 3.x-dev May 3, 2019
@tsteur tsteur deleted the 12540 branch May 3, 2019 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Opt-out does not unset session ID for CSRF protection
3 participants