Skip to content

mcpb sign produces bundles that strict zip parsers reject - including Claude Desktop itself ("Invalid comment length") #278

@jeffreyaven

Description

@jeffreyaven

Describe the bug
mcpb sign appends the signature block (MCPB_SIG_V1 + 4-byte LE length + DER PKCS#7 + MCPB_SIG_END) after the zip's end-of-central-directory (EOCD) record without declaring those bytes in the EOCD comment-length field. The result is not a strictly valid zip: the EOCD declares a 0-byte comment, but trailing data follows. Lenient parsers (Python zipfile, Info-ZIP unzip) tolerate this; strict parsers (yauzl) reject the file outright. Claude Desktop uses a strict parser, so a signed .mcpb cannot be previewed or installed in Claude Desktop at all - signing a bundle currently breaks it for the flagship consumer of the format.

To Reproduce
Steps to reproduce the behavior:

  1. npx --yes @anthropic-ai/mcpb pack my-extension/ test.mcpb
  2. npx --yes @anthropic-ai/mcpb sign test.mcpb --self-signed
  3. In Claude Desktop: Settings -> Extensions -> Install Extension -> select test.mcpb
  4. The extension preview fails with an "Invalid comment length" unzip error (see Logs). The same bundle installs fine before signing.

Expected behavior
Signed bundles remain installable in Claude Desktop (and parseable by any spec-strict zip reader). Trailing data can be made zip-legal by declaring it as the archive comment: patch the 2-byte comment-length field at EOCD offset +20 to the size of the appended signature block. Verified empirically: with that one patch, the same signed bundle previews and installs correctly in Claude Desktop, and extractSignatureBlock still finds the signature (it scans backwards for MCPB_SIG_END and is unaffected by the EOCD field).

Logs

Failed to preview extension: Failed to read or unzip file: Invalid comment length.
Expected: 2264. Found: 0. Are there extra bytes at the end of the file?
Or is the end of central dir signature `PK☺☻` in the comment?

2264 is exactly the appended signature block in this repro: 11-byte header + 4-byte length + 2237-byte DER + 12-byte footer.

Additional context

  • @anthropic-ai/mcpb 2.1.2; Claude Desktop for Windows (current as of June 2026).
  • Implementation wrinkle for the fix: the signature digest is computed over the pre-signature bytes, so the EOCD patch must happen before signing or the digest goes stale. The signature length for a given cert/key is deterministic, so a two-pass sign (or patching with the known length upfront) resolves the chicken-and-egg.
  • Zip comments cap at 65,535 bytes, which comfortably fits typical PKCS#7 blocks (~2-6 KB).
  • Combined with mcpb verify reports every signed bundle as "Extension is not signed" (node-forge p7.verify is unimplemented) #277 (mcpb verify always reports unsigned), the signing feature is currently not usable end to end: signed bundles fail verification in the CLI and fail installation in Claude Desktop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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