You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In multi-tenant or HPC environments where untrusted users can control environment variables, you can lock the keystore location to prevent them from overriding `HDF5_PLUGIN_KEYSTORE` with a malicious keystore.
1073
+
1074
+
**Runtime Lock (No Recompilation Required):**
1075
+
```bash
1076
+
# Unix/Linux: Create lock file to disable environment variable override
1077
+
sudo mkdir -p /etc/hdf5
1078
+
sudo touch /etc/hdf5/lock_keystore
1079
+
1080
+
# Windows: Create lock file
1081
+
mkdir "C:\ProgramData\HDF_Group\HDF5"
1082
+
type nul >"C:\ProgramData\HDF_Group\HDF5\lock_keystore"
1083
+
```
1084
+
1085
+
**Compile-Time Lock (Requires Rebuild):**
1086
+
```bash
1087
+
# Configure HDF5 with locked keystore (completely disables env var)
1088
+
cmake -DHDF5_LOCK_PLUGIN_KEYSTORE=ON \
1089
+
-DHDF5_PLUGIN_KEYSTORE_DIR=/etc/hdf5/keystore \
1090
+
/path/to/hdf5/source
1091
+
```
1092
+
1093
+
**When to Use:**
1094
+
- ✅ HPC clusters with untrusted users
1095
+
- ✅ Multi-tenant systems
1096
+
- ✅ Production servers with strict security requirements
1097
+
- ✅ Pre-built binaries distributed to security-critical environments
1098
+
1099
+
**How It Works:**
1100
+
1. If lock file exists, `HDF5_PLUGIN_KEYSTORE` environment variable is ignored
1101
+
2. HDF5 will only use the compile-time configured keystore (`HDF5_PLUGIN_KEYSTORE_DIR`)
1102
+
3. Prevents privilege escalation via keystore override attacks
1103
+
4. System administrators can apply this to pre-built HDF5 libraries without recompilation
1104
+
1105
+
**Verification:**
1106
+
```bash
1107
+
# Test that environment variable is ignored after locking
1108
+
export HDF5_PLUGIN_KEYSTORE=/tmp/fake_keystore
1109
+
1110
+
# Enable debug output to see which keystore is used
1111
+
HDF5_PLUGIN_KEYSTORE_DEBUG=1 h5dump test_file.h5
1112
+
1113
+
# Expected output: "Skipping HDF5_PLUGIN_KEYSTORE environment variable (locked by sysadmin)"
0 commit comments