Hmbown/CodeWhale · error · io::Error

legacy spillover ownership sidecar must not be a symlink

Error message

legacy spillover ownership sidecar must not be a symlink

What it means

read_legacy_spillover_ownership performs a symlink check on the ownership sidecar via std::fs::symlink_metadata before reading it, refusing PermissionDenied with this message if the sidecar itself is a symlink. This is a security guard preventing an attacker from redirecting the ownership read to an arbitrary file through a planted symlink.

Solutions

  1. Remove the symlinked sidecar and let the owning session republish it (`rm <sidecar>` then re-run the operation).
  2. Ensure spillover/artifact directories are writable only by the owning user (chmod 700 / private temp dirs).
  3. Audit how the sidecar directory was populated; do not symlink fixture or restore paths into it.
  4. Keep the symlink check in place — recreate the file as a regular file, never as a link.

Example fix

// before
ls -l spillover.json  # spillover.json -> /etc/passwd (symlink)
// after
rm spillover.json && chmod 700 $(dirname spillover.json)  # republish creates a regular file
Defensive patterns

Strategy: validation

Validate before calling

// check before read
let meta = std::fs::symlink_metadata(path)?;
if meta.file_type().is_symlink() { return Err("sidecar is a symlink; remove it"); }

Type guard

fn is_regular_file(p: &std::path::Path) -> bool {
    std::fs::symlink_metadata(p).map(|m| m.is_file()).unwrap_or(false)
}

Try / catch

// rust
match read_legacy_spillover_ownership(&payload) {
    Err(e) if e.kind() == std::io::ErrorKind::PermissionDenied => {
        eprintln!("ownership sidecar is a symlink; remove it and republish");
    }
    other => other?,
}

Prevention

When it happens

Trigger: read_legacy_spillover_ownership finding legacy_spillover_ownership_path(payload_path) exists as a symlink — e.g. a malicious file placed in a shared/artifact directory pointing the sidecar at /etc/passwd or another target.

Common situations: Shared or world-writable spillover directories where another user planted a symlink; build/test setups that symlink fixture directories; restore tools that recreated sidecars as links.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/dc08a65fd103e240. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/tools/truncate.rs:166

        digest: crate::hashing::sha256_hex(bytes),
        size_bytes: bytes.len().try_into().unwrap_or(u64::MAX),
    };
    let sidecar = legacy_spillover_ownership_path(payload_path);
    let encoded = serde_json::to_vec_pretty(&ownership)
        .map_err(|error| io::Error::new(io::ErrorKind::InvalidData, error))?;
    crate::utils::write_atomic(&sidecar, &encoded)?;
    Ok(sidecar)
}

pub(crate) fn read_legacy_spillover_ownership(
    payload_path: &Path,
) -> io::Result<LegacySpilloverOwnership> {
    let sidecar = legacy_spillover_ownership_path(payload_path);
    if std::fs::symlink_metadata(&sidecar)?
        .file_type()
        .is_symlink()
    {
        return Err(io::Error::new(
            io::ErrorKind::PermissionDenied,
            "legacy spillover ownership sidecar must not be a symlink",
        ));
    }
    let ownership = serde_json::from_slice::<LegacySpilloverOwnership>(&std::fs::read(sidecar)?)
        .map_err(|error| io::Error::new(io::ErrorKind::InvalidData, error))?;
    if ownership.schema_version != LEGACY_SPILLOVER_OWNER_SCHEMA_VERSION {
        return Err(io::Error::new(
            io::ErrorKind::InvalidData,
            "unsupported legacy spillover ownership schema",
        ));
    }
    Ok(ownership)
}

/// Resolve the spillover-file path for a SHA256 content hash. Separate
/// namespace (`sha_<hex>.txt`) from the tool-call-id files so legacy
/// SHA-addressed evidence can be recognized without colliding with

View on GitHub (pinned to 73e0f67d83)