{"record":{"id":"c8e90d13b3b2779d","repo":"astrid-runtime/astrid","slug":"stale-mount-recovery-belongs-to-another-acting-pri","errorCode":null,"errorMessage":"stale mount recovery belongs to another acting principal","messagePattern":"stale mount recovery belongs to another acting principal","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-provider-fskit/src/main.rs","lineNumber":284,"sourceCode":"        )?;\n    }\n    update_registry(|registry| {\n        registry.mounts.remove(&path_key(&record.mountpoint));\n        Ok(())\n    })?;\n    cleanup_created_mountpoint(&record.mountpoint, record.auto_created_mountpoint)?;\n    Ok(StorageProviderSuccessV1::Unmounted {\n        mount_id: record.mount_id,\n    })\n}\n\nfn authorize_stale_cleanup(\n    lease_is_live: bool,\n    requested_by: &astrid_core::PrincipalId,\n    acting_principal: &astrid_core::PrincipalId,\n) -> Result<()> {\n    if !lease_is_live && requested_by != acting_principal {\n        bail!(\"stale mount recovery belongs to another acting principal\");\n    }\n    Ok(())\n}\n\nfn lease_from_response(body: AdminResponseBody) -> Result<StorageMountLeaseV1> {\n    match body {\n        AdminResponseBody::StorageMountLease(lease) => Ok(*lease),\n        AdminResponseBody::Error(error) => bail!(\"kernel refused storage mount: {error}\"),\n        _ => bail!(\"kernel returned an unexpected storage mount response\"),\n    }\n}\n\nfn into_success(body: AdminResponseBody) -> Result<serde_json::Value> {\n    match body {\n        AdminResponseBody::Success(value) => Ok(value),\n        AdminResponseBody::Error(error) => {\n            bail!(\"kernel refused storage lifecycle request: {error}\")\n        },","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-provider-fskit/src/main.rs#L266-L302","documentation":"authorize_stale_cleanup() governs unmounting mounts whose kernel lease is no longer live. Stale recovery is only allowed by the same principal that originally requested the mount; a different acting principal is refused, preventing users from tearing down each other's stale mounts.","triggerScenarios":"Calling unmount() for a mount whose lease is dead (lease_is_live == false) while acting_principal != requested_by on the stored MountRecord.","commonSituations":"An admin or service account attempts to clean up a stale mount created by another user; credential rotation changed the effective principal id between mount and cleanup; scripting cleanup across machines under a shared account with different principal ids.","solutions":["Perform the stale unmount using the same PrincipalId that originally requested the mount","Have the original owner run the cleanup, or use an administrative mechanism intended for cross-principal recovery","Verify the acting principal configuration (identity file/token) matches the original requester"],"exampleFix":"// before\nunmount_as(current_principal, \"/mnt/share\")?; // principal differs from requester\n// after\nunmount_as(original_requester_principal, \"/mnt/share\")?;","handlingStrategy":"validation","validationCode":"// rust\nanyhow::ensure!(\n    acting_principal == record.requested_by,\n    \"stale recovery requires the original requesting principal\"\n);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run cleanup under the same identity that created the mount","Record requested_by alongside mounts in your own bookkeeping","Provide an explicit admin recovery flow rather than reusing unmount across principals"],"tags":["authorization","mount","security","rust"],"backgroundTag":"permission-denied","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}