SlideShare a Scribd company logo
SICHER IN DIE CLOUD
MIT ANGULAR UND SPRING BOOT
9. MAI 2017
1
ANDREAS FALK
http://www.novatec-gmbh.de
andreas.falk@novatec-gmbh.de
@NT_AQE, @andifalk
2
ARCHITECTURE /
THREAT MODEL
3 . 1
3 . 2
SQLInjectionCSRFXSS OWASP OAuth2
OpenID-Connect AbUser-Stories
AuthenticationAuthorization Secure Coding
Security-Testing SSO DoSSensitive-Data Data-
Privacy Crypto Code-ReviewsThreat-
ModelingArchitectureDependencies
DASTSAML SAST DevSecOps
3 . 3
SQLInjectionCSRFXSS OWASP
OAuth2OpenID-Connect
Authentication Authorization Secure CodingSecurity-
Testing
3 . 4
HTTPS://GITHUB.COM/OWASP/TOP10
3 . 5
APP SECURITY VERIFICATION STANDARD PRO ACTIVE CONTROLS
https://github.com/OWASP/ASVS
https://www.owasp.org/index.php/
OWASP_Proactive_Controls
3 . 6
ANGULAR
4 . 1
ANGULARJS = ANGULAR 1
ANGULAR = ANGULAR 2.X, 4.X, 5.X, ...
4 . 2
A3: CROSS-SITE SCRIPTING (XSS)
4 . 3
ANGULAR JS SECURITY
https://angularjs.blogspot.de/2016/09/angular-16-expression-sandbox-removal.html
4 . 4
ANGULAR SECURITY
“...The basic idea is to implement
automatic, secure escaping for all values
that can reach the DOM... By default,
with no speci c action for developers,
Angular apps must be secure...”
https://github.com/angular/angular/issues/8511
4 . 5
ANGULAR XSS
PROTECTION
ANGULAR TEMPLATE = SAFE
INPUT VALUES = UNSAFE
4 . 6
ANGULAR COMPONENT
TYPESCRIPT
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css']
})
export class AppComponent {
untrustedHtml:string =
'<em><script>alert("hello")</script></em>';
}
4 . 7
ANGULAR TEMPLATE
HTML BINDINGS
<h2>Binding of potentially dangerous HTML-snippets</h2>
<h3>Encoded HTML snippet</h3>
<h3 class="trusted">{{untrustedHtml}}</h3>
<h3>Sanitized HTML snippet</h3>
<h3 class="trusted" [innerhtml]="untrustedHtml"></h3>
4 . 8
UNSAFE ANGULAR API'S
ElementRef: Direct access to DOM!
DomSanitizer: Deactivates XSS-Protection!
Do NOT use!
https://angular.io/docs/ts/latest
4 . 9
DEMO
4 . 10
BACKEND
5 . 1
A1: INJECTION
5 . 2
SPRING MVC + SPRING DATA JPA
PREVENT INJECTIONS USING BEAN VALIDATION
@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;
...
}
5 . 3
SPRING DATA JPA
PREVENT SQL-INJECTION USING PREPARED STATEMENTS
@Query(
"select u from User u where u.username = "
+ " :username and u.password = :password")
User findByUsernameAndPassword(
@Param("username") String username,
@Param("password") String password);
5 . 4
A8: CROSS-SITE REQUEST FORGERY (CSRF)
5 . 5
DOUBLE SUBMIT CSRF TOKEN
5 . 6
SPRING SECURITY
SECURE BY DEFAULT
Authentication required for all HTTP endpoints
Session Fixation Protection
Session Cookie (HttpOnly, Secure)
CSRF Protection
Security Response Header
5 . 7
SPRING SECURITY CSRF CONFIGURATION
ANGULAR SUPPORT
@Configuration
public class WebSecurityConfiguration
extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http)
throws Exception {
…
http
.csrf().csrfTokenRepository(
CookieCsrfTokenRepository.withHttpOnlyFalse()
);
}
5 . 8
WHO AM I?
A2: BROKEN AUTHENTICATION AND SESSION MANAGEMENT
A10: UNDERPROTECTED APIS
5 . 9
AUTHENTICATION (STATEFUL OR STATELESS?)
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)
5 . 10
OAUTH 2
5 . 11
OPENID CONNECT
5 . 12
OAUTH 2 / OPENID CONNECT RESOURCE
@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
5 . 13
IMPLICIT GRANT
Implicit Client Implementer’s Guide
OAuth 2.0 Threat Model and Security Considerations
5 . 14
CLIENT CREDENTIALS
GRANT
5 . 15
RESOURCE OWNER
GRANT
DO NOT USE!
5 . 16
WHAT CAN I ACCESS?
A4: BROKEN ACCESS CONTROL
A10: UNDERPROTECTED APIS
5 . 17
AUTHORIZATION OF REST API
ROLE BASED
public class UserBoundaryService {
@PreAuthorize("hasRole('ADMIN')")
public List<User> findAllUsers() {...}
}
5 . 18
AUTHORIZATION OF REST API
PERMISSION BASED
public class TaskBoundaryService {
@PreAuthorize("hasPermission(#taskId, 'TASK', 'WRITE')")
public Task findTask(UUID taskId) {...}
}
5 . 19
AUTHORIZATION OF REST API
INTEGRATIONTEST
public class AuthorizationIntegrationTest {
@WithMockUser(roles = "ADMIN")
@Test
public void verifyFindAllUsersAuthorized() {...}
@WithMockUser(roles = "USER")
@Test(expected = AccessDeniedException.class)
public void verifyFindAllUsersUnauthorized() {...}
}
5 . 20
DEMO
5 . 21
WHAT ABOUT THE
CLOUD?
6 . 1
GOOD OLD FRIENDS ...UND MORE...
CSRF XSS SQL Injection Session Fixation
Vulnerable Dependencies Weak Passwords
Broken Authorization Sensitive Data Exposure
Distributed DoS
Economic DoS
6 . 2
WEAK PASSWORDS
6 . 3
SO WHAT HAS BEEN CHANGED
IN THE CLOUD?
6 . 4
6 . 5
ROTATE, REPAIR, REPAVE
JUSTIN SMITH
“What if every server inside my data
center had a maximum lifetime of two
hours? This approach would frustrate
malware writers...”
6 . 6
WHAT ABOUT APPLICATION
CONFIGURATION AND SENSIBLE DATA IN
THE CLOUD?
6 . 7
MANAGE DISTRIBUTED CONFIGURATION AND SECRETS
WITH SPRING CLOUD AND VAULT
Friday 19th May, 2017 6:00pm to 6:50pm
6 . 8
ONE MORE THING...
7 . 1
A7: INSUFFICIENT ATTACK PROTECTION
7 . 2
7 . 3
http://www.novatec-gmbh.de
http://blog.novatec-gmbh.de
andreas.falk@novatec-gmbh.de
@NT_AQE, @andifalk
8

More Related Content

PDF
Sicher in die Cloud mit Angular und Spring Boot (Karlsruher Entwicklertag 2017)
PDF
Manage distributed configuration and secrets with spring cloud and vault (Spr...
PDF
Lock it down
PPTX
Building IoT Solutions with Nitrogen
PDF
Hashicorp Vault Associate Certification Concepts Part 2
PDF
CKA Certified Kubernetes Administrator Notes
PDF
Hashicorp Vault Associate Certification Configuration Part 3
PDF
Fosdem10
Sicher in die Cloud mit Angular und Spring Boot (Karlsruher Entwicklertag 2017)
Manage distributed configuration and secrets with spring cloud and vault (Spr...
Lock it down
Building IoT Solutions with Nitrogen
Hashicorp Vault Associate Certification Concepts Part 2
CKA Certified Kubernetes Administrator Notes
Hashicorp Vault Associate Certification Configuration Part 3
Fosdem10

What's hot (20)

PDF
SSL Pinning and Bypasses: Android and iOS
PDF
[2014/10/06] HITCON Freetalk - App Security on Android
PDF
Understanding Windows Access Token Manipulation
PPTX
BlueHat v17 || Scaling Incident Response - 5 Keys to Successful Defense at S...
PDF
Mise en place d'un client VPN l2tp IPsec sous docker
PDF
Open SSL and MS Crypto API EKON21
PDF
BlueHat v17 || Go Hunt: An Automated Approach for Security Alert Validation
PDF
Java security
PPTX
Top 13 best security practices
PDF
OSSEC @ ISSA Jan 21st 2010
PDF
RSA OSX Malware
PDF
URL to HTML
PDF
Opencast Matterhorn Stream Security
PDF
BlueHat v17 || Where, how, and why is SSL traffic on mobile getting intercept...
PDF
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Sprin...
DOC
Some ISPF Tricks
PDF
Security threat analysis points for enterprise with oss
PDF
DEF CON 23: Stick That In Your (root)Pipe & Smoke It
PDF
Developing a Secure Active Directory
PDF
Внедрение безопасности в веб-приложениях в среде выполнения
SSL Pinning and Bypasses: Android and iOS
[2014/10/06] HITCON Freetalk - App Security on Android
Understanding Windows Access Token Manipulation
BlueHat v17 || Scaling Incident Response - 5 Keys to Successful Defense at S...
Mise en place d'un client VPN l2tp IPsec sous docker
Open SSL and MS Crypto API EKON21
BlueHat v17 || Go Hunt: An Automated Approach for Security Alert Validation
Java security
Top 13 best security practices
OSSEC @ ISSA Jan 21st 2010
RSA OSX Malware
URL to HTML
Opencast Matterhorn Stream Security
BlueHat v17 || Where, how, and why is SSL traffic on mobile getting intercept...
Lock That Shit Down! Auth Security Patterns for Apps, APIs, and Infra - Sprin...
Some ISPF Tricks
Security threat analysis points for enterprise with oss
DEF CON 23: Stick That In Your (root)Pipe & Smoke It
Developing a Secure Active Directory
Внедрение безопасности в веб-приложениях в среде выполнения
Ad

Similar to JAX 2017 - Sicher in die Cloud mit Angular und Spring Boot (20)

PDF
JavaOne 2014 - Securing RESTful Resources with OAuth2
PDF
Spring security oauth2
PDF
OAuth2 & OpenID Connect with Spring Security
PPTX
Spa Secure Coding Guide
PDF
Modern Security with OAuth 2.0 and JWT and Spring by Dmitry Buzdin
PDF
De la bonne utilisation de OAuth2
PDF
APIsecure 2023 - OAuth, OIDC and protecting third-party credentials, Ed Olson...
PDF
Web Application Security Reloaded for the HTML5 era
PDF
APIDays Paris Security Workshop
PDF
Secured REST Microservices with Spring Cloud
PDF
Secure your api from basics to beyond
PDF
Building layers of defense for your application
PPTX
Addressing Top API Security Risks
PDF
Mixing OAuth 2.0, Jersey and Guice to Build an Ecosystem of Apps - JavaOne...
PDF
JavaOne 2013 BOF 3861 - Mixing OAuth 2.0, Jersey and Guice to Build an Ecosys...
PDF
Checkmarx meetup API Security - API Security top 10 - Erez Yalon
PDF
Checkmarx meetup API Security - API Security in depth - Inon Shkedy
PDF
Web App Security for Java Developers - PWX 2021
PDF
Web App Security for Java Developers - UberConf 2021
PDF
AngularJS Security: defend your Single Page Application
JavaOne 2014 - Securing RESTful Resources with OAuth2
Spring security oauth2
OAuth2 & OpenID Connect with Spring Security
Spa Secure Coding Guide
Modern Security with OAuth 2.0 and JWT and Spring by Dmitry Buzdin
De la bonne utilisation de OAuth2
APIsecure 2023 - OAuth, OIDC and protecting third-party credentials, Ed Olson...
Web Application Security Reloaded for the HTML5 era
APIDays Paris Security Workshop
Secured REST Microservices with Spring Cloud
Secure your api from basics to beyond
Building layers of defense for your application
Addressing Top API Security Risks
Mixing OAuth 2.0, Jersey and Guice to Build an Ecosystem of Apps - JavaOne...
JavaOne 2013 BOF 3861 - Mixing OAuth 2.0, Jersey and Guice to Build an Ecosys...
Checkmarx meetup API Security - API Security top 10 - Erez Yalon
Checkmarx meetup API Security - API Security in depth - Inon Shkedy
Web App Security for Java Developers - PWX 2021
Web App Security for Java Developers - UberConf 2021
AngularJS Security: defend your Single Page Application
Ad

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Empathic Computing: Creating Shared Understanding
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPT
Teaching material agriculture food technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
cuic standard and advanced reporting.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Cloud computing and distributed systems.
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Electronic commerce courselecture one. Pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation theory and applications.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Empathic Computing: Creating Shared Understanding
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Teaching material agriculture food technology
Unlocking AI with Model Context Protocol (MCP)
Digital-Transformation-Roadmap-for-Companies.pptx
A Presentation on Artificial Intelligence
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Review of recent advances in non-invasive hemoglobin estimation
The Rise and Fall of 3GPP – Time for a Sabbatical?
cuic standard and advanced reporting.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Cloud computing and distributed systems.
The AUB Centre for AI in Media Proposal.docx
NewMind AI Weekly Chronicles - August'25 Week I
Electronic commerce courselecture one. Pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

JAX 2017 - Sicher in die Cloud mit Angular und Spring Boot