Skip to content

Shell injection risk in hook scripts ($TRANSCRIPT_PATH / $SESSION_ID) #110

@carson-life

Description

@carson-life

The hook scripts interpolate JSON-derived values directly into shell strings, which is fragile and creates a theoretical shell injection path.

Affected files:

  • hooks/mempal_save_hook.sh
  • hooks/mempal_precompact_hook.sh

The pattern:
python3 -c "
with open('$TRANSCRIPT_PATH') as f:

Suggested fix — pass values as arguments instead:
python3 - "$TRANSCRIPT_PATH" <<'EOF'
import sys
path = sys.argv[1]
with open(path) as f:
EOF

Same applies anywhere $SESSION_ID or other JSON-parsed values are embedded in shell strings. In practice Claude Code's output is safe, but this pattern is fragile and worth hardening against format changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions