openai/codex · error · SetupFailure

HelperDpapiProtectFailed

HelperDpapiProtectFailed

Error message

dpapi protect failed for offline user: {err}

What it means

The DPAPI CryptProtectData helper failed while encrypting the offline sandbox user's password before writing it to the secrets directory. Without a protected blob the credentials cannot be persisted safely, so secret writing is aborted with the underlying error chained.

Solutions

  1. Check the chained error for the CryptProtectData GetLastError code
  2. Verify DPAPI machine-scope protection is available (the code uses CRYPTPROTECT_LOCAL_MACHINE) and not blocked by policy or a broken credential store
  3. Ensure the process identity can access the DPAPI machine keys; running elevated usually resolves protection-key access failures
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win/sandbox_users.rs:423 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/704fa8ce66714832. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/windows-sandbox-rs/src/bin/setup_main/win/sandbox_users.rs:423

fn write_secrets(
    codex_home: &Path,
    offline_user: &str,
    offline_pwd: &str,
    online_user: &str,
    online_pwd: &str,
) -> Result<()> {
    let secrets_dir = sandbox_secrets_dir(codex_home);
    std::fs::create_dir_all(&secrets_dir).map_err(|err| {
        anyhow::Error::new(SetupFailure::new(
            SetupErrorCode::HelperUsersFileWriteFailed,
            format!(
                "failed to create secrets dir {}: {err}",
                secrets_dir.display()
            ),
        ))
    })?;
    let offline_blob = dpapi_protect(offline_pwd.as_bytes()).map_err(|err| {
        anyhow::Error::new(SetupFailure::new(
            SetupErrorCode::HelperDpapiProtectFailed,
            format!("dpapi protect failed for offline user: {err}"),
        ))
    })?;
    let online_blob = dpapi_protect(online_pwd.as_bytes()).map_err(|err| {
        anyhow::Error::new(SetupFailure::new(
            SetupErrorCode::HelperDpapiProtectFailed,
            format!("dpapi protect failed for online user: {err}"),
        ))
    })?;
    let users = SandboxUsersFile {
        version: SETUP_VERSION,
        offline: SandboxUserRecord {
            username: offline_user.to_string(),
            password: BASE64.encode(offline_blob),
        },
        online: SandboxUserRecord {
            username: online_user.to_string(),

View on GitHub (pinned to 339751715c)