Skip to content

fix(sec): SEC-01 replace shell interpolation in python3 -c with heredoc#58

Merged
majiayu000 merged 2 commits intomainfrom
feat/fix-sec01-gc-scheduled-shell-injection
Apr 12, 2026
Merged

fix(sec): SEC-01 replace shell interpolation in python3 -c with heredoc#58
majiayu000 merged 2 commits intomainfrom
feat/fix-sec01-gc-scheduled-shell-injection

Conversation

@majiayu000
Copy link
Copy Markdown
Owner

Summary

  • SEC-01: LOG_DIR, VIBEGUARD_DIR, REFLECTION_FILE, mf, CUTOFF, and BEFORE were interpolated directly into python3 -c "..." double-quoted strings in scripts/gc/gc-scheduled.sh. A value containing a single quote breaks Python syntax; a crafted VIBEGUARD_LOG_DIR env var could execute arbitrary Python code when the launchd/systemd timer fires.
  • Replaced all three python3 -c "..." blocks with python3 <<'PYEOF' heredocs (single-quoted delimiter — no shell expansion).
  • Paths are now passed exclusively via prefixed env vars (_GC_CUTOFF, _GC_MF, _GC_BEFORE, _GC_LOG_DIR, _GC_VIBEGUARD_DIR, _GC_REFLECTION_FILE) and read inside Python via os.environ.
  • Cleaned up shell-escaped \" sequences inside f-string expressions that were valid only inside a shell double-quoted string and would cause SyntaxError in Python < 3.12.

Test plan

  • Python AST parse of all three heredoc blocks passes (ast.parse)
  • Manual: run bash scripts/gc/gc-scheduled.sh in a sandboxed env to confirm normal operation
  • Manual: set VIBEGUARD_LOG_DIR to a path containing single quotes and confirm no injection

…ed.sh

SEC-01: LOG_DIR, VIBEGUARD_DIR, REFLECTION_FILE, mf, CUTOFF, and BEFORE
were interpolated directly into python3 -c double-quoted strings. A value
containing a single quote could break Python syntax; a crafted env var
could execute arbitrary code when the launchd/systemd timer fires.

Fix: replace all three python3 -c "..." blocks with heredoc (<<'PYEOF')
and pass paths exclusively via prefixed env vars (_GC_*) read through
os.environ inside Python. Also unescape shell-escaped \" sequences that
are now unnecessary and would cause SyntaxError in Python < 3.12.

Signed-off-by: majiayu000 <1835304752@qq.com>
…validator

docs/how/memory-files.md uses `project/.claude/CLAUDE.md` as a conceptual
placeholder to illustrate where a project-level CLAUDE.md lives. The path
does not exist in this repo and is not meant to — it is documentation prose,
not a file reference. Add it to the allowlist so validate-doc-paths.sh stops
treating it as a broken link.

Signed-off-by: majiayu000 <1835304752@qq.com>
@majiayu000
Copy link
Copy Markdown
Owner Author

/gemini review

1 similar comment
@majiayu000
Copy link
Copy Markdown
Owner Author

/gemini review

@majiayu000 majiayu000 merged commit 59f7c50 into main Apr 12, 2026
3 checks passed
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.

1 participant