Skip to main content

Data encrypted at rest,
keys under Ranger policies.

Ranger KMS creates and stores the keys of the HDFS encryption zones, and access to them is authorized by Ranger policies and audited. Follow a file in an encryption zone and learn the service architecture and the layered keys.

Ranger KMS is the KMS for transparent encryption in HDFS: it stores the encryption keys of the encryption zones, and access to them is decided by Ranger policies.

In HDFS

One key per zone

Each HDFS encryption zone has a key, stored in the KMS, and each file in the zone also has its own data encryption key.

End to end

Only the client decrypts

HDFS stores only encrypted data and encrypted data encryption keys. The client does the decryption, after obtaining the key from the KMS.

In Ranger

Under policy and audit

Access to the keys is authorized by Ranger policies, and KMS operations are recorded in the audit.

On this page

See an encrypted file​

Press Play or step through. Underlined names lead to the Glossary.

ClientApplication that reads and writes
HDFS clientCreates, writes, and reads files
HDFSMetadata and blocks
NameNodeStores each file's EDEK
DataNodesSee only encrypted bytes
Ranger KMSStores the keys
Ranger KMSGenerates and decrypts EDEKs
Zone keyEncrypts the EDEKs
RangerPolicies and audit
Ranger AdminKey access policies
AuditRecord of operations
Step 1 of 7

1 One zone, one key

Before any file exists, the administrator creates a key in the KMS and an encryption zone in an HDFS directory, linked to that key. The zone has a single key, and everything written inside it is encrypted.

  1. One zone, one key. Before any file exists, the administrator creates a key in the KMS and an encryption zone in an HDFS directory, linked to that key. The zone has a single key, and everything written inside it is encrypted.
  2. The client creates a file in the zone. For the application, nothing changes: the client asks the NameNode to create the file, as in any HDFS directory.
  3. The NameNode asks the KMS for an EDEK. Each file in the zone has its own data encryption key, the DEK. The NameNode asks the KMS to generate one: the KMS creates a random key, encrypts it with the zone key, and returns only the encrypted version, the EDEK. The NameNode stores it in the file metadata.
  4. The client receives the EDEK. The NameNode hands the client the file's EDEK and the version of the zone key that encrypted it. HDFS handles only EDEKs: the plaintext DEK never passes through it.
  5. The KMS checks the permission and decrypts. The client asks the KMS to decrypt the EDEK, and the KMS first checks whether the client has permission on the zone key version. In Ranger KMS, this permission comes from Ranger policies, which the KMS plugin fetches from Ranger Admin and caches. If permission is granted, the KMS returns the DEK to the client.
  6. The client encrypts and decrypts. The DataNodes only store. With the DEK, the client itself encrypts what it writes and decrypts what it reads. The DataNodes receive and store only encrypted bytes, which is what protects the data at rest and in transit.
  7. Every operation is recorded. The KMS records the operations on the keys in the Ranger audit, and the destinations of the records, such as Solr and HDFS, are configurable in Ambari.
Figure 1 - A file in an encryption zone. The NameNode asks the KMS for a new EDEK. To read or write, the client asks the KMS to decrypt it, and only the client sees the DEK.

Architecture​

The KMS stores the keys; HDFS only calls it; Ranger decides and records.

Ranger KMS architecture: HDFS client, NameNode, DataNodes, Ranger KMS, Ranger Admin, Kerberos, audit and master keyThe HDFS client creates and reads files on the NameNode, which stores the EDEK of each file, and the DataNodes receive only encrypted bytes. The NameNode asks Ranger KMS to generate the EDEK, and the client asks Ranger KMS to decrypt it. Ranger KMS stores the zone keys, has a Ranger plugin with a local copy of the policies and is served through a REST API over HTTP. Ranger Admin provides the policies, Kerberos authenticates access to the KMS and the audit receives the records, with destinations such as Solr and HDFS. The master key is kept in the KMS database or, optionally, in an HSM.HDFS clientencrypts and decrypts dataHDFSNameNodestores the EDEKof each fileDataNodessee onlyencrypted bytesRanger KMSRanger KMS ServerREST API over HTTPZone keysone per zoneRanger plugincached policiesKMS databasemaster keyHSMmaster key (optional)Ranger Adminaccess policiesfor the keyspoliciesKerberosauthenticates KMS accessAuditSolrHDFSrecordscreates and reads filesgenerates EDEKdecrypts EDEK
Figure 2 - Ranger KMS architecture: the HDFS client and NameNode, the KMS with the zone keys and the Ranger plugin, Ranger Admin, Kerberos, the audit, and the master key, in the KMS database or in an HSM. Underlined terms lead to the Glossary.

What the figure shows:

  1. The HDFS client encrypts and decrypts the data. It creates and reads files on the NameNode and asks Ranger KMS to decrypt the EDEK.
  2. The NameNode stores the EDEK of each file and asks Ranger KMS to generate it.
  3. The DataNodes receive only encrypted bytes.
  4. The Ranger KMS Server answers through a REST API over HTTP: this is how the NameNode and the HDFS clients talk to the KMS.
  5. The zone keys are stored in the KMS, one per encryption zone.
  6. The Ranger plugin in the KMS fetches the key access policies from Ranger Admin and keeps a local copy.
  7. The master key, from which the encryption keys are created, is stored in the KMS database or, optionally, in an HSM.
  8. Ranger Admin provides the key access policies.
  9. Kerberos can authenticate access to the KMS.
  10. The audit receives the records of the KMS operations, with destinations such as Solr and HDFS.

HDFS points to the KMS through a KeyProvider.

The layered keys​

Each key protects the next, from the master key to the file content. Go into a level to see what it holds.

Level 1 of 4

Master key

The key from which the KMS creates the encryption keys. It is stored in the KMS database or, optionally, in an HSM.

  • HSMA security device dedicated to storing keys, an alternative to the KMS database for storing the master key.
  1. Master key. The key from which the KMS creates the encryption keys. It is stored in the KMS database or, optionally, in an HSM.
    • HSM. A security device dedicated to storing keys, an alternative to the KMS database for storing the master key.
  2. Zone key. Each encryption zone has a single key, chosen when the zone is created. The key has a unique name and, when it is rolled over, gets a new version.
    • Key version. Each version has its own material. A file's EDEK stays associated with the version that encrypted it.
    • Nested zone. Inside a zone it is possible to create others, with different keys. A file's EDEK uses the key of the nearest ancestor zone.
  3. Data encryption key (DEK). Each file in the zone has its own DEK. The client uses it to encrypt what it writes and decrypt what it reads.
    • EDEK. The DEK encrypted with the zone key. The EDEK is what HDFS stores, in the file metadata. The KMS generates and decrypts it.
  4. File content. What the client writes reaches HDFS encrypted. The DataNodes see only a stream of encrypted bytes.
    • DataNode. Stores the encrypted bytes and never has access to plaintext data or data encryption keys.
Figure 3 - The key layers. The terms beside each level go with that level.

Who decides access​

Access to the data and access to the keys are decided in different places.

To the files

Who reads, writes, and lists the data and metadata of an encryption zone is decided by the normal HDFS permissions.

To the keys

Who uses the zone keys is decided by the KMS, with its own permissions. In Ranger KMS, these permissions are Ranger policies, maintained in Ranger Admin.

If HDFS is compromised

Whoever gains access to an HDFS superuser account reaches only the encrypted content and the EDEKs. The keys remain under other permissions, in the KMS and in the key store.

Why Ranger KMS​

Transparent

No application changes

Data read from and written to the encryption zones is encrypted and decrypted without changing the application code.

End to end

At rest and in transit

Only the client encrypts and decrypts. HDFS never stores or accesses plaintext data or data encryption keys, and the data stays encrypted on disk and on the network.

Granularity

One key per zone, one per file

Each zone has its own key, each file has its own DEK, and zones can be nested with different keys.

Central administration

Keys and permissions in Ranger

Keys can be created, rolled over, and listed through the Ranger Admin REST API or the hadoop key command line, and the permissions on them are Ranger policies.

Master key

In the database or in an HSM

The master key can be stored in the KMS database or in an HSM, with a utility to migrate it from one to the other.

Availability

One or more servers

The service supports one or more servers, and clients can switch between them or use a load balancer.

Where it comes from

HDFS transparent encryption needs a key service in the cluster: the Hadoop KMS, a server based on the Hadoop KeyProvider API that HDFS queries as a client. In TDP Datacenter, Ranger KMS takes this place and is administered by Ranger.

In the TDP editions​

Available in the TDP editions
EditionVersionDocumentation
TDP Datacenter2.4.0TDP Datacenter components

In TDP Datacenter​

In TDP Datacenter, Ranger KMS is the RANGER_KMS service, installed and managed by Ambari.

Service components

RANGER_KMS_SERVER (master, one or more). The RANGER_KMS_SERVER requires HDFS_CLIENT (HDFS). Component category.

Database

The KMS database is configurable in kms-properties (DB_FLAVOR, db_host, db_name, and db_user), and the creation of the database and user by Ambari, in create_db_user (kms-env). In the documented installation, Ranger KMS uses its own PostgreSQL database.

Master key

The master key password is configurable in KMS_MASTER_KEY_PASSWD (kms-properties) and in ranger.db.encrypt.key.password (dbks-site). The HSM can be enabled in ranger.ks.hsm.enabled, with the type in ranger.ks.hsm.type, and the Keysecure integration in ranger.kms.keysecure.enabled (dbks-site).

Key provider

The KMS KeyProvider is configurable in hadoop.kms.key.provider.uri (kms-site). In HDFS, the provider for the encryption zones is set in dfs.encryption.key.provider.uri (hdfs-site) and in hadoop.security.key.provider.path (core-site).

Cache

The cache of the KMS keys and metadata can be enabled in hadoop.kms.cache.enable, and the expiration times are configurable in hadoop.kms.cache.timeout.ms and hadoop.kms.current.key.cache.timeout.ms (kms-site).

Authentication

The KMS authentication type is configurable in hadoop.kms.authentication.type, with the HTTP endpoint principal in hadoop.kms.authentication.kerberos.principal (kms-site) and the service principal and keytab in ranger.ks.kerberos.principal and ranger.ks.kerberos.keytab (dbks-site). See Kerberos.

Authorization

The Ranger plugin in the KMS fetches the policies from Ranger Admin, in ranger.plugin.kms.policy.rest.url, for the Ranger service set in ranger.plugin.kms.service.name. The polling interval and the local copy directory are configurable in ranger.plugin.kms.policy.pollIntervalMs and ranger.plugin.kms.policy.cache.dir (ranger-kms-security). See Ranger.

Audit

The destinations are configurable in ranger-kms-audit, such as Solr (xasecure.audit.destination.solr) and HDFS (xasecure.audit.destination.hdfs), and the window that groups repeated records, in hadoop.kms.audit.aggregation.window.ms (kms-site). See Security in TDP Datacenter.

Process

The user, group, port, maximum memory, and log directory of the service are configurable in kms_user, kms_group, kms_port, ranger_kms_max_heap_size, and kms_log_dir (kms-env).

Dependencies

Ambari requires in the cluster Ranger and HDFS.

Used by

HDFS uses the KMS in the encryption zones. See Security in TDP Datacenter.

Next steps​

Sources​

Transparent Encryption in HDFS

Hadoop KMS

Apache Ranger

Ranger REST API: XKeyREST

Ranger SafeNet KeySecure HSM Integration