[go: nahoru, domu]

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

Refreshing results results in token mismatch error #13182

Closed
omega13a opened this issue Apr 12, 2017 · 8 comments
Closed

Refreshing results results in token mismatch error #13182

omega13a opened this issue Apr 12, 2017 · 8 comments
Assignees
Labels
Bug A problem or regression with an existing feature
Milestone

Comments

@omega13a
Copy link

Steps to reproduce

  1. Submit a query
  2. After the results are displayed, hit refresh

Expected behaviour

It to refresh the results

Actual behaviour

I get a message saying "Error: Token Mismatch" every signal time.

Server configuration

Operating system: Fedora 24

Web server: nginx 1.11.13

Database: MariaDB 10.1.22

PHP version: 7.1.3

phpMyAdmin version: 4.7.0

Client configuration

Browser: Firefox 52.0.2

Operating system: Fedora 24

@nijel
Copy link
Contributor
nijel commented Apr 12, 2017

I can't reproduce this. Did you wait some time before doing refresh? Also did you refresh by browser or by the link in phpMyAdmin?

@omega13a
Copy link
Author

It happens to me every single time no matter how long I wait. I used the link in phpMyAdmin to refresh.

@limitusus
Copy link

I faced a similar problem just after upgrading from v4.6.2 to v4.7.0.

I'm not familiar with phpMyAdmin but it seems the token mismatch error happens when I put a POST request after logged in, for exporting query result.

In my case it happens for 781 bytes query, while it does not happen for 576 bytes query.
In the former case a POST form is generated and a GET form is generated in the latter case.

And I confirmed no error happens when I bypassed token checks, by inserting

$token_mismatch = false;

in line 931, libraries/common.inc.php.

@Fenn-CS
Copy link
Contributor
Fenn-CS commented Apr 13, 2017

Unfortunately I am unable to reproduce the error on 4.8.0-dev (latest stable 4.7.0)

@limitusus
Copy link

I checked even a simple query can reproduce this issue:

select 1 FROM plugins
WHERE
1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and
1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and
1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and
1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and
1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and 1=1 and
1=1
LIMIT 1;

does occur "token mismatch" error,
while the query just removing only one 1=1 and does not occur this error.

I explored the source code and Util::linkOrButton judges whether POST or GET to show for "Export" or other links to implement, and the query length above is the threshold in my environment.

BTW I checked the code and thought,

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (PMA_isValid($_POST['token'])) {
        $token_provided = true;
        $token_mismatch = ! hash_equals($_SESSION[' PMA_token '], $_POST['token']);
    }

    if ($token_mismatch) {
        /**
         * We don't allow any POST operation parameters if the token is mismatched
         * or is not provided
         */
        $whitelist = array('ajax_request');
        PMA\libraries\Sanitize::removeRequestVars($whitelist);
    }
}

requires token key in form parameter every POST request, right?
I see no key token in "Export" link form.

Of course token key exists when a POST request is sent for SQL execution.

Util::linkOrButton might not be inserting token key for POST form creation?

@kzalewski
Copy link

The "token mismatch" error is occurring for me even when I press the "Refresh" button in the Status tab. I can no longer refresh the process list. This happened after upgrading to 4.7.0.

devenbansod added a commit that referenced this issue Apr 18, 2017
Issue #13182
Specifically the error mentioned in the comment: #13182 (comment)

Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
@JannemanDev
Copy link

I also experience this issue right after my upgrade from 4.6.3 to 4.7.0. If I run a SQL statement and click on export results I get "Token mismatch". But only with bigger/more complex queries. Very simple ones work.

My token gets blank and inside common.inc.php it fails on
if (PMA_isValid($_POST['token'])) {
With the workaround
$token_mismatch = false;
after this if statement then it works again.

The commit from @devenbansod didn't fix this.

@nijel nijel self-assigned this Apr 28, 2017
@nijel nijel added the Bug A problem or regression with an existing feature label Apr 28, 2017
@nijel nijel added this to the 4.7.1 milestone Apr 28, 2017
@nijel nijel closed this as completed in 0f1c011 Apr 28, 2017
@limitusus
Copy link
limitusus commented May 1, 2017

Looks fixed.
Looking forward to 4.7.1 release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A problem or regression with an existing feature
Projects
None yet
Development

No branches or pull requests

6 participants