Skip to content

fix(security): skip hidden directories in skill template discovery#433

Open
HMAKT99 wants to merge 1 commit intogarrytan:mainfrom
HMAKT99:arun/fix-discover-hidden-dirs
Open

fix(security): skip hidden directories in skill template discovery#433
HMAKT99 wants to merge 1 commit intogarrytan:mainfrom
HMAKT99:arun/fix-discover-hidden-dirs

Conversation

@HMAKT99
Copy link
Contributor

@HMAKT99 HMAKT99 commented Mar 24, 2026

Summary

  • discoverTemplates() in scripts/discover-skills.ts scans subdirectories for .tmpl files
  • SKIP set only blocks node_modules, .git, dist
  • Hidden directories (.claude/, .agents/, .codex/) were being scanned
  • These contain symlinked skill installs — a malicious .tmpl in a symlinked skill directory would be discovered and processed by gen-skill-docs

Fix

- .filter(d => d.isDirectory() && !SKIP.has(d.name))
+ .filter(d => d.isDirectory() && !d.name.startsWith('.') && !SKIP.has(d.name))

Skips all dot-prefixed directories. All 28 legitimate skills still generate. All tests pass.

1 file, 1 line changed

scripts/discover-skills.ts

Test plan

  • All existing tests pass (0 fail)
  • 28 Claude skills still generate
  • 27 Codex skills still generate
  • .claude/, .agents/, .codex/ directories skipped

discoverTemplates() scans subdirectories for SKILL.md.tmpl files but
only skips node_modules, .git, and dist. Hidden directories like
.claude/, .agents/, and .codex/ (which contain symlinked skill
installs) were being scanned, allowing a malicious .tmpl in a
symlinked skill to inject into the generation pipeline.

Fix: add !d.name.startsWith('.') to the subdirs() filter. This skips
all dot-prefixed directories, matching the standard convention that
hidden dirs are not source code.
hmzyly pushed a commit to hmzyly/gstack that referenced this pull request Mar 24, 2026
- Add handoff/SKILL.md.tmpl and handoff/SKILL.md: structured context
  transfer between agents. Captures decisions, assumptions, danger zones,
  and open threads. Two modes: quick (~30s) and deep (~2min, default).
  Artifact lands at HANDOFF.md (gitignored) and is auto-injected into
  CLAUDE.md so the next agent loads it automatically.

- Fix security issue garrytan#433: skip dot-prefixed directories in
  discoverTemplates() to prevent malicious symlinked .tmpl files in
  .claude/.agents/.codex/ from being discovered and processed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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