The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(keyring): allow read-only secret mount permissions
Steven Enamakelbe1ecca9331f
diff --git a/crates/openhuman-core/src/security/keyring/encrypted_file_backend.rs b/crates/openhuman-core/src/security/keyring/encrypted_file_backend.rsindex a159e88d47..c29132f406 100644--- a/crates/openhuman-core/src/security/keyring/encrypted_file_backend.rs+++ b/crates/openhuman-core/src/security/keyring/encrypted_file_backend.rs@@ -256,10 +256,9 @@ fn master_key_from_env(/// Reads the file named by [`MASTER_KEY_FILE_ENV`].///-/// On Unix a key file must be owner-only readable (`0400` or `0600`). Any-/// group/other permission can expose the key that decrypts the whole store,-/// so it is rejected before the file is read. Container secret mounts must be-/// configured with an owner-only mode and matching uid/gid for the core.+/// On Unix a key file must not be writable by other users. Read-only group or+/// other permissions are supported for container secret mounts, where the+/// runtime may add group-read access for a non-root core.fn read_master_key_file(path: &Path) -> Result<String, String> {#[cfg(unix)]{@@ -268,12 +267,6 @@ fn read_master_key_file(path: &Path) -> Result<String, String> {format!("cannot inspect master key file permissions ({MASTER_KEY_FILE_ENV}): {e}")})?;let mode = metadata.permissions().mode() & 0o777;- if key_file_mode_is_private(mode) {- return Err(format!(- "master key file ({MASTER_KEY_FILE_ENV}) has insecure permissions \- {mode:04o}; restrict it to owner-readable 0400 or 0600"- ));- }if key_file_mode_is_other_writable(mode) {return Err(format!("master key file ({MASTER_KEY_FILE_ENV}) is writable by other users; \@@ -284,12 +277,6 @@ fn read_master_key_file(path: &Path) -> Result<String, String> {std::fs::read_to_string(path).map_err(|e| format!("cannot read master key file: {e}"))}-/// Whether a master-key file has any group/other permission bits.-#[cfg(unix)]-fn key_file_mode_is_private(mode: u32) -> bool {- mode & 0o077 != 0-}-#[cfg(unix)]fn key_file_mode_is_other_writable(mode: u32) -> bool {mode & 0o002 != 0diff --git a/crates/openhuman-core/src/security/keyring/encrypted_file_backend_tests.rs b/crates/openhuman-core/src/security/keyring/encrypted_file_backend_tests.rsindex 3fa0597ec2..a0a30730da 100644--- a/crates/openhuman-core/src/security/keyring/encrypted_file_backend_tests.rs+++ b/crates/openhuman-core/src/security/keyring/encrypted_file_backend_tests.rs@@ -263,15 +263,14 @@ fn read_master_key_file_returns_contents_and_reports_a_missing_file() {#[cfg(unix)]#[test]-fn read_master_key_file_rejects_a_world_readable_secret_mount() {+fn read_master_key_file_accepts_read_only_secret_mounts() {use std::os::unix::fs::PermissionsExt;let tmp = tempfile::TempDir::new().unwrap();let path = tmp.path().join("master.key");std::fs::write(&path, hex_key(0x44)).unwrap();std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o644)).unwrap();- let err = read_master_key_file(&path).expect_err("world-readable key files are unsafe");- assert!(err.contains("insecure permissions"), "{err}");+ read_master_key_file(&path).expect("read-only secret mounts are supported");}#[cfg(unix)]@@ -284,20 +283,18 @@ fn read_master_key_file_rejects_other_writable_files() {std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o602)).unwrap();let err = read_master_key_file(&path).expect_err("other-writable key files are unsafe");- assert!(err.contains("insecure permissions"), "{err}");+ assert!(err.contains("writable by other users"), "{err}");}#[cfg(unix)]#[test]-fn key_file_permissions_require_owner_only_access() {- for mode in [0o644, 0o444, 0o604, 0o666, 0o602, 0o440, 0o640] {- assert!(key_file_mode_is_private(mode), "{mode:04o}");+fn key_file_permissions_reject_other_writes_but_allow_read_only_access() {+ for mode in [0o400, 0o600, 0o644, 0o444, 0o604, 0o440, 0o640] {+ assert!(!key_file_mode_is_other_writable(mode), "{mode:04o}");}- for mode in [0o400, 0o600] {- assert!(!key_file_mode_is_private(mode), "{mode:04o}");+ for mode in [0o602, 0o666] {+ assert!(key_file_mode_is_other_writable(mode), "{mode:04o}");}- assert!(key_file_mode_is_other_writable(0o602));- assert!(!key_file_mode_is_other_writable(0o644));}#[test]diff --git a/gitbooks/features/cloud-deploy.md b/gitbooks/features/cloud-deploy.mdindex bec3dc3ba8..59c5277c6d 100644--- a/gitbooks/features/cloud-deploy.md+++ b/gitbooks/features/cloud-deploy.md@@ -533,12 +533,13 @@ Restrict the mode where the mount is declared:```Set the `emptyDir` medium and the core UID/GID to match the ownership applied- by the init container. The `defaultMode: 0400` setting is important: it- gives the non-root core access through its matching UID while keeping group- and other permissions clear. Do not use `fsGroup` to grant access: kubelet- can turn the projected file into `0440`, which the core rejects. An- equivalent setup is a secret volume whose `defaultMode` is `0400` and whose- file is mounted with ownership matching the core's `runAsUser`/`runAsGroup`.+ by the init container. The `defaultMode: 0400` setting is important. For a+ direct non-root mount, also provide `fsGroup` (or equivalent group access)+ matching the core's group so kubelet can make the file readable; the resulting+ read-only `0440` mode is accepted. The init-container recipe above instead+ grants access by changing the copied file's owner. An equivalent setup is a+ secret volume whose `defaultMode` is `0400` and whose file is mounted with+ ownership matching the core's `runAsUser`/`runAsGroup`.- Docker Swarm: set `mode: 0400` (with `uid`/`gid` for a non-root user) on theservice's secret.- A plain file: `chmod 600` it, owned by the user the core runs as.