Default to Async
PancakesCon 5, 24/03/2024
Prevent DoS attacks on your app and your day
Allon Mureinik
Senior Manager, Seeker (IAST) Agents R&D, Synopsys
allon.mureinik@synopsys.com
© 2024 Synopsys, Inc. 2
Can we prevent DoS in our apps?
Default to Async (Allon Mureinik, cc-by-sa-4.0)
© 2024 Synopsys, Inc. 3
No, not that kind of DOS
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/save-dos-818218/
© 2024 Synopsys, Inc. 4
This kind of DoS
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/no-service-1496954/
© 2024 Synopsys, Inc. 5
This kind of DoS
“The Denial of Service (DoS) attack is
focused on making a resource (site,
application, server) unavailable for the
purpose it was designed.”
(https://owasp.org/www-community/attacks/Denial_of_Service)
Default to Async (Allon Mureinik, cc-by-sa-4.0)
© 2024 Synopsys, Inc. 6
DDoS – in a different lecture
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/distributed-6001953/
© 2024 Synopsys, Inc. 7
We want to focus on the application
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/application-1249006/
© 2024 Synopsys, Inc. 8
It’s not about speed – it’s about [not] blocking others
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/speed-1116526/
© 2024 Synopsys, Inc. 9
Overwork that parser (JSON Example)
const express = require('express');
const app = express();
app.use(express.json());
app.post('/json', (req, res) => {
const numKeys = Object.keys(req.body).length;
res.end(numKeys + ' keys in the payload');
});
app.listen(3000, () => console.log('Listening on port 3000'));
Default to Async (Allon Mureinik, cc-by-sa-4.0)
© 2024 Synopsys, Inc. 10
How bad is it really?
Default to Async (Allon Mureinik, cc-by-sa-4.0)
-50
0
50
100
150
200
250
300
0 200 400 600 800 1000 1200
Time
(ms)
String Length (KB)
© 2024 Synopsys, Inc. 11
What can we do?
Default to Async (Allon Mureinik, cc-by-sa-4.0)
© 2024 Synopsys, Inc. 12
What can we do?
• Don’t allow tainted input to be parsed
–Not realistic…
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/no-entry-1379330/
© 2024 Synopsys, Inc. 13
What can we do?
• Don’t allow tainted input to be parsed
–Not realistic…
• Limit the size of the input
–E.g., in the above Express example:
app.use(express.json({limit: '40kb'})
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/speed-limit-4873715/
© 2024 Synopsys, Inc. 14
What can we do?
• Don’t allow tainted input to be parsed
–Not realistic…
• Limit the size of the input
–E.g., in the above Express example:
app.use(express.json({limit: '40kb'})
• Do it in the background, not the event loop
–E.g., use a library like BFJ or JSONStream
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/fade-2102225/
© 2024 Synopsys, Inc. 15
Bomb that parser (XML Example)
Default to Async (Allon Mureinik, cc-by-sa-4.0)
const express = require('express');
const app = express();
app.use(express.text({type: '*/*'}));
const libxmljs = require('libxmljs2');
const opts = {noent: true, nocdata: true, noblanks: true, huge: true};
app.post('/xml', (req, res) => {
const parsed = libxmljs.parseXml(req.body, opts);
res.end(parsed.childNodes().length + ' child nodes in the payload');
});
app.listen(3000, () => console.log('Listening on port 3000'));
© 2024 Synopsys, Inc. 16
Sounds serious, let’s have a laugh
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/joker-3976603/
© 2024 Synopsys, Inc. 17
Or a billion laughs
<?xml version="1.0"?>
<!DOCTYPE lolz [
<!ENTITY lol0 "lol">
<!ELEMENT lolz (#PCDATA)>
<!ENTITY lol1 "&lol0;&lol0;&lol0;&lol0;&lol0;&lol0;&lol0;&lol0;&lol0;&lol0;">
<!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
<!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">
<!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">
<!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">
<!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">
<!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">
]>
<lolz>&lol9;</lolz>
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://en.wikipedia.org/wiki/Billion_laughs_attack
© 2024 Synopsys, Inc. 18
How bad is it really?
Default to Async (Allon Mureinik, cc-by-sa-4.0)
0
5
10
15
20
25
30
35
1 2 3 4 5 6 7
Size
(MB)
# Lolz
XML Expansion per Lol
XML Length Expanded Length
~650b
~29MB
© 2024 Synopsys, Inc. 19
What can we do?
Default to Async (Allon Mureinik, cc-by-sa-4.0)
© 2024 Synopsys, Inc. 20
What can we do?
• Don’t use XML
–If you can…
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/no-entry-1379330/
© 2024 Synopsys, Inc. 21
What can we do?
• Don’t use XML
–If you can…
• Don’t allow tainted input in your XML
–If you can…
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/no-entry-1379330/
© 2024 Synopsys, Inc. 22
What can we do?
• Don’t use XML
–If you can…
• Don’t allow tainted input in your XML
–If you can…
•Configure your library to not expand entities
–If you can…
–libxml wrappers:{noent: false} or {huge: false}
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/configure-1883381/
© 2024 Synopsys, Inc. 23
What can we do?
• Don’t use XML
–If you can…
• Don’t allow tainted input in your XML
–If you can…
•Configure your library to not expand entities
–If you can…
–libxml wrappers:{noent: false} or {huge: false}
•Sanitize your input
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/sanitizer-3470901/
© 2024 Synopsys, Inc. 24
ReDoS
const express = require('express');
const app = express();
app.get('/regexp', (req, res) => {
// Consider a regex like /(a+)+/
const regexp = new RegExp(req.query.regexp);
const text = req.query.text;
res.end(regexp.test(text) ? 'Match!' : 'No match');
});
app.listen(3000, () => console.log('Listening on port 3000'));
Default to Async (Allon Mureinik, cc-by-sa-4.0)
© 2024 Synopsys, Inc. 25
How bad is it really?
Default to Async (Allon Mureinik, cc-by-sa-4.0)
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
© 2024 Synopsys, Inc. 26
What can we do?
Default to Async (Allon Mureinik, cc-by-sa-4.0)
© 2024 Synopsys, Inc. 27
What can we do?
• Check your regexes
– SAST tools are usually pretty good at this
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/check-1159941/
© 2024 Synopsys, Inc. 28
What can we do?
• Check your regexes
– SAST tools are usually pretty good at this
• Don’t allow tainted input as regex
– Not always possible…
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/no-entry-1379330/
© 2024 Synopsys, Inc. 29
What can we do?
• Check your regexes
– SAST tools are usually pretty good at this
• Don’t allow tainted input as regex
– Not always possible…
• Don’t allow tainted input to be evaluated by a dodgy regex
– Usually not possible…
– Use length limits
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/no-entry-1379330/
© 2024 Synopsys, Inc. 30
What can we do?
• Check your regexes
– SAST tools are usually pretty good at this
• Don’t allow tainted input as regex
– Not always possible…
• Don’t allow tainted input to be evaluated by a dodgy regex
– Usually not possible…
– Use length limits
• Think about alternatives to regex
– re2 isn’t vulnerable to ReDoS
– Use specific tools for specific needs (e.g., validator.js)
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/alternative-3203434/
© 2024 Synopsys, Inc. 31
Some general take aways
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/takeaway-3438027/
© 2024 Synopsys, Inc. 32
Can we prevent DoS in our day?
Default to Async (Allon Mureinik, cc-by-sa-4.0)
© 2024 Synopsys, Inc. 33
“Let’s have a meeting”
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/meeting-6528201/
© 2024 Synopsys, Inc. 34
You need to fit it in your day
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/fit-4584641/
© 2024 Synopsys, Inc. 35
Limited time == limited communication
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/time-limit-4456645/
© 2024 Synopsys, Inc. 36
It’s exclusionary
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/racism-4670344/
© 2024 Synopsys, Inc. 37
The timezone problem
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/timezone-5429333/
© 2024 Synopsys, Inc. 38
The language problem
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/language-3786977/
© 2024 Synopsys, Inc. 39
The like-me problem
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/similar-3856992/
© 2024 Synopsys, Inc. 40
The solution – default to async
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/icon/asynchronous-learning-27462/
© 2024 Synopsys, Inc. 41
Don’t be a
stranger
allon.mureinik@synopsys.com
@mureinik
https://www.linkedin.com/in/mureinik/
Default to Async (Allon Mureinik, cc-by-sa-4.0)
© 2024 Synopsys, Inc. 42
Questions
Default to Async (Allon Mureinik, cc-by-sa-4.0)
https://thenounproject.com/term/questions/1195076/

More Related Content

PDF
This DoS goes loop-di-loop
PDF
Webinar–OWASP Top 10 for JavaScript for Developers
PDF
OWASP Portland - OWASP Top 10 For JavaScript Developers
PPTX
20160211 OWASP Charlotte RASP
PPTX
Dont run with scissors
PPTX
20160225 OWASP Atlanta Prevoty RASP
PDF
Neoito — Secure coding practices
PDF
ruxc0n 2012
This DoS goes loop-di-loop
Webinar–OWASP Top 10 for JavaScript for Developers
OWASP Portland - OWASP Top 10 For JavaScript Developers
20160211 OWASP Charlotte RASP
Dont run with scissors
20160225 OWASP Atlanta Prevoty RASP
Neoito — Secure coding practices
ruxc0n 2012

Similar to Default to Async - Prevent DoS attacks on your app and your day (20)

PDF
Technical Architecture of RASP Technology
PPTX
Lightweight Self-Protecting JavaScript
PPTX
Banfootguns devseccon 2019
PDF
AppSec Tel Aviv - OWASP Top 10 For JavaScript Developers
PPTX
Lightweight Self-Protecting JavaScript
PDF
Serverless Security Guy Podjarny Liran Tal
PPTX
Web security-–-everything-we-know-is-wrong-eoin-keary
PDF
Introduction to node.js by Ran Mizrahi @ Reversim Summit
ODP
Node.js security
PDF
Locking the Throne Room - How ES5+ might change views on XSS and Client Side ...
PDF
Top 10 Security Vulnerabilities (2006)
PDF
Defensive programming in Javascript and Node.js
PDF
Intro to node.js - Ran Mizrahi (27/8/2014)
PDF
Intro to node.js - Ran Mizrahi (28/8/14)
PDF
50 common web developer interview questions [2020 updated] [www.full stack....
PDF
Locking the Throneroom 2.0
PPTX
Defensive programming
PPTX
My Little Webap - DevOpsSec is Magic
PPTX
DevBeat 2013 - Developer-first Security
Technical Architecture of RASP Technology
Lightweight Self-Protecting JavaScript
Banfootguns devseccon 2019
AppSec Tel Aviv - OWASP Top 10 For JavaScript Developers
Lightweight Self-Protecting JavaScript
Serverless Security Guy Podjarny Liran Tal
Web security-–-everything-we-know-is-wrong-eoin-keary
Introduction to node.js by Ran Mizrahi @ Reversim Summit
Node.js security
Locking the Throne Room - How ES5+ might change views on XSS and Client Side ...
Top 10 Security Vulnerabilities (2006)
Defensive programming in Javascript and Node.js
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (28/8/14)
50 common web developer interview questions [2020 updated] [www.full stack....
Locking the Throneroom 2.0
Defensive programming
My Little Webap - DevOpsSec is Magic
DevBeat 2013 - Developer-first Security
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
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Developing a website for English-speaking practice to English as a foreign la...
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Architecture types and enterprise applications.pdf
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
Consumable AI The What, Why & How for Small Teams.pdf
DOCX
search engine optimization ppt fir known well about this
PPT
What is a Computer? Input Devices /output devices
PPTX
Benefits of Physical activity for teenagers.pptx
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PPTX
Microsoft Excel 365/2024 Beginner's training
PPTX
The various Industrial Revolutions .pptx
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
STKI Israel Market Study 2025 version august
PPTX
Chapter 5: Probability Theory and Statistics
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PPT
Geologic Time for studying geology for geologist
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PPTX
2018-HIPAA-Renewal-Training for executives
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Zenith AI: Advanced Artificial Intelligence
Developing a website for English-speaking practice to English as a foreign la...
Final SEM Unit 1 for mit wpu at pune .pptx
Architecture types and enterprise applications.pdf
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Consumable AI The What, Why & How for Small Teams.pdf
search engine optimization ppt fir known well about this
What is a Computer? Input Devices /output devices
Benefits of Physical activity for teenagers.pptx
Custom Battery Pack Design Considerations for Performance and Safety
Microsoft Excel 365/2024 Beginner's training
The various Industrial Revolutions .pptx
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
STKI Israel Market Study 2025 version august
Chapter 5: Probability Theory and Statistics
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
Geologic Time for studying geology for geologist
NewMind AI Weekly Chronicles – August ’25 Week III
2018-HIPAA-Renewal-Training for executives

Default to Async - Prevent DoS attacks on your app and your day

  • 1. Default to Async PancakesCon 5, 24/03/2024 Prevent DoS attacks on your app and your day Allon Mureinik Senior Manager, Seeker (IAST) Agents R&D, Synopsys allon.mureinik@synopsys.com
  • 2. © 2024 Synopsys, Inc. 2 Can we prevent DoS in our apps? Default to Async (Allon Mureinik, cc-by-sa-4.0)
  • 3. © 2024 Synopsys, Inc. 3 No, not that kind of DOS Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/save-dos-818218/
  • 4. © 2024 Synopsys, Inc. 4 This kind of DoS Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/no-service-1496954/
  • 5. © 2024 Synopsys, Inc. 5 This kind of DoS “The Denial of Service (DoS) attack is focused on making a resource (site, application, server) unavailable for the purpose it was designed.” (https://owasp.org/www-community/attacks/Denial_of_Service) Default to Async (Allon Mureinik, cc-by-sa-4.0)
  • 6. © 2024 Synopsys, Inc. 6 DDoS – in a different lecture Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/distributed-6001953/
  • 7. © 2024 Synopsys, Inc. 7 We want to focus on the application Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/application-1249006/
  • 8. © 2024 Synopsys, Inc. 8 It’s not about speed – it’s about [not] blocking others Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/speed-1116526/
  • 9. © 2024 Synopsys, Inc. 9 Overwork that parser (JSON Example) const express = require('express'); const app = express(); app.use(express.json()); app.post('/json', (req, res) => { const numKeys = Object.keys(req.body).length; res.end(numKeys + ' keys in the payload'); }); app.listen(3000, () => console.log('Listening on port 3000')); Default to Async (Allon Mureinik, cc-by-sa-4.0)
  • 10. © 2024 Synopsys, Inc. 10 How bad is it really? Default to Async (Allon Mureinik, cc-by-sa-4.0) -50 0 50 100 150 200 250 300 0 200 400 600 800 1000 1200 Time (ms) String Length (KB)
  • 11. © 2024 Synopsys, Inc. 11 What can we do? Default to Async (Allon Mureinik, cc-by-sa-4.0)
  • 12. © 2024 Synopsys, Inc. 12 What can we do? • Don’t allow tainted input to be parsed –Not realistic… Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/no-entry-1379330/
  • 13. © 2024 Synopsys, Inc. 13 What can we do? • Don’t allow tainted input to be parsed –Not realistic… • Limit the size of the input –E.g., in the above Express example: app.use(express.json({limit: '40kb'}) Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/speed-limit-4873715/
  • 14. © 2024 Synopsys, Inc. 14 What can we do? • Don’t allow tainted input to be parsed –Not realistic… • Limit the size of the input –E.g., in the above Express example: app.use(express.json({limit: '40kb'}) • Do it in the background, not the event loop –E.g., use a library like BFJ or JSONStream Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/fade-2102225/
  • 15. © 2024 Synopsys, Inc. 15 Bomb that parser (XML Example) Default to Async (Allon Mureinik, cc-by-sa-4.0) const express = require('express'); const app = express(); app.use(express.text({type: '*/*'})); const libxmljs = require('libxmljs2'); const opts = {noent: true, nocdata: true, noblanks: true, huge: true}; app.post('/xml', (req, res) => { const parsed = libxmljs.parseXml(req.body, opts); res.end(parsed.childNodes().length + ' child nodes in the payload'); }); app.listen(3000, () => console.log('Listening on port 3000'));
  • 16. © 2024 Synopsys, Inc. 16 Sounds serious, let’s have a laugh Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/joker-3976603/
  • 17. © 2024 Synopsys, Inc. 17 Or a billion laughs <?xml version="1.0"?> <!DOCTYPE lolz [ <!ENTITY lol0 "lol"> <!ELEMENT lolz (#PCDATA)> <!ENTITY lol1 "&lol0;&lol0;&lol0;&lol0;&lol0;&lol0;&lol0;&lol0;&lol0;&lol0;"> <!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;"> <!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;"> <!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;"> <!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;"> <!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;"> <!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;"> <!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;"> <!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;"> ]> <lolz>&lol9;</lolz> Default to Async (Allon Mureinik, cc-by-sa-4.0) https://en.wikipedia.org/wiki/Billion_laughs_attack
  • 18. © 2024 Synopsys, Inc. 18 How bad is it really? Default to Async (Allon Mureinik, cc-by-sa-4.0) 0 5 10 15 20 25 30 35 1 2 3 4 5 6 7 Size (MB) # Lolz XML Expansion per Lol XML Length Expanded Length ~650b ~29MB
  • 19. © 2024 Synopsys, Inc. 19 What can we do? Default to Async (Allon Mureinik, cc-by-sa-4.0)
  • 20. © 2024 Synopsys, Inc. 20 What can we do? • Don’t use XML –If you can… Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/no-entry-1379330/
  • 21. © 2024 Synopsys, Inc. 21 What can we do? • Don’t use XML –If you can… • Don’t allow tainted input in your XML –If you can… Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/no-entry-1379330/
  • 22. © 2024 Synopsys, Inc. 22 What can we do? • Don’t use XML –If you can… • Don’t allow tainted input in your XML –If you can… •Configure your library to not expand entities –If you can… –libxml wrappers:{noent: false} or {huge: false} Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/configure-1883381/
  • 23. © 2024 Synopsys, Inc. 23 What can we do? • Don’t use XML –If you can… • Don’t allow tainted input in your XML –If you can… •Configure your library to not expand entities –If you can… –libxml wrappers:{noent: false} or {huge: false} •Sanitize your input Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/sanitizer-3470901/
  • 24. © 2024 Synopsys, Inc. 24 ReDoS const express = require('express'); const app = express(); app.get('/regexp', (req, res) => { // Consider a regex like /(a+)+/ const regexp = new RegExp(req.query.regexp); const text = req.query.text; res.end(regexp.test(text) ? 'Match!' : 'No match'); }); app.listen(3000, () => console.log('Listening on port 3000')); Default to Async (Allon Mureinik, cc-by-sa-4.0)
  • 25. © 2024 Synopsys, Inc. 25 How bad is it really? Default to Async (Allon Mureinik, cc-by-sa-4.0) 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
  • 26. © 2024 Synopsys, Inc. 26 What can we do? Default to Async (Allon Mureinik, cc-by-sa-4.0)
  • 27. © 2024 Synopsys, Inc. 27 What can we do? • Check your regexes – SAST tools are usually pretty good at this Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/check-1159941/
  • 28. © 2024 Synopsys, Inc. 28 What can we do? • Check your regexes – SAST tools are usually pretty good at this • Don’t allow tainted input as regex – Not always possible… Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/no-entry-1379330/
  • 29. © 2024 Synopsys, Inc. 29 What can we do? • Check your regexes – SAST tools are usually pretty good at this • Don’t allow tainted input as regex – Not always possible… • Don’t allow tainted input to be evaluated by a dodgy regex – Usually not possible… – Use length limits Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/no-entry-1379330/
  • 30. © 2024 Synopsys, Inc. 30 What can we do? • Check your regexes – SAST tools are usually pretty good at this • Don’t allow tainted input as regex – Not always possible… • Don’t allow tainted input to be evaluated by a dodgy regex – Usually not possible… – Use length limits • Think about alternatives to regex – re2 isn’t vulnerable to ReDoS – Use specific tools for specific needs (e.g., validator.js) Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/alternative-3203434/
  • 31. © 2024 Synopsys, Inc. 31 Some general take aways Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/takeaway-3438027/
  • 32. © 2024 Synopsys, Inc. 32 Can we prevent DoS in our day? Default to Async (Allon Mureinik, cc-by-sa-4.0)
  • 33. © 2024 Synopsys, Inc. 33 “Let’s have a meeting” Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/meeting-6528201/
  • 34. © 2024 Synopsys, Inc. 34 You need to fit it in your day Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/fit-4584641/
  • 35. © 2024 Synopsys, Inc. 35 Limited time == limited communication Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/time-limit-4456645/
  • 36. © 2024 Synopsys, Inc. 36 It’s exclusionary Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/racism-4670344/
  • 37. © 2024 Synopsys, Inc. 37 The timezone problem Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/timezone-5429333/
  • 38. © 2024 Synopsys, Inc. 38 The language problem Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/language-3786977/
  • 39. © 2024 Synopsys, Inc. 39 The like-me problem Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/similar-3856992/
  • 40. © 2024 Synopsys, Inc. 40 The solution – default to async Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/icon/asynchronous-learning-27462/
  • 41. © 2024 Synopsys, Inc. 41 Don’t be a stranger allon.mureinik@synopsys.com @mureinik https://www.linkedin.com/in/mureinik/ Default to Async (Allon Mureinik, cc-by-sa-4.0)
  • 42. © 2024 Synopsys, Inc. 42 Questions Default to Async (Allon Mureinik, cc-by-sa-4.0) https://thenounproject.com/term/questions/1195076/