MongoDB 安全&安全檢查列表

shkstart發表於2022-01-06

Security

安全

MongoDB provides various features, such as authentication, access control, encryption, to secure your MongoDB deployments. Some key security features include:

MongoD提供了各種各樣的功能讓你安全地部署MongoDB,諸如:身份認證、訪問控制、加密。一些關鍵的安全功能包括:

Authentication Authorization TLS/SSL
AuthenticationSCRAMx.509 Role-Based Access ControlEnable Access ControlManage Users and Roles TLS/SSL (Transport Encryption)Configure mongod and mongos for TLS/SSLTLS/SSL Configuration for Clients
Enterprise Only Encryption
Kerberos AuthenticationLDAP Proxy AuthenticationEncryption at RestAuditing Client-Side Field Level Encryption
Authentication Authorization TLS/SSL
身份認證 SCRAM x.509 基於角色的訪問控制 啟動訪問控制 使用者與角色管理 TLS/SSL (傳輸加密) 使用TLS/SSL配置mongod和mongos 為客戶端配置TLS/SSL
Enterprise Only Encryption
Kerberos 驗證 LDAP 代理驗證 靜態加密 審計 客戶端欄位級加密

Security Checklist

安全檢查列表

MongoDB also provides the Security Checklist for a list of recommended actions to protect a MongoDB deployment.

MongoDB還為如何保護MongoDB部署提供了一個建議的操作列表即安全檢查列表

Last updated: 2019-12-05

最後更新於:2019-12-05

This documents provides a list of security measures that you should implement to protect your MongoDB installation. The list is not meant to be exhaustive.

這個文件提供了一個保護MongoDB應該實施的安全措施列表。這個列表並不是完整無遺的。

Pre-production Checklist/Considerations

生產環境前的檢查列表/注意事項

➤ Enable Access Control and Enforce Authentication

➤啟動訪問控制和強制身份認證

Enable access control and specify the authentication mechanism. You can use MongoDB’s SCRAM or x.509 authentication mechanism or integrate with your existing Kerberos/LDAP infrastructure. Authentication requires that all clients and servers provide valid credentials before they can connect to the system.

啟動訪問控制和指定身份認證的機制。你可以使用MongoDB的SCRMA或者x.509身份認證機制或者整合你已經使用的Kerberos/LDAP基礎設施。身份認證要求所有的客戶端和服務端在連線到系統之前提供有效的憑證。

See Authentication and Enable Access Control.

請參閱身份認證和開啟訪問控制。

➤ Configure Role-Based Access Control

➤ 配置基於角色的訪問控制

Create a user administrator first, then create additional users. Create a unique MongoDB user for each person/application that accesses the system.

首先建立一個管理員使用者,然後再建立其他的使用者。 前端培訓為每一人/應用程式建立唯一的使用者以訪問系統。

Follow the principle of least privilege. Create roles that define the exact access rights required by a set of users. Then create users and assign them only the roles they need to perform their operations. A user can be a person or a client application.

遵循最小許可權原則。為一組使用者建立他們所需的確切訪問許可權的角色。然後建立使用者並且僅為他們分配執行操作所需的角色。一個使用者可以是個人或者一個客戶端程式。

TIP

A user can have privileges across different databases. If a user requires privileges on multiple databases, create a single user with roles that grant applicable database privileges instead of creating the user multiple times in different databases.

提示:

一個使用者在不同資料庫可以擁有不同的許可權。如果一個使用者要求在多個資料庫的許可權,使用有多個可授予適當資料庫許可權的角色來建立一個單一使用者,而不是給不同的資料庫建立多個使用者。

See Role-Based Access Control and Manage Users and Roles.

請參閱基於角色的訪問控制和使用者與角色管理。

➤ Encrypt Communication (TLS/SSL)

➤ 加密通訊(TLS/SSL)

Configure MongoDB to use TLS/SSL for all incoming and outgoing connections. Use TLS/SSL to encrypt communication between  mongod and  mongos components of a MongoDB deployment as well as between all applications and MongoDB.

配置MongoDB為所有傳入和傳出連線使用TLS/SSL。使用TLS/SSL加密MongoDB部署的 mongodmongos元件以及所有應用程式和MongoDB之間的通訊。

Starting in version 4.0, MongoDB uses the native TLS/SSL OS libraries:

從4.0版本開始,MongoDB使用作業系統原生的TLS/SSL庫:

Windows Secure Channel (Schannel)
Linux/BSD OpenSSL
macOS Secure Transport
作業系統 使用的系統庫
Linux/BSD OpenSSL
macOS Secure Transport

NOTE

Starting in version 4.0, MongoDB disables support for TLS 1.0 encryption on systems where TLS 1.1+ is available. For more details, see Disable TLS 1.0.

注意

從4.0版本開始,在支援TLS1.1+的系統上,MongoDB會禁用TLS1.0加密。更多詳細資訊,請參閱 禁用TLS1.0.

請參閱使用TLS/SSL配置mongod和mongos

➤ Encrypt and Protect Data

➤加密和保護資料

Starting with MongoDB Enterprise 3.2, you can encrypt data in the storage layer with the WiredTiger storage engine’s native Encryption at Rest.

從MongoDB 3.2企業版開始,你可以使用WiredTiger儲存引擎的本地靜態加密來加密儲存層的資料。

If you are not using WiredTiger’s encryption at rest, MongoDB data should be encrypted on each host using file-system, device, or physical encryption (e.g. dm-crypt). Protect MongoDB data using file-system permissions. MongoDB data includes data files, configuration files, auditing logs, and key files.

如果你沒有使用WiredTiger的靜態加密,MongoDB的資料應該在每臺主機上使用檔案系統、裝置或物理加密(例如dm-crypt)。使用檔案系統許可權保護MongoDB資料。MongoDB資料包括資料檔案、配置檔案、審計日誌以及秘鑰檔案。

Collect logs to a central log store. These logs contain DB authentication attempts including source IP address.

將日誌收集到一箇中央日誌儲存區。這些日誌包含了DB身份認證嘗試及其源IP地址.

➤ Limit Network Exposure

➤ 限制網路暴露

Ensure that MongoDB runs in a trusted network environment and configure firewall or security groups to control inbound and outbound traffic for your MongoDB instances.

確保MongoDB執行在受信任的網路環境中並且配置防火牆或者安全組來控制MongoDB例項的入站和出站流量。

Allow only trusted clients to access the network interfaces and ports on which MongoDB instances are available. For instance, use IP whitelisting to allow access from trusted IP addresses (see )

只允許受信任的客戶端訪問MongoDB例項所在的網路介面和埠。例如,使用白名單機制允許受信任的IP地址訪問。

NOTE

Starting with MongoDB 3.6, MongoDB binaries,  mongod and  mongos, bind to  localhost by default. From MongoDB versions 2.6 to 3.4, only the binaries from the official MongoDB RPM (Red Hat, CentOS, Fedora Linux, and derivatives) and DEB (Debian, Ubuntu, and derivatives) packages would bind to  localhost by default. To learn more about this change, see Localhost Binding Compatibility Changes.

注意

從MongoDB 3.6開始,MongoDB的二進位制檔案: mongodmongos會預設繫結在 localhost上。MongoDB 2.6到3.4版本,只有官方MongoDB RPM(Red Hat、CentOS、Fedora Linux和衍生品)和DEB(Debian、Ubuntu和衍生品)包中的二進位制檔案預設繫結在localhost。瞭解更多關於這個改變的資訊,請參閱localhost繫結相容變更

See:

  • Network and Configuration Hardening

  • net.bindIp configuration setting

  • security.clusterIpSourceWhitelist configuration setting

  • authenticationRestrictions to specify per-user IP whitelist.

請參閱:

  • 網路和配置加固

  • net.bindIp配置設定

  • security.clusterIpSourceWhitelist配置設定

  • authenticationRestrictions為每個使用者指定IP白名單

Disable direct SSH root access.

禁用直接SSH root訪問。

➤ Audit System Activity

➤系統活動審計

Track access and changes to database configurations and data. MongoDB Enterprise includes a system auditing facility that can record system events (e.g. user operations, connection events) on a MongoDB instance. These audit records permit forensic analysis and allow administrators to verify proper controls. You can set up filters to record specific events, such as authentication events.

跟蹤對資料庫配置和資料的訪問和更改。MongoDB企業版包含了一個系統審計工具,可以記錄MongoDB例項上的系統事件(例如使用者操作、連線事件)。這些審計記錄使審查分析得以進行並且允許管理員去驗證適當的控制。可以設定過濾器來記錄特定的事件,例如身份認證事件。

See Auditing and Configure Auditing.

請參閱Auditing 和Configure Auditing

➤ Run MongoDB with a Dedicated User

➤使用專用使用者執行MongoDB

Run MongoDB processes with a dedicated operating system user account. Ensure that the account has permissions to access data but no unnecessary permissions.

使用一個專用的作業系統賬戶執行MongoDB程式。確保這個賬戶除了訪問資料,沒有不必要的許可權。

See Install MongoDB for more information on running MongoDB.

關於執行MongoDB的更多資訊,請參閱MongoDB安裝

➤ Run MongoDB with Secure Configuration Options

➤ 使用安全的配置選項執行MongoDB

MongoDB supports the execution of JavaScript code for certain server-side operations:  mapReduce and  $where. If you do not use these operations, disable server-side scripting by using the  --noscripting option on the command line.

MongoDB支援使用JavaScript程式碼對伺服器端執行特定的操作,包括: mapReduce$where。如果你不使用這些操作,在命令列使用 --noscripting選項來禁用伺服器端指令碼。

Keep input validation enabled. MongoDB enables input validation by default through the  net.wireObjectCheck setting. This ensures that all documents stored by the  mongod instance are valid BSON.

確保啟用了輸入驗證。MongoDB預設透過 net.wireObjectCheck設定啟用輸入驗證。這確保了 mongod例項儲存的所有文件都是有效的BSON。

SEE:Network and Configuration Hardening.

請參閱:網路和配置加固

➤ Request a Security Technical Implementation Guide (where applicable)

➤索取安全技術實施指南(如適用)

The Security Technical Implementation Guide (STIG) contains security guidelines for deployments within the United States Department of Defense. MongoDB Inc. provides its STIG, upon request, for situations where it is required. Please request a copy for more information.

安全技術實施指南(STIG)包含美國國防部內部部署的安全指南。MongoDB公司為需要的情況提供了它的STIG。請索取一個副本以獲取更多資訊。

➤ Consider Security Standards Compliance

➤考慮安全標準的合規性

For applications requiring HIPAA or PCI-DSS compliance, please refer to the MongoDB Security Reference Architecture to learn more about how you can use the key security capabilities to build compliant application infrastructure.

對於需要遵循HIPAA或者PCI-DSS的應用程式,請參看MongoDB安全參考架構以瞭解更多關於如何使用關鍵安全功能來構建合規的應用程式基礎設施。

Periodic/Ongoing Production Checks

定期/持續的產品檢查

Periodically check for MongoDB Product CVE and upgrade your products .

定期檢查MongoDB產品通用漏洞披露並且更新你的產品。

Consult the MongoDB end of life dates and upgrade your MongoDB installation. In general, try to stay on the latest version.

查詢MongoDB的生命週期終止日期並升級你的MongoDB。一般來說,儘量使用最新的版本。

Ensure that your information security management system policies and procedures extend to your MongoDB installation, including performing the following:

確保你的資訊保安管理的系統策略和程式在你安裝的MongoDB上生效,包括執行以下操作:

  • Periodically apply patches to your machine and review guidelines.

  • Review policy/procedure changes, especially changes to your network rules to prevent inadvertent MongoDB exposure to the Internet.

  • Review MongoDB database users and periodically rotate them.

  • 定期對你的裝置打補丁並且檢查操作指南

  • 檢查策略及流程變更,尤其是網路規則的更改,以防無意中將MongoDB暴露在網際網路。

  • 檢查MongoDB資料庫使用者並定期進行輪換。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27721058/viewspace-2850975/,如需轉載,請註明出處,否則將追究法律責任。

相關文章