Skip to content

fix: audit bug hunt — uninstall env leak, cursor strip, publish injection, band typos - #1196

Open
adiraj66132 wants to merge 4 commits into
DietrichGebert:mainfrom
adiraj66132:fix/audit-bug-hunts
Open

adiraj66132 wants to merge 4 commits into
DietrichGebert:mainfrom
adiraj66132:fix/audit-bug-hunts

Conversation

@adiraj66132

@adiraj66132 adiraj66132 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What

An audit of the repo found 12 real bugs. This PR fixes all of them, 3 small cleanups from a follow-up review, and 5 issues filed after the first review (#1263, #1268, #1274, #1275, #1279).

The bad ones

  1. Running npm test could delete your real ponytail settings. The uninstall test passed through your XDG_CONFIG_HOME / Qoder / CodeBuddy env vars into a script that deletes files. Now the test scrubs those vars first.

  2. Uninstalling Cursor hooks could wipe hooks that aren't ours. A hooks.json with an empty event list got deleted and the script said "Removed ponytail hooks" even though there were none. Now it only touches events that actually contain a ponytail hook.

  3. A malicious skill folder name could run shell commands. The publish script builds a shell command from directory names. A folder named x$(evil) would execute when a maintainer published. Now only plain names (a-z, 0-9, -) are allowed — and every name is checked before the first upload, so one bad folder can't leave a half-finished publish.

The annoying ones

  1. Correct answers written as module.exports = … always scored 0 in the debounce benchmark (wrong file extension). Fixed.

  2. /ponytail band banana (typo) hid the band. Now it does nothing, same as a typo'd mode switch.

  3. Projects in paths like /tmpfoo were skipped by band import (treated as temp dirs). Fixed with a proper path check.

The small ones

  1. stop ponytail (double space) didn't turn ponytail off. Now it does.

  2. One corrupt line in a transcript could crash the whole band import. Now it skips that line. The file handle is also always closed, even when the read fails.

  3. A weird release tag (like v5.4-beta) bypassed the version check. Now it fails.

  4. A missing claude CLI made the benchmark spend money then crash without a summary. Now it exits cleanly up front.

  5. Uninstall left the band flag behind and wrote settings.json non-atomically (could truncate it). Both fixed. Cursor's hooks.json writes are atomic the same way.

  6. The over-engineering judge looked at the whole seeded repo instead of just the agent's changes, and only printed 5 of 8 arms. Both fixed.

Follow-up review cleanups

  • Publish checks all skill names up front (no half-done run).
  • Band import always closes the file it opens (no leaked handles on a bad read).
  • Tiny tidy in the temp-dir check (same behavior, less code).

Issues filed after the first review

Tests

Risk

  • Uninstall now also removes ~/.claude/.ponytail-band and Qoder's ponytail-modes (intended — ponytail state).
  • The OpenClaw build deletes unknown dirs under .openclaw/skills/ (generated output; a hand-edited dir there is not preserved).
  • Non-vX.Y.Z release tags now fail the version check on purpose (normal releases unchanged).
  • No secrets, keys, or machine paths in the diff.

…tion, band typos

Twelve confirmed bugs from a full-repo audit:

Must fix:
- tests/uninstall.test.js: scrub XDG/Qoder/CodeBuddy config dirs so npm test
  cannot delete a developer's real ponytail state
- scripts/cursor-hooks.js: stripPonytail no longer deletes event keys that
  never held a ponytail hook (empty arrays survive; false 'removed' gone)
- scripts/publish-openclaw-skills.js: refuse skill dirs that are not plain
  [a-z0-9-] slugs before they reach a shell:true command line

Should fix:
- benchmarks/correctness.js: write the debounce harness as .cjs when the
  submission uses module.exports (was always .mjs, so CJS scored 0)
- hooks/ponytail-mode-tracker.js: /ponytail band <typo> ignores like
  /ponytail ulta instead of toggling the band off
- hooks/ponytail-band-import.js: temp-dir skip matches on a real path
  separator (/tmpfoo is a project, not /tmp)

Nice to have:
- hooks/ponytail-config.js: collapse internal whitespace so 'stop  ponytail'
  deactivates
- hooks/ponytail-band-import.js: guard the transcript cwd JSON.parse so one
  corrupt line cannot abort the whole import
- scripts/check-versions.js: release-tag guard fails closed on non-X.Y.Z tags
- benchmarks/agentic/run.py: catch BaseException from workers; check claude
  on PATH before warm-up so a missing CLI exits cleanly
- scripts/uninstall.js: remove .ponytail-band; atomic settings.json writes
- scripts/cursor-hooks.js: atomic hooks.json writes
- benchmarks/agentic/judge.py: exclude seeded fixture files from the judge
  text; print every arm, not a hardcoded five

Regression tests added for the env scrub, empty-array strip, band typo,
temp-prefix project, corrupt cwd, module.exports debounce, and band flag.
…nscript fd, simpler TEMP

- publish-openclaw-skills.js: check every skill dir name before the first
  publish so a bad name never leaves a half-done run
- ponytail-band-import.js: close the transcript fd in finally so a read
  error cannot leak a handle; drop the TEMP .map (only tmpdir needs the trim)
@adiraj66132

adiraj66132 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Added a follow-up commit with the remaining hardcoded values and cleanups:

  • benchmarks/agentic/complete.py now reports every arm found in the results instead of the hardcoded ARMS_ORDER.
  • benchmarks/agentic/run.py checks for claude before warming the cache (previously a missing CLI crashed inside warm_cache) and uses tempfile.gettempdir() for the selftest plugin dir.
  • scripts/check-versions.js now also checks plugin.yaml (8 manifests).
  • scripts/build-openclaw-skills.js reads homepage/license from package.json and discovers skills from skills/, failing on a missing description.
  • tests/band-import.test.js uses /tmp on POSIX so the temp-prefix fixture also works on macOS.

Verified: check-versions, OpenClaw build (no generated diff), band test, and both Python selftests pass. npm test is 145/146; the only failure is the pandas test because pandas is not installed here.

The benchmark now shows every arm it finds, and checks for claude before warming the cache. Version checks include plugin.yaml, the OpenClaw build reads homepage and license from package.json, and the band test works on macOS.
Closes DietrichGebert#1263: a wrong-shaped ~/.cursor/hooks.json now warns and lets the rest of uninstall run.
Closes DietrichGebert#1268: the OpenClaw build prunes stale generated dirs, tests catch them, and publish uses the source skill list.
Closes DietrichGebert#1274: check-rule-copies pins the whole never-cut fragment and checks the hook fallback copy.
Closes DietrichGebert#1275: docs name the OpenCode V2 hook actually registered.
Closes DietrichGebert#1279: uninstall removes Qoder per-project mode flags.
caioniehues pushed a commit to caioniehues/ponytail that referenced this pull request Nov 18, 2026
)

With Qoder detection on (QODER_SESSION_ID set), the mode tracker writes
per-project flags under $QODER_CONFIG_DIR/ponytail-modes
(hooks/ponytail-runtime.js:40). scripts/uninstall.js:30 removed
ponytail-modes under the Claude, Cursor and CodeBuddy directories only,
so the Qoder directory survived every uninstall. A leftover flag starts
a reinstall with the project's previous mode instead of the configured
default, the same effect DietrichGebert#676 fixed for the shared Qoder flag.

Repro (scratch dirs, detection emulated with QODER_SESSION_ID):

  before uninstall: qoder/.ponytail-active and
    qoder/ponytail-modes/5be02fc2...b6fd28
  after uninstall: qoder/ponytail-modes/5be02fc2...b6fd28 remained

The fix adds getQoderDir() to the directory list, so the Qoder
ponytail-modes directory is removed like the other three. After the
fix the same repro leaves 0 files.

Not covered: Windows untested; Qoder itself is not installed, detection
was emulated. Open PR DietrichGebert#1202 makes this Qoder path the default via
QODER_PROJECT_DIR, so the leak becomes the default case once it
merges; this change is independent of it and of DietrichGebert#1196, which edits
other parts of uninstall.js.

(cherry picked from commit 1b43cab)
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