SERVER-SIDE JAVASCRIPT INJECTION ATTACKING AND DEFENDING NOSQL AND NODE.JS BRYAN SULLIVAN SENIOR SECURITY RESEARCHER, ADOBE SYSTEMS

Similar documents
NoSQL, But Even Less Security Bryan Sullivan, Senior Security Researcher, Adobe Secure Software Engineering Team

Server-Side JavaScript Injection Bryan Sullivan, Senior Security Researcher, Adobe Secure Software Engineering Team July 2011

Attacking MongoDB. Firstov Mihail

No SQL! no injection? A talk on the state of NoSQL security

Advanced Web Technology 10) XSS, CSRF and SQL Injection 2

Project 2: Web Security Pitfalls

What about MongoDB? can req.body.input 0; var date = new Date(); do {curdate = new Date();} while(curdate-date<10000)

NO SQL! NO INJECTION?

ICON UK 2015 node.js for Domino developers. Presenter: Matt White Company: LDC Via

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

Application security testing: Protecting your application and data

NoSQL replacement for SQLite (for Beatstream) Antti-Jussi Kovalainen Seminar OHJ-1860: NoSQL databases

Security Model for the Client-Side Web Application Environments

CTF Web Security Training. Engin Kirda

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

Full URLs, specified in RFC 3986 have up to eight parts.

Exploi'ng NoSQL Like Never Before HITB AMS 2014

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

A Server and Browser-Transparent CSRF Defense for Web 2.0 Applications. Slides by Connor Schnaith

Web Application Security

A Tale of the Weaknesses of Current Client-side XSS Filtering

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

Carlos Muñoz Application Security Engineer WhiteHat

DNS REBINDING DENIS BARANOV, POSITIVE TECHNOLOGIES

HTML Form Widgets. Review: HTML Forms. Review: CGI Programs

Exploits: XSS, SQLI, Buffer Overflow

Dynamic Web-Enabled Data Collection

Webapps Vulnerability Report

Universal XSS via IE8s XSS Filters

CSCC09F Programming on the Web. Mongo DB

RESTful web applications with Apache Sling

Performance Testing for Ajax Applications

Advanced XSS. Nicolas Golubovic

SQL Injection January 23, 2013

Magento Security and Vulnerabilities. Roman Stepanov

Security Basics - Lessons From a Paranoid. Stuart Larsen Yahoo! Paranoids - Pentest

AJAX and JSON Lessons Learned. Jim Riecken, Senior Software Engineer, Blackboard Inc.

Cloud Elements! Marketing Hub Provisioning and Usage Guide!

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

Contents. 2 Alfresco API Version 1.0

Spectrum Technology Platform

Check list for web developers

JAVASCRIPT AND COOKIES

WIRIS quizzes web services Getting started with PHP and Java

Defending against XSS,CSRF, and Clickjacking David Bishop

Web Application Attacks And WAF Evasion

Viewing Form Results

(WAPT) Web Application Penetration Testing

Bug Report. Date: March 19, 2011 Reporter: Chris Jarabek

Document Structure Integrity: A Robust Basis for Cross-Site Scripting Defense

Secure Coding in Node.js

Hacking HTML5. No VirtualBox? VirtualBox (~4 gb needed) Apache + PHP Chrome + Firefox. unpack zeronights.zip

Login with Amazon. Getting Started Guide for Websites. Version 1.0

An Open Source NoSQL solution for Internet Access Logs Analysis

Cyber Security Challenge Australia 2014

Hack Yourself First. Troy troyhunt.com

Chapter 1 Web Application (In)security 1

@tobiastrelle. codecentric AG 1

Current Data Security Issues of NoSQL Databases

Cloud Elements ecommerce Hub Provisioning Guide API Version 2.0 BETA

Web [Application] Frameworks

HTTPParameter Pollution. ChrysostomosDaniel

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

SESSION IDENTIFIER ARE FOR NOW, PASSWORDS ARE FOREVER

WEB SECURITY CONCERNS THAT WEB VULNERABILITY SCANNING CAN IDENTIFY

Advanced Web Security, Lab

RESTing On Your Laurels Will Get You Pwned. By Abraham Kang, Dinis Cruz, and Alvaro Munoz

The Risks of Client-Side Data Storage From cookie to database

EVALUATING COMMERCIAL WEB APPLICATION SECURITY. By Aaron Parke

Network Security Exercise #8

Web Application Security

It is highly recommended that you are familiar with HTML and JavaScript before attempting this tutorial.

Thomas Röthlisberger IT Security Analyst

A Tale of the Weaknesses of Current Client-Side XSS Filtering

Cross Site Scripting (XSS) and PHP Security. Anthony Ferrara NYPHP and OWASP Security Series June 30, 2011

Complete Cross-site Scripting Walkthrough

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

Why NoSQL? Your database options in the new non- relational world IBM Cloudant 1

Building a Real-Time Cloud Analytics Service with Node.js

MarkLogic Server. Node.js Application Developer s Guide. MarkLogic 8 February, Copyright 2016 MarkLogic Corporation. All rights reserved.

Visualizing a Neo4j Graph Database with KeyLines

Dynamic Content. Dynamic Web Content: HTML Forms CGI Web Servers and HTTP

Bypassing Internet Explorer s XSS Filter

XHTML Forms. Form syntax. Selection widgets. Submission method. Submission action. Radio buttons

Intrusion detection for web applications

Preparing for the Cross Site Request Forgery Defense

InPost UK Limited GeoWidget Integration Guide Version 1.1

Next Generation Clickjacking

Relax Everybody: HTML5 Is Securer Than You Think

Application Security Testing. Erez Metula (CISSP), Founder Application Security Expert

User and Programmer Guide for the FI- STAR Monitoring Service SE

Open Source Technologies on Microsoft Azure

5 Mistakes to Avoid on Your Drupal Website

Where every interaction matters.

Transcription:

SERVER-SIDE JAVASCRIPT INJECTION ATTACKING AND DEFENDING NOSQL AND NODE.JS BRYAN SULLIVAN SENIOR SECURITY RESEARCHER, ADOBE SYSTEMS

POP QUIZ!

SERVER-SIDE JAVASCRIPT INJECTION VS XSS» Client-side JavaScript injection (aka XSS) #2 on OWASP Top Ten #4 on 2011 CWE/SANS Top 25» It s really bad.» But server-side is much worse.

BROWSER WAR FALLOUT V8

BROWSER WAR FALLOUT V8 despite its deplorable shortcomings, JavaScript is cool and people like it Kris Kowal

JAVASCRIPT DATABASES

JAVASCRIPT WEB SERVER var http = require('http'); http.createserver(function (req, res) { res.writehead(200, {'Content-Type': 'text/plain'}); res.end('hello World\n'); }).listen(1337, "127.0.0.1"); console.log('server running at http://127.0.0.1:1337/');

POP QUIZ PART 2

COMMONJS javascript: not just for browsers any more! var http = require('http'); http.createserver(function (req, res) { res.writehead(200, {'Content-Type': 'text/plain'}); res.end('hello World\n'); }).listen(1337, "127.0.0.1"); console.log('server running at http://127.0.0.1:1337/');

COMMONJS javascript: not just for browsers any more! var http = require('http'); http.createserver(function (req, res) { res.writehead(200, {'Content-Type': 'text/plain'}); res.end('hello World\n'); }).listen(1337, "127.0.0.1"); console.log('server running at http://127.0.0.1:1337/');

NODE.JS DOCUMENTATION http://nodejs.org/docs/v0.5.0/api/» Globals» STDIO» Timers» Modules» C/C++ Addons» Process» Utilities» Events» Buffers» Streams» Crypto» TLS/SSL» String Decoder» File System» Path» Net» UDP/Datagram» DNS» HTTP» HTTPS» URL» Querystrings» Readline» REPL» VM» Child Processes» Assertion Testing» TTY» OS» Debugger

NODE.JS DOCUMENTATION http://nodejs.org/docs/v0.5.0/api/» Globals» STDIO» Timers» Modules» C/C++ Addons» Process» Utilities» Events» Buffers» Streams» Crypto» TLS/SSL» String Decoder» File System» Path» Net» UDP/Datagram» DNS» HTTP» HTTPS» URL» Querystrings» Readline» REPL» VM» Child Processes» Assertion Testing» TTY» OS» Debugger

NODE.JS DOCUMENTATION http://nodejs.org/docs/v0.5.0/api/» Globals» STDIO» Timers» Modules» C/C++ Addons» Process» Utilities» Events» Buffers» Streams» Crypto» TLS/SSL» String Decoder» File System» Path» Net» UDP/Datagram» DNS» HTTP» HTTPS» URL» Querystrings» Readline» REPL» VM» Child Processes» Assertion Testing» TTY» OS» Debugger

NOSQL

POP QUIZ PART 3

NOSQL INJECTION» Special case: MongoDB and PHP» MongoDB expects input in JSON array format find( { 'artist' : 'Amy Winehouse' } )» In PHP, you do this with associative arrays $collection->find(array('artist' => 'Amy Winehouse'));

MONGODB AND PHP NOSQL INJECTION» You also use associative arrays for query criteria find( { 'album_year' : { '$gte' : 2011} } ) find( { 'artist' : { '$ne' : 'Lady Gaga' } } )» But PHP will automatically create associative arrays from querystring inputs with square brackets page.php?param[foo]=bar param == array('foo' => 'bar');

NOSQL INJECTION DEMO #1

$WHERE CLAUSES» Q: What does this have to do with SSJS injection?» A: The $where clause lets you specify script to filter results find( { '$where' : 'function() { return artist == "Weezer"; }}' ) find ( '$where' : 'function() { var len = artist.length; for (int i=2; i<len; i++) { if (len % i == 0) return false; } return true; }')

NOSQL INJECTION DEMO #2

REST APIS AND CSRF» From the MongoDB documentation One valid way to run the Mongo database is in a trusted environment, with no security and authentication This is the default option and is recommended» From the Cassandra Wiki The default AllowAllAuthenticator approach is essentially pass-through» From CouchDB: The Definitive Guide» Riak The Admin Party : Everyone can do everything by default No authentication or authorization support

PORT SCANNING» If an attacker finds an open port, he s already won Database MongoDB 27017 28017 27080 CouchDB 5984 Hbase 9000 Cassandra 9160 Neo4j 7474 Riak 8098 Default Port(s)

PORT SCANNING» If an attacker finds an open port, he s already won Database MongoDB 27017 28017 27080 CouchDB 5984 Hbase 9000 Cassandra 9160 Neo4j 7474 Riak 8098 Default Port(s)

CSRF FIREWALL BYPASS

REST API EXAMPLES (COUCHDB)» Create a document POST /mydb/doc_id HTTP/1.0 {"album" : "Brothers", "artist" : "The Black Keys"}» Retrieve a document GET /mydb/doc_id HTTP/1.0» Update a document PUT /mydb/doc_id HTTP/1.0 {"album" : "Brothers", "artist" : "The Black Keys"}» Delete a document DELETE /mydb/doc_id HTTP/1.0

TRADITIONAL GET-BASED CSRF <img src="http://nosql:5984/_all_dbs"/>» Easy to make a potential victim request this URL» But it doesn t do the attacker any good» He needs to get the data back out to himself

RIA GET-BASED CSRF <script> var xhr = new XMLHttpRequest(); xhr.open('get', 'http://nosql:5984/_all_dbs'); xhr.send(); </script>» Same-origin policy won t allow this (usually)» Same issue for PUT and DELETE

POST-BASED CSRF <form method=post action='http://nosql:5984/db'> <input type='hidden' name='{"data"}' value='' /> </form> <script> // auto-submit the form </script>» Ok by the same-origin policy!

CSRF INJECTION DEMOS

POST IS ALL AN ATTACKER NEEDS Insert arbitrary data Insert arbitrary script data Execute any REST command from inside the firewall

QUESTIONS?» http://blogs.adobe.com/asset» brsulliv @ adobe