openai/codex · error

CheckTokenMembership failed

Error message

CheckTokenMembership failed: {}

What it means

CheckTokenMembership returned zero after the Administrators SID was built (and freed), so the process could not determine whether its token belongs to the Administrators group for the elevation check.

Solutions

  1. Retry the membership check
  2. Inspect the Win32 error code; verify the process token is accessible and not malformed
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at codex-rs/windows-sandbox-rs/src/setup.rs:513 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/bb8f8e6c8268df8a. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/windows-sandbox-rs/src/setup.rs:513

            0,
            0,
            0,
            0,
            0,
            0,
            &mut administrators_group,
        );
        if ok == 0 {
            return Err(anyhow!(
                "AllocateAndInitializeSid failed: {}",
                GetLastError()
            ));
        }
        let mut is_member = 0i32;
        let check = CheckTokenMembership(0, administrators_group, &mut is_member as *mut _);
        FreeSid(administrators_group as *mut _);
        if check == 0 {
            return Err(anyhow!("CheckTokenMembership failed: {}", GetLastError()));
        }
        Ok(is_member != 0)
    }
}

fn canonical_existing(paths: &[PathBuf]) -> Vec<PathBuf> {
    paths
        .iter()
        .filter_map(|p| {
            if !p.exists() {
                return None;
            }
            Some(dunce::canonicalize(p).unwrap_or_else(|_| p.clone()))
        })
        .collect()
}

fn profile_read_roots(user_profile: &Path) -> Vec<PathBuf> {

View on GitHub (pinned to 339751715c)