HDDS-14574. Enforce 700 permissions on Ozone Metadata and Data(hdds) directories#9735
HDDS-14574. Enforce 700 permissions on Ozone Metadata and Data(hdds) directories#9735Gargi-jais11 wants to merge 3 commits intoapache:masterfrom
Conversation
|
@ChenSammi , @sumitagrawl and @jojochuang Please review the patch. |
sreejasahithi
left a comment
There was a problem hiding this comment.
Thanks @Gargi-jais11 for working on this, left few comments
...ner-service/src/main/java/org/apache/hadoop/ozone/container/common/volume/StorageVolume.java
Show resolved
Hide resolved
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServerUtils.java
Outdated
Show resolved
Hide resolved
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/server/ServerUtils.java
Outdated
Show resolved
Hide resolved
| // (for data volumes, we want to ensure the root has secure permissions, | ||
| // even if the directory already existed from a previous run) | ||
| // This follows the same pattern as metadata directories in getDirectoryFromConfig() | ||
| if (b.conf != null && root.exists() && HDDS_VOLUME_DIR.equals(b.getStorageDirStr())) { |
There was a problem hiding this comment.
this is called here also, and even during loading root also, check if this is duplicate OR for different path.
There was a problem hiding this comment.
These are not duplicates - they set permissions on different paths. Line 789 sets permissions on the volume root (e.g., /data/hdds1), while line 807 sets permissions on the storage directory (e.g., /data/hdds1/hdds). Both levels need secure permissions for defense-in-depth.
| // (permissions are also set in StorageVolume.initializeImpl(), | ||
| // but this ensures they're set even if directory already existed | ||
| // from a previous run with incorrect permissions) | ||
| if (volumeType == StorageVolume.VolumeType.DATA_VOLUME) { |
There was a problem hiding this comment.
This is required only for datavolume other other volume types ?
There was a problem hiding this comment.
The volumeType == StorageVolume.VolumeType.DATA_VOLUME check is correct. Permission setting is only for data volumes.
META_VOLUME (MetadataVolume) - Stores Ratis metadata which is managed by Ratis.
DbVolume is for db instance storage. So not sure we can use same config hdds.datanode.dir.data.permissions over here as well. However the parent hdds/ directory is the HddsVolume storage dir and gets permissions from hdds.datanode.data.dir.permissions (default 700). So container.db is already protected by that parent hierarchy.
What changes were proposed in this pull request?
Current Behaviour:
For Ozone metadata of OM, SCM, DN and Recon and Datanode Directory(/data/hdds) have 750 and 755 permissions respectively.
Proposed Behaviour:
We should bring Ozone up to parity with HDFS, where we have both a parameter that controls the permission, as well as health alerts for lax permissions.
Incorrectly permissioned data directories can lead to a serious data breach as any user (e.g. any Spark application) is able to read the data files.
Make the default permissions for all ozone metadata and data directories as 700 similar to hdfs.
Added new config for data directory permission:
hdds.datanode.data.dir.permissionswith default value of 700 and changed ozone metadata directory permissions to 700 from 750.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-14574
How was this patch tested?
Added unit tests. Also manually tested for permissions: