Most Critical Web Application Security Risks
Shows HTML source code. Might reveal hidden or commmented out elements
Shows HTTP requests like GET and POST Reveals construction of session token and JSON data
Tool for API development
Authorization based on user
Access control is defined for every single user
Authorization based on group permissions
User is part of a group
Authorization based on permissions and resource sensivity
System administrator defines the secrecy level of resources
By clicking on Administration Section, the user is forwarded to Login
A login with user standarduser of role USER won't show administration section ## Implementation in Spring Boot
This leads to a permission denied site with error code 403 ## Implementation in Spring Boot
@Configuration @EnableWebSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Autowired private AuthenticationEntryPoint authEntryPoint; @Override protected void configure(HttpSecurity http) throws Exception { http.httpBasic().authenticationEntryPoint(authEntryPoint); http.authorizeRequests().antMatchers("/", "/login", "/logout", "/css/**").permitAll(); http.authorizeRequests().antMatchers("/userInfo").access("hasAnyRole('ROLE_USER', 'ROLE_ADMIN')"); http.authorizeRequests().antMatchers("/admin").access("hasRole('ROLE_ADMIN')"); http.authorizeRequests().and().exceptionHandling().accessDeniedPage("/403"); http.authorizeRequests().and().formLogin()// .loginProcessingUrl("/j_spring_security_check") .loginPage("/login")// .defaultSuccessUrl("/userInfo")// .failureUrl("/login?error=true")// .usernameParameter("username")// .passwordParameter("password") .and().logout().logoutUrl("/logout").logoutSuccessUrl("/logoutSuccessful"); } }
Permissions are defined in class WebSecurityConfig
This class defines, which role a user needs to access a certain site
Examples for Roles are:
Insufficient conception of identity and access control
The consequences are insecure session management and authentication
Attackers are able to:
The Brute-force attack is an automated process with the intention of determining passwords
By testing random strings or number combinations, the attacker tries to gain access to an account or a server
Attackers use public lists with often used, as unsecure considered passwords. Examples are:
Brute-force attacks can be executed with security tools like OWASP ZAP
As you can see in the illustration, OWASP ZAP is testing different password combinations
Do not allow registration with weak passwords
Also, list every reason for validation failure
Block user login after too many attempts
Assign a generic identifier to the Session ID
Session ID might contain information about used technologies or user accounts
Let Web Application Frameworks handle Session Management
User tries a registration with password "abc"
Password validation prints every failure reason
private boolean isPasswordValid(final String password, Errors errors) { final PasswordValidator validator = new PasswordValidator(Arrays.asList( new LengthRule(8, 30), new UppercaseCharacterRule(1), new DigitCharacterRule(1), new SpecialCharacterRule(1))); final RuleResult result = validator.validate(new PasswordData(password)); for (int i = 0; i < result.getDetails().size(); i++) { errors.rejectValue("password", result.getDetails().get(i).getErrorCode()); } if (result.isValid()) { return true; } return false; }
Passwort validator checks if the given password has:
Untrusted data with malicious is sent to an interpreter as part of a command or query.
The interpreter executes the manipulated query
Disclosure to unauthorized parties
Data loss or manipulation
Denial of access
Prepared Statements
Stored Procedures
White List Input Validation
Escaping All User-Supplied Input
prepare("SELECT * FROM users WHERE id = ?"); $statement->execute(array($id)); while($row = $statement->fetch()) { echo $row['firstname']." ".$row['lastname'].""; echo "E-Mail: ".$row['email'].""; } ?>
CREATE PROCEDURE SelectAllUsers AS SELECT * FROM Users GO; EXEC SelectAllUsers;
String tableParam; switch(PARAM): case "Value1": tableParam = "Drinks"; break; case "Value2": tableParam = "Meals"; break; default : throw new InputValidationException("unexpected value provided for table param");