Hmbown/CodeWhale · critical

reviewed plugin executable bytes changed before spawn

Error message

reviewed plugin executable bytes changed before spawn

What it means

bind_file hashes the reviewed plugin's executable file bytes and compares them to the digest recorded at review time. This error means the on-disk executable no longer matches the reviewed hash, so spawning it would execute unreviewed code. It is a pre-spawn integrity check against binary tampering or replacement.

Solutions

  1. Re-review / re-approve the plugin so the recorded hash matches the current executable, after verifying the new binary is authentic
  2. Restore the original reviewed binary (reinstall the pinned plugin version) so the hash matches again
  3. Pin the plugin to an immutable version or checksum-verified install method so updates cannot silently change bytes

Example fix

# before
$ sha256sum $(which plugin)  # abc123... but reviewed hash is def456...
# after
$ codewhale plugin re-approve --path $(which plugin)  # records new hash after verification
# or reinstall the pinned version:
$ pkg install plugin==1.2.3
Defensive patterns

Strategy: validation

Validate before calling

import hashlib

def executable_matches_reviewed(path: str, expected_sha256: str) -> bool:
    return hashlib.sha256(open(path, 'rb').read()).hexdigest() == expected_sha256

Prevention

When it happens

Trigger: bind_file (called from prepare_stdio_launch and bind_command) finalizes a SHA-based hasher over the launch file and bails when the computed hex digest differs from the expected hash. Any byte-level change to the executable between review and spawn triggers it.

Common situations: Package manager or plugin auto-update replaced the binary; a build tool rebuilt the executable with different bytes; antivirus or disk issues corrupted the file; symlink was retargeted to a different binary.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at crates/tui/src/mcp.rs:1027

        let mut hasher = sha2::Sha256::new();
        hasher.update(b"codewhale-plugin-file-bytes-v1\0");
        let mut buffer = [0_u8; 64 * 1024];
        loop {
            let read = file
                .read(&mut buffer)
                .context("read reviewed launch file")?;
            if read == 0 {
                break;
            }
            hasher.update(&buffer[..read]);
        }
        let actual = hasher
            .finalize()
            .iter()
            .map(|byte| format!("{byte:02x}"))
            .collect::<String>();
        if &actual != expected {
            anyhow::bail!("reviewed plugin executable bytes changed before spawn");
        }
        file.seek(std::io::SeekFrom::Start(0))
            .context("rewind reviewed launch file after verification")?;

        #[cfg(unix)]
        let launch_path = {
            use std::os::fd::AsRawFd as _;
            let fd = file.as_raw_fd();
            // SAFETY: `fd` is owned by `file`; clearing only FD_CLOEXEC keeps
            // that same descriptor available across the imminent exec.
            let flags = unsafe { libc::fcntl(fd, libc::F_GETFD) };
            if flags < 0 || unsafe { libc::fcntl(fd, libc::F_SETFD, flags & !libc::FD_CLOEXEC) } < 0
            {
                anyhow::bail!("failed to inherit reviewed plugin executable descriptor");
            }
            #[cfg(target_os = "linux")]
            let prefix = "/proc/self/fd";
            #[cfg(not(target_os = "linux"))]

View on GitHub (pinned to 73e0f67d83)