Skip to content

fix(skills): harden v0.21 skills store, archives, git sync, and control installs - #379

Merged
kombuchapunk merged 8 commits into
mainfrom
fix/v021-bug-hunt
Dec 4, 2026
Merged

kombuchapunk merged 8 commits into
mainfrom
fix/v021-bug-hunt

Conversation

@kombuchapunk

Copy link
Copy Markdown
Collaborator

Summary

Hardens the newly shipped v0.21.0 skills stack (packages/skills + packages/cli/src/control/skills.ts) across security, data-loss prevention, DoS protection, cross-platform correctness, and atomicity after five rounds of multi-model adversarial QA (Claude Opus 5.5, Gemini 4 Neon, and Codex).

Key Fixes

  • Scanner & archive safety (format.ts, archive.ts):
    • Caps directory traversal (MAX_WALK_DIRS = 1024) to stop exponential symlink diamond-DAG DoS (20-level diamond drops from >135 s to ~170 ms), detects case-variant symlink cycles via realpathSync.native, rejects non-regular files (FIFOs/sockets/devices, direct or symlinked) and Windows NTFS ADS (:) paths, and refuses to pack unsafe/truncated skill scans.
    • Fixes USTAR archive UTF-8 byte-length handling (splitUstarPath), NFC + case-insensitive duplicate/ignored-segment validation, and linear-time frontmatter parsing (splitMappingLine, zero polynomial ReDoS).
    • Hardens replacePathAtomic with backup-and-restore rollback on failure and best-effort post-commit backup cleanup (tolerant of Windows EPERM).
  • Store & symlink safety (store.ts):
    • Implements POSIX-exact raw symlink walking (walkPathToTarget via readlinkSync, platform-aware / vs [\\/] splitting, 40-hop cap) to close linkOnly self-deletion / ELOOP cycles across symlinked parents, aliases, raw .. targets, and multi-hop chains.
    • Resolves ..-containing sourceDir for linkOnly installs without lexical path.resolve drift so the exact validated target is linked.
    • Protects native canonical entries (isSameDirEntry) when skillsDir === harnessDir (including case-variants, symlinked parents, linkOnly symlinks, and broken symlinks).
    • Guards Claude Code's reserved "synced" directory across discoverSkills, adoptSkill, removeSkill, assertAllowedHarnessSlug, and syncGitCollection — including when another harness's skillsDir aliases .claude/skills (even as a dangling symlink).
    • Requires !hasUnsafeScanProblem(scanned.problems) in isUnmodifiedManagedCopy so unreadable local files inside a managed copy cannot be silently deleted without --force, while byte-identical managed copies with benign frontmatter warnings still unlink cleanly.
    • Pre-flights reserved-slug validation in adoptSkill before mutating source files or state.
  • Git sync & control daemon (git.ts, control/skills.ts):
    • Pre-flights collectionId validation before git clone, rejects duplicate/unsafe/conflicting skills before writing anything, and separates canonical overwrite from harness force (forceHarnesses = !!opts?.overwrite) so ordinary git resyncs never overwrite user-edited harness copies.
    • Consistently recognizes managed vs independent harness symlinks across preflight and installation.

Verification

  • Verified across multi-model adversarial QA (Claude Opus 5.5, Gemini 4 Neon, and Codex) with live dist stress probes.
  • npm run lint, npm run typecheck, npm run build, npm run schemas -- --check, npm run conformance, and full monorepo npm run test:coverage (100% Stmts / Branch / Funcs / Lines across all 183 test files / 4,878 tests).

…ontrol installs

Signed-off-by: kombuchapunk <35040017+kombuchapunk@users.noreply.github.com>
…dings

Signed-off-by: kombuchapunk <35040017+kombuchapunk@users.noreply.github.com>
… git, and store

Signed-off-by: kombuchapunk <35040017+kombuchapunk@users.noreply.github.com>
…ive canonical slots, and managed links

Signed-off-by: kombuchapunk <35040017+kombuchapunk@users.noreply.github.com>
…ude synced dir

Signed-off-by: kombuchapunk <35040017+kombuchapunk@users.noreply.github.com>
…tion, and dangling synced alias

Signed-off-by: kombuchapunk <35040017+kombuchapunk@users.noreply.github.com>
Signed-off-by: kombuchapunk <35040017+kombuchapunk@users.noreply.github.com>
Signed-off-by: kombuchapunk <35040017+kombuchapunk@users.noreply.github.com>
@kombuchapunk
kombuchapunk merged commit 9708098 into main Dec 4, 2026
18 checks passed
@kombuchapunk
kombuchapunk deleted the fix/v021-bug-hunt branch December 4, 2026 01:41
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