openai/codex · error

CreateRestrictedToken failed: {}

Error message

CreateRestrictedToken failed: {}

What it means

Error "CreateRestrictedToken failed: {}" thrown in openai/codex.

Source

Thrown at codex-rs/windows-sandbox-rs/src/token.rs:493

    entries[logon_idx].Attributes = 0;
    entries[logon_idx + 1].Sid = psid_everyone;
    entries[logon_idx + 1].Attributes = 0;

    let mut new_token: HANDLE = 0;
    let flags = DISABLE_MAX_PRIVILEGE | LUA_TOKEN | WRITE_RESTRICTED;
    let ok = CreateRestrictedToken(
        base_token,
        flags,
        0,
        std::ptr::null(),
        0,
        std::ptr::null(),
        entries.len() as u32,
        entries.as_mut_ptr(),
        &mut new_token,
    );
    if ok == 0 {
        return Err(anyhow!("CreateRestrictedToken failed: {}", GetLastError()));
    }

    // Additional restricting SIDs are identity markers, not capabilities. Deliberately exclude
    // them from the default DACL so possessing a route identity cannot grant object access.
    let mut dacl_sids: Vec<*mut c_void> = Vec::with_capacity(psid_capabilities.len() + 2);
    dacl_sids.push(psid_logon);
    dacl_sids.push(psid_everyone);
    dacl_sids.extend_from_slice(psid_capabilities);
    set_default_dacl(new_token, &dacl_sids)?;

    enable_single_privilege(new_token, "SeChangeNotifyPrivilege")?;
    Ok(new_token)
}

#[cfg(test)]
#[path = "token_tests.rs"]
mod tests;

View on GitHub (pinned to 339751715c)

Solutions

  1. Run the command through the elevated Windows sandbox runner so the process has the privileges CreateRestrictedToken needs; inspect the inner Win32 error in the message payload for the concrete failure code.

When it happens

Trigger: Thrown at codex-rs/windows-sandbox-rs/src/token.rs:493 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/97bd2bc5a588fe29. Report an issue: GitHub.