SQL Injection vulnerability (Users DB) on FlatCore v1.4.6
Closed this issue · 1 comments
Exploit Title: SQL Injection vulnerability (Users DB) on FlatCore v1.4.6
Date: 11-April-2017
Exploit Author: @shardulm94
Software Link: https://github.com/flatCore/flatCore-CMS/archive/v1.4.6.zip
Version: 1.4.6
Description:
SQL Injection allows an attacker to run malicious SQL statements on a database and thus being able to read or modify the data in the database. With enough privileges assigned to the database user, it can allow the attacker to delete tables or drop databases.
Exploit:
The vulnerability is due to a non-parameterized SQL query at https://github.com/flatCore/flatCore-CMS/blob/master/core/password.php#L37. This vulnerability along with missing validation on the email field of the registration and password reset forms can be used to create an administrator account with full privileges. We assume that FlatCore is installed at http://localhost/flatcore/
and new registrations are enabled.
- Go to
http://localhost/flatcore/register/
. Fill in the usernameuname
and some password. Fill in the email fields as'; UPDATE fc_user SET user_class='administrator', user_verified='verified', user_drm='||drm_acp_user|||||' WHERE user_nick='uname' --
. This step is required since the password reset form checks for valid emails in the DB before reset. - Since the register page uses parameterized query, the whole email string will be stored in the DB.
- Now go to
http://localhost/flatcore/password/
and put in the email address mentioned while registering. Due to https://github.com/flatCore/flatCore-CMS/blob/master/core/password.php#L36, the query will effectively becomeUPDATE fc_user SET user_reset_psw = '$reset_token' WHERE user_mail = ''; UPDATE fc_user SET user_class='administrator', user_verified='verified', user_drm='||drm_acp_user|||||' WHERE user_nick='uname' --
. - As you can see, this will set administrator as the user class for now newly created user
uname
and will also give it permissions to manage the user management screen. - Once inside the admin panel, the attacker can give himself extra privileges.
References:
https://www.owasp.org/index.php/SQL_Injection
Screenshots:
Registration Form
Password Reset
New user created and verified with ability to edit users
Logged in as new user and change privileges
Impact: Read and modify the users database
Mitigation: Use of Parameterized SQL Queries and Validation on email fields
I've changed the SQL Queries to Prepared Statements and the E-Mail Adress will be validated.