SlideShare a Scribd company logo
Node.js Security:
Breaking The Loop
Liran Tal
Engineering Manager @ Nielsen Marketing Cloud
March 2017
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
The Magical 2010
The Magical 2010
Backbone.js
Underscore.js
AngularJS
Knockout.js
Node.js
npm
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Node.JS is JavaScript

JavaScript is Everywhere
Security Horror Stories

in Node.JS
Fail #1
By January 2015
◇ rimrafall package published to npm
rimrafall
◇ npm pre-install script
$ rm –rf /*
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Fail #2
validator.js
◇ helps validate and sanitize strings
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
$ npm install validator.js --save
validator.js

!=

validator
malicious modules of similar names
3,500,000 socket.io
2,000 socketio
malicious modules of similar names
Fail #3
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
seemingly innocent tutorial to learn from
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Node.js

Security Mindset
Essential Node.js Security
https://leanpub.com/nodejssecurity/c/jsheroes
Security by HTTP Headers1
The Big 3
The Big 3
1. Strict-Transport-Security
2. X-Frame-Options
3. Content-Security-Policy
The Big 3
1. Strict-Transport-Security
The Big 3
Browsers enforce secure
(HTTPS) connections to the
server
Security by HTTP Headers
1. Strict-Transport-Security
The Big 3
http://www.bank.com
<a href=“https://bank.com/login">
http://www.bank.com/login
Security by HTTP Headers
1. Strict-Transport-Security
The Big 3
http://www.bank.com
https://www.bank.com
Security by HTTP Headers
2. X-Frame-Options
The Big 3
Clickjacking (User Interface redress attack,
UI redress attack, UI redressing) is a
malicious technique of tricking a Web user
into clicking on something different from
what the user perceives they are clicking on
Security by HTTP Headers
2. X-Frame-Options
The Big 3
Security by HTTP Headers
2. X-Frame-Options
The Big 3
Security by HTTP Headers
3. Content-Security-Policy
The Big 3
Whitelist Trusted Content
Security by HTTP Headers
3. Content-Security-Policy
The Big 3
Whitelist Trusted Content
Security by HTTP Headers
1. Strict-Transport-Security
2. X-Frame-Options
3. Content-Security-Policy
The Big 3
Security by HTTP Headers
1. Strict-Transport-Security
2. X-Frame-Options
3. Content-Security-Policy
The Big 3
Security by HTTP Headers
Helmet
Securing ExpressJS
Putting it all
together

with Helmet and
ExpressJS
2 noSQL Injections
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
What is going on here?
No HTTP body in ExpressJS
it relies on bodyParser
lib
ExpressJS uses
bodyParser
library to
access HTTP
body payload
ExpressJS uses
bodyParser
library to
access HTTP
body payload
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Validate Input
◇ Validate Length and Type
◇ Validate & Sanitize input to expected
type
◇ Parameters Binding
◇ Security in Depth
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
ReDoS
3 Regular Expressions DoS
Regular Expressions
• ^([01]?dd?|2[0-4]d|25[0-5]).([01]?d
d?|2[0-4]d|25[0-5]).([01]?dd?|
2[0-4]d|25[0-5]).([01]?dd?|2[0-4]d|
25[0-5])$
Matching an IP address
• ^([01]?dd?|2[0-4]d|25[0-5]).([01]?d
d?|2[0-4]d|25[0-5]).([01]?dd?|
2[0-4]d|25[0-5]).([01]?dd?|2[0-4]d|
25[0-5])$
Let’s Match Song Titles
Can you help with the regex?
^([a-zA-Z0-9])$
• Match words and numbers
^([a-zA-Z0-9]+s?)$
• Match words and numbers
• Allow spaces in between (duh)
^([a-zA-Z0-9]+s?)+$
• Match words and numbers
• Allow spaces in between (duh)
• Repeat
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
ReDoS Attacks
◇ Catastrophic Backtracking
◇ Exploits greedy quantifiers
◇ Simple regex are vulnerable too:

/^(a+)+$/
Regex DoS is a Real Problem
◇2017 - ms
◇2016 - Hawk
◇2016 - Tough Cookie
◇2016 - Moment
◇2015 - Uglify
◇2014 - Marked
◇2013 - Validator.js
Regex Best Practices?
University of Birmingham UK
http://www.cs.bham.ac.uk/~hxt/research/reg-exp-sec.pdf
Best Practice #1
◇ DO NOT WRITE YOUR OWN REGEX
Best Practice #2
◇ DO NOT WRITE YOUR OWN REGEX
Best Practice #3
◇Validator Node.js Module
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Best Practice #4
◇ safe-regex node.js module
◇ checks regex complexity/backtracking
vulnerability
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Secure Dependencies
Management
4
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
Are my dependencies
vulnerable?
ask yourself
Secure Dependencies
Management
Snyk
Cluj JSHeroes 2017 - Liran Tal on Node.js Security
snyk
◇ check cve db for known issues
◇ check installed node_modules dir
◇ provides patch-level fix
◇ provides interactive patch wizard
SecurityOps
Integrated Security into your

build pipeline
1
2
3
Employ Secure HTTP headers with Helmet
Be mindful to NoSQL Injections
Summary
4 Snyk to secure Your npm
dependencies
Avoid writing your own RegEx
Thank you!
liran.tal@nielsen.com
@liran_tal
https://leanpub.com/nodejssecurity/c/jsheroes

More Related Content

PDF
Analysis of an OSS supply chain attack - How did 8 millions developers downlo...
Jarrod Overson
 
PDF
SBA Live Academy - Secure Containers for Developer by Mathias Tausig
SBA Research
 
PPTX
My Bro The ELK
Tripwire
 
PPTX
Openssl
Adam Moravcik
 
PPTX
Threat hunting != Throwing arrow! Hunting for adversaries in your it environment
Nahidul Kibria
 
PDF
Tools &amp; techniques, building a dev secops culture at mozilla sba live a...
SBA Research
 
PDF
Станислав Семенов, Data Scientist, Kaggle top-3, «О соревновании Telstra Kagg...
Mail.ru Group
 
PPTX
Continuous Monitoring Deck
Brian Fennimore
 
Analysis of an OSS supply chain attack - How did 8 millions developers downlo...
Jarrod Overson
 
SBA Live Academy - Secure Containers for Developer by Mathias Tausig
SBA Research
 
My Bro The ELK
Tripwire
 
Openssl
Adam Moravcik
 
Threat hunting != Throwing arrow! Hunting for adversaries in your it environment
Nahidul Kibria
 
Tools &amp; techniques, building a dev secops culture at mozilla sba live a...
SBA Research
 
Станислав Семенов, Data Scientist, Kaggle top-3, «О соревновании Telstra Kagg...
Mail.ru Group
 
Continuous Monitoring Deck
Brian Fennimore
 

What's hot (9)

PPTX
Detection index learning based on cyber threat intelligence and its applicati...
CODE BLUE
 
PPTX
Pursue the Attackers – Identify and Investigate Lateral Movement Based on Beh...
CODE BLUE
 
PPTX
Open source security tools for Kubernetes.
Michael Ducy
 
PPTX
Moby and kubernetes entitlements
Moby Project
 
PDF
Securing your Rails application
clucasKrof
 
PPTX
ModSecurity and NGINX: Tuning the OWASP Core Rule Set
NGINX, Inc.
 
PDF
JWT: jku x5u
snyff
 
PDF
Adaptive Defense - Understanding Cyber Attacks
Jermund Ottermo
 
PDF
Intrigue Core: Scaling Assessment Automation
Jonathan Cran
 
Detection index learning based on cyber threat intelligence and its applicati...
CODE BLUE
 
Pursue the Attackers – Identify and Investigate Lateral Movement Based on Beh...
CODE BLUE
 
Open source security tools for Kubernetes.
Michael Ducy
 
Moby and kubernetes entitlements
Moby Project
 
Securing your Rails application
clucasKrof
 
ModSecurity and NGINX: Tuning the OWASP Core Rule Set
NGINX, Inc.
 
JWT: jku x5u
snyff
 
Adaptive Defense - Understanding Cyber Attacks
Jermund Ottermo
 
Intrigue Core: Scaling Assessment Automation
Jonathan Cran
 
Ad

Similar to Cluj JSHeroes 2017 - Liran Tal on Node.js Security (20)

PDF
Node.js security - JS Day Italy 2018
Liran Tal
 
PDF
Node.js Security - XSS, Vulnerable Dependencies, Snyk, OWASP
Liran Tal
 
PDF
Node.js Security Done Right - Tips and Tricks They Won't Teach You In School
Liran Tal
 
PDF
"Black Clouds and Silver Linings in Node.js Security" Liran Tal
Julia Cherniak
 
PDF
Fosdem10
wremes
 
PDF
Kicking off with Zend Expressive and Doctrine ORM (ConFoo YVR 2017)
James Titcumb
 
PDF
Config Management Camp 2017 - If it moves, give it a pipeline
Mark Rendell
 
PDF
DDD17 - Web Applications Automated Security Testing in a Continuous Delivery...
Fedir RYKHTIK
 
PDF
Secure WordPress Development Practices
Brandon Dove
 
PDF
PLNOG 5: Eric Ziegast, Zbigniew Jasinski - DNSSEC
PROIDEA
 
PPTX
It's a Dangerous World
MongoDB
 
PDF
Application Security around OWASP Top 10
Sastry Tumuluri
 
PDF
Swift Install Workshop - OpenStack Conference Spring 2012
Joe Arnold
 
PDF
Gartner Security & Risk Management Summit 2018
Paula Januszkiewicz
 
PDF
Atelier Technique CISCO ACSS 2018
African Cyber Security Summit
 
PDF
[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...
OWASP Russia
 
PPTX
SSRF For Bug Bounties
OWASP Nagpur
 
PPTX
Jon McCoy - AppSec-USA-2014 Hacking C#(.NET) Applications:Defend by Design
jonmccoy
 
PPTX
Low Hanging Fruit, Making Your Basic MongoDB Installation More Secure
MongoDB
 
PDF
The Sysdig Secure DevOps Platform
Ashnikbiz
 
Node.js security - JS Day Italy 2018
Liran Tal
 
Node.js Security - XSS, Vulnerable Dependencies, Snyk, OWASP
Liran Tal
 
Node.js Security Done Right - Tips and Tricks They Won't Teach You In School
Liran Tal
 
"Black Clouds and Silver Linings in Node.js Security" Liran Tal
Julia Cherniak
 
Fosdem10
wremes
 
Kicking off with Zend Expressive and Doctrine ORM (ConFoo YVR 2017)
James Titcumb
 
Config Management Camp 2017 - If it moves, give it a pipeline
Mark Rendell
 
DDD17 - Web Applications Automated Security Testing in a Continuous Delivery...
Fedir RYKHTIK
 
Secure WordPress Development Practices
Brandon Dove
 
PLNOG 5: Eric Ziegast, Zbigniew Jasinski - DNSSEC
PROIDEA
 
It's a Dangerous World
MongoDB
 
Application Security around OWASP Top 10
Sastry Tumuluri
 
Swift Install Workshop - OpenStack Conference Spring 2012
Joe Arnold
 
Gartner Security & Risk Management Summit 2018
Paula Januszkiewicz
 
Atelier Technique CISCO ACSS 2018
African Cyber Security Summit
 
[1.2] Трюки при анализе защищенности веб приложений – продвинутая версия - С...
OWASP Russia
 
SSRF For Bug Bounties
OWASP Nagpur
 
Jon McCoy - AppSec-USA-2014 Hacking C#(.NET) Applications:Defend by Design
jonmccoy
 
Low Hanging Fruit, Making Your Basic MongoDB Installation More Secure
MongoDB
 
The Sysdig Secure DevOps Platform
Ashnikbiz
 
Ad

Recently uploaded (20)

PDF
Immersive experiences: what Pharo users do!
ESUG
 
PDF
Exploring AI Agents in Process Industries
amoreira6
 
PPTX
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
PDF
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
PDF
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
PDF
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PDF
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
PDF
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
PDF
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
PDF
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
PDF
Bandai Playdia The Book - David Glotz
BluePanther6
 
PPTX
Presentation about variables and constant.pptx
safalsingh810
 
DOCX
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
PPTX
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
PDF
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
Immersive experiences: what Pharo users do!
ESUG
 
Exploring AI Agents in Process Industries
amoreira6
 
AI-Ready Handoff: Auto-Summaries & Draft Emails from MQL to Slack in One Flow
bbedford2
 
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
49784907924775488180_LRN2959_Data_Pump_23ai.pdf
Abilash868456
 
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
lesson-2-rules-of-netiquette.pdf.bshhsjdj
jasmenrojas249
 
Balancing Resource Capacity and Workloads with OnePlan – Avoid Overloading Te...
OnePlan Solutions
 
Bandai Playdia The Book - David Glotz
BluePanther6
 
Presentation about variables and constant.pptx
safalsingh810
 
Can You Build Dashboards Using Open Source Visualization Tool.docx
Varsha Nayak
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 

Cluj JSHeroes 2017 - Liran Tal on Node.js Security