spec-kit icon indicating copy to clipboard operation
spec-kit copied to clipboard

chore: update DocGuard extension to v0.23.0

Open raccioly opened this issue 6 months ago • 1 comments

DocGuard Community Extension Update

Updates the DocGuard community extension catalog entry.

Changes

  • Version: v0.21.1
  • Download: spec-kit-docguard-v0.21.1.zip
  • Repository: https://github.com/raccioly/docguard

Release Notes

Security patch — closes issue #190. Command injection vulnerability in docguard init via the ai field of .specify/init-options.json is fixed.

Security

  • Issue #190: command injection in cli/commands/init.mjs and cli/ensure-skills.mjs. The detectAIAgent() helper returned the ai field from .specify/init-options.json without validation, and that value was then shell-interpolated into an execSync invocation:

    const aiFlag = `--ai ${detectedAgent}`;
    execSync(`specify init ... ${aiFlag} ...`);
    

    A local attacker with file-system write access to a victim's repo could plant {"ai": "claude; touch /tmp/pwned;"} and trigger arbitrary command execution on the victim's next docguard init.

    Severity: Medium (requires local file-system access; pre-fix detectAIAgent consumed configs from any project DocGuard ran in).

    Discovered: 23 duplicate auto-generated draft PRs from the "Sentinel" AI agent flagged this during the v0.19 cleanup sweep. The drafts were closed as noise but the underlying finding was tracked in #190 — fixed properly here.

    Fix (two layers, defense in depth):

    1. getDetectedAgent() now allowlist-validates the ai field against /^[a-zA-Z0-9_-]{1,32}$/. Anything else (shell metacharacters, non-strings, oversized values) returns null.
    2. New safeSpawnSpecify(args, opts) helper uses execFileSync with args passed as an array — no shell interpolation possible. Both unsafe call sites (init.mjs and ensure-skills.mjs) now use this helper. Cross-platform (POSIX direct exec / Windows cmd.exe /c specify.cmd).

Tests

  • 596 → 610 (+14): tests/security-init-injection.test.mjs pins both defense layers. Tests every shell metacharacter (;, backtick, $(), |, &&, newline), oversized values, non-string types, malformed JSON, missing config files. Asserts the legitimate allowlist (claude, cursor-agent, gemini, agy, copilot, windsurf, codex, roo, amp, kiro-cli, tabnine, underscore-bearing future names).

Audit

grep -rn execSync cli/ was re-run; remaining call sites are all hardcoded literals (no attacker-influenced interpolation): freshness git probes, score's git probe, setup/doc-quality which-style detection. Documented in commit message.


This PR was automatically generated by the DocGuard release pipeline.

raccioly avatar May 26 '26 16:05 raccioly

Please address Copilot feedback and resolve conflicts. After merging this PR I would recommend any new/updated extensions submission to go through the extension submission issue template so you do not have to deal with so much back and forth.

mnriem avatar Jun 01 '26 13:06 mnriem

Addressed the review feedback:

  • ✅ Conflicts resolved — rebased onto current main. The diff is now just the docguard entry, the catalog/entry updated_at timestamps, and the matching docs/community/extensions.md row.
  • ✅ Version reconciled to v0.25.0 — title, description, catalog version, and download URL all match now (the v0.21.1 / v0.23.0 mismatch Copilot flagged is gone). The v0.25.0 release asset is published and verified.
  • ✅ Docs table synced with the catalog description.

Understood on the Extension Submission issue template — I'll route future DocGuard updates through it. Thanks @mnriem!

raccioly avatar Jun 08 '26 18:06 raccioly

Thank you!

mnriem avatar Jun 09 '26 13:06 mnriem