Hacking TYPO3 v9 (T3DD19 edition)

Oliver Hader
Oliver HaderM.Sc. at TYPO3, hofhäckerei, inpublica.it
Hacking
TYPO3
Oliver Hader
oliver@typo3.org
@ohader
TYPO3 Developer Days 2019
August 1st, 2019
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 2
▪Research & Development
▪Security Team Lead
▪50% TYPO3 GmbH
▪50% freelance software engineer
▪#hof #cycling #paramedic #in.die.musik
~# whoami
Oliver Hader
@ohader
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 3
▪ session probably recorded
▪ real attack vectors are shown
▪ hackers probably knew already
▪ official security fixes available
▪ report to security@typo3.org
Disclaimer
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
Web Application
Security Basics
4
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
Web Application Security
5
▪ CIA/compliance triad
▪ confidentiality
▪ private, personal, sensitive information
▪ integrity
▪ manipulation of information (“fake news”)
▪ availability
▪ denial of service
▪ online bank account
▪ blocking information flow https://www.ibm.com/blogs/cloud-computing/2018/01/16/drive-compliance-cloud/
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 6
Hacking Playground
CONFIDENTIALITY - unauthorised access to information
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 7
Hacking Playground
INTEGRITY - e.g. manipulated information
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 8
Hacking Playground
AVAILABILITY - information/service not available
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 9
Web Application Security
Open Web Application Security Project - TOP 10 vulnerabilities
https://www.owasp.org/images/7/72/OWASP_Top_10-2017_%28en%29.pdf.pdf
TYPO3 core TYPO3 3rd party extensionsPHP world
TYPO3vulnerabilitiesinpast5years
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 10
Web Application Security
attack chains - multiple components might be affected
https://www.owasp.org/images/7/72/OWASP_Top_10-2017_%28en%29.pdf.pdf
Hacking
Playground

https://github.com/
ohader/typo3v9-
hack/
11TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 12
Hacking Playground
https://github.com/ohader/typo3v9-hack
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
Session

Hi-Jacking
thanks to Cross-Site Scripting
13
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
Session Hi-Jacking - insecure cookie
14
▪ https://typo3.org/security/advisory/typo3-core-sa-2018-009/
▪ Install Tool Cookie did not have HttpOnly flag
▪ addressed on December 11th, 2018
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 15
Insecure Install Tool Cookie (HTTP-only flag missing)
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 16
… cookies can be read by (any) JavaScript …
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
Session Hi-Jacking - cross-site scripting
17
▪ https://typo3.org/security/advisory/typo3-core-sa-2018-006/
▪ file.youtube or file.vimeo vulnerable to cross-site scripting
▪ addressed on December 11th, 2018
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 18
Session Hi-Jacking - cross-site scripting & insecure cookie
Asset.youtube file & JavaScript to be executed
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 19
Insecure Deserialization - Basics
… social engineering - somebody must click the file …
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 20
Insecure Deserialization - Basics
strange result & XSS exploitation in background
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 21
Session Hi-Jacking - cross-site scripting & insecure cookie
view of attacker - retrieving session cookie
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
Remote Code

Execution #1
thanks to Insecure Deserialization
22
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 23
Insecure Deserialization - Basics
__destruct() or __wakeup() methods are executed on deserialization
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 24
Insecure Deserialization - Basics
user submitted payload to be deserialized
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
Remote Code Execution #1
25
▪ https://typo3.org/security/advisory/typo3-core-sa-2019-020/
▪ https://blog.ripstech.com/2019/typo3-overriding-the-database/
▪ overrideVals[<table>][l10n_diffsource]=<serialized payload>
▪ addressed on June 25th, 2019
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 26
Insecure Deserialization - Basics
__destruct() saves content to filesystem
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 27
Remote Code Execution #1
making use of FileCookieJar as attack container
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 28
Remote Code Execution #1
prepare attack against TYPO3 backend
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 29
Remote Code Execution #1
actual attack payload that shall be executed
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 30
Remote Code Execution #1
XSRF token needs to be know (valid backend user required)
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 31
Remote Code Execution #1
output of injected & executed /typo3/hack.php
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 32
Remote Code Execution #1
… new admin user h4ck3r31 …
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
Remote Code

Execution #2
thanks to

Information Disclosure

& Insecure Deserialization
33
typo3conf/
LocalConfiguration.php.old
34TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 35
typo3conf/LocalConfiguration.php.old backup file
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 36
… what else can we find here? (standard configuration)
encryptionKey
37TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 38
Extbase __trustedProperties deserialisation
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 39
HMAC signing of __trustedProperties - based on encryptionKey
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 40
Remote Code Execution #2
similar attack using FileCookieJar
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 41
Remote Code Execution #2
output of injected & executed /typo3/hack.php
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
Okay, but what’s the point?!
42
▪ When being hacked, update ALL sensitive information
▪ backend user passwords
▪ frontend user password
▪ database credentials
▪ TYPO3 encryption key
▪ private/public key files
▪ …
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
“Flexibility”
#1
thanks to insecure TypoScript

(Cross-Site Scripting & SQL Injection)
43
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 44
GET/POST data in TypoScript - insertData injection
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 45
… retrieving arbitrary values from database …
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
Flexibility #1 - using TypoScript
46
▪ http://…/?name=Oliver
▪ http://…/?name=<script>alert(‘XSS’)</script>
▪ http://…/?name={db:be_users:1:password}
▪ http://…/?name={file:1:contents}
▪ http://…/?name={getenv:PATH}
▪ …
▪ https://docs.typo3.org/m/typo3/reference-typoscript/master/en-
us/DataTypes/Index.html
▪ TypoScript is powerful…
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
“Flexibility”
#2
thanks to TypoScript for non-admins

(Remote Code Execution)
47
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
Flexibility #2 - using TypoScript/TSconfig
48
▪ https://typo3.org/security/advisory/typo3-core-sa-2019-019/
▪ Remote Code Execution using Page TSconfig
▪ access to pages.TSconfig needs to be granted explicitly
▪ addressed on June 25th, 2019
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 49
Page TSconfig assignments for pages
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 50
Page TSconfig supports conditions as well…
TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 51
▪ TYPO3 Security Team needs YOU
▪ core, extension & infrastructure security
▪ GitHub, packagist.org - not only TER
▪ feedback, advise, educate
▪ analyse & hack (PoC)
▪ ask @ohader / oliver@typo3.org
▪ (security reports to security@typo3.org)
TYPO3 Security Team
more?
join T3DD Security Workshop
on Sunday Morning
52
qstns?
53
1 of 53

More Related Content

Similar to Hacking TYPO3 v9 (T3DD19 edition)(20)

44CON Hacking Enterprises44CON Hacking Enterprises
44CON Hacking Enterprises
in.security Ltd.509 views
Jackpot! sbancare un atm con ploutus.dJackpot! sbancare un atm con ploutus.d
Jackpot! sbancare un atm con ploutus.d
Antonio Parata3.3K views
Mitre ATT&CK by Mattias Almeflo NixuMitre ATT&CK by Mattias Almeflo Nixu
Mitre ATT&CK by Mattias Almeflo Nixu
Nixu Corporation1K views
Macro malware   common techniques - publicMacro malware   common techniques - public
Macro malware common techniques - public
Security Bootcamp1.1K views

More from Oliver Hader(12)

Recently uploaded(20)

Hacking TYPO3 v9 (T3DD19 edition)

  • 2. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 2 ▪Research & Development ▪Security Team Lead ▪50% TYPO3 GmbH ▪50% freelance software engineer ▪#hof #cycling #paramedic #in.die.musik ~# whoami Oliver Hader @ohader
  • 3. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 3 ▪ session probably recorded ▪ real attack vectors are shown ▪ hackers probably knew already ▪ official security fixes available ▪ report to security@typo3.org Disclaimer
  • 4. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org Web Application Security Basics 4
  • 5. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org Web Application Security 5 ▪ CIA/compliance triad ▪ confidentiality ▪ private, personal, sensitive information ▪ integrity ▪ manipulation of information (“fake news”) ▪ availability ▪ denial of service ▪ online bank account ▪ blocking information flow https://www.ibm.com/blogs/cloud-computing/2018/01/16/drive-compliance-cloud/
  • 6. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 6 Hacking Playground CONFIDENTIALITY - unauthorised access to information
  • 7. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 7 Hacking Playground INTEGRITY - e.g. manipulated information
  • 8. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 8 Hacking Playground AVAILABILITY - information/service not available
  • 9. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 9 Web Application Security Open Web Application Security Project - TOP 10 vulnerabilities https://www.owasp.org/images/7/72/OWASP_Top_10-2017_%28en%29.pdf.pdf TYPO3 core TYPO3 3rd party extensionsPHP world TYPO3vulnerabilitiesinpast5years
  • 10. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 10 Web Application Security attack chains - multiple components might be affected https://www.owasp.org/images/7/72/OWASP_Top_10-2017_%28en%29.pdf.pdf
  • 12. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 12 Hacking Playground https://github.com/ohader/typo3v9-hack
  • 13. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org Session
 Hi-Jacking thanks to Cross-Site Scripting 13
  • 14. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org Session Hi-Jacking - insecure cookie 14 ▪ https://typo3.org/security/advisory/typo3-core-sa-2018-009/ ▪ Install Tool Cookie did not have HttpOnly flag ▪ addressed on December 11th, 2018
  • 15. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 15 Insecure Install Tool Cookie (HTTP-only flag missing)
  • 16. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 16 … cookies can be read by (any) JavaScript …
  • 17. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org Session Hi-Jacking - cross-site scripting 17 ▪ https://typo3.org/security/advisory/typo3-core-sa-2018-006/ ▪ file.youtube or file.vimeo vulnerable to cross-site scripting ▪ addressed on December 11th, 2018
  • 18. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 18 Session Hi-Jacking - cross-site scripting & insecure cookie Asset.youtube file & JavaScript to be executed
  • 19. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 19 Insecure Deserialization - Basics … social engineering - somebody must click the file …
  • 20. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 20 Insecure Deserialization - Basics strange result & XSS exploitation in background
  • 21. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 21 Session Hi-Jacking - cross-site scripting & insecure cookie view of attacker - retrieving session cookie
  • 22. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org Remote Code
 Execution #1 thanks to Insecure Deserialization 22
  • 23. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 23 Insecure Deserialization - Basics __destruct() or __wakeup() methods are executed on deserialization
  • 24. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 24 Insecure Deserialization - Basics user submitted payload to be deserialized
  • 25. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org Remote Code Execution #1 25 ▪ https://typo3.org/security/advisory/typo3-core-sa-2019-020/ ▪ https://blog.ripstech.com/2019/typo3-overriding-the-database/ ▪ overrideVals[<table>][l10n_diffsource]=<serialized payload> ▪ addressed on June 25th, 2019
  • 26. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 26 Insecure Deserialization - Basics __destruct() saves content to filesystem
  • 27. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 27 Remote Code Execution #1 making use of FileCookieJar as attack container
  • 28. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 28 Remote Code Execution #1 prepare attack against TYPO3 backend
  • 29. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 29 Remote Code Execution #1 actual attack payload that shall be executed
  • 30. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 30 Remote Code Execution #1 XSRF token needs to be know (valid backend user required)
  • 31. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 31 Remote Code Execution #1 output of injected & executed /typo3/hack.php
  • 32. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 32 Remote Code Execution #1 … new admin user h4ck3r31 …
  • 33. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org Remote Code
 Execution #2 thanks to
 Information Disclosure
 & Insecure Deserialization 33
  • 34. typo3conf/ LocalConfiguration.php.old 34TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
  • 35. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 35 typo3conf/LocalConfiguration.php.old backup file
  • 36. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 36 … what else can we find here? (standard configuration)
  • 37. encryptionKey 37TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org
  • 38. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 38 Extbase __trustedProperties deserialisation
  • 39. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 39 HMAC signing of __trustedProperties - based on encryptionKey
  • 40. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 40 Remote Code Execution #2 similar attack using FileCookieJar
  • 41. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 41 Remote Code Execution #2 output of injected & executed /typo3/hack.php
  • 42. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org Okay, but what’s the point?! 42 ▪ When being hacked, update ALL sensitive information ▪ backend user passwords ▪ frontend user password ▪ database credentials ▪ TYPO3 encryption key ▪ private/public key files ▪ …
  • 43. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org “Flexibility” #1 thanks to insecure TypoScript
 (Cross-Site Scripting & SQL Injection) 43
  • 44. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 44 GET/POST data in TypoScript - insertData injection
  • 45. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 45 … retrieving arbitrary values from database …
  • 46. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org Flexibility #1 - using TypoScript 46 ▪ http://…/?name=Oliver ▪ http://…/?name=<script>alert(‘XSS’)</script> ▪ http://…/?name={db:be_users:1:password} ▪ http://…/?name={file:1:contents} ▪ http://…/?name={getenv:PATH} ▪ … ▪ https://docs.typo3.org/m/typo3/reference-typoscript/master/en- us/DataTypes/Index.html ▪ TypoScript is powerful…
  • 47. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org “Flexibility” #2 thanks to TypoScript for non-admins
 (Remote Code Execution) 47
  • 48. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org Flexibility #2 - using TypoScript/TSconfig 48 ▪ https://typo3.org/security/advisory/typo3-core-sa-2019-019/ ▪ Remote Code Execution using Page TSconfig ▪ access to pages.TSconfig needs to be granted explicitly ▪ addressed on June 25th, 2019
  • 49. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 49 Page TSconfig assignments for pages
  • 50. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 50 Page TSconfig supports conditions as well…
  • 51. TYPO3 Developer Days 2019 - Hacking TYPO3 - oliver.hader@typo3.org 51 ▪ TYPO3 Security Team needs YOU ▪ core, extension & infrastructure security ▪ GitHub, packagist.org - not only TER ▪ feedback, advise, educate ▪ analyse & hack (PoC) ▪ ask @ohader / oliver@typo3.org ▪ (security reports to security@typo3.org) TYPO3 Security Team
  • 52. more? join T3DD Security Workshop on Sunday Morning 52