http://www.novatec-gmbh.de
andreas.falk@novatec-gmbh.de
@NT_AQE, @andifalk
“...The basic idea is to implement automatic, secure escaping for all values that can reach the DOM... By default, with no specific action for developers, Angular apps must be secure...”https://github.com/angular/angular/issues/8511
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css']
})
export class AppComponent {
untrustedHtml:string =
'<em><script>alert("hello")</script></em>';
}
Binding of potentially dangerous HTML-snippets
Encoded HTML snippet
{{untrustedHtml}}
Sanitized HTML snippet
ElementRef: Direct access to DOM!
DomSanitizer: Deactivates XSS-Protection!
Do NOT use!
https://angular.io/docs/ts/latest
@Entity
public class Person extends AbstractPersistable<Long> {
@NotNull
@Pattern(regexp = "^[A-Za-z0-9- ]{1,30}$")
private String lastName;
@NotNull
@Enumerated(EnumType.STRING)
private GenderEnum gender;
...
}
@Query(
"select u from User u where u.username = "
+ " :username and u.password = :password")
User findByUsernameAndPassword(
@Param("username") String username,
@Param("password") String password);
@Configuration
public class WebSecurityConfiguration
extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http)
throws Exception {
…
http
.csrf().csrfTokenRepository(
CookieCsrfTokenRepository.withHttpOnlyFalse()
);
}
Session Cookie | Token (Bearer, JWT) |
---|---|
With each Request | Manually as Header |
Potential CSRF! | No CSRF possible |
Persisted when unloading DOM | No automatic persistence |
One domain | Cross domain (CORS) |
Sensitive Information (HTTPS) | Sensitive Information (HTTPS) |
@EnableResourceServer
@Configuration
public class OAuth2Configuration {
@Bean
public JwtAccessTokenConverterConfigurer
jwtAccessTokenConverterConfigurer() {
return new MyJwtConfigurer(...);
}
static class MyJwtConfigurer
implements JwtAccessTokenConverterConfigurer {
@Override
public void configure(
JwtAccessTokenConverter converter) {...}
}
}
OAuth 2.0 Threat Model and Security Considerations
public class UserBoundaryService {
@PreAuthorize("hasRole('ADMIN')")
public List<User> findAllUsers() {...}
}
public class TaskBoundaryService {
@PreAuthorize("hasPermission(#taskId, 'TASK', 'WRITE')")
public Task findTask(UUID taskId) {...}
}
public class AuthorizationIntegrationTest {
@WithMockUser(roles = "ADMIN")
@Test
public void verifyFindAllUsersAuthorized() {...}
@WithMockUser(roles = "USER")
@Test(expected = AccessDeniedException.class)
public void verifyFindAllUsersUnauthorized() {...}
}
Distributed DoS
Economic DoS
“What if every server inside my data center had a maximum lifetime of two hours? This approach would frustrate malware writers...”
Friday 19th May, 2017 6:00pm to 6:50pm
http://www.novatec-gmbh.de http://blog.novatec-gmbh.de
andreas.falk@novatec-gmbh.de
@NT_AQE, @andifalk