Shield talk elasticsearch meetup Zurich 27.05.2015

63
Shield security for Elasticsearch

Transcript of Shield talk elasticsearch meetup Zurich 27.05.2015

Page 1: Shield talk elasticsearch meetup Zurich 27.05.2015

Shieldsecurity for Elasticsearch

Page 2: Shield talk elasticsearch meetup Zurich 27.05.2015
Page 3: Shield talk elasticsearch meetup Zurich 27.05.2015

Agenda• Introduction

• Security requirements

• Alternative approaches

• Shield features

• Demo

• Q&A

Page 4: Shield talk elasticsearch meetup Zurich 27.05.2015

Security requirements

• Prevent unauthorised access

• Preserve data integrity

• Provide an audit trail

Page 5: Shield talk elasticsearch meetup Zurich 27.05.2015

Alternative approaches

• Network separation, Firewall etc.

• Reverse proxy

• Apache HTTPD

• nginx

Page 6: Shield talk elasticsearch meetup Zurich 27.05.2015

es cluster

node

node

node

client

reverse proxy

Page 7: Shield talk elasticsearch meetup Zurich 27.05.2015

Shield introduction

• provides security features for Elasticsearch

• installs as a plugin on an Elasticsearch node

• License required

• integrates security at a low-level

Page 8: Shield talk elasticsearch meetup Zurich 27.05.2015

Shield installation

• bin/plugin -i elasticsearch/license/latest

• bin/plugin -i elasticsearch/shield/latest

Page 9: Shield talk elasticsearch meetup Zurich 27.05.2015

Shield features• IP filtering

• Authentication

• Authorization

• Node authentication & encryption

• Auditing

Page 10: Shield talk elasticsearch meetup Zurich 27.05.2015

/doc_store/doc/7384

es cluster

node

node

{      "_id":  "837826",      "_source":  {          "type":  “delivery_note”,          "content":  …      }  }

Page 11: Shield talk elasticsearch meetup Zurich 27.05.2015

/doc_store/doc/7384

es cluster

node

nodenode

user access

node access

Page 12: Shield talk elasticsearch meetup Zurich 27.05.2015
Page 13: Shield talk elasticsearch meetup Zurich 27.05.2015

IP filtering• Application-level filtering of IP addresses

• Prevent clients from accessing a cluster

• Prevent nodes from joining a cluster

• configuration in elasticsearch.yml

• Dynamic update of rules possible

Page 14: Shield talk elasticsearch meetup Zurich 27.05.2015

shield.transport.filter.allow: “10.0.0.100”shield.transport.filter.deny: “10.0.0.0/24”

one allow and deny statement

allow takes precedence

Page 15: Shield talk elasticsearch meetup Zurich 27.05.2015

shield.transport.filter.allow: [“10.0.0.1”, “10.0.0.2”]shield.transport.filter.deny: _all

statements can contain an array

“_all” denies everything not declared before

Page 16: Shield talk elasticsearch meetup Zurich 27.05.2015

shield.transport.filter.allow: company.comshield.transport.filter.deny: *.google.com

statements can contain domain names

Page 17: Shield talk elasticsearch meetup Zurich 27.05.2015

shield.transport.filter.allow: localhostshield.transport.filter.deny: '*.google.com'shield.http.filter.allow: 172.16.0.0/16shield.http.filter.deny: _all

transport and http client separation

Page 18: Shield talk elasticsearch meetup Zurich 27.05.2015

/doc_store/doc/7384

es cluster

node

node

Authentication IP filtering

Page 19: Shield talk elasticsearch meetup Zurich 27.05.2015
Page 20: Shield talk elasticsearch meetup Zurich 27.05.2015

Authentication• Users must prove their identity to access a resource

• Authentication provider implemented as realms

• Realms live in an realm chain

• Multiple providers

• esusers

• LDAP

• Active Directory

Page 21: Shield talk elasticsearch meetup Zurich 27.05.2015

shield.authc: realms: es_users: type: esusers order: 0 ldap1: type: ldap order: 1 enabled: false url: "ldap://path/to/ldap"

elasticsearch.yml

Page 22: Shield talk elasticsearch meetup Zurich 27.05.2015

shield.authc: realms: es_users: type: esusers order: 0 ldap1: type: ldap order: 1 enabled: false url: "ldap://path/to/ldap"

elasticsearch.yml

realm definition

Page 23: Shield talk elasticsearch meetup Zurich 27.05.2015

shield.authc: realms: es_users: type: esusers order: 0 ldap1: type: ldap order: 1 enabled: false url: "ldap://path/to/ldap"

elasticsearch.yml

each realm has a specific type

Page 24: Shield talk elasticsearch meetup Zurich 27.05.2015

shield.authc: realms: es_users: type: esusers order: 0 ldap1: type: ldap order: 1 enabled: false url: "ldap://path/to/ldap"

elasticsearch.yml

each realm has a execution order

Page 25: Shield talk elasticsearch meetup Zurich 27.05.2015

esusers

• File based internal realm

• Easy to use

• command line administration tools

Page 26: Shield talk elasticsearch meetup Zurich 27.05.2015

esusers

• bin/shield/esusers list

• bin/shield/esusers useradd <user> -r <role>

• bin/shield/esusers userdel <user>

Page 27: Shield talk elasticsearch meetup Zurich 27.05.2015

Demo

Page 28: Shield talk elasticsearch meetup Zurich 27.05.2015

LDAP & Active Directory realms

• authentication against external ldap or ad server

• supports SSL/TLS using ldap

• Elasticsearch roles can be mapped to LDAP/AD groups

• cached users in memory

Page 29: Shield talk elasticsearch meetup Zurich 27.05.2015

monitoring: - "cn=admins,dc=example,dc=com"user: - "cn=users,dc=example,dc=com" - "cn=admins,dc=example,dc=com" - "cn=John Doe,cn=contractors,dc=example,dc=com"

config/shield/rolemapping.yml

Page 30: Shield talk elasticsearch meetup Zurich 27.05.2015

monitoring: - "cn=admins,dc=example,dc=com"user: - "cn=users,dc=example,dc=com" - "cn=admins,dc=example,dc=com" - "cn=John Doe,cn=contractors,dc=example,dc=com"

config/shield/rolemapping.yml

Elasticsearch role name

Page 31: Shield talk elasticsearch meetup Zurich 27.05.2015

monitoring: - "cn=admins,dc=example,dc=com"user: - "cn=users,dc=example,dc=com" - "cn=admins,dc=example,dc=com" - "cn=John Doe,cn=contractors,dc=example,dc=com"

config/shield/rolemapping.yml

values are ldap groups and users

Page 32: Shield talk elasticsearch meetup Zurich 27.05.2015

/doc_store/doc/7384

es cluster

node

node

Authorization

Authentication IP filtering

Page 33: Shield talk elasticsearch meetup Zurich 27.05.2015
Page 34: Shield talk elasticsearch meetup Zurich 27.05.2015

Authorization• Determines if the user has the right to execute a

action over a resource

• Role based access control (RBAC)

• Every role defines a set of permissions over clusters and indices

• set of predefined permissions

Page 35: Shield talk elasticsearch meetup Zurich 27.05.2015

administrator: cluster: all indices: '*': all

user: indices: '*': search

logs_user: indices: 'logs-*': read

config/shield/roles.yml

Page 36: Shield talk elasticsearch meetup Zurich 27.05.2015

administrator: cluster: all indices: '*': all

user: indices: '*': search

logs_user: indices: 'logs-*': read

config/shield/roles.yml

Elasticsearch role name

Page 37: Shield talk elasticsearch meetup Zurich 27.05.2015

administrator: cluster: all indices: '*': all

user: indices: '*': search

logs_user: indices: 'logs-*': read

config/shield/roles.yml

cluster related privileges

Page 38: Shield talk elasticsearch meetup Zurich 27.05.2015

administrator: cluster: all indices: '*': all

user: indices: '*': search

logs_user: indices: 'logs-*': read

config/shield/roles.yml

indices and aliases privileges

Page 39: Shield talk elasticsearch meetup Zurich 27.05.2015

administrator: cluster: all indices: '*': all

user: indices: '*': search

logs_user: indices: 'logs-*': read

config/shield/roles.yml

access to all indices with any action

Page 40: Shield talk elasticsearch meetup Zurich 27.05.2015

administrator: cluster: all indices: '*': all

user: indices: '*': search

logs_user: indices: 'logs-*': read

config/shield/roles.yml

access to suggest and search permission

on all indices

Page 41: Shield talk elasticsearch meetup Zurich 27.05.2015

administrator: cluster: all indices: '*': all

user: indices: '*': search

logs_user: indices: 'logs-*': read

config/shield/roles.yml

access to read every index which starts with “logs-“

Page 42: Shield talk elasticsearch meetup Zurich 27.05.2015

Complete privileges reference:

http://www.elastic.co/guide/en/shield/current/reference.html#privileges-list

Page 43: Shield talk elasticsearch meetup Zurich 27.05.2015

{ content: … type: offer}

{ content: … type: pod}

{ content: … type: delivery_note}

documents

Page 44: Shield talk elasticsearch meetup Zurich 27.05.2015

{ content: … type: offer}

{ content: … type: pod}

{ content: … type: delivery_note}

documents

admin

/documents/doc/_search

Page 45: Shield talk elasticsearch meetup Zurich 27.05.2015

{ content: … type: offer}

{ content: … type: pod}

{ content: … type: delivery_note}

documents

admin

/documents/doc/_search

admin: indices: ‘documents’: all

Page 46: Shield talk elasticsearch meetup Zurich 27.05.2015

{ content: … type: offer}

{ content: … type: pod}

{ content: … type: delivery_note}

documents

logistics

Page 47: Shield talk elasticsearch meetup Zurich 27.05.2015

{ content: … type: offer}

{ content: … type: pod}

{ content: … type: delivery_note}

documents

logistics

"filter": {"terms": {"type": ["pod", "delivery_note"]}}

Page 48: Shield talk elasticsearch meetup Zurich 27.05.2015

{ content: … type: offer}

{ content: … type: pod}

{ content: … type: delivery_note}

documents

/documents_logistics/_search

logistics: indices: ‘documents_logistics’: all

"filter": {"terms": {"type": ["pod", "delivery_note"]}}

logistics

Page 49: Shield talk elasticsearch meetup Zurich 27.05.2015

Demo

Page 50: Shield talk elasticsearch meetup Zurich 27.05.2015

es cluster

node node

Page 51: Shield talk elasticsearch meetup Zurich 27.05.2015

es cluster

node node

Page 52: Shield talk elasticsearch meetup Zurich 27.05.2015

es cluster

node node

Page 53: Shield talk elasticsearch meetup Zurich 27.05.2015

Node authentication and encryption

• traffic encryption using SSL/TLS

• node authentication using certificates

• certificates can be self signed or signed by CA (recommended)

• traffic separation

• JCE extensions for stronger encryption

Page 54: Shield talk elasticsearch meetup Zurich 27.05.2015

shield.ssl.keystore.path: /usr/local/es/config/node01.jksshield.ssl.keystore.password: mypassword

elasticsearch.yml

full path to the keystore file

Page 55: Shield talk elasticsearch meetup Zurich 27.05.2015

shield.ssl.keystore.path: /usr/local/es/config/node01.jksshield.ssl.keystore.password: mypassword

elasticsearch.yml

the password to decrypt the keystore

Page 56: Shield talk elasticsearch meetup Zurich 27.05.2015

shield.transport.ssl: trueshield.http.ssl: true

elasticsearch.yml

enable SSL on the HTTP layer

enable SSL on the network layer

Page 57: Shield talk elasticsearch meetup Zurich 27.05.2015
Page 58: Shield talk elasticsearch meetup Zurich 27.05.2015

Auditing

• Logging of security events

• Currently outputs to file

• Logging level

Page 59: Shield talk elasticsearch meetup Zurich 27.05.2015

shield.audit.enabled: true

elasticsearch.yml

enable audit logging

Page 60: Shield talk elasticsearch meetup Zurich 27.05.2015

Auditing examples

• access

• failed authentications

• anonymous requests

• unauthorised access

Page 61: Shield talk elasticsearch meetup Zurich 27.05.2015

Q&A

Page 63: Shield talk elasticsearch meetup Zurich 27.05.2015

Credits• mimacom: www.mimacom.com

• Elasticsearch: https://www.elastic.co/

• Images: • https://icons8.com/ • http://dilbert.com/ • http://c279160.r60.cf1.rackcdn.com/assets/blog_post/meta_og_image/115/hiring.png • http://funny-pictures-blog.com/wp-content/uploads/funny-pictures/Security-Gate-Fail.jpg • http://2.bp.blogspot.com/-o-0b_5ReFyQ/VOwNd6ktk4I/AAAAAAAAMkE/B8HL_zQAjGY/

s1600/security-chain-fence-funny-demotivational-posters-1296250082.jpg • http://s2.quickmeme.com/img/5c/

5c9e05a465c753417dbde949ee285fd9e56f0739ad0254de838a7d8c61c1a318.jpg • http://media.giphy.com/media/YdaqReCo5D51m/giphy.gif