Skip to content

Fix PROJECT_DIR path traversal when installed via plugin cache#2

Merged
fdaviddpt merged 1 commit intoDigital-Process-Tools:mainfrom
DickSwart:fix/project-dir-path-traversal
Mar 23, 2026
Merged

Fix PROJECT_DIR path traversal when installed via plugin cache#2
fdaviddpt merged 1 commit intoDigital-Process-Tools:mainfrom
DickSwart:fix/project-dir-path-traversal

Conversation

@DickSwart
Copy link
Copy Markdown
Contributor

@DickSwart DickSwart commented Mar 21, 2026

Summary

  • save-session.sh and run-consolidation.sh computed PROJECT_DIR by navigating 3 levels up from the script's own path
  • This works when the plugin is copied into .claude/remember/scripts/ inside a project, but breaks when installed via the Claude Code plugin cache — the traversal resolves to the cache root instead of the project root
  • session-start-hook.sh already used CLAUDE_PROJECT_DIR correctly; this PR brings the other two scripts in line with that pattern

Changes

Both save-session.sh (line 57) and run-consolidation.sh (line 37):

# Before:
PROJECT_DIR="$(cd "$(dirname "$0")/../../.." && pwd)"
PIPELINE_DIR="${PROJECT_DIR}/.claude/remember"

# After:
PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$(cd "$(dirname "$0")/../../.." && pwd)}"
PIPELINE_DIR="${CLAUDE_PLUGIN_ROOT:-${PROJECT_DIR}/.claude/remember}"

The original path traversal is kept as a fallback, so this is fully backwards compatible for users who installed the plugin manually.

Test plan

  • Install plugin via plugin cache and verify .remember/now.md is created after tool use threshold is reached
  • Verify manual install (copied into .claude/remember/) still works via the fallback path
  • Run save-session.sh --dry with CLAUDE_PROJECT_DIR set to confirm correct project root is used

Closes #1

🤖 Generated with Claude Code

When installed via the Claude Code plugin system, scripts resolve
PROJECT_DIR by navigating up 3 levels from their own path. This works
when copied into .claude/remember/scripts/ but breaks in the plugin
cache (resolves to the cache root instead of the project root).

Use CLAUDE_PROJECT_DIR (set by Claude Code for all hooks) with the
existing path traversal as a fallback for backwards compatibility.
Apply the same fix to PIPELINE_DIR using CLAUDE_PLUGIN_ROOT.

session-start-hook.sh already used CLAUDE_PROJECT_DIR correctly;
save-session.sh and run-consolidation.sh now match that pattern.

Fixes Digital-Process-Tools#1
Copy link
Copy Markdown
Contributor

@fdaviddpt fdaviddpt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean fix. The bug is real — plugin cache installs break the ../../.. path traversal.

The ${CLAUDE_PROJECT_DIR:-fallback} and ${CLAUDE_PLUGIN_ROOT:-fallback} pattern is already used in session-start-hook.sh, so this brings the other two scripts into consistency. Backward compatible — manual installs work unchanged.

Reviewed by Max.

@fdaviddpt fdaviddpt merged commit 87d5620 into Digital-Process-Tools:main Mar 23, 2026
@fdaviddpt
Copy link
Copy Markdown
Contributor

Thanks for the contribution, Dick. Clean fix, real bug — merged. First external PR on this project. Welcome aboard. — Max

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

save-session.sh and run-consolidation.sh fail when installed via plugin cache (PROJECT_DIR path traversal)

2 participants