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

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

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

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

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

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

Application security testing: Protecting your application and data

WEB SECURITY CONCERNS THAT WEB VULNERABILITY SCANNING CAN IDENTIFY

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

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

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

Attacking MongoDB. Firstov Mihail

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

NO SQL! NO INJECTION?

Network Security Exercise #8

Web-Application Security

Web Application Security

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

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

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

Web Application Security

CSE598i - Web 2.0 Security OWASP Top 10: The Ten Most Critical Web Application Security Vulnerabilities

Webapps Vulnerability Report

EVALUATING COMMERCIAL WEB APPLICATION SECURITY. By Aaron Parke

(WAPT) Web Application Penetration Testing

The Top Web Application Attacks: Are you vulnerable?

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

Magento Security and Vulnerabilities. Roman Stepanov

Cyber Security Challenge Australia 2014

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

Thomas Röthlisberger IT Security Analyst

Check list for web developers

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

Exploi'ng NoSQL Like Never Before HITB AMS 2014

MongoDB in the NoSQL and SQL world. Horst Rechner Berlin,

Overview of Databases On MacOS. Karl Kuehn Automation Engineer RethinkDB

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

Hack Proof Your Webapps

Chapter 1 Web Application (In)security 1

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

Project 2: Web Security Pitfalls

Detecting and Exploiting XSS with Xenotix XSS Exploit Framework

Sichere Webanwendungen mit Java

Where every interaction matters.

Sitefinity Security and Best Practices

Exploiting Web 2.0 Next Generation Vulnerabilities

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

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

Web Application Report

OWASP Top Ten Tools and Tactics

Cross-Site Scripting

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

Complete Cross-site Scripting Walkthrough

SQL VS. NO-SQL. Adapted Slides from Dr. Jennifer Widom from Stanford

Hack Yourself First. Troy troyhunt.com

HTTPParameter Pollution. ChrysostomosDaniel

How To Write A Web Application Vulnerability Scanner And Security Auditor

Security Model for the Client-Side Web Application Environments

An Open Source NoSQL solution for Internet Access Logs Analysis

SQL INJECTION IN MYSQL

Web application security

Using Free Tools To Test Web Application Security

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

Still Aren't Doing. Frank Kim

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

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

Institutionen för datavetenskap

Security Testing with Selenium

Blackbox Reversing of XSS Filters

Preparing for the Cross Site Request Forgery Defense

Acunetix Website Audit. 5 November, Developer Report. Generated by Acunetix WVS Reporter (v8.0 Build )

Network Security Web Security

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

Web application security: Testing for vulnerabilities

Testnet Summerschool. Web Application Security Testing. Dave van Stein

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

Web Application Penetration Testing

Next Generation Clickjacking

SECURE APPLICATION DEVELOPMENT CODING POLICY OCIO TABLE OF CONTENTS

We protect you applications! No, you don t. Digicomp Hacking Day 2013 May 16 th 2013

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

Web Application Attacks And WAF Evasion

Improving Web Application Security by Eliminating CWEs Weijie Chen, China INFSY 6891 Software Assurance Professor Dr. Maurice Dawson 15 December 2015

Current Data Security Issues of NoSQL Databases

Web Application Guidelines

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

The Dark Side of Ajax. Jacob West Fortify Software

Security Awareness For Website Administrators. State of Illinois Central Management Services Security and Compliance Solutions

What is Web Security? Motivation

Advanced Web Security, Lab

OWASP AND APPLICATION SECURITY

ETHICAL HACKING APPLICATIO WIRELESS110 00NETWORK APPLICATION MOBILE MOBILE0001

MongoDB Developer and Administrator Certification Course Agenda

NoSQL Database Systems and their Security Challenges

Hack-proof Your Drupal App. Key Habits of Secure Drupal Coding

DIPLOMA IN WEBDEVELOPMENT

Transcription:

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

Agenda Eventual Consistency REST APIs and CSRF NoSQL Injection SSJS Injection

NoSQL databases

Eric Brewer s CAP Theorem Choose any two: Availability Consistency Partition Tolerance

Eventual consistency in social networking

Writes don t propagate immediately

Reading stale data

Reading stale data a more serious case

Agenda Eventual Consistency REST APIs and CSRF NoSQL Injection SSJS Injection

Authentication is unsupported or discouraged 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 The Admin Party : Everyone can do everything by default Riak 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

Port Scanning Demo

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

REST document API examples (CouchDB) Retrieve a document GET /mydb/doc_id HTTP/1.0 Create a document POST /mydb/ HTTP/1.0 { "album" : "Brothers", "artist" : "Black Keys" } Update a document PUT /mydb/doc_id HTTP/1.0 { "album" : "Brothers", "artist" : "The Black Keys" } Delete a document DELETE /mydb/doc_id? rev=12345 HTTP/1.0

Cross-Site Request Forgery (CSRF) firewall bypass

REST document API examples (CouchDB) Retrieve a document GET /mydb/doc_id HTTP/1.0 Create a document POST /mydb/ HTTP/1.0 { "album" : "Brothers", "artist" : "Black Keys" } Update a document PUT /mydb/doc_id HTTP/1.0 { "album" : "Brothers", "artist" : "The Black Keys" } Delete a document DELETE /mydb/doc_id? rev=12345 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> Just as easy to make a potential victim request this URL 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!

REST-CSRF Demo

POST is all an attacker needs Insert arbitrary data Insert arbitrary script data Execute any REST command from inside the firewall

Agenda Eventual Consistency REST APIs and CSRF NoSQL Injection SSJS Injection

NoSQL injection Most developers believe they don t have to worry about things like this with MongoDB we are not building queries from strings, so traditional SQL injection attacks are not a problem. -MongoDB Developer FAQ They re mostly correct

MongoDB and PHP MongoDB expects input in JSON array format find( { 'artist' : 'The Black Keys' } ) In PHP, you do this with associative arrays $collection->find(array('artist' => 'The Black Keys')); This makes injection attacks difficult Like parameterized queries for SQL

MongoDB and PHP 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

$where queries 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

Agenda Eventual Consistency REST APIs and CSRF NoSQL Injection SSJS Injection

Browser war fallout Browser wars have given us incredibly fast and powerful JS engines V8 WebKit Nitro SpiderMonkey Rhino Used for a lot more than just browsers Like NoSQL database engines

Server-side JavaScript injection vs. XSS Client-side JavaScript injection (aka XSS) is #2 on OWASP Top Ten Use it to steal authentication cookies Impersonate victim Create inline phishing sites Self-replicating webworms ie Samy It s really bad. But server-side is much worse.

Server-Side Javascript Injection (SSJI)

SSJI red flags $where clauses Built with user input Injected from querystring manipulation eval() clauses Map/Reduce Stored views/design docs More CSRF possibilities here

Wrapping Up

Conclusions 1. Always use authentication/authorization. Firewalls alone are not sufficient Sometimes you may have to write your own auth code This is unfortunate but better than the alternative 2. Be extremely careful with server-side script. Validate, validate, validate Escape input too

Read my blog: http://blogs.adobe.com/asset Email me: brsulliv