{"record":{"id":"53f617ac09036aa2","repo":"astrid-runtime/astrid","slug":"winfsp-service-launch-exceeds-limit","errorCode":null,"errorMessage":"WinFsp service launch exceeds limit","messagePattern":"WinFsp service launch exceeds limit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-provider-winfsp/src/win.rs","lineNumber":167,"sourceCode":"    /// Request was rejected.\n    Failure { code: String, message: String },\n}\n\nconst SERVICE_MAX_LAUNCH_BYTES: u64 = 64 * 1024;\nconst SERVICE_MAX_CONTROL_BYTES: usize = 64 * 1024;\nconst SERVICE_MAX_CALLBACK_BYTES: usize = 8 * 1024 * 1024;\nconst SERVICE_POLL: Duration = Duration::from_secs(1);\n\n/// Run the hidden kernel-created `WinFsp` service mode.\npub(crate) fn service_main() -> Result<()> {\n    let mut bytes = Vec::new();\n    std::io::stdin()\n        .lock()\n        .take(SERVICE_MAX_LAUNCH_BYTES + 1)\n        .read_to_end(&mut bytes)\n        .context(\"read WinFsp service launch\")?;\n    if bytes.len() as u64 > SERVICE_MAX_LAUNCH_BYTES {\n        bail!(\"WinFsp service launch exceeds limit\");\n    }\n    let launch: StorageProviderServiceLaunchV1 =\n        serde_json::from_slice(&bytes).context(\"decode WinFsp service launch\")?;\n    validate_service_launch(&launch)?;\n    let challenge = storage_provider_service_ready_challenge(\n        &launch.parent.token,\n        STORAGE_FILESYSTEM_SERVICE_READY_SCHEMA_V1,\n        crate::PROVIDER_NAME,\n        launch.lease.mount_id.as_uuid(),\n        &launch.control_path,\n        &launch.lease.resource_path,\n        &launch.lease.callback_path,\n    )\n    .map_err(anyhow::Error::msg)?;\n    let runtime = Arc::new(\n        tokio::runtime::Builder::new_multi_thread()\n            .enable_all()\n            .build()","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-provider-winfsp/src/win.rs#L149-L185","documentation":"The WinFsp private service reads its launch document (StorageProviderServiceLaunchV1) from stdin capped at SERVICE_MAX_LAUNCH_BYTES via take(SERVICE_MAX_LAUNCH_BYTES + 1). If the byte count exceeds the cap, service_main bails before JSON parsing. It is a bounded-read defense for the privileged service's IPC input.","triggerScenarios":"The parent writes a launch document larger than SERVICE_MAX_LAUNCH_BYTES to the service's stdin, e.g. oversized token fields, extra nested data, or garbage bytes beyond the JSON document.","commonSituations":"Embedding very long tokens or control paths in the launch; a parent/child version mismatch inflating the payload; accidental extra writes to the child's stdin pipe.","solutions":["Trim the launch payload the parent writes (shorten tokens/paths, remove non-schema fields)","Have the parent write exactly one JSON document and close stdin","Align parent and service crate versions so the payload shape matches expectations","Raise SERVICE_MAX_LAUNCH_BYTES in the crate only if genuinely needed, rebuilding both binaries together"],"exampleFix":"// before\nwrite_all(serde_json::to_vec(&launch_with_full_audit_log)?)\n// after\nlaunch.extra = None; // drop oversized optional fields\nwrite_all(serde_json::to_vec(&launch)?)","handlingStrategy":"validation","validationCode":"let bytes = serde_json::to_vec(&launch)?;\nif bytes.len() as u64 > SERVICE_MAX_LAUNCH_BYTES {\n    return Err(format!(\"launch payload {} bytes exceeds limit {}\", bytes.len(), SERVICE_MAX_LAUNCH_BYTES));\n}","typeGuard":"fn launch_within_limit(launch: &StorageProviderServiceLaunchV1, max: u64) -> bool {\n    serde_json::to_vec(launch).map(|b| (b.len() as u64) <= max).unwrap_or(false)\n}","tryCatchPattern":"match service_err {\n    Err(e) if e.to_string().contains(\"launch exceeds limit\") => {\n        eprintln!(\"trim launch payload or raise SERVICE_MAX_LAUNCH_BYTES\");\n    }\n    other => other?,\n}","preventionTips":["Size-check the serialized launch before writing stdin","Avoid embedding large blobs in the launch document","Keep parent and service binaries version-aligned"],"tags":["windows","winfsp","ipc","payload-size"],"backgroundTag":"payload-too-large","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"}