INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt...

66
NoSQL MEANS No SECURITY? Philipp Kre@xer

Transcript of INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt...

Page 1: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

NoSQLMEANS No SECURITY?

Philipp Krenn̴̴̴̴@xeraa

Page 2: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

INFRASTRUCTURE | DEVELOPER ADVOCATE

Page 3: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

https://db-engines.com/en/ranking

Page 4: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the
Page 5: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the
Page 6: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the
Page 7: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the
Page 8: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the
Page 9: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the
Page 10: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Injections

Page 11: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

JavaScript InjectionHTTP://WWW.KALZUMEUS.COM/2010/09/22/SECURITY-LESSONS-LEARNED-FROM-THE-DIASPORA-LAUNCH/

def self.search(query) Person.all('$where' => "function() { return this.diaspora_handle.match(/^#{query}/i) || this.profile.first_name.match(/^#{query}/i) || this.profile.last_name.match(/^#{query}/i); }")end

Page 12: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Problem JS Evaluation$where

db.eval()

db.runCommand( { mapReduce:

db.collection.group()

Page 13: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Solution JS EvaluationDEACTIVATE: --noscripting OR security.javascriptEnabled: false

ESCAPE: CodeWScope

Page 14: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Saarbrücker Cybersicherheits-Studenten entdecken bis zu 40.000 ungesicherte

Datenbanken im Internet— http://www.uni-saarland.de/nc/aktuelles/artikel/nr/12173.html,

Feb 2015

Page 15: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Massive ransomware attack takes out 27,000 MongoDB servers

— http://www.techrepublic.com/article/massive-ransomware-attack-takes-out-27000-mongodb-servers/, Jan 2017

Page 16: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Bound to all interfaces by default?

Page 17: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the
Page 18: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Authentication enabled by default?

Page 19: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Authentication & Authorization

Page 20: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Enableauth=true

Page 21: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

<3.0MONGODB CHALLENGE RESPONSE

(MONGODB-CR)

Page 22: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

>=3.0IETF RFC 5802 (SCRAM-SHA-1)

Page 23: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

SCRAM-SHA-1CONFIGURABLE iterationCount

SALT PER USER INSTEAD OF SERVERSHA-1 INSTEAD OF MD5

SERVER AUTHENTICATES AGAINST THE CLIENT AS WELL

Page 24: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Predefined Rolesread / readAnyDatabase

readWrite / readWriteAnyDatabasedbAdmin / dbAdminAnyDatabase

userAdmin / userAdminAnyDatabasedbOwner

BACKUP, RESTORE, CLUSTER MANAGEMENT,...

Page 25: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the
Page 26: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

>=3.0SSL INCLUDED

(ALMOST) EVERYWHERE

Page 27: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the
Page 28: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Bound to all interfaces by default?

Page 29: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Protected Mode

Page 30: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

>=3.2.0ANSWER LOCAL QUERIES

RESPOND WITH AN ERROR FOR REMOTE

Page 31: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Authentication & Authorization

Page 32: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

a tiny layer of authentication— http://redis.io/topics/security

Page 33: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

AUTH <password> COMMAND

PLAIN-TEXT PASSWORD IN REDIS.CONF

NO (BUILT-IN) SSL OR RATE LIMITS

Page 34: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Hiding Commands

Page 35: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

SET IN REDIS.CONF

RESET AFTER RESTART

Page 36: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

rename-command CONFIG mysecretconfigname

Page 37: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

rename-command CONFIG ""

Page 38: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

PS: Don't Pass in Random Lua Scripts

Page 39: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the
Page 40: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Bound to all interfaces by default?

Page 41: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Broadcasting on the local subnet?

Page 42: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Running as root?

Page 43: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Cockroachesclaims that disappear for a while when proved wrong, but just keep on coming back

Page 44: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Scripting

Page 45: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

ELASTICSEARCHHTTPS://WWW.ELASTIC.CO/COMMUNITY/SECURITY

CVE-2014-3120 (6.8): Dynamic scriptingCVE-2014-6439 (4.3): CORS misconfigurationCVE-2015-1427 (6.8): Groovy sandbox escapeCVE-2015-3337 (4.3): Directory traversalCVE-2015-4165 (3.3): File modificationsCVE-2015-5377 (5.1): RCE related to GroovyCVE-2015-5531 (5.0): Directory traversal

Page 46: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

ELASTICSEARCHHTTPS://WWW.ELASTIC.CO/COMMUNITY/SECURITY

CVE-2014-3120 (6.8): Dynamic scriptingCVE-2014-6439 (4.3): CORS misconfigurationCVE-2015-1427 (6.8): Groovy sandbox escapeCVE-2015-3337 (4.3): Directory traversalCVE-2015-4165 (3.3): File modificationsCVE-2015-5377 (5.1): RCE related to GroovyCVE-2015-5531 (5.0): Directory traversal

Page 47: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Painless

Page 48: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

HIRED DEVELOPER

1 YEAR DEVELOPMENT

Page 49: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Why build a brand new language when there are already so many to choose

from?— https://www.elastic.co/blog/painless-a-new-scripting-language

Page 50: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

GoalSECURE & PERFORMANT

Page 51: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

POST posts/doc/1/_update{ "script": { "lang": "painless", "source": """if(ctx._source.details.containsKey("plus_ones")) { ctx._source.details.plus_ones++;} else { ctx._source.details.plus_ones = 1;}""" }}

Page 52: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Painless DEFAULTGROOVY, PYTHON, JAVASCRIPT DEPRECATED

Page 53: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Authentication & Authorization

Page 54: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the
Page 55: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

$ curl -XGET 'http://67.205.153.88:9200/_cat/indices'yellow open goal12 5 1 9397 0 27mb 27mbyellow open please_read 5 1 1 0 4.9kb 4.9kbyellow open un-webhose 5 1 2294 1 25.4mb 25.4mbyellow open goal11 5 1 4828 0 13.3mb 13.3mb

Page 56: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

$ curl -XGET 'http://67.205.153.88:9200/please_read/_search?pretty'{ "took" : 1, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 1, "max_score" : 1.0, "hits" : [ { "_index" : "please_read", "_type" : "info", "_id" : "AVm3qmXeus_FduwRD54v", "_score" : 1.0, "_source" : { "Info" : "Your DB is Backed up at our servers, to restore send 0.5 BTC to the Bitcoin Address then send an email with your server ip", "Bitcoin Address" : "12JNfaS2Gzic2vqzGMvDEo38MQSX1kDQrx", "Email" : "[email protected]" } } ] }}

Page 57: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the
Page 58: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the
Page 59: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the
Page 60: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Conclusion

Page 61: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Injections Are Still a Thing

Page 62: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Enable Security by Default

Page 63: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Be Creative — Or Not

Page 64: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Custom Scripting Can Make Sense

Page 65: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Security Takes Time

Page 66: INFRASTRUCTURE | DEVELOPER ADVOCATE · 2018-02-06 · scram-sha-1 configurable iterationcount salt per user instead of server sha-1 instead of md5 server authenticates against the

Thanks!QUESTIONS?

Philipp Krenn̴̴̴̴̴@xeraa