SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Don’t Run with Scissors!
How to standardize the way your developers use
dangerous aspects of your framework
Morgan Roman
About Me
Currently work on the application security team
Special thanks to Hailey Dhanens, Aravind
Sreenivasa, John Heasman, Krishna Rai, Josh
Estalilla, and Skyler Berg
Note: My examples may use one particular library or
framework, but this strategy is independent of any
framework/language/library.
The problem
A B
The easy way
Validation
Encoding
Logging
The secure way
The solution
A B
Make the easy way the secure way
This is BAD!
A B
The easy way
Validation
Encoding
Logging
The secure way
This is GOOD!
A B
Make the easy way the secure way
If you make the easy way the secure way
● Developers will do whatever is simplest, which is secure
● You will need less developer training
● Training will be more effective
● Security will not impede development
Example: Reducing XSS thanks to React
1. By Default: HTML will not encode user input by default
a. It relies on the developer to encode the user input
b. The app will ‘work’ without proper encoding
c. This leads to XSS
2. React/JSX makes it safe by default
a. By default it encodes
b. If you want to go unsafe, you have a scary name!
3. Result: developers usually do it the safe way
Example XXE in .Net
1. By default: XMLDocument uses document type
definitions (DTD)
a. This lead to XML external entity attacks
b. To turn it off you had to set the ProhibitDtd property to true
2. From .Net 4.6 onward it was safe by default
a. If you really wanted, you can turn it back on
3. Result: developers do it the safe way
The developers just wanted to parse XML!
And then they shoot themselves in the foot!
Make the easy way the secure way!
A B
I just wanted to parse XML!
How to make it easy
1. Find the bad pattern
2. Make the the safe pattern the default one
3. Train the developers to use the safe pattern
4. Build tools to enforce the new rules
ReDoS: Regex Denial of Service
● In some frameworks an inefficient regex can hold up a thread perpetually
● The safe way is to ALWAYS wrap it in a timeout
Developers have to remember a timeout every time!
ReDoS: Make it safe by default
This gets technical
Do this once right so you don’t repeat yourself
If you use the default regex class, a poorly crafted regular expression can result in
executing with exponential time. Instead use the MySafeRegex class since this
bounds the execution to a reasonable amount of time.
ReDoS: Sample training
If you use <THE BAD WAY>, <BAD THING WILL HAPPEN>. Instead use the
<THE GOOD WAY> since <IT STOPS THE BAD THING>.
DO NOT DO THIS:
<EXAMPLE OF THE BAD WAY>
DO THIS INSTEAD:
<EXAMPLE OF THE GOOD WAY>
How to write training/documentation
Explain it simply and clearly.
You do not need to use
security lingo like
XXE/ReDoS/XSS/RCE etc.
First show an example on how the
developer intends to do it.
Then show how they can do it correctly.
Make sure it is simple to do.
If you want, you can include more details and links to OWASP or another good resource.
When should you train developers?
● When they get access to the repository
● Once a year, retrain for their specific department
ReDoS Code Analysis
Simple way
Use a regex to find where your developers are
using the bad method:
I recommend using a tool like DevSkim, but you
can use any code searching tool like grep
https://github.com/microsoft/DevSkim
Complex and more accurate way
Use a static analyzer to find all instances of the
base regex class being used
Roslyn is a great tool for this. You can get the
type of all objects and then show results for
banned classes.
Example unsafe regex class rule for DevSkim
Clear description
Optional:
Link to documentation
Start with simple rules.
Go for 80%
Optional:
Have exclusions
When to use this code analysis
● In the IDE is great, but difficult to get adoption
● Developers are open to feedback in pull requests before merge
The target is developers. Include it as part of your existing CI/CD pipeline
● On your own cadence for your entire code base
The target is the security team. Schedule a regular cadence for this
How we made it easy to stop ReDoS
1. Find the bad pattern
2. Make the the safe pattern the default one
3. Train the developers to use the safe pattern
4. Build tools to enforce the new rules
XXE in Java: Bad Pattern and Safe Default
● By default the SAXParser XML parser for Java allows DTDs
● Create a wrapper factory
SAXParser is just an example Java library, I am not picking on it for any particular reason.
This is explained for other Java libraries on:
https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html accessed 07/29/2019
Wrap in your own class
Set to safe by default
XXE in Java: Training
If you use the standard XML parsers like SAXParser, you may allow an attacker to
remotely write files and control the server through the DTD. Instead use the
MySafeXMLParserFactory since it blocks the attacker from setting DTD variables.
XXE in Java: Enforce the Rules
How we made it easy to stop XXE
1. Find the bad pattern
2. Make the the safe pattern the default one
3. Train the developers to use the safe pattern
4. Build tools to enforce the new rules
Dangers of Open Redirects
● Open redirects can trick users into malicious phishing sites
● If you don’t block the protocol, you can get XSS if the payload is:
javascript:alert(1)
● We often recommend people to use a whitelist
Let’s play spot the bug!!!
mysafewebsitexcom.evilwebsite.com
evilwebsite.com?foo=mysafewebsite.com
Redirect safely once and for all!
● Make a Safe Redirect with:
○ An internal redirect method
■ Blocks all non-http(s) protocols
■ Only allows redirects to your
specific site
○ An external redirect method
■ Blocks all non-http(s) protocols
■ Requires a whitelist as an
argument
You can assume all internal redirects are safe
You can audit all uses of the external redirect to
ensure it has a good whitelist
Example DevSkim Rules for Open Redirects
For ‘unsafe’ use cases
Aim for 80% on your rule
Dangers of Server Side Request Forgery
Hacker
Vulnerable
Server
Victim
Server
Blocked
Bypasses the firewall
Server Side Request Forgery
● Sometimes an application must perform web calls (This is a feature)
● You want to limit the damage of SSRFAAS (SSRF as a service)
○ Block internal IPs
○ Have a built in timeout for long running requests
○ Block calls to the file system (This can lead to local file inclusion and then code execution)
● Set up a safe version that inherits all the features of your web client library
● Block bad behavior by default
● Ban any use of the original class, and only allow your wrapper
Recap on how to do this
1. Find the bad pattern
2. Make the the safe pattern the default one
3. Train the developers to use the safe pattern
4. Build tools to enforce the new rules
Make the easy way the secure way!
A B
Thank You
morgan.roman@docusign.com
If you use <THE BAD WAY>, <BAD THING WILL HAPPEN>. Instead use the
<THE GOOD WAY> since <IT STOPS THE BAD THING>.
DO NOT DO THIS:
<EXAMPLE OF THE BAD WAY>
DO THIS INSTEAD:
<EXAMPLE OF THE GOOD WAY>
How to write training/documentation

Weitere ähnliche Inhalte

Ähnlich wie Dont run with scissors

Reversing malware analysis training part11 exploit development advanced
Reversing malware analysis training part11 exploit development advancedReversing malware analysis training part11 exploit development advanced
Reversing malware analysis training part11 exploit development advancedCysinfo Cyber Security Community
 
Cypress Best Pratices for Test Automation
Cypress Best Pratices for Test AutomationCypress Best Pratices for Test Automation
Cypress Best Pratices for Test AutomationKnoldus Inc.
 
Analysis of-quality-of-pkgs-in-packagist-univ-20171024
Analysis of-quality-of-pkgs-in-packagist-univ-20171024Analysis of-quality-of-pkgs-in-packagist-univ-20171024
Analysis of-quality-of-pkgs-in-packagist-univ-20171024Clark Everetts
 
Perfomatix - NodeJS Coding Standards
Perfomatix - NodeJS Coding StandardsPerfomatix - NodeJS Coding Standards
Perfomatix - NodeJS Coding StandardsPerfomatix Solutions
 
How to secure your web applications with NGINX
How to secure your web applications with NGINXHow to secure your web applications with NGINX
How to secure your web applications with NGINXWallarm
 
30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software EngineerSean Coates
 
iOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersRyanISI
 
Get Your Database Under Control
Get Your Database Under ControlGet Your Database Under Control
Get Your Database Under ControlGrant Fritchey
 
Reversing & malware analysis training part 11 exploit development advanced
Reversing & malware analysis training part 11   exploit development advancedReversing & malware analysis training part 11   exploit development advanced
Reversing & malware analysis training part 11 exploit development advancedAbdulrahman Bassam
 
Web Security: What's wrong, and how the bad guys can break your website
Web Security: What's wrong, and how the bad guys can break your websiteWeb Security: What's wrong, and how the bad guys can break your website
Web Security: What's wrong, and how the bad guys can break your websiteAndrew Sorensen
 
Software Bugs A Software Architect Point Of View
Software Bugs    A Software Architect Point Of ViewSoftware Bugs    A Software Architect Point Of View
Software Bugs A Software Architect Point Of ViewShahzad
 
AppSec How-To: Achieving Security in DevOps
AppSec How-To: Achieving Security in DevOpsAppSec How-To: Achieving Security in DevOps
AppSec How-To: Achieving Security in DevOpsCheckmarx
 
Banfootguns devseccon 2019
Banfootguns devseccon 2019Banfootguns devseccon 2019
Banfootguns devseccon 2019Morgan Roman
 
Cm9 secure code_training_1day_input sanitization
Cm9 secure code_training_1day_input sanitizationCm9 secure code_training_1day_input sanitization
Cm9 secure code_training_1day_input sanitizationdcervigni
 
Slides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetingsSlides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetings10n Software, LLC
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesInductive Automation
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Codeeddiehaber
 

Ähnlich wie Dont run with scissors (20)

Reversing malware analysis training part11 exploit development advanced
Reversing malware analysis training part11 exploit development advancedReversing malware analysis training part11 exploit development advanced
Reversing malware analysis training part11 exploit development advanced
 
Javascript best practices
Javascript best practicesJavascript best practices
Javascript best practices
 
Cypress Best Pratices for Test Automation
Cypress Best Pratices for Test AutomationCypress Best Pratices for Test Automation
Cypress Best Pratices for Test Automation
 
Analysis of-quality-of-pkgs-in-packagist-univ-20171024
Analysis of-quality-of-pkgs-in-packagist-univ-20171024Analysis of-quality-of-pkgs-in-packagist-univ-20171024
Analysis of-quality-of-pkgs-in-packagist-univ-20171024
 
Perfomatix - NodeJS Coding Standards
Perfomatix - NodeJS Coding StandardsPerfomatix - NodeJS Coding Standards
Perfomatix - NodeJS Coding Standards
 
How to secure your web applications with NGINX
How to secure your web applications with NGINXHow to secure your web applications with NGINX
How to secure your web applications with NGINX
 
30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer
 
iOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for BeginnersiOS Application Penetration Testing for Beginners
iOS Application Penetration Testing for Beginners
 
Get Your Database Under Control
Get Your Database Under ControlGet Your Database Under Control
Get Your Database Under Control
 
Reversing & malware analysis training part 11 exploit development advanced
Reversing & malware analysis training part 11   exploit development advancedReversing & malware analysis training part 11   exploit development advanced
Reversing & malware analysis training part 11 exploit development advanced
 
Web Security: What's wrong, and how the bad guys can break your website
Web Security: What's wrong, and how the bad guys can break your websiteWeb Security: What's wrong, and how the bad guys can break your website
Web Security: What's wrong, and how the bad guys can break your website
 
Node.js security tour
Node.js security tourNode.js security tour
Node.js security tour
 
Software Bugs A Software Architect Point Of View
Software Bugs    A Software Architect Point Of ViewSoftware Bugs    A Software Architect Point Of View
Software Bugs A Software Architect Point Of View
 
Enterprise PHP
Enterprise PHPEnterprise PHP
Enterprise PHP
 
AppSec How-To: Achieving Security in DevOps
AppSec How-To: Achieving Security in DevOpsAppSec How-To: Achieving Security in DevOps
AppSec How-To: Achieving Security in DevOps
 
Banfootguns devseccon 2019
Banfootguns devseccon 2019Banfootguns devseccon 2019
Banfootguns devseccon 2019
 
Cm9 secure code_training_1day_input sanitization
Cm9 secure code_training_1day_input sanitizationCm9 secure code_training_1day_input sanitization
Cm9 secure code_training_1day_input sanitization
 
Slides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetingsSlides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetings
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Code
 

Kürzlich hochgeladen

All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445ruhi
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...Neha Pandey
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Servicegwenoracqe6
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirtrahman018755
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...aditipandeya
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607dollysharma2066
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLimonikaupta
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsstephieert
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 

Kürzlich hochgeladen (20)

All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
Call Girls In Noida 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In Noida 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In Noida 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In Noida 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
 
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
FULL ENJOY Call Girls In Mayur Vihar Delhi Contact Us 8377087607
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 26 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRLLucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
Lucknow ❤CALL GIRL 88759*99948 ❤CALL GIRLS IN Lucknow ESCORT SERVICE❤CALL GIRL
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girls
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 

Dont run with scissors

  • 1. Don’t Run with Scissors! How to standardize the way your developers use dangerous aspects of your framework Morgan Roman
  • 2. About Me Currently work on the application security team Special thanks to Hailey Dhanens, Aravind Sreenivasa, John Heasman, Krishna Rai, Josh Estalilla, and Skyler Berg Note: My examples may use one particular library or framework, but this strategy is independent of any framework/language/library.
  • 3. The problem A B The easy way Validation Encoding Logging The secure way
  • 4. The solution A B Make the easy way the secure way
  • 5. This is BAD! A B The easy way Validation Encoding Logging The secure way
  • 6. This is GOOD! A B Make the easy way the secure way
  • 7. If you make the easy way the secure way ● Developers will do whatever is simplest, which is secure ● You will need less developer training ● Training will be more effective ● Security will not impede development
  • 8. Example: Reducing XSS thanks to React 1. By Default: HTML will not encode user input by default a. It relies on the developer to encode the user input b. The app will ‘work’ without proper encoding c. This leads to XSS 2. React/JSX makes it safe by default a. By default it encodes b. If you want to go unsafe, you have a scary name! 3. Result: developers usually do it the safe way
  • 9. Example XXE in .Net 1. By default: XMLDocument uses document type definitions (DTD) a. This lead to XML external entity attacks b. To turn it off you had to set the ProhibitDtd property to true 2. From .Net 4.6 onward it was safe by default a. If you really wanted, you can turn it back on 3. Result: developers do it the safe way The developers just wanted to parse XML! And then they shoot themselves in the foot!
  • 10. Make the easy way the secure way! A B I just wanted to parse XML!
  • 11. How to make it easy 1. Find the bad pattern 2. Make the the safe pattern the default one 3. Train the developers to use the safe pattern 4. Build tools to enforce the new rules
  • 12. ReDoS: Regex Denial of Service ● In some frameworks an inefficient regex can hold up a thread perpetually ● The safe way is to ALWAYS wrap it in a timeout Developers have to remember a timeout every time!
  • 13. ReDoS: Make it safe by default This gets technical Do this once right so you don’t repeat yourself
  • 14. If you use the default regex class, a poorly crafted regular expression can result in executing with exponential time. Instead use the MySafeRegex class since this bounds the execution to a reasonable amount of time. ReDoS: Sample training
  • 15. If you use <THE BAD WAY>, <BAD THING WILL HAPPEN>. Instead use the <THE GOOD WAY> since <IT STOPS THE BAD THING>. DO NOT DO THIS: <EXAMPLE OF THE BAD WAY> DO THIS INSTEAD: <EXAMPLE OF THE GOOD WAY> How to write training/documentation Explain it simply and clearly. You do not need to use security lingo like XXE/ReDoS/XSS/RCE etc. First show an example on how the developer intends to do it. Then show how they can do it correctly. Make sure it is simple to do. If you want, you can include more details and links to OWASP or another good resource.
  • 16. When should you train developers? ● When they get access to the repository ● Once a year, retrain for their specific department
  • 17. ReDoS Code Analysis Simple way Use a regex to find where your developers are using the bad method: I recommend using a tool like DevSkim, but you can use any code searching tool like grep https://github.com/microsoft/DevSkim Complex and more accurate way Use a static analyzer to find all instances of the base regex class being used Roslyn is a great tool for this. You can get the type of all objects and then show results for banned classes.
  • 18. Example unsafe regex class rule for DevSkim Clear description Optional: Link to documentation Start with simple rules. Go for 80% Optional: Have exclusions
  • 19. When to use this code analysis ● In the IDE is great, but difficult to get adoption ● Developers are open to feedback in pull requests before merge The target is developers. Include it as part of your existing CI/CD pipeline ● On your own cadence for your entire code base The target is the security team. Schedule a regular cadence for this
  • 20. How we made it easy to stop ReDoS 1. Find the bad pattern 2. Make the the safe pattern the default one 3. Train the developers to use the safe pattern 4. Build tools to enforce the new rules
  • 21. XXE in Java: Bad Pattern and Safe Default ● By default the SAXParser XML parser for Java allows DTDs ● Create a wrapper factory SAXParser is just an example Java library, I am not picking on it for any particular reason. This is explained for other Java libraries on: https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html accessed 07/29/2019 Wrap in your own class Set to safe by default
  • 22. XXE in Java: Training If you use the standard XML parsers like SAXParser, you may allow an attacker to remotely write files and control the server through the DTD. Instead use the MySafeXMLParserFactory since it blocks the attacker from setting DTD variables.
  • 23. XXE in Java: Enforce the Rules
  • 24. How we made it easy to stop XXE 1. Find the bad pattern 2. Make the the safe pattern the default one 3. Train the developers to use the safe pattern 4. Build tools to enforce the new rules
  • 25. Dangers of Open Redirects ● Open redirects can trick users into malicious phishing sites ● If you don’t block the protocol, you can get XSS if the payload is: javascript:alert(1) ● We often recommend people to use a whitelist Let’s play spot the bug!!! mysafewebsitexcom.evilwebsite.com evilwebsite.com?foo=mysafewebsite.com
  • 26. Redirect safely once and for all! ● Make a Safe Redirect with: ○ An internal redirect method ■ Blocks all non-http(s) protocols ■ Only allows redirects to your specific site ○ An external redirect method ■ Blocks all non-http(s) protocols ■ Requires a whitelist as an argument You can assume all internal redirects are safe You can audit all uses of the external redirect to ensure it has a good whitelist
  • 27. Example DevSkim Rules for Open Redirects For ‘unsafe’ use cases Aim for 80% on your rule
  • 28. Dangers of Server Side Request Forgery Hacker Vulnerable Server Victim Server Blocked Bypasses the firewall
  • 29. Server Side Request Forgery ● Sometimes an application must perform web calls (This is a feature) ● You want to limit the damage of SSRFAAS (SSRF as a service) ○ Block internal IPs ○ Have a built in timeout for long running requests ○ Block calls to the file system (This can lead to local file inclusion and then code execution) ● Set up a safe version that inherits all the features of your web client library ● Block bad behavior by default ● Ban any use of the original class, and only allow your wrapper
  • 30. Recap on how to do this 1. Find the bad pattern 2. Make the the safe pattern the default one 3. Train the developers to use the safe pattern 4. Build tools to enforce the new rules Make the easy way the secure way! A B
  • 32. If you use <THE BAD WAY>, <BAD THING WILL HAPPEN>. Instead use the <THE GOOD WAY> since <IT STOPS THE BAD THING>. DO NOT DO THIS: <EXAMPLE OF THE BAD WAY> DO THIS INSTEAD: <EXAMPLE OF THE GOOD WAY> How to write training/documentation

Hinweis der Redaktion

  1. DocuSign is a esignature platform. I was an SDET. I wrote web and api tests. I would help out the security team by creating regression tests for them occasionally. DocuSign has an amazing set of integration tests.
  2. May add filter?
  3. Is repeating bad?
  4. Simple as possible to get it running Hard to undo bad patterns The default
  5. Angular does it too!
  6. DTD = document type definitions
  7. The Gist of what we are doing Bad pattern Make it safe by default
  8. Add image
  9. Remember to explain DevSkim made by microsoft Talk about blocking with these tools at the PR How to convince devs: Before they get git access During PRs Bad idea in the IDE
  10. Format of the code { "name": "Possible regex denial of service attack", "id": "REDOS_1", "description": "It is possible to perform a regex denial of service attack with the standard .Net regex library. ", "recommendation": "Please use MySafeRegex class to generate this", "applies_to": [ "csharp" ], "severity": "important", "patterns": [ { "pattern": "new Regex\\(", "type": "regex-word", "scopes": [ "code" ] } ], "conditions": [ { "pattern": { "pattern": "new MySafeRegex\\(", "type": "regex-word", "scopes": [ "code" ] }, "search_in": "finding-only", "negate_finding": true } ] },
  11. The Gist of what we are doing Bad pattern Make it safe by default
  12. Note that you didn’t need exceptions in this one
  13. The Gist of what we are doing Bad pattern Make it safe by default
  14. Mysafewebsitexcom.evilwebsite.com would match evilwebsite.com?foo=mysafewebsitexcom would match
  15. Removw file write