Secure Coding in Node.js



Similar documents
Secure development and the SDLC. Presented By Jerry

Magento Security and Vulnerabilities. Roman Stepanov

The Top Web Application Attacks: Are you vulnerable?

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

Where every interaction matters.

How to break in. Tecniche avanzate di pen testing in ambito Web Application, Internal Network and Social Engineering

WEB SECURITY CONCERNS THAT WEB VULNERABILITY SCANNING CAN IDENTIFY

Real World Java Web Security

Web Application Report

Rational AppScan & Ounce Products

Creating Stronger, Safer, Web Facing Code. JPL IT Security Mary Rivera June 17, 2011

Securing Your Web Application against security vulnerabilities. Ong Khai Wei, IT Specialist, Development Tools (Rational) IBM Software Group

Adobe Systems Incorporated

WHITE PAPER. FortiWeb and the OWASP Top 10 Mitigating the most dangerous application security threats

OWASP Top Ten Tools and Tactics

elearning for Secure Application Development

OWASP TOP 10 ILIA

Secure Programming Lecture 12: Web Application Security III

Web Application Security Assessment and Vulnerability Mitigation Tests

Out of the Fire - Adding Layers of Protection When Deploying Oracle EBS to the Internet

Hack Proof Your Webapps

Successful Strategies for QA- Based Security Testing

Certified Secure Web Application Security Test Checklist

Learning objectives for today s session

Contemporary Web Application Attacks. Ivan Pang Senior Consultant Edvance Limited

How To Understand And Understand The Security Of A Web Browser (For Web Users)

Early Vulnerability Detection for Supporting Secure Programming

MANAGED SECURITY TESTING

APPLICATION SECURITY AND ITS IMPORTANCE

Essential IT Security Testing

Secure Web Application Coding Team Introductory Meeting December 1, :00 2:00PM Bits & Pieces Room, Sansom West Room 306 Agenda

WEB SITE SECURITY. Jeff Aliber Verizon Digital Media Services

(WAPT) Web Application Penetration Testing

Mobile Application Security

National Information Security Group The Top Web Application Hack Attacks. Danny Allan Director, Security Research

Web Application Hacking (Penetration Testing) 5-day Hands-On Course

Making your web application. White paper - August secure

Passing PCI Compliance How to Address the Application Security Mandates

Cyber Security & Data Privacy. January 22, 2014

Web Engineering Web Application Security Issues

Six Essential Elements of Web Application Security. Cost Effective Strategies for Defending Your Business

Web Application Penetration Testing

Sichere Webanwendungen mit Java

Cracking the Perimeter via Web Application Hacking. Zach Grace, CISSP, CEH January 17, Mega Conference

SESSION IDENTIFIER ARE FOR NOW, PASSWORDS ARE FOREVER

Web Application Report

Development Processes (Lecture outline)

Using Free Tools To Test Web Application Security

OWASP AND APPLICATION SECURITY

Bank Hacking Live! Ofer Maor CTO, Hacktics Ltd. ATC-4, 12 Jun 2006, 4:30PM

Sichere Software- Entwicklung für Java Entwickler

Black Box versus White Box: Different App Testing Strategies John B. Dickson, CISSP

Ethical Hacking as a Professional Penetration Testing Technique

A Network Administrator s Guide to Web App Security

Reducing Application Vulnerabilities by Security Engineering

OWASP and OWASP Top 10 (2007 Update) OWASP. The OWASP Foundation. Dave Wichers. The OWASP Foundation. OWASP Conferences Chair

Attack Vector Detail Report Atlassian

Testing the OWASP Top 10 Security Issues

Hacking Web Apps. Detecting and Preventing Web Application Security Problems. Jorge Blanco Alcover. Mike Shema. Technical Editor SYNGRESS

Application Code Development Standards

Sitefinity Security and Best Practices

Security Testing with Selenium

Promoting Application Security within Federal Government. AppSec DC November 13, The OWASP Foundation

Security Assessment through Google Tools -Focusing on the Korea University Website

Architectural Design Patterns. Design and Use Cases for OWASP. Wei Zhang & Marco Morana OWASP Cincinnati, U.S.A.

Web Application Security

QuickBooks Online: Security & Infrastructure

Strategic Information Security. Attacking and Defending Web Services

Integrating Security Testing into Quality Control

FINAL DoIT v.4 PAYMENT CARD INDUSTRY DATA SECURITY STANDARDS APPLICATION DEVELOPMENT AND MAINTENANCE PROCEDURES

BUILDING AN OFFENSIVE SECURITY PROGRAM BUILDING AN OFFENSIVE SECURITY PROGRAM

State of The Art: Automated Black Box Web Application Vulnerability Testing. Jason Bau, Elie Bursztein, Divij Gupta, John Mitchell

SQuAD: Application Security Testing

Testnet Summerschool. Web Application Security Testing. Dave van Stein

1. Introduction. 2. Web Application. 3. Components. 4. Common Vulnerabilities. 5. Improving security in Web applications

3. Broken Account and Session Management. 4. Cross-Site Scripting (XSS) Flaws. Web browsers execute code sent from websites. Account Management

Chapter 1 Web Application (In)security 1

Finding and Preventing Cross- Site Request Forgery. Tom Gallagher Security Test Lead, Microsoft

Security starts in the head(er)

Detecting Web Application Vulnerabilities Using Open Source Means. OWASP 3rd Free / Libre / Open Source Software (FLOSS) Conference 27/5/2008

How to start a software security initiative within your organization: a maturity based and metrics driven approach OWASP

Excellence Doesn t Need a Certificate. Be an. Believe in You AMIGOSEC Consulting Private Limited

External Network & Web Application Assessment. For The XXX Group LLC October 2012

ETHICAL HACKING APPLICATIO WIRELESS110 00NETWORK APPLICATION MOBILE MOBILE0001

WHITE PAPER FORTIWEB WEB APPLICATION FIREWALL. Ensuring Compliance for PCI DSS 6.5 and 6.6

Project 2: Web Security Pitfalls

Is Drupal secure? A high-level perspective on web vulnerabilities, Drupal s solutions, and how to maintain site security

WEB APPLICATION FIREWALLS: DO WE NEED THEM?

Addressing Cyber Security in Oracle Utilities Applications

Conducting Web Application Pentests. From Scoping to Report For Education Purposes Only

ASP.NET MVC Secure Coding 4-Day hands on Course. Course Syllabus

Web application security

05.0 Application Development

Barracuda Web Site Firewall Ensures PCI DSS Compliance

Overview of the Penetration Test Implementation and Service. Peter Kanters

What is Web Security? Motivation

How to Build a Trusted Application. John Dickson, CISSP

Integrating Security into the Application Development Process. Jerod Brennen, CISSP CTO & Principal Security Consultant, Jacadis

Web applications. Web security: web basics. HTTP requests. URLs. GET request. Myrto Arapinis School of Informatics University of Edinburgh

APPLICATION SECURITY: FROM WEB TO MOBILE. DIFFERENT VECTORS AND NEW ATTACK

Transcription:

Secure Coding in Node.js Advanced Edition Copyright 2015 nvisium LLC 590 Herndon Parkway Suite 120, Herndon VA 20170 571.353.7551 www.nvisium.com 1

Introduction Seth Law VP of Research & Development @ nvisium Developer/Contributor of Django.nV, Swift.nV, SiRATool, RAFT, Grails.nV Hacker, AppSec Architect, Security Consultant Soccer Hooligan Copyright 2015 nvisium LLC 590 Herndon Parkway Suite 120, Herndon VA 20170 571.353.7551 www.nvisium.com 2

Your App

Hopefully, not your App

node.js + security =???

Good The developer is in charge of the entire HTTP interaction. Bad Node.js Your web server is only as secure as you make it. Introduces trivial to exploit SSI depending on programming techniques

Google + Security 70,000,000 60,000,000 50,000,000 40,000,000 Google + Security 30,000,000 20,000,000 10,000,000 0 Node.js Rails Django Flask Play Grails October 5, 2015

Reporting a Bug nodejs.org docs Information Disclosure

blog.risingstack.com - Node.js Security Checklist Config mgmt (Headers + data handling) Authentication Session Mgmt (Cookies + CSRF) Data Validation (XSS, SQLi, Command Injection) Secure Transmission (SSL, HSTS) Denial of Service Error Handling Other resources

Houston, we have a problem

OWASP Top 10 Injection Broken Authentication & Session Management Cross-Site Scripting Insecure Direct Object References Security Misconfiguration Sensitive Data Exposure Missing Function Level Access Control Cross-Site Request Forgery Using Components with Known Vulns Invalidated Redirects and Forwards

OWASP Top 10 Injection Broken Authentication & Session Management Cross-Site Scripting Insecure Direct Object References Security Misconfiguration Sensitive Data Exposure Missing Function Level Access Control Cross-Site Request Forgery Using Components with Known Vulns Invalidated Redirects and Forwards

Vulnerabilities Insecure Direct Object Reference Mass Assignment Cross Site Request Forgery (CSRF) Business Logic Flaws Defenses Tools Agenda

Security Mindset All comes down to trust Trust you can defend against a reasonable level of attacker skill set Trust you can recover from that which you cannot prevent Your users can trust your product Your product does not trust its users

Vulnerabilities Why? Disclaimer

Insecure Direct Object Reference AKA IDOR Seeing a rise in the number of instances. Authorization Knowledge of identifier values is the only thing required to access the associated record.

IDOR

IDOR Changing an identifier value.

Mitigation Insecure Direct Object Reference Always check to see if a user has access to a resource or function before operating on it. Access controls should be enforced at the controller level, not the route level. This double checks access in the case that multiple routes point to the same controller.

Mass Assignment AKA Data-Binding Attacks Active-record pattern abuse Add parameters to request to modify data

Mass Assignment

Mass Assignment Mitigation Don t trust user input Only save/store expected parameters

CSRF AKA Session Riding, XSRF A web application will process all requests that include authorization cookies, no questions asked.

Problem?

Is not enabled by default app.use(express.csrf()); Needs a little help app.use(function (req, res, next) { res.locals.csrftoken = req.session._csrf; }); next(); CSRF

CSRF Inside the view <input type=hidden name=_csrf value= {{csrftoken}} ></input> Request is validated when Express sees the token in: req.body._csrf req.query._csrf req.headers[ x-csrf-token ]

CSRF Issues (Express CSRF) Uses Math.random and session secret Multi-step process == mistakes Order matters! Must be included after express.session Express ignores tokens in GET, OPTIONS and HEAD requests method-override anyone?

CSRF

Not so secret

CSRF

Mitigation Secret must be secret Any sensitive form Pay attention to RESTful APIs Periodically check code for CSRF QA tests? CSRF

Is it possible to bypass steps? Process validation Business Logic Flaws What about Node.js asynchronous functions calls? Especially when dealing with authorization decisions.

Demo Control Flow (goat.js) Copyright 2015 nvisium LLC 590 Herndon Parkway Suite 120, Herndon VA 20170 571.353.7551 www.nvisium.com 42

Mitigation Wait for asynchronous when making authorization decisions. async library Business Logic Flaws

Defense Copyright 2015 nvisium LLC 590 Herndon Parkway Suite 120, Herndon VA 20170 571.353.7551 www.nvisium.com 44

Defense Strategy - Integrate into the SDLC Teach first (seccasts.com) Design Test Test Test Start over

Defense Library Security Security Middleware Helmet.js Kraken.js

NPM 343 new modules/day

Node Security Project

Malicious Packages

retire.js

RequireSafe

Helmet.js crossdomain.xml CSP (Content Security Policy) X-Powered-By nosniff frame guard xssfilter HPKP HSTS ienoopen nocache

Kraken.js - Lusca Cross Site Request Forgery (CSRF) Content Security Policy (CSP) X-Frame-Options Platform for Privacy Preferences (P3P) HTTP Strict Transport Security (HSTS) X-XSS-Protection

Defense Tools - Static Code Analysis JSPrime ScanJS HP Fortify IBM AppScan Source

Defense JSPrime - Static Code Analysis

Defense ScanJS - Static Code Analysis

Defense ScanJS - Static Code Analysis DEPRECATED

Tools Weaknesses Geared towards single pages/files Only effective at finding specific vulnerabilities False Positives Fortify/AppScan/Veracode

Conclusion Security is hard, try harder Copyright 2015 nvisium LLC 590 Herndon Parkway Suite 120, Herndon VA 20170 571.353.7551 www.nvisium.com 59

Questions? Copyright 2015 nvisium LLC 590 Herndon Parkway Suite 120, Herndon VA 20170 571.353.7551 www.nvisium.com 60

Thank you @sethlaw - Seth Law seth@nvisium.com Copyright 2015 nvisium LLC 590 Herndon Parkway Suite 120, Herndon VA 20170 571.353.7551 www.nvisium.com 61