Exploi'ng NoSQL Like Never Before HITB AMS 2014



Similar documents
Attacking MongoDB. Firstov Mihail

Cloud Scale Distributed Data Storage. Jürmo Mehine

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

An Open Source NoSQL solution for Internet Access Logs Analysis

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

Getting Started with SandStorm NoSQL Benchmark

Cloud Powered Mobile Apps with Azure

NOSQL INTRODUCTION WITH MONGODB AND RUBY GEOFF

Analytics March 2015 White paper. Why NoSQL? Your database options in the new non-relational world

MongoDB Developer and Administrator Certification Course Agenda

ASL IT Security Advanced Web Exploitation Kung Fu V2.0

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

Overview of Databases On MacOS. Karl Kuehn Automation Engineer RethinkDB

Media Upload and Sharing Website using HBASE

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

Database Management System Choices. Introduction To Database Systems CSE 373 Spring 2013

An Approach to Implement Map Reduce with NoSQL Databases

On- Prem MongoDB- as- a- Service Powered by the CumuLogic DBaaS Platform

NoSQL Databases. Nikos Parlavantzas

Document Oriented Database

ADVANCED DATABASES PROJECT. Juan Manuel Benítez V Gledys Sulbaran

NoSQL: Going Beyond Structured Data and RDBMS

Open Source Technologies on Microsoft Azure

Perl & NoSQL Focus on MongoDB. Jean-Marie Gouarné jmgdoc@cpan.org

Evaluation of NoSQL databases for large-scale decentralized microblogging

Getting Started with MongoDB

HDB++: HIGH AVAILABILITY WITH. l TANGO Meeting l 20 May 2015 l Reynald Bourtembourg

Cyber Security Challenge Australia 2014

FileMaker 12. ODBC and JDBC Guide

COSC 6397 Big Data Analytics. 2 nd homework assignment Pig and Hive. Edgar Gabriel Spring 2015

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

Can the Elephants Handle the NoSQL Onslaught?

Big Data. Facebook Wall Data using Graph API. Presented by: Prashant Patel Jaykrushna Patel

Big Data Development CASSANDRA NoSQL Training - Workshop. March 13 to am to 5 pm HOTEL DUBAI GRAND DUBAI

Ruby on Rails Secure Coding Recommendations

@tobiastrelle. codecentric AG 1

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

Assessing BYOD with the Smarthpone Pentest Framework. Georgia Weidman

Scaling up = getting a better machine. Scaling out = use another server and add it to your cluster.

SysPatrol - Server Security Monitor

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

MongoDB Security Guide

Lecture Data Warehouse Systems

Sentimental Analysis using Hadoop Phase 2: Week 2

What is Web Security? Motivation

How graph databases started the multi-model revolution

Programming Against Hybrid Databases with Java Handling SQL and NoSQL. Brian Hughes IBM

by

Current Data Security Issues of NoSQL Databases

Lecture 15 - Web Security

Cloud Application Development (SE808, School of Software, Sun Yat-Sen University) Yabo (Arber) Xu

Comparing SQL and NOSQL databases

STABLE & SECURE BANK lab writeup. Page 1 of 21

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

Using Redis as a Cache Backend in Magento

Big data and urban mobility

MADOCA II Data Logging System Using NoSQL Database for SPring-8

Big data is like teenage sex: everyone talks about it, nobody really knows how to do it, everyone thinks everyone else is doing it, so everyone

Securing ios Applications. Dr. Bruce Sams, OPTIMAbit GmbH

NoSQL systems: introduction and data models. Riccardo Torlone Università Roma Tre

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

Integrating Big Data into the Computing Curricula

Introduction to Big Data Training

Source Code Review Using Static Analysis Tools

MongoDB: document-oriented database

Sharding with postgres_fdw

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

Programming Hadoop 5-day, instructor-led BD-106. MapReduce Overview. Hadoop Overview

PaaS Operation Manual

NoSQL web apps. w/ MongoDB, Node.js, AngularJS. Dr. Gerd Jungbluth, NoSQL UG Cologne,

nosql and Non Relational Databases

FileMaker 11. ODBC and JDBC Guide

NoSQL Database Systems and their Security Challenges

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

UQC103S1 UFCE Systems Development. uqc103s/ufce PHP-mySQL 1

Evaluating NoSQL for Enterprise Applications. Dirk Bartels VP Strategy & Marketing

NoSQL Database Options

The MongoDB Tutorial Introduction for MySQL Users. Stephane Combaudon April 1st, 2014

Data storing and data access

CSCC09F Programming on the Web. Mongo DB

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

these three NoSQL databases because I wanted to see a the two different sides of the CAP

Programming with Genero BDL and NoSQL Databases

Web Applica+on Security: Be Offensive! About Me

NoSQL Databases. Institute of Computer Science Databases and Information Systems (DBIS) DB 2, WS 2014/2015

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

Oracle Database Cloud Services OGh DBA & Middleware Day

The Top Web Application Attacks: Are you vulnerable?

Agenda. SQL Injection Impact in the Real World Attack Scenario (1) CHAPTER 8 SQL Injection

MONGODB - THE NOSQL DATABASE

Big Data and Scripting Systems build on top of Hadoop

Portals and Hosted Files

How to hack a website with Metasploit

L7_L10. MongoDB. Big Data and Analytics by Seema Acharya and Subhashini Chellappan Copyright 2015, WILEY INDIA PVT. LTD.

Thick Client Application Security

Transcription:

Exploi'ng NoSQL Like Never Before HITB AMS 2014

About Me Independent Security Researcher Member @ OpenSecurity Currently Pursuing My Bachelors Degree (Amal Jyothi Colle Engineering) Spoken @ a couple of Conferences Sleep @ Morning, Researches and Codes @ Night And I Live in India (Kerala)

India is Awesome Kerala is Super Awesome J

Tea Gardens

Boat Rides

Boat Racing

Agenda More Emphasis Given on the Server- Client and Server Management Consoles PentesRng Scenarious are given more importance. We will not deal with Memory Related Bugs or issues. Demos

INTRO TO NOSQL

2 Words Super COOL

Key Takeovers Schema less Support ACID (atomicity, consistency, isolaron and durability) Open- source Not using the relaronal model Running well on clusters Built for the 21st century web estates

Mainly 4 types Wide Column Store / Column Families Hbase Cassandra Document Store MongoDB CouchDB Key Value / Tuple Store Riak Redis Graph Databases Neo4J DEX

NoSQL Security

Why Developers Need to Worry?

Low on Security Emphasizes on Trusted Environment Weak AuthenRcaRon Mechanisms or No security by Default. Man in the Middle Widely Open Source and API s Widely Exposed. API for PHP widely abused.

You Will Love this Part J

ABUSING API CALLS

No Proper ValidaRon in API Calls Developers Use them to Develop various ApplicaRons PHP is easy to abuse for Mongo,Couch, Cassandra.

MongoDB

Mongo Trivia Wri`en in: C++ Main point: Retains some friendly properres of SQL. (Query, index) Protocol: Custom, binary (BSON) Mongod is the "Mongo Daemon running on Port 27017 by Default Web Interface Runs on 28017 Mongo is the Client à Mongod Uses MongoDB Wire Protocol (TCP/IP Socket) Data is Represented using JSON format

Mongo Architecture

Mongo Client Mongo Client Mongo Client Mongo Server

ackers rspec've Mongo Client Mongo Client Mongo Client Sniffing,EnumeraRon,JS InjecRon,DOS Mongo Server

JS ATack Surface

Issues JavaScript A`acks mostly used against MongoDB VulnerabiliRes Keep Popping Up Run command RCE Mongo Shell FuncRons Purely Based on JavaScript Possible Chances to Overwrite FuncRons Resource ExhausRon Regex Matching,plenty of JavaScript operarons could be used

Create DB use dbname Create CollecRon db.createcollecron( collecron_name ) ome seful ongo ommands Insert Data db.collecron_name.insert({user_id: 25,age:10}) Delete Data db.collecron_name.remove({user_id: 25 }) Drop db.dropdatabase() db.collecron_name.drop() Version db.version() Stats db.hostinfo ()

Useful Commands for us db.killop(opid) db.listcommands() db.loadserverscripts() db.logout() db.repairdatabase()

db.runcommand(cmdobj) db.serverstatus() db.shutdownserver() db.stats() db.version() The list doesn t end here more API calls @ Mongo References.

Mapping SQL Logical Commands to MongoDB and mapped to && or to = to ==

Saving JavaScript

Post Exploita'on Phase Allows the a`acker to write JavaScript funcrons and save them Can use for further a`acks when needed. db.system.js.save( { _id : hitb2014ams", value : funcron (x, y){ return x + y; } } ); db.loadserverscripts()

Injec'ng JavaScript

Reference to DB in Mongo Mongo FuncRons get to refer the db object and its main funcrons An a`acker who finds an InjecRon point could abuse this. Found in Versions 2.2 or less Mongo Patched for versions above. Does JS InjecRon end here?

Timing Based Checks ApplicaRon can be tested for Rme based a`acks Mongo Shell Supports most of JavaScript funcrons funcron(){ return sleep(500);} would render the applicaron response delayed by 5sec. Module added to NoSQL framework while tesrng for JS InjecRon a`acks

THIS Pointer Reference Although mongo blocks reference to the db has ended A`acker could use this pointer to return objects and dumping as always

Vulnerable APP DEMO

What if THIS is Blocked? Version to Rescue Version command by default binds to mongo instances defined funcrons So if an admin blocks the this pointer funcron(){return this} Blocked FuncRon(){return version} or funcron(){return version()) Scenario useful when developer uses $where to evaluate js code.

Vulnerable APP DEMO

Mongo With PHP PHP converts parameter with brackets to arrays. Already addressed issue in previous researches Lets Look at Some New vectors $exists $type $all

Vulnerable APP DEMO

Resource Exhaus'on Mongo on 32 bit environment is too easy for a`ackers (Max Size limit 2GB) Use command creates arbitrary schemas on the fly A`acker could run it conrnuously exhausrng the disk space resource as well as memory. var i=1;while(1){use i=i+1;} An empty database takes up 192Mb

CouchDB

CouchDB Architecture

Couch Architecture Backend CouchDB Couch FUTIL Interface Administrator

Backend CouchDB uchdb acker Perspec've Couch FUTIL Interface Administrator

Key Features Wri`en in: Erlang CouchDB document is a JSON object Schema- Free Main point: DB consistency, ease of use Protocol: HTTP/REST Distributed database system Runs on Default Port : 5984,Binds to loopback interface by default Client uses REST API to communicate with the Backend Futon Web Interface

ATack Surface Admin Party = Game Over. Auth Cookie Sniffable CredenRals Send over Unencrypted Channel XSPA a`acks in ReplicaRon (limited to port web server ports) XSS,HTML InjecRon in Futon Interface DOS (Versions on 1.5 and below),file EnumeraRon a`acks

Vulnerabili'es XSS at the token interface HTML injecron can be used by a`ackers to lure the vicrm to other sites. XSPA A`ack can be used in the replicaron to check whether port is open or not Blind File Name EnumeraRon possible within the ReplicaRon

Addressing Auth Cookie Defaults to Expire within 10 min A`acker gaining access would want to use these 10 min Fruizully NoSQL Framework kicks in with automaron session grabbing and dumping necessary info.

PHP on Couch Driver Uses Curl Library to send the requests to the API Un validated PHP APPS could result in calling Arbitrary API Call ExecuRon Download PHP on Couch: h`ps://github.com/dready92/php- on- Couch/

Vulnerable APP DEMO

Redis

Redis Architecture

Key Features Key Value storage engine. Contains Redis Server and Client Driven By a Config File DocumentaRon is Laugh in a Park Redis supports five data structures: strings, hashes, lists, sets and ordered sets.

ATacks Discussed Bruteforce Redis Passwords Denial of Service on the FLY. Command Killing Config Rewrite Arbitrary File Rewrite Blind File EnumeraRon (usefull in pentests)

Redis Version Redis Version 2.6 No Support For ScripRng. Redis Introduced version 2.8 Added Ability for LUA Scripts

Did We Just Say Scrip'ng?

Welcome to Redis LUA Script Engine and Basics Redis uses LUA to manage scripts LUA engine is properly sandboxed and offers enough security Global variables protec?on Scripts are Executed using eval (Available from Redis 2.6)

Limited number of available of Available Libraries for Use base lib. table lib. string lib. math lib. debug lib. cjson lib. cmsgpack lib.

Key Points EVAL and EVALSHA are used to evaluate scripts using the Lua interpreter built into Redis. SCRIPT KILL,LISTS,EXISTS Important NB: When a script is running no other funcrons can be accessed or any operarons can be performed

Sample Lua One Line DOS redis- cli eval "$(cat test.lua)" 0 test.lua

Commands Disabled By an ATacker rename-command API Call Used Sample Command rename-command CONFIG l33tshit rename-command CONFIG " Disables the command completely

Arbitrary File Rewrite CONFIG GET Gives the Current set of ConfiguraRon CONFIG SET Sets the configuraron of the default command CONFIG SET dir /var/www

File Name Enumera'on Restricted Environment Allows to use dofile (open file in lua scriprng) Although file doesn t open gives the file or directory exists or not eval "dofile('/var/www')" 0 Directory Exists but cant open file eval "dofile('/var/wwws')" 0 No such directory exists

Vulnerable APP DEMO

Cassandra

Key Takeaways Wri`en in: Java Main point: Store huge datasets in "almost" SQL Protocol: CQL3 & Thri CQL3 is very similar SQL, but with some limitarons that come from the scalability (most notably: no JOINs, no aggregate funcrons.) Runs on Port : 9160

Sad Facts? No OR No UNION No subrequests Terms must be indexed Primary key can only be queried for

Security Issues Cassandra model Keyspace (=database) ColumnFamily > Data CQL injecron on Web Apps Shell Commands can be useful to a`acker(during privilege escalaron). SOURCE command Reads the contents of the file Database EnumeraRon and Dumping using NoSQL ExploitaRon Framework

H- Base

Key Points Wri`en in: Java Main point: Billions of rows X millions of columns Protocol: HTTP/REST (also Thri) Port:6379,8080(Rest API) Emphasis on Trusted Environment

Security Issues By Default offers No Security Man in The Middle A`acks REST API exposed Database Scanning and EnumeraRon using NoSQL ExploitaRon Framework

NoSQL DB s Never End!! More Research Needed Ne04j,Memcache,Riak are under scanners(some Discussed VulnerabiliRes applies to those also) Support for Neo4j,Memcache and Riak soon to be added Memory Leaks and Overflows on the Rise An excellent address to Ne04j security issue was wri`en recently Link:h`p://blog.scrt.ch/2014/05/09/neo4j- enter- the- graphdb/

Is Automa'on Needed? Do We have a framework?

NoSQL Exploita'on Framework

Key Points A framework of one of its Kind Open Source, Wri`en In Python I am not a hardcode coder(bugs are prone J ) Over 1200 lines of code J Documented API s Code Download:nosqlproject.com

Key Features Support for Mongo,Couch,Redis- Base and Cassandra Support for: NoSQL Run Web ApplicaRons Tests for JavaScript A`acks Mongo DB $ A`acks Couch PHP Driver A`ack Vectors MulRthreaded Mass IP List Scanner

And the List Con'nues Database Cloning Feature Brute force & DicRonary a`acks Post ExploitaRon Module Integrated Shodan IP List Grabber Sniffing DB credenrals and cookies Added More Payload List

Future Updates Updated Cassandra and HBase a`acks Resource ExhausRon Support for Riak,Memcache and Ne04j on its way. More Stable (Bug Less J )

Bugs or Contribute J Official Mailing List: feedback@nosqlproject.com Contribute By pulling from GITHUB.

References h`p://kkovacs.eu/cassandra- vs- mongodb- vs- couchdb- vs- redis

Thank You

Grab Me On Facebook : francis.alexander.33 Twi`er: @torque59 Github: torque59 LinkedIn: