SlideShare uma empresa Scribd logo
1 de 34
Low Hanging Fruit:
Securing Your Basic
MongoDB Installation
About: Tom Spitzer,
VP, Engineering, EC Wise
EC Wise builds/enables Complex Secure Solutions
Software Products / Service Delivery Platforms / Cyber Security
Key Practices: Security, Secure Software Development, Intelligent Systems, Data
Mature, International
Offices and customers: North and South America, Asia
~ 60 employees, senior experienced teams
Founded 1998
Prior to EC Wise I developed eCommerce and ERP systems
Learning Objectives
1. Understand how attackers are able to compromise other people’s data
2. Configure MongoDB instances securely
3. Encrypt data in transit
4. Set up MongoDB Authentication
5. Manage users, roles, and privileges, so that when a user logs in, that
user has access to a set of role based privileges
6. Know how to use Read Only Views to improve security
7. Benefits of using MongoDB Atlas
8. Have intelligent internal discussions about locking down MongoDB instances
Top Risks / Common Attacks
Ransomware – 2017 - “27,000 MongoDB servers” in January, WannaCry in May
Of course, affected MongoDB servers did not have authentication enabled!
DDOS, Steganography, “SQL/NoSQL Injection”, system hijacking
Political destabilization / infrastructure compromise
Massive data theft via “Advanced Persistent Threats”: Equifax, Yahoo, Target …
See references
for details
Slide 5
Common Weaknesses / Mitigations - Access
Weaknesses
Authentication weak or not enabled
Overly permissive, inappropriate, and
unused privileges
Abuse & lax management of privileged
and service accounts
e.g. do DBAs really require always-on
access to application data?
Mitigations
Least privilege
“Strong” authentication
Multiple MongoDB options
Access restrictions
Role Based Access Control
Account monitoring,
especially for servers
Slide 6
Common Weaknesses / Mitigations
– Surface Area
Weaknesses
Lack of Control of Info Assets
Storage media not secured
Too much info generally available
Mitigations
Inventory – what, where, how
Reduce surface area
Dispose of data that is no
longer needed;
(archive / delete)
Devalue data through encryption,
tokenization, masking
Pay attention to key management
Slide 7
Common Weaknesses / Mitigations – Practices
Weaknesses
Failure to apply patches
Risky DB features enabled
Weak application security
Lack of visibility into DB
and network activity
Mitigations
Create patch friendly environment
Disable risky DB features
-- noscripting
Take advantage of OWASP tools,
strategies
Move controls closer to the data itself
Log sensitive operations
Enterprise: Consider DLP or SIEM
I. Secure connectivity to and between servers
Secure Connectivity reduces Surface Area
MongoDB TLS (SSL successor) hierarchy
Walk through enabling TLS
Configuration options
Code examples
PKI is acronym laden!
MongoDB
TLS Hierarchy
CRUD API calls over TLS
Internal Traffic over TLS
CA Certificates File
Server Key &
Certificate PEM File
DB Server 1
DriverClient
Machine
CA Certificates File
CA Certificates File
Server Key &
Certificate PEM File
DB Server 3
CA Certificates File
Server Key &
Certificate PEM File
DB Server 2
MongoDB
TLS protected
communications
SSL/TLS configuration – Create server .pem files
# Initialize CA by creating PK for it
$ openssl genrsa -out CAKey.key -aes256
# Create CA certificate
$ openssl req -x509 -new -extensions v3_ca -key CAKey.key -out CA-cert.crt
# create key file and Certificate Signing Request for each server
# will prompt for information used to create Distinguished Name or DN
# Country, State/Province; Locality; Organization Name; Org Unit; Common Name; Email
$ openssl req -new -nodes -newkey rsa:2048 -keyout serverX.key -out serverX.csr
# have CA "sign" each server's CSR and generate server's public Cert
$openssl x509 -CA ./CA/CA-cert.crt -CAkey ./CA ./CA/CAkey.key -CAcreateserial -req
-in ./CSR/serverX.csr - out ./CERTS/serverX.crt
# create .pem file for each server
$ cat serverX.key serverX.crt > serverX.pem
# copy .pem and host CERT file to config directory
$ cp serverX.pem CA-cert.crt /mongodb/config/
Note: example creates self-signed certificate,
not recommended for production. For
production, have a CA create a cert; to do so
run the openSSL command to create a CSR,
and send it to your CA.
This process is more fully explained at
OpenSSL Essentials
#update MongDB Config file with SSL info
net:
port:27017
bindIP: 10.1.1.1
ssl:
mode: requireSSL OR preferSSL
PEMKeyFile: /mongodb/config/serverX.pem
CAFile: /mongodb/config/CA-cert.crt
Note:.pem is a
container file format
SSL/TLS configuration – Create Client .pem file
# generate client key and CSR, again it will prompt for DN components
# note that DN has to be different from server DN, can use different Org Unit
$ openssl req -new -nodes -newkey rsa:2048 -keyout rootuser.key -out rootuser.csr
# submit client CSR to CA for signing and Cert generation
$ openssl x509 - CA ./CA/CA-cert.crt -CAKey ./CA/CAKey -CAcreateserial
-req -in ./CSR/rootuser.csr -out ./CERTS/rootuser.crt
# concatenate client .pem
$ cat mongokey/rootuser.key ssl/CERTS/rootuser.crt > mongokey/rootuser.pem
# get client Cert subject details
$ openssl x509 -in mongokey/rootuser.pem -inform PEM -subject -nameopt RFC2253
[subject=emailAddress=tspitzer@ecwise.com,CN=root,OU=ECWiseClients,O=ECWise,L=SR,ST=CA,C=US]
Note: consider secure
repository for key storage, e.g.
keystore service in Java or
third party key manager; also
Protect .pem file directories
Note: be sure that client and
server certs have different
DNs, i.e. that at least one DN
component, or RDN differs
SSL/TLS configuration – restart with SSL
Restart mongod
[ts@SRDevLnxSvr02 ~]$ mongod -f /etc/mongod.conf
Provide CERT to client , and connect with SSL
[usert@Client ~]$ mongo --ssl --host server1 –sslPEMKeyFile ./mongokey/rootuser.pem --sslCAFile=CACert.crt
See appendices for application code examples
II. Authentication: Comparison of Options
Username /
Password
Local CA
Certificates
File
Certificate
1. Challenge/Response
(SCRAM-SHA-1) – based on RFC5802)
2. x.509 Certificate (requires CA)
Authentication Method Clear Text Password Identity Location
Challenge/Response
(SCRAM-SHA-1)
No (Digest) Internal
x.509 Certificate No (Digital Signature) External
Authentication Strategy Comparisons
Addresses
“Weak Authentication”
vulnerability
SCRAM-SHA-1:
Enable authentication, create accounts
Start MongoDB without access control
Connect in instance
Create user administrator
Restart instance with access control
$ mongod -f /etc/mongod.conf
Connect and authenticate as user administrator
mongo --ssl --host mongod_host --sslCAFile=/etc/ssl/mongodb.pem
-uUserAdmin -ppassword abc123
Create additional users
use admin
db.createUser(
{
user: "UserAdmin",
pwd: "abc123",
roles: [ { role: "userAdminAnyDatabase",
db: "admin" } ]
}
)
in /etc/mongod.conf
security.authorization: enabled
Slide 16
Note Client vs. Member
authentication capabilities
Authentication
using x.509 Certs
x.509 authentication: Create,assign, enable Certs
Create local certification authority or use third party
Generate and sign certificates for client and servers in replica set
Server and client certs must differ in organization part of DNs
RS member O, OU, and DC components must match
Start MongoDB replica set instances without access control
Initialize replica set
Update config.json
Restart replica set in x.509 mode (at command line or use config options)
mongod --replSet set509 --port $mport --sslMode requireSSL --clusterAuthMode x509 /
--sslCAFile root-ca.pem --sslAllowInvalidHostnames /
--sslPEMKeyFile <path to TLS/SSL certificate and key PEM file> --sslClusterFile ${cluster}.pem
Client Authentication
Examples
SCRAM-SHA-1
> db.getSiblingDB("admin").auth(
{
mechanism: "SCRAM-SHA-1",
user: "dbmaster",
pwd: "adminpasswd123",
digestPassword: true
}
);
-- create user
db.getSiblingDB("$external").runCommand(
{
createUser:
"CN=user,OU=OrgUnit,O=Org,L=Location,
ST=State, C=Country",
roles: [
{ role: 'readWrite', db: 'test' },
{ role: 'userAdminAnyDatabase', db: 'admin' }
] } )
-- Log in
> db.getSiblingDB("$external").auth(
{
mechanism: "MONGODB-X509",
user: "CN=user,OU=OrgUnit,O=Org,
L=Location,ST=State,C=Country" }
);
x.509 Certificate
FQDN
Client names must
match DN in cert
III. User & Role Management in MongoDB
Addresses “Overly permissive, inappropriate, and unused
privileges” vulnerability
Enable Access Control for authentication
Set up users and roles, applicable to both humans and services
Enforce the Least Privilege strategy we discussed earlier
Bind users and roles to machines or (sub)networks with
Authentication Restriction
Use Roles to Manage Privilege Assignments
Privilege allows an action on a resource.
MongoDB defines a “bunch” of privileged operations.
Roles are defined pairings of resources and actions that
you can assign users
Sixteen built-in roles, you have probably read about them
read, readWrite, dbAdmin, clusterAdmin, backup, restore, etc..
Create custom roles, assign users to roles per the scripts on following slides
class Authorization Model
Permission
Resource
Role
Action
User
User & Role Examples based on Mini-Clinic app*
Obviously, a medical clinic needs to be secure
Roles – Scheduler, Practitioner, Pharmacist, Auditor
Objects – Patient, Encounter, Observation, Prescription
Operations – Schedule Encounter, Make Diagnosis, Prescribe Medication
Mini-Clinic
Website
Mini-Clinic Restful
Services MongoDB
*based on
HL7 Fast Healthcare Interoperability Resources
Mini Clinic Role Mapping
Role  Data
Patient Encounters Observation
Medication
Order Medication
CUD R CUD R CUD R CUD R CUD R
Scheduler
√ (only
name) √ √
Practitioner
√ (no
national
ID) √ √ √ √ √ √
Pharmacist √ √ √ √
Auditor √ √ √ √ √ √ √ √ √ √
CUD = Create/Update/Delete
R = Read
Slide 23
User and Role Management Examples
db = db.getSiblingDB('admin');
//create scheduler
db.createRole(
{
"role": "scheduler",
"privileges": [
{
"resource": {"db": "mini_clinic",
"collection": "scheduler_patient"},
"actions": ["find"]
},
{
"resource": {"db": "mini_clinic",
"collection": "encounter"},
"actions": ["find","insert","update"]
}
],
"roles": []
“authenticationRestrictions”:
[{ “clientSource”: [“192.168.17.6”,
“127.0.0.1”] ,
“serverAddress”: [“10.10.10.0/24”,
“127.0.0.1”] }]
}
);
//create scheduler user
db.dropUser("user_scheduler");
db.createUser(
{
"user": "user_scheduler",
"pwd": "ecwise.c1m",
"roles": [
{
"role": "scheduler",
"db": "admin“
“authenticationRestrictions”:
[{“clientSource”: [“192.168.17.6”,
“127.0.0.1”] ,
“serverAddress”: [“10.10.10.0/24”,
“127.0.0.1”] }]
}
]
}
);
DBs on separate subnet, not accessible to internet
Amazon VLAN/VPCs
Dedicated OS users for DB and App Services
Localhost Default (3.6)
Use -bind_ip (net.bindIp) to tell MongoDB
what other adapter and sockets to listen to
IP Whitelisting (3.6)
(enhances authentication)
Router
Single Public Access
Shard + Replication set
Shard + Replication set
Shard + Replication set
Configure Server
Replication Set
Application
Mongo DB Cluster
Internal Network behind firewall
Authentication with account & password
Internal Authentication between nodes of cluster
With Key File (or X.509 certification)
VPN Access
Maintenance
Admin user
VPN Authentication
IV. Network/OS considerations
You’re mainly addressing
“Surface Area” risks, i.e.
limiting areas of exposure
V. Read Only Views
Addresses both “Surface area reduction” and “weak authorization” risks
Enable administrators to define a query that is materialized at runtime
db.createView(<name>, <collection>, <pipeline>, <options>)
where pipeline is an array that consists of the aggregation pipeline stage
Admins can define permissions on who can access the views
Use these Views in your applications to provide another level of security
Read only views
db = db.getSiblingDB('admin');
/* create View */
db.createView(
"scheduler_patient",
"patient",
{
$project:
{
"firstName": 1,
"lastName": 1
}
}
);
db.createView(
"practitioner_patient",
"patient",
{
$project:
{
"nationalID": 0
}
}
);
set13:PRIMARY> db.patient.findone({lastName : “Maddin”})
{ "_id" : ObjectId("5914108c8e034900016a5172"), "nationalID" : "1234-
5678-90", "firstName" : "Joe", "dob" : "1985-08-08", "lastName" :
"Maddin", "phone" : "400-800-1234", "gender" : "MALE" }
set13:PRIMARY> db.scheduler_patient.findone({lastName :
“Maddin”})
{ "_id" : ObjectId("5914108c8e034900016a5172"), "firstName" : "Joe",
"lastName" : "Maddin" }
set13:PRIMARY> db.practitioner_patient.findone({lastName :
“Maddin”})
{ "_id" : ObjectId("5914108c8e034900016a5172"), "firstName" : "Joe",
"dob" : "1985-08-08", "lastName" : "Maddin", "phone" : "400-800-
1234", "gender" : "MALE" }
// everything BUT national ID
VI. MongoDB Atlas has (more) Security Baked In
TLS/SSL enabled by default with mongodb+srv connection string
Authentication, and authorization via SCRAM
Network isolation and VPC Peering on AWS
IP whitelists using Authentication Restriction
Encrypted storage volumes
Roles not definable: create users through Atlas UI and assign them to
predefined roles
VII. Architecting a secure system
Consider the whole application from the UI/service initiation down to the DB
A layered security strategy will be most effective
Break down organizational barriers – work across teams
Always encrypt network traffic
Decide on authentication model: stand-alone vs. integrated with corporate
Think carefully about Roles
Organizational commitment to devote resources to security is key
Slide 29
Thank You
Closing comments/questions?
For follow up:
Tom Spitzer
tspitzer@ecwise.com
@tspitzer_ecwise
https://www.linkedin.com/in/tom-spitzer-74643/
415-572-4156
Appendix
Examples and References
Some additional code examples and web
references are provided
MongoDB x.509 authentication settings
{
"db" : "mongodb://localhost:27001/db-name?ssl=true",
"dbOpts": {
"user": "emailAddress=john.doe@example.com,CN=XYZ,OU=XYZ-Client,O=XYZ,L=XYZ,ST=XYZ,C=XYZ",
"auth": { "authMechanism": "MONGODB-X509" },
"server": {
"sslValidate": false,
"sslKey": {"filePath": "/absolute/path/to/db-user.pem"},
"sslCert": {"filePath": "/absolute/path/to/db-user.crt"}
}
}
}
self._role_mapping = {'AUTHORIZE': self.get_authorize_db, 'SCHEDULER': self.get_scheduler_db,
'PRACTITIONER': self.get_practitioner_db,
'PHARMACIST': self.get_pharmacist_db,
'AUDITOR': self.get_auditor_db}
def _get_database(self, type):
username = config[type]['username']
password = config[type]['password']
cert_path = config['security']['cert_path']
uri = "mongodb://%s:%s@%s:%s" % (
quote_plus(username), quote_plus(password), self._host, self._port)
return MongoClient(uri, ssl=True, ssl_ca_cert=cert_path)[self._db_name]
def get_database_by_role(self, role):
return self._role_mapping.get(role, None)()
def get_authorize_db(self):
if self._authorize_db is None:
self._authorize_db = self._get_database('mongo_authorize')
return self._authorize_db
Mini Clinic Python SSL connection
MongoDB Security References
MongoDB Docs: Use x.509 Certificates to Authenticate Clients
MongoDB Docs: Use x.509 Certificate for Membership Authentication
Blog Post: MongoDB, TLS, and x.509 Authentication Deep Dive
MongoDB Docs: Configure mongod and mongos for TLS/SSL
TLS/SSL Configuration for Clients
Providing Least Privileged Data Access in MongoDB
Cyber-Security References
• CyberCriminals and their APT and AVT Techniques
• InfoSec Institute: Anatomy of an APT Attack: Step by Step Approach
• Forrester Wave: Data Loss Prevention Suites Q4, 2016
• Data Guardian’s Definitive Guide to Data Loss Prevention
• How to Avoid Ransomware attacks against MongoDB
• InfoWorld Guide to MongoDB Security
• MongoDB Security Checklist (product documentation)
• Download link for MongoDB Security Reference Architecture

Mais conteúdo relacionado

Mais procurados

MongoDB 2.4 Security Features
MongoDB 2.4 Security FeaturesMongoDB 2.4 Security Features
MongoDB 2.4 Security Features
MongoDB
 
Security Features in MongoDB 2.4
Security Features in MongoDB 2.4Security Features in MongoDB 2.4
Security Features in MongoDB 2.4
MongoDB
 

Mais procurados (20)

Securing Your MongoDB Implementation
Securing Your MongoDB ImplementationSecuring Your MongoDB Implementation
Securing Your MongoDB Implementation
 
RSA Conference 2017 session: What System Stores on the Disk Without Telling You
RSA Conference 2017 session: What System Stores on the Disk Without Telling YouRSA Conference 2017 session: What System Stores on the Disk Without Telling You
RSA Conference 2017 session: What System Stores on the Disk Without Telling You
 
BlueHat v18 || May i see your credentials, please
BlueHat v18 || May i see your credentials, pleaseBlueHat v18 || May i see your credentials, please
BlueHat v18 || May i see your credentials, please
 
The hacker playbook: How to think and act like a cybercriminal to reduce risk...
The hacker playbook: How to think and act like a cybercriminal to reduce risk...The hacker playbook: How to think and act like a cybercriminal to reduce risk...
The hacker playbook: How to think and act like a cybercriminal to reduce risk...
 
Webinar: MongoDB 2.6 New Security Features
Webinar: MongoDB 2.6 New Security FeaturesWebinar: MongoDB 2.6 New Security Features
Webinar: MongoDB 2.6 New Security Features
 
DEF CON 23 - Sean - metcalf - red vs blue ad attack and defense
DEF CON 23 - Sean - metcalf - red vs blue ad attack and defenseDEF CON 23 - Sean - metcalf - red vs blue ad attack and defense
DEF CON 23 - Sean - metcalf - red vs blue ad attack and defense
 
MongoDB 2.4 Security Features
MongoDB 2.4 Security FeaturesMongoDB 2.4 Security Features
MongoDB 2.4 Security Features
 
Eyes Wide Shut: What Do Your Passwords Do When No One is Watching?
Eyes Wide Shut: What Do Your Passwords Do When No One is Watching?Eyes Wide Shut: What Do Your Passwords Do When No One is Watching?
Eyes Wide Shut: What Do Your Passwords Do When No One is Watching?
 
Fatal signs: 10 symptoms when you think you’ve been hacked
Fatal signs: 10 symptoms when you think you’ve been hackedFatal signs: 10 symptoms when you think you’ve been hacked
Fatal signs: 10 symptoms when you think you’ve been hacked
 
DerbyCon 2019 - Kerberoasting Revisited
DerbyCon 2019 - Kerberoasting RevisitedDerbyCon 2019 - Kerberoasting Revisited
DerbyCon 2019 - Kerberoasting Revisited
 
Securing Your MongoDB Deployment
Securing Your MongoDB DeploymentSecuring Your MongoDB Deployment
Securing Your MongoDB Deployment
 
Security Features in MongoDB 2.4
Security Features in MongoDB 2.4Security Features in MongoDB 2.4
Security Features in MongoDB 2.4
 
Understanding "Red Forest" - The 3-Tier ESAE and Alternative Ways to Protect ...
Understanding "Red Forest" - The 3-Tier ESAE and Alternative Ways to Protect ...Understanding "Red Forest" - The 3-Tier ESAE and Alternative Ways to Protect ...
Understanding "Red Forest" - The 3-Tier ESAE and Alternative Ways to Protect ...
 
Mdb dn 2016_11_ops_mgr
Mdb dn 2016_11_ops_mgrMdb dn 2016_11_ops_mgr
Mdb dn 2016_11_ops_mgr
 
WMI for Penetration Testers - Arcticcon 2017
WMI for Penetration Testers - Arcticcon 2017WMI for Penetration Testers - Arcticcon 2017
WMI for Penetration Testers - Arcticcon 2017
 
Html5 Application Security
Html5 Application SecurityHtml5 Application Security
Html5 Application Security
 
The DNS Tunneling Blindspot
The DNS Tunneling BlindspotThe DNS Tunneling Blindspot
The DNS Tunneling Blindspot
 
Certified Pre-Owned
Certified Pre-OwnedCertified Pre-Owned
Certified Pre-Owned
 
Persistant Cookies and LDAP Injection
Persistant Cookies and LDAP InjectionPersistant Cookies and LDAP Injection
Persistant Cookies and LDAP Injection
 
Not a Security Boundary
Not a Security BoundaryNot a Security Boundary
Not a Security Boundary
 

Semelhante a Low Hanging Fruit, Making Your Basic MongoDB Installation More Secure

Semelhante a Low Hanging Fruit, Making Your Basic MongoDB Installation More Secure (20)

MongoDB World 2018: Low Hanging Fruit: Making Your Basic MongoDB Installation...
MongoDB World 2018: Low Hanging Fruit: Making Your Basic MongoDB Installation...MongoDB World 2018: Low Hanging Fruit: Making Your Basic MongoDB Installation...
MongoDB World 2018: Low Hanging Fruit: Making Your Basic MongoDB Installation...
 
It's a Dangerous World
It's a Dangerous World It's a Dangerous World
It's a Dangerous World
 
Securing Your Enterprise Web Apps with MongoDB Enterprise
Securing Your Enterprise Web Apps with MongoDB Enterprise Securing Your Enterprise Web Apps with MongoDB Enterprise
Securing Your Enterprise Web Apps with MongoDB Enterprise
 
Securing MongoDB to Serve an AWS-Based, Multi-Tenant, Security-Fanatic SaaS A...
Securing MongoDB to Serve an AWS-Based, Multi-Tenant, Security-Fanatic SaaS A...Securing MongoDB to Serve an AWS-Based, Multi-Tenant, Security-Fanatic SaaS A...
Securing MongoDB to Serve an AWS-Based, Multi-Tenant, Security-Fanatic SaaS A...
 
Operations: Security
Operations: SecurityOperations: Security
Operations: Security
 
Operations: Security Crash Course — Best Practices for Securing your Company
Operations: Security Crash Course — Best Practices for Securing your CompanyOperations: Security Crash Course — Best Practices for Securing your Company
Operations: Security Crash Course — Best Practices for Securing your Company
 
Tips to Remediate your Vulnerability Management Program
Tips to Remediate your Vulnerability Management ProgramTips to Remediate your Vulnerability Management Program
Tips to Remediate your Vulnerability Management Program
 
Securing Your MongoDB Deployment
Securing Your MongoDB DeploymentSecuring Your MongoDB Deployment
Securing Your MongoDB Deployment
 
Percona Live 2021 - MongoDB Security Features
Percona Live 2021 - MongoDB Security FeaturesPercona Live 2021 - MongoDB Security Features
Percona Live 2021 - MongoDB Security Features
 
Enterprise Cloud Security
Enterprise Cloud SecurityEnterprise Cloud Security
Enterprise Cloud Security
 
(SACON) Sudarshan Pisupati & Sahir Hidayatullah - active deception sacon
(SACON) Sudarshan Pisupati & Sahir Hidayatullah - active deception sacon(SACON) Sudarshan Pisupati & Sahir Hidayatullah - active deception sacon
(SACON) Sudarshan Pisupati & Sahir Hidayatullah - active deception sacon
 
Enabling Web Apps For DoD Security via PKI/CAC Enablement (Forge.Mil case study)
Enabling Web Apps For DoD Security via PKI/CAC Enablement (Forge.Mil case study)Enabling Web Apps For DoD Security via PKI/CAC Enablement (Forge.Mil case study)
Enabling Web Apps For DoD Security via PKI/CAC Enablement (Forge.Mil case study)
 
SSecuring Your MongoDB Deployment
SSecuring Your MongoDB DeploymentSSecuring Your MongoDB Deployment
SSecuring Your MongoDB Deployment
 
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
 
Jan 2008 Allup
Jan 2008 AllupJan 2008 Allup
Jan 2008 Allup
 
Protecting Your Key Asset – Data Protection Best Practices V2.0 Final
Protecting Your Key Asset – Data Protection Best Practices V2.0   FinalProtecting Your Key Asset – Data Protection Best Practices V2.0   Final
Protecting Your Key Asset – Data Protection Best Practices V2.0 Final
 
XP Days 2019: First secret delivery for modern cloud-native applications
XP Days 2019: First secret delivery for modern cloud-native applicationsXP Days 2019: First secret delivery for modern cloud-native applications
XP Days 2019: First secret delivery for modern cloud-native applications
 
Bootstrapping - Session 1 - Your First Week with Amazon EC2
Bootstrapping - Session 1 - Your First Week with Amazon EC2Bootstrapping - Session 1 - Your First Week with Amazon EC2
Bootstrapping - Session 1 - Your First Week with Amazon EC2
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptx
 
Achieving compliance With MongoDB Security
Achieving compliance With MongoDB Security Achieving compliance With MongoDB Security
Achieving compliance With MongoDB Security
 

Mais de MongoDB

Mais de MongoDB (20)

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 

Low Hanging Fruit, Making Your Basic MongoDB Installation More Secure

  • 1. Low Hanging Fruit: Securing Your Basic MongoDB Installation
  • 2. About: Tom Spitzer, VP, Engineering, EC Wise EC Wise builds/enables Complex Secure Solutions Software Products / Service Delivery Platforms / Cyber Security Key Practices: Security, Secure Software Development, Intelligent Systems, Data Mature, International Offices and customers: North and South America, Asia ~ 60 employees, senior experienced teams Founded 1998 Prior to EC Wise I developed eCommerce and ERP systems
  • 3. Learning Objectives 1. Understand how attackers are able to compromise other people’s data 2. Configure MongoDB instances securely 3. Encrypt data in transit 4. Set up MongoDB Authentication 5. Manage users, roles, and privileges, so that when a user logs in, that user has access to a set of role based privileges 6. Know how to use Read Only Views to improve security 7. Benefits of using MongoDB Atlas 8. Have intelligent internal discussions about locking down MongoDB instances
  • 4. Top Risks / Common Attacks Ransomware – 2017 - “27,000 MongoDB servers” in January, WannaCry in May Of course, affected MongoDB servers did not have authentication enabled! DDOS, Steganography, “SQL/NoSQL Injection”, system hijacking Political destabilization / infrastructure compromise Massive data theft via “Advanced Persistent Threats”: Equifax, Yahoo, Target … See references for details
  • 5. Slide 5 Common Weaknesses / Mitigations - Access Weaknesses Authentication weak or not enabled Overly permissive, inappropriate, and unused privileges Abuse & lax management of privileged and service accounts e.g. do DBAs really require always-on access to application data? Mitigations Least privilege “Strong” authentication Multiple MongoDB options Access restrictions Role Based Access Control Account monitoring, especially for servers
  • 6. Slide 6 Common Weaknesses / Mitigations – Surface Area Weaknesses Lack of Control of Info Assets Storage media not secured Too much info generally available Mitigations Inventory – what, where, how Reduce surface area Dispose of data that is no longer needed; (archive / delete) Devalue data through encryption, tokenization, masking Pay attention to key management
  • 7. Slide 7 Common Weaknesses / Mitigations – Practices Weaknesses Failure to apply patches Risky DB features enabled Weak application security Lack of visibility into DB and network activity Mitigations Create patch friendly environment Disable risky DB features -- noscripting Take advantage of OWASP tools, strategies Move controls closer to the data itself Log sensitive operations Enterprise: Consider DLP or SIEM
  • 8. I. Secure connectivity to and between servers Secure Connectivity reduces Surface Area MongoDB TLS (SSL successor) hierarchy Walk through enabling TLS Configuration options Code examples
  • 9. PKI is acronym laden! MongoDB TLS Hierarchy
  • 10. CRUD API calls over TLS Internal Traffic over TLS CA Certificates File Server Key & Certificate PEM File DB Server 1 DriverClient Machine CA Certificates File CA Certificates File Server Key & Certificate PEM File DB Server 3 CA Certificates File Server Key & Certificate PEM File DB Server 2 MongoDB TLS protected communications
  • 11. SSL/TLS configuration – Create server .pem files # Initialize CA by creating PK for it $ openssl genrsa -out CAKey.key -aes256 # Create CA certificate $ openssl req -x509 -new -extensions v3_ca -key CAKey.key -out CA-cert.crt # create key file and Certificate Signing Request for each server # will prompt for information used to create Distinguished Name or DN # Country, State/Province; Locality; Organization Name; Org Unit; Common Name; Email $ openssl req -new -nodes -newkey rsa:2048 -keyout serverX.key -out serverX.csr # have CA "sign" each server's CSR and generate server's public Cert $openssl x509 -CA ./CA/CA-cert.crt -CAkey ./CA ./CA/CAkey.key -CAcreateserial -req -in ./CSR/serverX.csr - out ./CERTS/serverX.crt # create .pem file for each server $ cat serverX.key serverX.crt > serverX.pem # copy .pem and host CERT file to config directory $ cp serverX.pem CA-cert.crt /mongodb/config/ Note: example creates self-signed certificate, not recommended for production. For production, have a CA create a cert; to do so run the openSSL command to create a CSR, and send it to your CA. This process is more fully explained at OpenSSL Essentials #update MongDB Config file with SSL info net: port:27017 bindIP: 10.1.1.1 ssl: mode: requireSSL OR preferSSL PEMKeyFile: /mongodb/config/serverX.pem CAFile: /mongodb/config/CA-cert.crt Note:.pem is a container file format
  • 12. SSL/TLS configuration – Create Client .pem file # generate client key and CSR, again it will prompt for DN components # note that DN has to be different from server DN, can use different Org Unit $ openssl req -new -nodes -newkey rsa:2048 -keyout rootuser.key -out rootuser.csr # submit client CSR to CA for signing and Cert generation $ openssl x509 - CA ./CA/CA-cert.crt -CAKey ./CA/CAKey -CAcreateserial -req -in ./CSR/rootuser.csr -out ./CERTS/rootuser.crt # concatenate client .pem $ cat mongokey/rootuser.key ssl/CERTS/rootuser.crt > mongokey/rootuser.pem # get client Cert subject details $ openssl x509 -in mongokey/rootuser.pem -inform PEM -subject -nameopt RFC2253 [subject=emailAddress=tspitzer@ecwise.com,CN=root,OU=ECWiseClients,O=ECWise,L=SR,ST=CA,C=US] Note: consider secure repository for key storage, e.g. keystore service in Java or third party key manager; also Protect .pem file directories Note: be sure that client and server certs have different DNs, i.e. that at least one DN component, or RDN differs
  • 13. SSL/TLS configuration – restart with SSL Restart mongod [ts@SRDevLnxSvr02 ~]$ mongod -f /etc/mongod.conf Provide CERT to client , and connect with SSL [usert@Client ~]$ mongo --ssl --host server1 –sslPEMKeyFile ./mongokey/rootuser.pem --sslCAFile=CACert.crt See appendices for application code examples
  • 14. II. Authentication: Comparison of Options Username / Password Local CA Certificates File Certificate 1. Challenge/Response (SCRAM-SHA-1) – based on RFC5802) 2. x.509 Certificate (requires CA) Authentication Method Clear Text Password Identity Location Challenge/Response (SCRAM-SHA-1) No (Digest) Internal x.509 Certificate No (Digital Signature) External Authentication Strategy Comparisons Addresses “Weak Authentication” vulnerability
  • 15. SCRAM-SHA-1: Enable authentication, create accounts Start MongoDB without access control Connect in instance Create user administrator Restart instance with access control $ mongod -f /etc/mongod.conf Connect and authenticate as user administrator mongo --ssl --host mongod_host --sslCAFile=/etc/ssl/mongodb.pem -uUserAdmin -ppassword abc123 Create additional users use admin db.createUser( { user: "UserAdmin", pwd: "abc123", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } ) in /etc/mongod.conf security.authorization: enabled
  • 16. Slide 16 Note Client vs. Member authentication capabilities Authentication using x.509 Certs
  • 17. x.509 authentication: Create,assign, enable Certs Create local certification authority or use third party Generate and sign certificates for client and servers in replica set Server and client certs must differ in organization part of DNs RS member O, OU, and DC components must match Start MongoDB replica set instances without access control Initialize replica set Update config.json Restart replica set in x.509 mode (at command line or use config options) mongod --replSet set509 --port $mport --sslMode requireSSL --clusterAuthMode x509 / --sslCAFile root-ca.pem --sslAllowInvalidHostnames / --sslPEMKeyFile <path to TLS/SSL certificate and key PEM file> --sslClusterFile ${cluster}.pem
  • 18. Client Authentication Examples SCRAM-SHA-1 > db.getSiblingDB("admin").auth( { mechanism: "SCRAM-SHA-1", user: "dbmaster", pwd: "adminpasswd123", digestPassword: true } ); -- create user db.getSiblingDB("$external").runCommand( { createUser: "CN=user,OU=OrgUnit,O=Org,L=Location, ST=State, C=Country", roles: [ { role: 'readWrite', db: 'test' }, { role: 'userAdminAnyDatabase', db: 'admin' } ] } ) -- Log in > db.getSiblingDB("$external").auth( { mechanism: "MONGODB-X509", user: "CN=user,OU=OrgUnit,O=Org, L=Location,ST=State,C=Country" } ); x.509 Certificate FQDN Client names must match DN in cert
  • 19. III. User & Role Management in MongoDB Addresses “Overly permissive, inappropriate, and unused privileges” vulnerability Enable Access Control for authentication Set up users and roles, applicable to both humans and services Enforce the Least Privilege strategy we discussed earlier Bind users and roles to machines or (sub)networks with Authentication Restriction
  • 20. Use Roles to Manage Privilege Assignments Privilege allows an action on a resource. MongoDB defines a “bunch” of privileged operations. Roles are defined pairings of resources and actions that you can assign users Sixteen built-in roles, you have probably read about them read, readWrite, dbAdmin, clusterAdmin, backup, restore, etc.. Create custom roles, assign users to roles per the scripts on following slides class Authorization Model Permission Resource Role Action User
  • 21. User & Role Examples based on Mini-Clinic app* Obviously, a medical clinic needs to be secure Roles – Scheduler, Practitioner, Pharmacist, Auditor Objects – Patient, Encounter, Observation, Prescription Operations – Schedule Encounter, Make Diagnosis, Prescribe Medication Mini-Clinic Website Mini-Clinic Restful Services MongoDB *based on HL7 Fast Healthcare Interoperability Resources
  • 22. Mini Clinic Role Mapping Role Data Patient Encounters Observation Medication Order Medication CUD R CUD R CUD R CUD R CUD R Scheduler √ (only name) √ √ Practitioner √ (no national ID) √ √ √ √ √ √ Pharmacist √ √ √ √ Auditor √ √ √ √ √ √ √ √ √ √ CUD = Create/Update/Delete R = Read
  • 23. Slide 23 User and Role Management Examples db = db.getSiblingDB('admin'); //create scheduler db.createRole( { "role": "scheduler", "privileges": [ { "resource": {"db": "mini_clinic", "collection": "scheduler_patient"}, "actions": ["find"] }, { "resource": {"db": "mini_clinic", "collection": "encounter"}, "actions": ["find","insert","update"] } ], "roles": [] “authenticationRestrictions”: [{ “clientSource”: [“192.168.17.6”, “127.0.0.1”] , “serverAddress”: [“10.10.10.0/24”, “127.0.0.1”] }] } ); //create scheduler user db.dropUser("user_scheduler"); db.createUser( { "user": "user_scheduler", "pwd": "ecwise.c1m", "roles": [ { "role": "scheduler", "db": "admin“ “authenticationRestrictions”: [{“clientSource”: [“192.168.17.6”, “127.0.0.1”] , “serverAddress”: [“10.10.10.0/24”, “127.0.0.1”] }] } ] } );
  • 24. DBs on separate subnet, not accessible to internet Amazon VLAN/VPCs Dedicated OS users for DB and App Services Localhost Default (3.6) Use -bind_ip (net.bindIp) to tell MongoDB what other adapter and sockets to listen to IP Whitelisting (3.6) (enhances authentication) Router Single Public Access Shard + Replication set Shard + Replication set Shard + Replication set Configure Server Replication Set Application Mongo DB Cluster Internal Network behind firewall Authentication with account & password Internal Authentication between nodes of cluster With Key File (or X.509 certification) VPN Access Maintenance Admin user VPN Authentication IV. Network/OS considerations You’re mainly addressing “Surface Area” risks, i.e. limiting areas of exposure
  • 25. V. Read Only Views Addresses both “Surface area reduction” and “weak authorization” risks Enable administrators to define a query that is materialized at runtime db.createView(<name>, <collection>, <pipeline>, <options>) where pipeline is an array that consists of the aggregation pipeline stage Admins can define permissions on who can access the views Use these Views in your applications to provide another level of security
  • 26. Read only views db = db.getSiblingDB('admin'); /* create View */ db.createView( "scheduler_patient", "patient", { $project: { "firstName": 1, "lastName": 1 } } ); db.createView( "practitioner_patient", "patient", { $project: { "nationalID": 0 } } ); set13:PRIMARY> db.patient.findone({lastName : “Maddin”}) { "_id" : ObjectId("5914108c8e034900016a5172"), "nationalID" : "1234- 5678-90", "firstName" : "Joe", "dob" : "1985-08-08", "lastName" : "Maddin", "phone" : "400-800-1234", "gender" : "MALE" } set13:PRIMARY> db.scheduler_patient.findone({lastName : “Maddin”}) { "_id" : ObjectId("5914108c8e034900016a5172"), "firstName" : "Joe", "lastName" : "Maddin" } set13:PRIMARY> db.practitioner_patient.findone({lastName : “Maddin”}) { "_id" : ObjectId("5914108c8e034900016a5172"), "firstName" : "Joe", "dob" : "1985-08-08", "lastName" : "Maddin", "phone" : "400-800- 1234", "gender" : "MALE" } // everything BUT national ID
  • 27. VI. MongoDB Atlas has (more) Security Baked In TLS/SSL enabled by default with mongodb+srv connection string Authentication, and authorization via SCRAM Network isolation and VPC Peering on AWS IP whitelists using Authentication Restriction Encrypted storage volumes Roles not definable: create users through Atlas UI and assign them to predefined roles
  • 28. VII. Architecting a secure system Consider the whole application from the UI/service initiation down to the DB A layered security strategy will be most effective Break down organizational barriers – work across teams Always encrypt network traffic Decide on authentication model: stand-alone vs. integrated with corporate Think carefully about Roles Organizational commitment to devote resources to security is key
  • 29. Slide 29 Thank You Closing comments/questions? For follow up: Tom Spitzer tspitzer@ecwise.com @tspitzer_ecwise https://www.linkedin.com/in/tom-spitzer-74643/ 415-572-4156
  • 30. Appendix Examples and References Some additional code examples and web references are provided
  • 31. MongoDB x.509 authentication settings { "db" : "mongodb://localhost:27001/db-name?ssl=true", "dbOpts": { "user": "emailAddress=john.doe@example.com,CN=XYZ,OU=XYZ-Client,O=XYZ,L=XYZ,ST=XYZ,C=XYZ", "auth": { "authMechanism": "MONGODB-X509" }, "server": { "sslValidate": false, "sslKey": {"filePath": "/absolute/path/to/db-user.pem"}, "sslCert": {"filePath": "/absolute/path/to/db-user.crt"} } } }
  • 32. self._role_mapping = {'AUTHORIZE': self.get_authorize_db, 'SCHEDULER': self.get_scheduler_db, 'PRACTITIONER': self.get_practitioner_db, 'PHARMACIST': self.get_pharmacist_db, 'AUDITOR': self.get_auditor_db} def _get_database(self, type): username = config[type]['username'] password = config[type]['password'] cert_path = config['security']['cert_path'] uri = "mongodb://%s:%s@%s:%s" % ( quote_plus(username), quote_plus(password), self._host, self._port) return MongoClient(uri, ssl=True, ssl_ca_cert=cert_path)[self._db_name] def get_database_by_role(self, role): return self._role_mapping.get(role, None)() def get_authorize_db(self): if self._authorize_db is None: self._authorize_db = self._get_database('mongo_authorize') return self._authorize_db Mini Clinic Python SSL connection
  • 33. MongoDB Security References MongoDB Docs: Use x.509 Certificates to Authenticate Clients MongoDB Docs: Use x.509 Certificate for Membership Authentication Blog Post: MongoDB, TLS, and x.509 Authentication Deep Dive MongoDB Docs: Configure mongod and mongos for TLS/SSL TLS/SSL Configuration for Clients Providing Least Privileged Data Access in MongoDB
  • 34. Cyber-Security References • CyberCriminals and their APT and AVT Techniques • InfoSec Institute: Anatomy of an APT Attack: Step by Step Approach • Forrester Wave: Data Loss Prevention Suites Q4, 2016 • Data Guardian’s Definitive Guide to Data Loss Prevention • How to Avoid Ransomware attacks against MongoDB • InfoWorld Guide to MongoDB Security • MongoDB Security Checklist (product documentation) • Download link for MongoDB Security Reference Architecture

Notas do Editor

  1. The learning objectives are the guiding points to everything you include in your session, so it makes sense to use them as your starting point. LOs should be focused, discrete and oriented toward the attendee. They should also be active, stating what attendees should be able to do with the information in the talk. (Learning objectives that state an attendee should "understand" something are NOT active. :-) ). As an example of a good learning objective, for a session on MongoDB, Kubernetes and Docker containers a learning objective could be “Following this talk attendees should be able to define a highly available MongoDB deployment using Kubernetes services, replica sets and config maps”. The learning objectives should be presented to the audience as the first slide following the title and should be one of the few slides with text. We recommend three to five LOs.
  2. Don’t say “rights”
  3. One of the best way to describe solving a problem is describe how you solved it, and you have probably tried 2-3 ways of solving it before you figured out the right answer. Describe that process here. It often helps to illustrate with code and/or architectural diagrams
  4. Use FQDNs and ensure used hostname matches certificate CN PEM: Privacy Enhancement Mail container format (base64 encoded format) "SSL cipher selection": non-documented flag "--sslCipherConfig" see: https://jira.mongodb.org/browse/SERVER-16073 net.ssl.mode: disabled | allowSSL | preferSSL | requireSSL
  5. When to choose x.509?
  6. It often helps to illustrate with code and/or architectural diagrams
  7. See also http://pe-kay.blogspot.in/2016/02/securing-mongodb-using-x509-certificate.html, docs at https://docs.mongodb.com/manual/core/security-x.509/ Reference: Secure MongoDB with X.509 Authentication http://www.allanbank.com/blog/security/tls/x.509/2014/10/13/tls-x509-and-mongodb/ mongod --clusterAuthMode x509 --sslMode requireSSL --sslPEMKeyFile <path to TLS/SSL certificate and key PEM file> --sslCAFile <path to root CA PEM file>
  8. It often helps to illustrate with code and/or architectural diagrams
  9. It often helps to illustrate with code and/or architectural diagrams
  10. It often helps to illustrate with code and/or architectural diagrams
  11. Point out that HL7 is a standard