{"record":{"id":"0d1fcaf752da375d","repo":"libnyanpasu/clash-nyanpasu","slug":"failed-to-deserialize-sd","errorCode":null,"errorMessage":"Failed to deserialize SD","messagePattern":"Failed to deserialize SD","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"backend/tauri-plugin-deep-link/src/windows.rs","lineNumber":92,"sourceCode":"pub fn listen<F: FnMut(String) + Send + 'static>(mut handler: F) -> Result<()> {\n    if CRASH_COUNT.load(Ordering::Acquire) > 5 {\n        panic!(\"Local socket too many crashes\");\n    }\n\n    std::thread::spawn(move || {\n        let name = ID\n            .get()\n            .expect(\"listen() called before prepare()\")\n            .as_str()\n            .to_ns_name::<GenericNamespaced>()\n            .unwrap();\n        tokio::runtime::Builder::new_current_thread()\n            .enable_all()\n            .build()\n            .expect(\"failed to create tokio runtime\")\n            .block_on(async move {\n                let sdsf = \"D:(A;;GA;;;WD)\".to_wtf_16().unwrap();\n                let sd = SecurityDescriptor::deserialize(&sdsf).expect(\"Failed to deserialize SD\");\n                let listener = ListenerOptions::new()\n                    .name(name)\n                    .nonblocking(ListenerNonblockingMode::Both)\n                    .security_descriptor(sd)\n                    .create_tokio()\n                    .expect(\"Can't create listener\");\n\n                loop {\n                    match listener.accept().await {\n                        Ok(conn) => {\n                            let (rx, mut tx) = conn.split();\n                            let mut reader = BufReader::new(rx);\n                            let mut buf = String::new();\n                            if let Err(e) = reader.read_line(&mut buf).await {\n                                log::error!(\"Error reading from connection: {e}\");\n                                continue;\n                            }\n                            buf.pop();","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri-plugin-deep-link/src/windows.rs#L74-L110","documentation":"listen() deserializes the hardcoded security descriptor string \"D:(A;;GA;;;WD)\" with SecurityDescriptor::deserialize().expect(). Since the input is a compile-time constant, this panic should be impossible; it indicates a corrupted/misbehaving windows-rs security-descriptor implementation or binary tampering.","triggerScenarios":"Effectively unreachable with the current constant string; could fire only if the SDDL string was changed to an invalid form or the windows crate's SDDL parser fails unexpectedly.","commonSituations":"Modifying the SDDL string to a custom descriptor with a syntax error; unusual windows-rs crate version regressions in SDDL parsing.","solutions":["Keep the SDDL string \"D:(A;;GA;;;WD)\" unchanged","If customizing permissions, validate the SDDL syntax carefully before deserializing","Pin a windows-rs version known to parse the descriptor correctly"],"exampleFix":"// before\nlet sdsf = \"D:(GA;;;WD)\".to_wtf_16().unwrap(); // missing (A;;...) -> parse failure\n// after\nlet sdsf = \"D:(A;;GA;;;WD)\".to_wtf_16().unwrap(); // valid SDDL","handlingStrategy":"validation","validationCode":"// validate SDDL before deserializing\nlet sddl = \"D:(A;;GA;;;WD)\";\ndebug_assert!(sddl.starts_with(\"D:(A;;\") && sddl.ends_with(\"WD)\"), \"unexpected SDDL template\");","typeGuard":null,"tryCatchPattern":"let sd = SecurityDescriptor::deserialize(&sdsf)\n    .expect(\"Failed to deserialize SD: SDDL string must remain 'D:(A;;GA;;;WD)'\");","preventionTips":["Do not edit the hardcoded SDDL string without validating syntax","Pin tested windows-rs crate versions","Treat any occurrence of this panic as a build/tampering regression"],"tags":["rust","windows","security-descriptor","deep-link"],"backgroundTag":"internal-invariant-violation","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}