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

Login credentials do not correspond (json_decode issue) #1965

Closed
GTSLiDe opened this issue Oct 11, 2017 · 2 comments
Closed

Login credentials do not correspond (json_decode issue) #1965

GTSLiDe opened this issue Oct 11, 2017 · 2 comments

Comments

@GTSLiDe
Copy link

GTSLiDe commented Oct 11, 2017

Steps to reproduce

  1. Upgrade from 2.1.27.7 to 2.1.27.9
  2. Login using admin account
  3. Receive the error message "Login credentials do not correspond!"

Expected behaviour

The system should logs you in

Actual behaviour

Receive the error message "Login credentials do not correspond!"

Server configuration

Operating system:
CentOS and MacOS

Web server:
Apache2

Database:
MYSQL 5.6.35

PHP version:
5.6.31

Teampass version:
2.1.27.9

Teampass configuration file:

Updated from an older Teampass or fresh install:
PLEASE attach to this message the file /includes/config/tp.config.php.

Client configuration

Browser:
Chrome, Safari and Firefox
Operating system:
MacOS and CentOS

Logs

Web server error log

Insert your webserver log here

Log from the web-browser developer console (CTRL + SHIFT + i)

Insert the log here and especially the answer of the query that failed.

After an upgrade from 2.1.27.7 to 2.1.27.9, I was not able to login again.
After much troubleshooting I found that this code:
$post_data = filter_input(INPUT_POST, 'data', FILTER_SANITIZE_STRING);
in /sources/identify.php line 50, converted the array data to unreadable array which cause json_decode not able to decode it back and instead returning null.

var_dump($_POST['data']) output:
string(167) "{"login":"admin" , "pw":"admin" , "duree_session":"1000" , "screenHeight":"785" , "randomstring":"OviEU7mU9K" , "TimezoneOffset":"21600", "GACode":"" , "client":""}"

However, $post_data becomes unreadable array:

var_dump($post_data) output:

string(295) "{"login":"admin" , "pw":"admin" , "duree_session":"1000" , "screenHeight":"785" , "randomstring":"OviEU7mU9K" , "TimezoneOffset":"21600", "GACode":"" , "client":""}"

identify php - teampass_prod - applicationsmamphtdocsteampass_prod 2017-10-11 13-40-20

teampass 2017-10-11 13-42-41

Looks like filter_input(INPUT_POST, 'data', FILTER_SANITIZE_STRING); converts the " to ".

In order to fix this, I had to convert the quotes in $data variable in prepareExchangedData function in sources/main.functions.php line 1311:
$data = stripslashes(html_entity_decode($data));

monosnap 2017-10-11 13-52-07

Does anyone having this issue or is able to reproduce this issue on their side?

@GTSLiDe GTSLiDe changed the title Login credentials do not correspond Login credentials do not correspond (json_decode issue) Oct 11, 2017
@nilsteampassnet
Copy link
Owner

Thank you for reporting with this good analysis.
This helps a lot.

To prevent doing several changes, the most optimized way to adapt is to add the filter FILTER_FLAG_NO_ENCODE_QUOTES to the filter_input command.

I will commit the fix today.

nilsteampassnet added a commit that referenced this issue Oct 12, 2017
Fix for #1965, #1961
@nilsteampassnet
Copy link
Owner

Please use new 2.1.27.9 package by over-writing existing files.

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

No branches or pull requests

2 participants