preToolUse hook fires with empty stdin on remote linux workspace, preventing hooks from rewriting shell commands (e.g. RTK)

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

In a Linux remote workspace, Cursor command hooks fire for preToolUse and beforeShellExecution, but the hook process receives empty stdin. This prevents hooks from inspecting or rewriting Shell commands.

The same repro works correctly in a local macOS Cursor window on the same Cursor version.

Steps to Reproduce

  1. In a Linux remote workspace, create ~/.cursor/hooks.json:
{
  "version": 1,
  "hooks": {
    "preToolUse": [
      {
        "command": "hooks/capture-hook.sh preToolUse",
        "matcher": "Shell"
      }
    ],
    "beforeShellExecution": [
      {
        "command": "hooks/capture-hook.sh beforeShellExecution"
      }
    ]
  }
}
  1. Create ~/.cursor/hooks/capture-hook.sh:
#!/usr/bin/env bash
set -euo pipefail

event="${1:-unknown}"
log_file="$HOME/.cursor/hook-stdin-repro.log"
payload="$(cat)"

{
  printf -- '--- hook %s ---\n' "$(date -Is)"
  printf 'event_arg=%s\n' "$event"
  printf 'cursor_version=%s\n' "${CURSOR_VERSION:-}"
  printf 'cursor_code_remote=%s\n' "${CURSOR_CODE_REMOTE:-}"
  printf 'cursor_layout=%s\n' "${CURSOR_LAYOUT:-}"
  printf 'payload_bytes=%s\n' "$(printf '%s' "$payload" | wc -c)"
  printf 'payload=%s\n' "$payload"
} >> "$log_file"

printf '{"permission":"allow"}\n'
  1. Run chmod +x ~/.cursor/hooks/capture-hook.sh.
  2. Restart Cursor or reconnect the remote window.
  3. Ask the agent to run git status.
  4. Read ~/.cursor/hook-stdin-repro.log.

Expected Behavior

preToolUse should receive JSON on stdin containing the Shell tool input, including the command.

beforeShellExecution should receive JSON on stdin containing the shell command.

Actual remote result:

event_arg=preToolUse
cursor_version=3.10.17
cursor_code_remote=true
cursor_layout=unifiedAgent
payload_bytes=0
payload=

event_arg=beforeShellExecution
cursor_version=3.10.17
cursor_code_remote=true
cursor_layout=unifiedAgent
payload_bytes=0
payload=

Local macOS control on Cursor 3.10.17 receives non-empty stdin. The local preToolUse payload was 777 bytes and included "tool_name":"Shell" and "tool_input":{"command":"git status",...}.

Operating System

MacOS
Linux

Version Information

IDE:
Version: 3.10.17
VS Code Extension API: 1.125.0
Commit: c89f45b831621cdc5e951694db44fecd8fab1150
Date: 2026-07-05T06:39:45.228Z
Layout: IDE
Build Type: Stable
Release Track: Default
Electron: 40.10.3
Chromium: 144.0.7559.236
Node.js: 24.15.0
V8: 14.4.258.32-electron.0
xterm.js: 6.1.0-beta.256
Client OS: Darwin arm64 25.5.0

Remote hook environment:
cursor_version=3.10.17
cursor_code_remote=true
cursor_layout=unifiedAgent
Remote OS: Linux 6.8.0-1057-aws
Remote server commit: c89f45b831621cdc5e951694db44fecd8fab1150

For AI issues: which model did you use?

N/A - hook/runtime issue, not model-specific.

For AI issues: add Request ID with privacy disabled

N/A

Additional Information

Impact: hooks that need to inspect or rewrite Shell commands cannot work in remote workspaces. For example, RTK configures a Shell preToolUse hook (rtk hook cursor) that expects the Shell command payload on stdin so it can return updated_input. Because stdin is empty in the remote case, RTK returns {} and Cursor runs the original command unchanged.

Isolation notes:

  • Hook discovery works.
  • preToolUse with matcher: "Shell" matches.
  • The hook process runs.
  • A static hook returning {"updated_input":{"command":"echo FORCE_REWRITE_MARKER"}} successfully rewrites the Shell command.

The failure appears specific to stdin payload delivery for command hooks in remote workspaces.

Additional remote environment details:

  • Remote distro: Ubuntu 22.04.5 LTS (Jammy)
  • Kernel: Linux 6.8.0-1057-aws x86_64
  • Remote shell: /usr/bin/fish
  • Remote agent folder: /nail/home/davelu/.cursor-server
  • Cursor server path on PATH: /nail/home/davelu/.cursor-server/bin/linux-x64/c89f45b831621cdc5e951694db44fecd8fab1150/...
  • Only installed remote server commit: c89f45b831621cdc5e951694db44fecd8fab1150
  • Relevant env: CURSOR_AGENT=1, CURSOR_LAYOUT=unifiedAgent, VSCODE_AGENT_FOLDER=/nail/home/davelu/.cursor-server
  • SSH remote workspace: SSH_CONNECTION is present

Does this stop you from using Cursor

No - Cursor works, but with this issue