{"record":{"id":"bcfde76809bed029","repo":"openai/codex","slug":"cryptprotectdata-failed","errorCode":null,"errorMessage":"CryptProtectData failed: {}","messagePattern":"CryptProtectData failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/windows-sandbox-rs/src/dpapi.rs","lineNumber":39,"sourceCode":"    let mut in_blob = make_blob(data);\n    let mut out_blob = CRYPT_INTEGER_BLOB {\n        cbData: 0,\n        pbData: std::ptr::null_mut(),\n    };\n    let ok = unsafe {\n        CryptProtectData(\n            &mut in_blob,\n            std::ptr::null(),\n            std::ptr::null(),\n            std::ptr::null_mut(),\n            std::ptr::null_mut(),\n            // Use machine scope so elevated and non-elevated processes can decrypt.\n            CRYPTPROTECT_UI_FORBIDDEN | CRYPTPROTECT_LOCAL_MACHINE,\n            &mut out_blob,\n        )\n    };\n    if ok == 0 {\n        return Err(anyhow!(\"CryptProtectData failed: {}\", unsafe {\n            GetLastError()\n        }));\n    }\n    let slice =\n        unsafe { std::slice::from_raw_parts(out_blob.pbData, out_blob.cbData as usize) }.to_vec();\n    unsafe {\n        if !out_blob.pbData.is_null() {\n            LocalFree(out_blob.pbData as HLOCAL);\n        }\n    }\n    Ok(slice)\n}\n\n#[allow(clippy::unnecessary_mut_passed)]\npub fn unprotect(blob: &[u8]) -> Result<Vec<u8>> {\n    let mut in_blob = make_blob(blob);\n    let mut out_blob = CRYPT_INTEGER_BLOB {\n        cbData: 0,","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/windows-sandbox-rs/src/dpapi.rs#L21-L57","documentation":"Error \"CryptProtectData failed: {}\" thrown in openai/codex.","triggerScenarios":"Thrown at codex-rs/windows-sandbox-rs/src/dpapi.rs:39 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}