Skip to content

CLI should verify integrity of downloaded PTY binaries before execution #10

@andrerfneves

Description

@andrerfneves

Summary

lunel-cli downloads a native PTY helper from GitHub Releases and executes it without verifying a checksum or signature.

This means the npm package itself is not the full trust boundary: a later network fetch determines which native binary is executed on the user's machine.

Affected code

cli/src/index.ts

  • downloadPtyBinary()
  • ensurePtyBinaryReady()
  • ensurePtyProcess()

Current behavior

On startup, if the PTY helper is not already present in the local config directory, the CLI:

  1. downloads a platform-specific executable from GitHub Releases
  2. writes it to disk
  3. marks it executable
  4. spawns it

The code currently checks only that the HTTP request succeeded. It does not verify:

  • a pinned SHA-256 checksum
  • a detached signature
  • a signed manifest
  • an OS-level code signature / notarization gate before execution

Why this matters

Even if the published npm tarball is trustworthy, the runtime still depends on an out-of-band binary fetch. Without integrity verification, users are trusting:

  • GitHub release asset contents
  • release account security
  • transport / infra in the middle
  • any local tampering with the cached PTY binary after first download

This is especially sensitive because the fetched artifact is a native executable that is immediately run.

Additional concern

ensurePtyBinaryReady() appears to trust any already-cached PTY binary if the file exists. There is no revalidation on subsequent runs. So if the cached file is replaced locally, future executions will run it automatically.

Recommended fix

At minimum:

  • publish SHA-256 checksums for PTY assets per version / platform
  • pin the expected hash in the CLI for the matching release asset
  • verify the downloaded file before chmod + exec
  • fail closed on mismatch

Better long-term options:

  • signed checksum manifest
  • code signing / notarization where supported
  • versioned cache layout keyed by exact CLI/PTy asset version
  • optional revalidation of cached binaries on launch

Suggested acceptance criteria

  • downloads are hash-verified before execution
  • cached binaries are versioned and/or verified before reuse
  • checksum mismatch causes a hard failure with a clear error
  • docs explain the trust model for the PTY helper

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions