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

SQL bug (with fix) in PostgreSQL Store checkServerNonce method #148

Open
GoogleCodeExporter opened this issue Apr 4, 2016 · 0 comments
Open

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Using the PostgreSQL store, replay a request using an already used nonce.


What is the expected output? What do you see instead?
Expected:
AuthException2 [ Error ]: Duplicate timestamp/nonce combination, possible 
replay attack. Request rejected.

Actual:
 ERROR:  duplicate key value violates unique constraint "oauth_server_nonce_osn_consumer_key_osn_token_osn_timestamp_key"


What version of the product are you using? On what operating system?
Version 175, OS: FreeBSD 10.1, PHP 5.4.29, Postgresql 9.3.4

Please provide any additional information below.
Replace lines 1616-1624 of library/store/OAuthStorePostgreSQL.php with the 
following code to fix the issue:

        $this->query('
            INSERT INTO oauth_server_nonce (
                osn_consumer_key,
                osn_token,
                osn_timestamp,
                osn_nonce
            )
            SELECT \'%s\', \'%s\', %d, \'%s\' 
            WHERE NOT EXISTS (
                SELECT 1 FROM oauth_server_nonce 
                WHERE osn_consumer_key = \'%s\'
                    AND osn_token = \'%s\'
                    AND osn_timestamp = %d
                    AND osn_nonce = \'%s\' 
            )',
            $consumer_key, $token, $timestamp, $nonce,
            $consumer_key, $token, $timestamp, $nonce);

Original issue reported on code.google.com by [email protected] on 20 Apr 2015 at 4:03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant