SlideShare a Scribd company logo
1 of 30
So, you wanna crypto (in AEM)
Damien Antipa (@visiongeist)
Antonio Sanso (@asanso)
Adobe Research Switzerland
Who are these guys BTW
Damien Antipa
Senior UX Engineer Adobe Research Switzerland
Who are these guys BTW
Antonio Sanso
Software Engineer Adobe Research Switzerland
Committer and PMC Member for Apache Sling
VP (Chair) for Apache Oltu (OAuth Protocol Implementation in Java)
Internet Bug Bounty, Google Security Hall of Fame, Facebook Security
Whitehat, GitHub Security Bug Bounty, Microsoft Honor Roll
What is Cryptography?
DISCLAIMER – I am not a cryptographer
Cryptography is the art of protecting information
Confidentiality vs Integrity
Encryption Sign/Validate
Integrity Protection
Encryption
Plaintext: hello
Ciphertext: ΠΞιιΘ
AES
3DES
RSA
Integrity protection
HMAC
RSA
DSA
Plaintext: hello
Plaintext: hello
Cryptography in AEM
Why not DIY #1?
I need to encrypt
Why not DIY #2?
Plaintext: hello
Ciphertext: ΠΞιιΘ
AES ECB
AES ECB
Encryption is NOT Authentication
★
Encrypt Than MAC
AEM Use Case: Encapsulate Token
Encapsulated Token
Sticky session
JSON Web Token
eyJhbGciOiJIUzI1NiIs
InR5cCI6IkpXVCJ9.
eyJpc3MiOiJhZW0iLC
JzdWIiOiJhc2Fuc28iL
CJleHAiOjE0MzUwNj
g3MTEsImlhdCI6MT
QzNTA2NTExMX0.
MaGUiPg07ezuP9yA
OaVLETQH6HMOpfo
Gwg_c0-PDw
{"alg":"HS256","typ":"JWT"}Header
Claims {"iss":"aem","sub":"asanso","exp":14350
11,"iat":1435065111}
Signature HMAC
★
Encapsulated Token
JWT
{…,"sub":"asanso","exp":1435068711,"iat":1435065111, …}
★
/etc/key/hmac
AEM Use Case: CSRF Protection
Problem - CSRF
CSRF = Cross site request forgery
OWASP TOP 10
CSRF – How does the attack work?
POST http://bank.com/transfer.do HTTP/1.1
acct=BOB&amount=100
The Attack (Mallory Page)
<form action="http://bank.com/transfer.do" method="POST">
<input type="hidden" name="acct" value=”ANTONIO"/>
<input type="hidden" name=amount" value="100000"/>
<input type="submit" value=”Show pictures"/>
</form>
Browsers make requests (with cookies) to any other origin
CSRF – AEM <= 6.0 Protection
Apache Sling Referrer Filter
White list of allowed referrer
for
POST/PUT/DELETE operations
Q. IS IT SAFE ? A. YES
CSRF – AEM <= 6.0 Protection
HTTP HTTP
Referer
HTTPS HTTPS
Referer
HTTP HTTPS
Referer
HTTPS HTTP
<html>
<script>
function load() {
var postdata = '<form id=dynForm method=POST action='http://bank.com/transfer.do'>' +
'<input type=hidden name=acct value=ANTONIO />' +
'<input type=hidden name=amount value=100000 />' +
'</form>';
top.frames[0].document.body.innerHTML=postdata;
top.frames[0].document.getElementById('dynForm').submit();
}
</script>
<body onload="load()">
<iframe src="about:blank" id="noreferer"></iframe>
</body>
</html>
CSRF – Token (Classic solution)
- Include a hidden form field
<form action="http://bank.com/transfer.do" method="POST">
...
<input type="hidden" name="csrfToken" value=“ewqakjdsa”/>
</form>
- Store the token server side in a database
- Check if the token match
- Not cachable !
- Not scalable !
Goals of the CSRF implementation
★
- Easy to use
- Transparent to application code
- No dependencies
- Auto refresh
- Available on author and publish
- No leakage to other domain
- Browser support
- IE8+
- Scalable and Cacheable
- No sticky sessions
- No HTTP Sessions
How to use it in a project
If you are building an admin UI based on Granite, you need to do:
NOTHING - we include it for you
If you are building an independent or public facing login, you to:
you need to add granite.csrf.standalone client library
In both scenarios your Javascript code does NOT need to do
anything or be aware of the CSRF token.
Ensure Integrity and Caching
- Use JSON Web Token
- Sign using system HMAC key
- Validate the token using standard JWT validation
- Short expiration time
- Asynchronous update
http://localhost:4502/libs/granite/csrf/token.json
Covered Communication
- HTML forms. Make sure the synchronous POST includes the TOKEN
- Make sure all non-GET AJAX calls include the token
- “Asynchronous” file upload for legacy IE.
Make sure that form submissions to dynamically created
iFrames include the TOKEN.
MONKEY PATCH
EVERYTHING
XMLHttpRequest.prototype.send = function(method) {
this.setRequestHeader('CSRF-Token', globalToken);
send.apply(this, arguments);
};
function handleForm(ev) {
var form = ev.target;
if (form.nodeName.toLowerCase() === 'form') {
input = document.createElement('input');
input.setAttribute('type', 'hidden');
input.setAttribute('name', 'CSRF-Token');
input.setAttribute('value', globalToken);
form.appendChild(input);
}
}
document.addEventListener(
'submit', handleForm, true /* capture phase */);
https://docs.adobe.com/docs/en/aem/6-
0/develop/ref/javadoc/com/adobe/granite/crypto/CryptoSupport.html
https://docs.adobe.com/docs/en/aem/6-
0/develop/ref/javadoc/com/adobe/granite/oauth/jwt/package-
summary.html
Documentation
Questions?
Damien Antipa, Senior UX Engineer
Twitter: @visiongeist
Antonio Sanso, Software Engineer
Twitter: @asanso

More Related Content

What's hot

Integrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptIntegrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptFrancois Marier
 
Windows Azure - Automating app lifecycle
Windows Azure - Automating app lifecycleWindows Azure - Automating app lifecycle
Windows Azure - Automating app lifecycleSriram Krishnan
 
Websockets en Ruby en 5 Minutos
Websockets en Ruby en 5 MinutosWebsockets en Ruby en 5 Minutos
Websockets en Ruby en 5 Minutosdamianmarti
 
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Alex Kavanagh
 
Windows Azure loves OSS
Windows Azure loves OSSWindows Azure loves OSS
Windows Azure loves OSSKazumi Hirose
 
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best PracticesWindows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best PracticesSriram Krishnan
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindSam Keen
 
Xss mitigation php [Repaired]
Xss mitigation php [Repaired]Xss mitigation php [Repaired]
Xss mitigation php [Repaired]Tinashe Makuti
 
Security and Privacy on the Web in 2015
Security and Privacy on the Web in 2015Security and Privacy on the Web in 2015
Security and Privacy on the Web in 2015Francois Marier
 
Weird new tricks for browser fingerprinting
Weird new tricks for browser fingerprintingWeird new tricks for browser fingerprinting
Weird new tricks for browser fingerprintingRoel Palmaers
 
10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...
10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...
10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...Matt Raible
 
Nodejs Security
Nodejs SecurityNodejs Security
Nodejs SecurityJason Ross
 
Node Day - Node.js Security in the Enterprise
Node Day - Node.js Security in the EnterpriseNode Day - Node.js Security in the Enterprise
Node Day - Node.js Security in the EnterpriseAdam Baldwin
 
Practical Exploitation - Webappy Style
Practical Exploitation - Webappy StylePractical Exploitation - Webappy Style
Practical Exploitation - Webappy StyleRob Fuller
 
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...Puppet
 
Tackling Legacy Code November 2015
Tackling Legacy Code November 2015Tackling Legacy Code November 2015
Tackling Legacy Code November 2015Tomas Malmsten
 

What's hot (20)

Integrity protection for third-party JavaScript
Integrity protection for third-party JavaScriptIntegrity protection for third-party JavaScript
Integrity protection for third-party JavaScript
 
Windows Azure - Automating app lifecycle
Windows Azure - Automating app lifecycleWindows Azure - Automating app lifecycle
Windows Azure - Automating app lifecycle
 
Don't Get Stung
Don't Get StungDon't Get Stung
Don't Get Stung
 
Websockets en Ruby en 5 Minutos
Websockets en Ruby en 5 MinutosWebsockets en Ruby en 5 Minutos
Websockets en Ruby en 5 Minutos
 
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3
 
Windows Azure loves OSS
Windows Azure loves OSSWindows Azure loves OSS
Windows Azure loves OSS
 
Windows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best PracticesWindows Azure - Cloud Service Development Best Practices
Windows Azure - Cloud Service Development Best Practices
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
Dancing with websocket
Dancing with websocketDancing with websocket
Dancing with websocket
 
Xss mitigation php [Repaired]
Xss mitigation php [Repaired]Xss mitigation php [Repaired]
Xss mitigation php [Repaired]
 
Security and Privacy on the Web in 2015
Security and Privacy on the Web in 2015Security and Privacy on the Web in 2015
Security and Privacy on the Web in 2015
 
Weird new tricks for browser fingerprinting
Weird new tricks for browser fingerprintingWeird new tricks for browser fingerprinting
Weird new tricks for browser fingerprinting
 
10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...
10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...
10 Excellent Ways to Secure Your Spring Boot Application - The Secure Develop...
 
Socket.IO
Socket.IOSocket.IO
Socket.IO
 
Web socket with php v2
Web socket with php v2Web socket with php v2
Web socket with php v2
 
Nodejs Security
Nodejs SecurityNodejs Security
Nodejs Security
 
Node Day - Node.js Security in the Enterprise
Node Day - Node.js Security in the EnterpriseNode Day - Node.js Security in the Enterprise
Node Day - Node.js Security in the Enterprise
 
Practical Exploitation - Webappy Style
Practical Exploitation - Webappy StylePractical Exploitation - Webappy Style
Practical Exploitation - Webappy Style
 
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
 
Tackling Legacy Code November 2015
Tackling Legacy Code November 2015Tackling Legacy Code November 2015
Tackling Legacy Code November 2015
 

Viewers also liked

You wanna crypto in AEM
You wanna crypto in AEMYou wanna crypto in AEM
You wanna crypto in AEMDamien Antipa
 
Cross Site Request Forgery
Cross Site Request ForgeryCross Site Request Forgery
Cross Site Request ForgeryTony Bibbs
 
OAuth Hacks A gentle introduction to OAuth 2 and Apache Oltu
OAuth Hacks A gentle introduction to OAuth 2 and Apache OltuOAuth Hacks A gentle introduction to OAuth 2 and Apache Oltu
OAuth Hacks A gentle introduction to OAuth 2 and Apache OltuAntonio Sanso
 
Dynamic Components using Single-Page-Application Concepts in AEM/CQ
Dynamic Components using Single-Page-Application Concepts in AEM/CQDynamic Components using Single-Page-Application Concepts in AEM/CQ
Dynamic Components using Single-Page-Application Concepts in AEM/CQNetcetera
 

Viewers also liked (6)

You wanna crypto in AEM
You wanna crypto in AEMYou wanna crypto in AEM
You wanna crypto in AEM
 
Top X OAuth 2 Hacks
Top X OAuth 2 HacksTop X OAuth 2 Hacks
Top X OAuth 2 Hacks
 
Cross Site Request Forgery
Cross Site Request ForgeryCross Site Request Forgery
Cross Site Request Forgery
 
Cqcon
CqconCqcon
Cqcon
 
OAuth Hacks A gentle introduction to OAuth 2 and Apache Oltu
OAuth Hacks A gentle introduction to OAuth 2 and Apache OltuOAuth Hacks A gentle introduction to OAuth 2 and Apache Oltu
OAuth Hacks A gentle introduction to OAuth 2 and Apache Oltu
 
Dynamic Components using Single-Page-Application Concepts in AEM/CQ
Dynamic Components using Single-Page-Application Concepts in AEM/CQDynamic Components using Single-Page-Application Concepts in AEM/CQ
Dynamic Components using Single-Page-Application Concepts in AEM/CQ
 

Similar to So, you wanna crypto (in AEM) - Cryptography and security in AEM

Case Studies and Lessons Learned from SSL/TLS Certificate Verification Vulner...
Case Studies and Lessons Learned from SSL/TLS Certificate Verification Vulner...Case Studies and Lessons Learned from SSL/TLS Certificate Verification Vulner...
Case Studies and Lessons Learned from SSL/TLS Certificate Verification Vulner...JPCERT Coordination Center
 
How LinkedIn changed its security model in order to offer an API
How LinkedIn changed its security model  in order to offer an APIHow LinkedIn changed its security model  in order to offer an API
How LinkedIn changed its security model in order to offer an APILinkedIn
 
SSL Pinning and Bypasses: Android and iOS
SSL Pinning and Bypasses: Android and iOSSSL Pinning and Bypasses: Android and iOS
SSL Pinning and Bypasses: Android and iOSAnant Shrivastava
 
Web API Security
Web API SecurityWeb API Security
Web API SecurityStefaan
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsLewis Ardern
 
Django Web Application Security
Django Web Application SecurityDjango Web Application Security
Django Web Application Securitylevigross
 
Von JavaEE auf Microservice in 6 Monaten - The Good, the Bad, and the wtfs...
Von JavaEE auf Microservice in 6 Monaten - The Good, the Bad, and the wtfs...Von JavaEE auf Microservice in 6 Monaten - The Good, the Bad, and the wtfs...
Von JavaEE auf Microservice in 6 Monaten - The Good, the Bad, and the wtfs...André Goliath
 
Top Ten Tips For Tenacious Defense In Asp.Net
Top Ten Tips For Tenacious Defense In Asp.NetTop Ten Tips For Tenacious Defense In Asp.Net
Top Ten Tips For Tenacious Defense In Asp.Netalsmola
 
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018HashiCorp
 
Top Ten Proactive Web Security Controls v5
Top Ten Proactive Web Security Controls v5Top Ten Proactive Web Security Controls v5
Top Ten Proactive Web Security Controls v5Jim Manico
 
Defending Against Attacks With Rails
Defending Against Attacks With RailsDefending Against Attacks With Rails
Defending Against Attacks With RailsTony Amoyal
 
Abusing bleeding edge web standards for appsec glory
Abusing bleeding edge web standards for appsec gloryAbusing bleeding edge web standards for appsec glory
Abusing bleeding edge web standards for appsec gloryPriyanka Aash
 
Advanced nginx in mercari - How to handle over 1,200,000 HTTPS Reqs/Min
Advanced nginx in mercari - How to handle over 1,200,000 HTTPS Reqs/MinAdvanced nginx in mercari - How to handle over 1,200,000 HTTPS Reqs/Min
Advanced nginx in mercari - How to handle over 1,200,000 HTTPS Reqs/MinMasahiro Nagano
 
APIDays Australia - Openresty for scale
APIDays Australia - Openresty for scaleAPIDays Australia - Openresty for scale
APIDays Australia - Openresty for scaleSteven Cooper
 
Hands on web development with play 2.0
Hands on web development with play 2.0Hands on web development with play 2.0
Hands on web development with play 2.0Abbas Raza
 
Owasp top 10_openwest_2019
Owasp top 10_openwest_2019Owasp top 10_openwest_2019
Owasp top 10_openwest_2019Sean Jackson
 
Jon McCoy - AppSec-USA-2014 Hacking C#(.NET) Applications:Defend by Design
Jon McCoy - AppSec-USA-2014 Hacking C#(.NET) Applications:Defend by DesignJon McCoy - AppSec-USA-2014 Hacking C#(.NET) Applications:Defend by Design
Jon McCoy - AppSec-USA-2014 Hacking C#(.NET) Applications:Defend by Designjonmccoy
 
Rails security: above and beyond the defaults
Rails security: above and beyond the defaultsRails security: above and beyond the defaults
Rails security: above and beyond the defaultsMatias Korhonen
 

Similar to So, you wanna crypto (in AEM) - Cryptography and security in AEM (20)

API SECURITY
API SECURITYAPI SECURITY
API SECURITY
 
Case Studies and Lessons Learned from SSL/TLS Certificate Verification Vulner...
Case Studies and Lessons Learned from SSL/TLS Certificate Verification Vulner...Case Studies and Lessons Learned from SSL/TLS Certificate Verification Vulner...
Case Studies and Lessons Learned from SSL/TLS Certificate Verification Vulner...
 
How LinkedIn changed its security model in order to offer an API
How LinkedIn changed its security model  in order to offer an APIHow LinkedIn changed its security model  in order to offer an API
How LinkedIn changed its security model in order to offer an API
 
SSL Pinning and Bypasses: Android and iOS
SSL Pinning and Bypasses: Android and iOSSSL Pinning and Bypasses: Android and iOS
SSL Pinning and Bypasses: Android and iOS
 
Web API Security
Web API SecurityWeb API Security
Web API Security
 
OWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript ApplicationsOWASP SF - Reviewing Modern JavaScript Applications
OWASP SF - Reviewing Modern JavaScript Applications
 
Django Web Application Security
Django Web Application SecurityDjango Web Application Security
Django Web Application Security
 
Von JavaEE auf Microservice in 6 Monaten - The Good, the Bad, and the wtfs...
Von JavaEE auf Microservice in 6 Monaten - The Good, the Bad, and the wtfs...Von JavaEE auf Microservice in 6 Monaten - The Good, the Bad, and the wtfs...
Von JavaEE auf Microservice in 6 Monaten - The Good, the Bad, and the wtfs...
 
Top Ten Tips For Tenacious Defense In Asp.Net
Top Ten Tips For Tenacious Defense In Asp.NetTop Ten Tips For Tenacious Defense In Asp.Net
Top Ten Tips For Tenacious Defense In Asp.Net
 
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
 
Top Ten Proactive Web Security Controls v5
Top Ten Proactive Web Security Controls v5Top Ten Proactive Web Security Controls v5
Top Ten Proactive Web Security Controls v5
 
Defending Against Attacks With Rails
Defending Against Attacks With RailsDefending Against Attacks With Rails
Defending Against Attacks With Rails
 
Abusing bleeding edge web standards for appsec glory
Abusing bleeding edge web standards for appsec gloryAbusing bleeding edge web standards for appsec glory
Abusing bleeding edge web standards for appsec glory
 
Advanced nginx in mercari - How to handle over 1,200,000 HTTPS Reqs/Min
Advanced nginx in mercari - How to handle over 1,200,000 HTTPS Reqs/MinAdvanced nginx in mercari - How to handle over 1,200,000 HTTPS Reqs/Min
Advanced nginx in mercari - How to handle over 1,200,000 HTTPS Reqs/Min
 
Owasp top 10 2013
Owasp top 10 2013Owasp top 10 2013
Owasp top 10 2013
 
APIDays Australia - Openresty for scale
APIDays Australia - Openresty for scaleAPIDays Australia - Openresty for scale
APIDays Australia - Openresty for scale
 
Hands on web development with play 2.0
Hands on web development with play 2.0Hands on web development with play 2.0
Hands on web development with play 2.0
 
Owasp top 10_openwest_2019
Owasp top 10_openwest_2019Owasp top 10_openwest_2019
Owasp top 10_openwest_2019
 
Jon McCoy - AppSec-USA-2014 Hacking C#(.NET) Applications:Defend by Design
Jon McCoy - AppSec-USA-2014 Hacking C#(.NET) Applications:Defend by DesignJon McCoy - AppSec-USA-2014 Hacking C#(.NET) Applications:Defend by Design
Jon McCoy - AppSec-USA-2014 Hacking C#(.NET) Applications:Defend by Design
 
Rails security: above and beyond the defaults
Rails security: above and beyond the defaultsRails security: above and beyond the defaults
Rails security: above and beyond the defaults
 

So, you wanna crypto (in AEM) - Cryptography and security in AEM

Editor's Notes

  1. granite.csrf.standalone - no dependencies
  2. granite.csrf.standalone - no dependencies
  3. granite.csrf.standalone - no dependencies
  4. granite.csrf.standalone - no dependencies
  5. granite.csrf.standalone - no dependencies
  6. granite.csrf.standalone - no dependencies
  7. granite.csrf.standalone - no dependencies
  8. granite.csrf.standalone - no dependencies
  9. granite.csrf.standalone - no dependencies
  10. granite.csrf.standalone - no dependencies
  11. granite.csrf.standalone - no dependencies
  12. granite.csrf.standalone - no dependencies
  13. granite.csrf.standalone - no dependencies
  14. granite.csrf.standalone - no dependencies
  15. granite.csrf.standalone - no dependencies
  16. granite.csrf.standalone - no dependencies
  17. granite.csrf.standalone - no dependencies
  18. granite.csrf.standalone - no dependencies
  19. granite.csrf.standalone - no dependencies
  20. granite.csrf.standalone - no dependencies
  21. how did we solve it??
  22. do not want to bore you with the details but in case you are wondering… for instance for the AJAX call we patched the XMLHttpRequest prototype. and add a HTTP Request header As an app dev you can simply ignore this, you can keep using jQuery etc. (this is simplified code) globalToken includes the token
  23. same game for forms