openai/codex · error · anyhow::Error

refusing to use symlink lock file

Error message

refusing to use symlink lock file {}

What it means

open_managed_ca_lock refuses to open the managed-CA lock file because symlink_metadata shows the path is a symbolic link. Locking through a symlink would allow an attacker to redirect locking and artifact writes, so the CA locking path must be a regular file.

Solutions

  1. Inspect the symlink at the reported lock path and remove it
  2. Audit the proxy dir for tampering if the link was not created by you
  3. Let codex recreate a regular lock file on the next run
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/network-proxy/src/certs.rs:555 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/755cae2a989a4153. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/network-proxy/src/certs.rs:555

fn lock_managed_ca_artifacts(proxy_dir: &Path) -> Result<File> {
    let lock_path = proxy_dir.join(MANAGED_MITM_CA_ARTIFACT_LOCK);
    let file = open_managed_ca_lock(&lock_path)?;
    file.lock()
        .with_context(|| format!("failed to lock {}", lock_path.display()))?;
    Ok(file)
}

fn managed_ca_certificate_lock_path(certificate_path: &Path) -> Option<PathBuf> {
    let file_name = certificate_path.file_name()?.to_string_lossy();
    Some(certificate_path.with_file_name(format!(".{file_name}.lock")))
}

fn open_managed_ca_lock(path: &Path) -> Result<File> {
    if fs::symlink_metadata(path)
        .ok()
        .is_some_and(|metadata| metadata.file_type().is_symlink())
    {
        return Err(anyhow!(
            "refusing to use symlink lock file {}",
            path.display()
        ));
    }

    #[cfg(unix)]
    use std::os::unix::fs::OpenOptionsExt;

    let mut options = OpenOptions::new();
    options.read(true).write(true).create(true).truncate(false);
    #[cfg(unix)]
    options.mode(0o600);
    options
        .open(path)
        .with_context(|| format!("failed to open {}", path.display()))
}

fn prune_managed_ca_artifacts(proxy_dir: &Path) {

View on GitHub (pinned to 339751715c)