Repository navigation
Conversation
Stop unbounded hook directory walks during list, install inspect, and hook invoke. Reject more than 50 hook JSON files or 8 nested directories. - Cap hookFiles walk (50 JSON files, depth 8) - Cover over-cap and at-cap trees in bundle-plugins tests - Document the limits in README, compatibility, and changelog Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 24, 2026, 9:04 AM ET / 13:04 UTC (Revision 12). ClawSweeper reviewWhat this changesBabelfish now streams declared Claude Code and Codex hook directories, rejecting trees with more than 50 unique JSON files or eight nested directories, with boundary tests and compatibility documentation. Merge readiness⛔ Blocked before merge - 6 items remain The resource cap addresses an unbounded hook scan and has credible CLI proof, but the unchanged PR head still makes existing oversized plugins fail during inspection. That failure reaches listing, regeneration, and hook invocation. The strict default needs an approved upgrade contract, and GitHub currently reports merge conflicts. Priority: P2 Review scores
Verification
How this fits togetherBabelfish reads installed source-plugin manifests and hook files to build OpenClaw plugin listings and generated tools. It also reads those files before running imported hooks for OpenClaw events. flowchart LR
A[Installed plugin manifest] --> B[Declared hook paths]
B --> C[Hook directory walk]
C --> D{Within file and depth limits?}
D -->|Yes| E[Imported hook definitions]
D -->|No| F[Inspection error]
E --> G[Listing, generated tools, and hook runs]
Decision needed
Why: The cap is useful, but its unconditional rejection changes installed-plugin behavior and can affect other plugins; the contributor has explicitly left that product choice open. Before merge
Findings
Agent review detailsSecurityNeeds attention: The cap adds no dependency or execution source, but an oversized plugin can prevent imported decision hooks from being evaluated. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Agree on an upgrade contract that bounds hostile walks while preserving existing installations by default, then prove fresh installs, oversized upgrades, and mixed-plugin hook behavior after resolving conflicts. Do we have a high-confidence way to reproduce the issue? Yes. The captured compiled-CLI trace shows the boundary cases after the patch, and source inspection shows the uncapped current-main walk and the new rejection path; the reviewer did not execute code. Is this the best way to solve the issue? No. Streaming and a bounded scan address the resource concern, but unconditional rejection is not yet an approved upgrade-safe default. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1a81d46cc5d3. LabelsLabel changes: No label changes. Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (11 earlier review cycles; latest 8 shown)
|
readHooks now spends one 50-file budget across every declared hook path. hookFiles walks with opendir so a wide non-JSON directory is not loaded as one array before the cap is checked. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
|
Pushed
The oversized-tree upgrade contract (fail now vs opt-in) is still a maintainer product call. I did not change that default. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Share the seen-file set with directory discovery so conventional hooks/hooks.json plus a declared hooks directory counts as one file. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
|
@clawsweeper re-review
Discovery now shares the seen-file set, so conventional hooks/hooks.json plus a declared hooks directory counts once. The oversized-tree upgrade contract is still a maintainer product call; I did not change that default. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Combine the hook tree and stdin limits from openclaw#23 and openclaw#24. Preserve exact boundaries and overlapping-path accounting, and keep existing early-exit tests within the new payload budget. Co-authored-by: Sebastien Tardif <sebtardif@ncf.ca>
Combine #23 and #24: cap hook discovery at 50 unique files and eight nested directories, and reject command-hook stdin above 1 MiB before spawning. Oversized decision events fail closed. Includes exact-boundary and overlapping-path regressions, preserved early-stdin-close coverage, compatibility documentation, and release notes. Co-authored-by: Sebastien Tardif <sebtardif@ncf.ca>
|
Thanks @SebTardif. The hook discovery fix is now merged in #24 together with the related stdin limit, with your co-author credit and changelog acknowledgment preserved. The 51-file regression fails on the previous code; exact 50-file/eight-directory boundaries and overlapping-path accounting pass with the fix. The combined candidate passed all 134 tests and package validation, and #24's exact-head cross-platform, CodeQL, and constrained-memory checks are green: https://github.com/openclaw/babelfish/actions/runs/36669279416. Closing this PR as incorporated. |
What Problem This Solves
babelfish list,babelfish install, and every imported hook run walk the plugin hook directory with no file or depth limit. A plugin can pointhooksat a tree with thousands of JSON files or a very deep directory chain. Each walk re-reads that tree from disk.This PR stops the walk after 50 hook JSON files or 8 nested directories and fails closed, the same way a hook symlink already fails.
Evidence
Public path:
babelfish list codexagainst an installed Codex plugin whose manifest setshooksto a directory. The compiled CLI atdist/bin.jsis the same entrypoint asbabelfish list.Before the cap,
inspectBundlePluginloaded all 51 SessionStart hooks from a 51-file tree and loaded the SessionEnd hook from a 9-level tree. After the cap:The compiled walker in
dist/bundle-plugins.jscontains the same 50-file and 8-depth checks. README anddocs/compatibility.mddocument the limits.Real behavior proof
Behavior or issue addressed: Hook directory discovery no longer walks an unbounded plugin tree.
babelfish listrejects a 51-file hook directory and a 9-level hook directory, while 50 files and 8 nested directories still list.Real environment tested: macOS 26.6.2 (Darwin 25.6.0, arm64), Node v26.7.0, compiled
@openclaw/babelfishat/tmp/oc-pr-babelfish-F005after a local build,OPENCLAW_BABELFISH_ROOTpointed at temp Codex plugin installs.Exact steps or command run after this patch: Built the branch, then ran
node /tmp/proof-babelfish-f005.mjs. That script writes four temp Codex plugins (51 files, 50 files, depth 9, depth 8) and runsnode dist/bin.js list codexfor each.Evidence after fix: terminal output from the patched build:
Observed result after fix: The 51-file tree and the 9-level tree exit 1 with the cap errors. The 50-file tree lists one plugin with 50 hooks. The 8-level tree lists one plugin with 1 hook.
What was not tested:
babelfish installfrom a remote Git URL whose hook tree exceeds the cap. Inspect after install uses the sameinspectBundlePluginwalk aslist.Summary
babelfish list, install inspect, and hook invoke re-walk that tree with no bound.The missing walk cap has been present since Codex hook directory support in
9fb2d8d(2026-07-01), 59 days onmain.Compatibility
babelfish list, install inspect, and hook invokeVerification
npm run check.npm run pack:check.CHANGELOG.mdfor user-visible or operational changes.