{"record":{"id":"09692b34685d7209","repo":"astrid-runtime/astrid","slug":"invalid-parent-pid","errorCode":null,"errorMessage":"invalid parent PID","messagePattern":"invalid parent PID","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-provider-fskit/src/service.rs","lineNumber":399,"sourceCode":"}\n\n#[cfg(target_os = \"macos\")]\nfn mac_process_start_identity(pid: u32) -> Option<String> {\n    use libproc::libproc::bsd_info::BSDInfo;\n    use libproc::libproc::proc_pid::pidinfo;\n\n    let info = pidinfo::<BSDInfo>(i32::try_from(pid).ok()?, 0).ok()?;\n    Some(format!(\n        \"{}:{}\",\n        info.pbi_start_tvsec, info.pbi_start_tvusec\n    ))\n}\n\nfn validate_launch_parent(\n    parent: &astrid_core::storage_filesystem::StorageProviderParentLifetimeV1,\n) -> Result<()> {\n    if parent.pid <= 1 || parent.pid == std::process::id() {\n        bail!(\"invalid parent PID\");\n    }\n    if parent.token.len() < 16\n        || parent.token.len() > 512\n        || parent.token.chars().any(char::is_control)\n    {\n        bail!(\"invalid parent token\");\n    }\n    if let Some(identity) = parent.start_identity.as_deref()\n        && (identity.is_empty() || identity.len() > 512 || identity.chars().any(char::is_control))\n    {\n        bail!(\"invalid parent start identity\");\n    }\n    #[cfg(any(target_os = \"linux\", target_os = \"macos\"))]\n    if parent.start_identity.is_none() {\n        bail!(\"parent start identity is required on this platform\");\n    }\n    Ok(())\n}","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-provider-fskit/src/service.rs#L381-L417","documentation":"validate_launch_parent, invoked from validate_launch, checks the parent lifetime record supplied when launching the FSKit helper process. A parent pid of 0/1 or the provider's own pid is rejected, because such values cannot represent a real supervising process to monitor. This prevents launching without a meaningful lifetime owner.","triggerScenarios":"validate_launch_parent is given StorageProviderParentLifetimeV1 with pid <= 1 or pid == std::process::id() — e.g. a caller passing pid 0/1 as 'system', or accidentally passing the service's own pid.","commonSituations":"Config defaulting parent pid to 0/1 when the real parent is unknown; test harnesses reusing dummy pids; a launch request crafted by the service itself rather than its host app.","solutions":["Populate parent.pid with the actual PID of the supervising application before calling validate_launch","Never hard-code 0 or 1 as the parent PID; fail fast upstream if the parent is unknown","Ensure the launch request originates from the host app, not from the service process itself","Add an assertion/logging when pid is unset so misconfiguration surfaces early"],"exampleFix":"// before\nlet parent = StorageProviderParentLifetimeV1 { pid: 0, .. };\n// after\nlet parent = StorageProviderParentLifetimeV1 { pid: std::process::id(), token: token, .. }; // real host pid, not 0/1/self","handlingStrategy":"validation","validationCode":"fn parent_pid_ok(pid: u32) -> bool { pid > 1 && pid != std::process::id() }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass the real host application PID, never 0/1","Fail fast upstream if the parent PID is unknown","Ensure launch requests originate from the host app, not the service","Log the parent PID at launch for diagnosability"],"tags":["process","validation","security"],"backgroundTag":"invalid-argument-value","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"}