mgonzalezcx / WebGoat

WebGoat is a deliberately insecure application
https://webgoat.github.io/WebGoat/
Other
0 stars 0 forks source link

CX SQL_Injection @ webgoat-container/src/main/java/org/owasp/webgoat/users/RegistrationController.java [develop] #35

Open mgonzalezcx opened 2 years ago

mgonzalezcx commented 2 years ago

SQL_Injection issue exists @ webgoat-container/src/main/java/org/owasp/webgoat/users/RegistrationController.java in branch develop

The application's createLessonsForUser method executes an SQL query with execute, at line 50 of webgoat-container\src\main\java\org\owasp\webgoat\users\UserService.java. The application constructs this SQL query by embedding an untrusted string into the query without proper sanitization. The concatenated string is submitted to the database, where it is parsed and executed accordingly. An attacker would be able to inject arbitrary syntax and data into the SQL query, by crafting a malicious payload and providing it via the input getUsername; this input is then read by the registration method at line 36 of webgoat-container\src\main\java\org\owasp\webgoat\users\RegistrationController.java. This input then flows through the code, into a query and to the database server - without sanitization. This may enable an SQL Injection attack.

Severity: High

CWE:89

Vulnerability details and guidance

Internal Guidance

Checkmarx

Training Recommended Fix

Lines: 36 42


Code (Line #36):

    public String registration(@ModelAttribute("userForm") @Valid UserForm userForm, BindingResult bindingResult, HttpServletRequest request) throws ServletException {

Code (Line #42):

        userService.addUser(userForm.getUsername(), userForm.getPassword());