Skip to content

Plugin hook fingerprinting rejects npm-generated symlinks and prevents context-mode hooks from loading #56520

Open

Description

@ChristianWeinrich
  • Codex 0.164.0 rejects a valid npm-generated symlink while fingerprinting the context-mode plugin.
  • The hook fails before its script runs; focused checks of esbuild, TypeScript execution, and the MCP server succeeded.
  • The source inspection below identifies the rejection path. The proposed compatibility fix must preserve hook trust guarantees.

Environment

  • Codex CLI: 0.164.0 at the time of the failure.
  • Platform: macOS.
  • Plugin: context-mode 1.0.169.
  • Subscription, model, terminal version, and Codex doctor report: not included in this report.

What issue are you seeing?

I see this hook failure with context-mode installed (home directory redacted):

Hook failed
  └ unsupported plugin entry type: /Users/<user>/.codex/plugins/cache/context-mode/context-mode/1.0.169/node_modules/.bin/esbuild

The rejected entry is a normal npm-generated symlink:

node_modules/.bin/esbuild -> ../esbuild/bin/esbuild

During the original investigation, the target existed and executed successfully. The plugin contained additional npm-generated symlinks, so handling only this particular entry would not address the general problem.

What steps can reproduce the bug?

  1. Use Codex CLI 0.164.0 with context-mode 1.0.169 installed and its lifecycle hooks configured.
  2. Ensure the plugin's installed dependencies include node_modules/.bin/esbuild as the symlink shown above.
  3. Start a Codex session that loads the plugin hooks.
  4. Observe the fingerprinting error before the hook script executes.

These steps describe the observed installation. I have not yet verified a clean-install reproduction. The original cache path is no longer present, so I have not repeated the runtime reproduction in its current state.

What is the expected behavior?

Plugins with valid npm-generated symlinks pointing to files inside the plugin directory should load their hooks after the usual trust review.

Fingerprinting should account for supported symlinks without weakening change detection or allowing links to escape the plugin directory.

Additional information

The 0.164.0 fingerprint implementation uses symlink_metadata and accepts only directories and regular files. Symlinks reach the fallback branch, which emits the exact error above. The recursive scan includes node_modules.

PR #54619 introduced plugin-content fingerprinting for hook trust. This supports a compatibility regression in the new validation path; I have not established the first affected release through version bisection.

Focused local checks succeeded for the linked esbuild executable, TypeScript execution, and the context-mode MCP server. Successful MCP operation does not establish successful hook loading.

Related issues #18863 and #24770 concern symlinks being dropped during plugin installation. This report concerns existing symlinks being rejected during hook fingerprinting.

Activity

  1. added
    bug
    CLI
    hooks
    skills
    on Oct 23, 2026
  2. mfbgull commented on Oct 25, 2026

    @mfbgull

    Confirmed on Linux (Codex CLI 0.164.0) — second affected plugin and a reproducible workaround

    Hit the same failure today on Linux (Ubuntu, x86_64), so this is not macOS-specific. Same binary, same error, same root cause — adding evidence here rather than opening a duplicate.

    Additional affected plugin

    The bug is not limited to context-mode. omo@sisyphuslabs (5.1.40, installed from a local marketplace) fails with the same class of error:

    Hook failed
      └ unsupported plugin entry type: ~/.codex/plugins/cache/sisyphuslabs/omo/5.1.40/node_modules/.bin/comment-checker
    

    Its plugin tree contained 15 symlinks, and fingerprinting rejects more exotic variants than the original report shows:

    • 13 standard npm .bin shims (same as context-mode)
    • 2 dangling symlinks whose targets no longer exist (one pointed into ~/.npm/_npx/... — a cache npx can legitimately purge, so dangling links are a real-world state, not a corruption case)
    • 2 symlinks escaping the plugin root entirely into ~/.npm/_npx/...

    The last two make "just resolve the target" insufficient as a fix policy: resolving an escaping or dangling link inside a trust-fingerprint walk has security implications the fix must handle explicitly.

    Where it comes from (binary string table)

    The message originates from hooks/src/engine/plugin_fingerprint.rs; sibling strings confirm the walk is enumerating plugin entries to compute the hook-trust fingerprint:

    hooks/src/engine/plugin_fingerprint.rs
    unsupported plugin entry type: <path>
    failed to parse hooks config ...
    loading hooks from both <a> and <b>; prefer a single representation for this layer
    

    esbuild and comment-checker are not special — each is just the alphabetically-first symlink in the respective plugin's node_modules/.bin. Any npm-installed plugin with dependencies will hit this, since npm install always materializes .bin shims as symlinks.

    Verified workaround (survives until the next plugin update)

    Replacing every symlink in the plugin cache with real files lets fingerprinting complete, hooks load, and approval succeed:

    • file symlinks → #!/bin/sh exec-wrappers with the absolute target path (a dereferenced byte copy breaks JS shims that rely on their real path for require)
    • directory symlinks → cp -a dereferenced copies
    • dangling symlinks → delete

    After this: zero unsupported plugin entry type errors, one clean "plugin contents changed; hook approval required" prompt, hooks functional (validated pretooluse.mjs returns valid JSON on stdin-driven invocation, and all shimmed binaries execute).

    Two caveats for anyone using the workaround:

    1. It must be redone after every plugin update, since the cache is rebuilt with symlinks again.
    2. Writing replacements through the symlinks (instead of rm first) silently corrupts the real target files — do rm before writing.

    Suggested fix

    In plugin_fingerprint.rs, treat symlinks during the walk as one of:

    1. skip (hash only regular files) — simplest, preserves trust guarantees since hook content is still hashed;
    2. resolve and hash the target, rejecting dangling or root-escaping links explicitly;
    3. special-case the standard npm node_modules/.bin layout.

    Option (a) matches what the trust model actually needs: the fingerprint's job is detecting hook content changes, and symlinked build artifacts inside node_modules are not part of the trust surface.

  3. ChrisWeinrich commented on Oct 25, 2026

    @ChrisWeinrich

    The workaround works on my macOS setup with Codex CLI 0.164.0 and context-mode 1.0.169. Replacing the 14 internal file symlinks with executable wrappers removed the unsupported-entry failure; esbuild, tsc, tsx, and the Context Mode MCP checks pass. Full end-to-end hook execution has not yet been verified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIbughooksskills

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions