This DoS Goes Loop-di-Loop
Allon Mureinik
Senior Manager, Seeker Node.js and .NET Agents
Synopsys, Inc.
allon.mureinik@synopsys.com / @mureinik / https://www.linkedin.com/in/mureinik/
FlawCon, 20/10/2019
© 2019 Synopsys, Inc. 2This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0)
Developers vs Hackers
How will an
unreasonable person
abuse it?
How will a
reasonable person
use it?
https://thenounproject.com/term/theater/17128
© 2019 Synopsys, Inc. 3This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0)
Quick Reminder: Node.js’ Event Loop
https://thenounproject.com/term/redo/62716
© 2019 Synopsys, Inc. 4This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0)
Benchmarks
https://www.tandemseven.com/blog/performance-java-vs-node/
© 2019 Synopsys, Inc. 5This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0)
Reminder: Denial of Service (DoS)
https://thenounproject.com/term/decline/373722
© 2019 Synopsys, Inc. 6This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0)
Regex DoS (ReDoS)
console.log('a'sttime');
let regex = new RegExp('^(a+)+$');
for (let i = 1; i < 100; ++i) {
const str = Array(i + 1).join('a') + 'b';
const before = new Date();
regex.test(str);
const after = new Date();
const time = after - before;
console.log(`${i}t${time}`);
}
© 2019 Synopsys, Inc. 7This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0)
Regex DoS (ReDoS) - results
0
50,000
100,000
150,000
200,000
250,000
300,000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 33 34 35
Time(ms)
As
© 2019 Synopsys, Inc. 8This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0)
https://thenounproject.com/term/alternative-route/2902159
•Check your regexes
–E.g., use safe-regex, vuln-regex-detector
•Don’t allow tainted input as regex
–Not always possible…
–If you must, sanitize it (again safe-regex etc.)
•Don’t allow tainted input to be evaluated by a dodgy regex
–Usually not possible…
–Use length limits
•Think about alternative solutions
–re2 isn’t vulnerable to ReDoS
–Use specific tools for specific needs (e.g., validator.js)
Regex DoS (ReDoS) - Remediation
© 2019 Synopsys, Inc. 9This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0)
JSON DoS
for (let i = 1024; i <= 1024 * 1024 ; i += 1024) {
const str = '"' + Array(i + 1).join('a') + '"';
const before = new Date();
for (let j = 1; j < 100; ++j) {
JSON.parse(str);
}
const after = new Date();
console.log(`${i}t${after-before}`);
}
© 2019 Synopsys, Inc. 10This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0)
JSON DoS - Results
-50
0
50
100
150
200
250
300
0 200 400 600 800 1000 1200
Time(ms)
String Lengh (KB)
© 2019 Synopsys, Inc. 11This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0)
https://thenounproject.com/term/alternative-route/2902159/
•Don’t allow tainted input to be parsed
–Not realistic…
•Limit the size of the input
–Express: app.use(express.json({limit: '50kb'})
–Hapi: route.options.payload.maxBytes = 50 * 1024
•If you aren’t parsing JSON by a middle, consider alternative
libraries like BFJ or JSONStream
JSON DoS - Remediation
© 2019 Synopsys, Inc. 12This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0)
“If anything can hang, it will”
- Murphy’s law of storage
Storage (I/O) DoS
© 2019 Synopsys, Inc. 13This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0)
The are two ways to perform storage operations in Node.js:
1. The async way
–Delegate a storage operation to the kernel, and wait for a callback
–E.g.: fs.readDir, fs.writeFile, etc
–3rd parties follow similar patterns (e.g., fs-extra, adm-zip)
2. The wrong way
Storage (I/O) DoS - Remediation
© 2019 Synopsys, Inc. 15This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0)
Questions?
https://thenounproject.com/term/questions/1195076/
Thank You
Contact
allon.mureinik@synopsys.com
@mureinik
https://www.linkedin.com/in/mureinik/

More Related Content

PDF
Default to Async - Prevent DoS attacks on your app and your day
PDF
Node.js Security - XSS, Vulnerable Dependencies, Snyk, OWASP
PDF
Node.js security - JS Day Italy 2018
PDF
Douglas Crockford: Serversideness
PDF
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
ODP
Node.js security
PDF
ES6: The Awesome Parts
PDF
Killer Bugs From Outer Space
Default to Async - Prevent DoS attacks on your app and your day
Node.js Security - XSS, Vulnerable Dependencies, Snyk, OWASP
Node.js security - JS Day Italy 2018
Douglas Crockford: Serversideness
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Node.js security
ES6: The Awesome Parts
Killer Bugs From Outer Space

Similar to This DoS goes loop-di-loop (20)

PDF
Fault Tolerance 101
ODP
DevOps Days Vancouver 2014 Slides
PDF
Ch 18: Source Code Auditing
PDF
Defensive programming in Javascript and Node.js
PDF
AppSec Tel Aviv - OWASP Top 10 For JavaScript Developers
PDF
Angus Fletcher - Error Handling in Concurrent Systems
PDF
Promises generatorscallbacks
PPTX
Node.js - Advanced Basics
PDF
Think Async: Asynchronous Patterns in NodeJS
PPTX
introduction to node.js
PDF
Rust and the coming age of high integrity languages
PDF
Kamil witecki asynchronous, yet readable, code
PPT
Clojure's take on concurrency
PDF
CNIT 127: Ch 18: Source Code Auditing
PPTX
20160211 OWASP Charlotte RASP
PDF
Matthew Eernisse, NodeJs, .toster {webdev}
PPTX
Workshop 1: Good practices in JavaScript
PPTX
Reflections on Rousting Rust?
KEY
NodeJS
PDF
The Evolution of Async-Programming (SD 2.0, JavaScript)
Fault Tolerance 101
DevOps Days Vancouver 2014 Slides
Ch 18: Source Code Auditing
Defensive programming in Javascript and Node.js
AppSec Tel Aviv - OWASP Top 10 For JavaScript Developers
Angus Fletcher - Error Handling in Concurrent Systems
Promises generatorscallbacks
Node.js - Advanced Basics
Think Async: Asynchronous Patterns in NodeJS
introduction to node.js
Rust and the coming age of high integrity languages
Kamil witecki asynchronous, yet readable, code
Clojure's take on concurrency
CNIT 127: Ch 18: Source Code Auditing
20160211 OWASP Charlotte RASP
Matthew Eernisse, NodeJs, .toster {webdev}
Workshop 1: Good practices in JavaScript
Reflections on Rousting Rust?
NodeJS
The Evolution of Async-Programming (SD 2.0, JavaScript)
Ad

More from Allon Mureinik (20)

PDF
Who Watches the Watchmen (SciFiDevCon 2025)
PDF
Injustice - Developers Among Us (SciFiDevCon 2024)
PDF
What an episode of Rick and Morty taught me about (accidental) toxicity
PDF
We are the Borg, you will be interviewed
PDF
What I wish I knew about security - Allon Mureinik DevConf.CZ 2022
PDF
Somebody set up us the bomb DevConf.CZ 2022 Lightning Talk
PDF
Zoom out
PDF
Cognitive biases, blind spots and inclusion
PDF
How open source made me a better manager
PDF
Automatic for the People
PDF
Automatic for the people
PDF
Mockito - How a mocking library built a real community
PDF
Mockito - how a mocking library built a real community (August Penguin 2017)
PDF
Reversim Summit 2016 - Ja-WAT
PDF
Virtualization Management The oVirt Way (August Penguin 2015)
PDF
Step by Step - Reusing old features to build new ones
PDF
oVirt 3.5 Storage Features Overview
PDF
Disaster Recovery Strategies Using oVirt's new Storage Connection Management ...
PDF
Live Storage Migration in oVirt (Open Storage Meetup May 2013)
PDF
Retro Testing (DevConTLV Jan 2014)
Who Watches the Watchmen (SciFiDevCon 2025)
Injustice - Developers Among Us (SciFiDevCon 2024)
What an episode of Rick and Morty taught me about (accidental) toxicity
We are the Borg, you will be interviewed
What I wish I knew about security - Allon Mureinik DevConf.CZ 2022
Somebody set up us the bomb DevConf.CZ 2022 Lightning Talk
Zoom out
Cognitive biases, blind spots and inclusion
How open source made me a better manager
Automatic for the People
Automatic for the people
Mockito - How a mocking library built a real community
Mockito - how a mocking library built a real community (August Penguin 2017)
Reversim Summit 2016 - Ja-WAT
Virtualization Management The oVirt Way (August Penguin 2015)
Step by Step - Reusing old features to build new ones
oVirt 3.5 Storage Features Overview
Disaster Recovery Strategies Using oVirt's new Storage Connection Management ...
Live Storage Migration in oVirt (Open Storage Meetup May 2013)
Retro Testing (DevConTLV Jan 2014)
Ad

Recently uploaded (20)

PDF
E-Commerce Website Development Companyin india
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PPTX
Tech Workshop Escape Room Tech Workshop
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
PPTX
Matchmaking for JVMs: How to Pick the Perfect GC Partner
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PPTX
Airline CRS | Airline CRS Systems | CRS System
PDF
AI Guide for Business Growth - Arna Softech
PDF
Microsoft Office 365 Crack Download Free
PPTX
Computer Software - Technology and Livelihood Education
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PPTX
MLforCyber_MLDataSetsandFeatures_Presentation.pptx
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PPTX
GSA Content Generator Crack (2025 Latest)
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PDF
Visual explanation of Dijkstra's Algorithm using Python
E-Commerce Website Development Companyin india
How to Use SharePoint as an ISO-Compliant Document Management System
Tech Workshop Escape Room Tech Workshop
Salesforce Agentforce AI Implementation.pdf
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
Matchmaking for JVMs: How to Pick the Perfect GC Partner
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
DNT Brochure 2025 – ISV Solutions @ D365
Airline CRS | Airline CRS Systems | CRS System
AI Guide for Business Growth - Arna Softech
Microsoft Office 365 Crack Download Free
Computer Software - Technology and Livelihood Education
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
MLforCyber_MLDataSetsandFeatures_Presentation.pptx
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
GSA Content Generator Crack (2025 Latest)
Topaz Photo AI Crack New Download (Latest 2025)
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
Visual explanation of Dijkstra's Algorithm using Python

This DoS goes loop-di-loop

  • 1. This DoS Goes Loop-di-Loop Allon Mureinik Senior Manager, Seeker Node.js and .NET Agents Synopsys, Inc. allon.mureinik@synopsys.com / @mureinik / https://www.linkedin.com/in/mureinik/ FlawCon, 20/10/2019
  • 2. © 2019 Synopsys, Inc. 2This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0) Developers vs Hackers How will an unreasonable person abuse it? How will a reasonable person use it? https://thenounproject.com/term/theater/17128
  • 3. © 2019 Synopsys, Inc. 3This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0) Quick Reminder: Node.js’ Event Loop https://thenounproject.com/term/redo/62716
  • 4. © 2019 Synopsys, Inc. 4This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0) Benchmarks https://www.tandemseven.com/blog/performance-java-vs-node/
  • 5. © 2019 Synopsys, Inc. 5This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0) Reminder: Denial of Service (DoS) https://thenounproject.com/term/decline/373722
  • 6. © 2019 Synopsys, Inc. 6This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0) Regex DoS (ReDoS) console.log('a'sttime'); let regex = new RegExp('^(a+)+$'); for (let i = 1; i < 100; ++i) { const str = Array(i + 1).join('a') + 'b'; const before = new Date(); regex.test(str); const after = new Date(); const time = after - before; console.log(`${i}t${time}`); }
  • 7. © 2019 Synopsys, Inc. 7This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0) Regex DoS (ReDoS) - results 0 50,000 100,000 150,000 200,000 250,000 300,000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 33 34 35 Time(ms) As
  • 8. © 2019 Synopsys, Inc. 8This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0) https://thenounproject.com/term/alternative-route/2902159 •Check your regexes –E.g., use safe-regex, vuln-regex-detector •Don’t allow tainted input as regex –Not always possible… –If you must, sanitize it (again safe-regex etc.) •Don’t allow tainted input to be evaluated by a dodgy regex –Usually not possible… –Use length limits •Think about alternative solutions –re2 isn’t vulnerable to ReDoS –Use specific tools for specific needs (e.g., validator.js) Regex DoS (ReDoS) - Remediation
  • 9. © 2019 Synopsys, Inc. 9This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0) JSON DoS for (let i = 1024; i <= 1024 * 1024 ; i += 1024) { const str = '"' + Array(i + 1).join('a') + '"'; const before = new Date(); for (let j = 1; j < 100; ++j) { JSON.parse(str); } const after = new Date(); console.log(`${i}t${after-before}`); }
  • 10. © 2019 Synopsys, Inc. 10This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0) JSON DoS - Results -50 0 50 100 150 200 250 300 0 200 400 600 800 1000 1200 Time(ms) String Lengh (KB)
  • 11. © 2019 Synopsys, Inc. 11This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0) https://thenounproject.com/term/alternative-route/2902159/ •Don’t allow tainted input to be parsed –Not realistic… •Limit the size of the input –Express: app.use(express.json({limit: '50kb'}) –Hapi: route.options.payload.maxBytes = 50 * 1024 •If you aren’t parsing JSON by a middle, consider alternative libraries like BFJ or JSONStream JSON DoS - Remediation
  • 12. © 2019 Synopsys, Inc. 12This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0) “If anything can hang, it will” - Murphy’s law of storage Storage (I/O) DoS
  • 13. © 2019 Synopsys, Inc. 13This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0) The are two ways to perform storage operations in Node.js: 1. The async way –Delegate a storage operation to the kernel, and wait for a callback –E.g.: fs.readDir, fs.writeFile, etc –3rd parties follow similar patterns (e.g., fs-extra, adm-zip) 2. The wrong way Storage (I/O) DoS - Remediation
  • 14. © 2019 Synopsys, Inc. 15This DoS Goes Loop-di-Loop (Allon Mureinik, FlawCon 2019, cc-by-sa-4.0) Questions? https://thenounproject.com/term/questions/1195076/