fix(miner): validate commitSha as hex before joining it into the replay snapshot path#7927
Conversation
… replay path normalizeCommitSha accepted any non-empty string and the value was join()'d straight into planReplaySnapshotPath's on-disk path, so a '../..'-laden commitSha could escape the repo dir (path traversal). Enforce the same 7-40 hex format its sibling replay-task-generation.ts already applies, so a malformed/traversal value throws invalid_commit_sha before it ever reaches path.join. Placeholder short SHAs in the affected fixtures (miner-replay-snapshot + the miner-store-seam-rollout cross-file consumer) updated to valid hex. Closes JSONbored#7796
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7927 +/- ##
==========================================
- Coverage 91.77% 88.42% -3.36%
==========================================
Files 731 89 -642
Lines 74902 21317 -53585
Branches 22847 3698 -19149
==========================================
- Hits 68741 18849 -49892
+ Misses 5083 2290 -2793
+ Partials 1078 178 -900
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Caution 🛑 LoopOver review result - fixes requiredReview updated: 2026-07-21 18:44:24 UTC
Review summary Nits — 4 non-blocking
CI checks failing
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
|
LoopOver is closing this pull request on the maintainer's behalf (CI is failing (codecov/patch)). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed. |
Summary
normalizeCommitSha(packages/loopover-miner/lib/replay-snapshot.ts) accepted any non-empty string, and the value is join()'d straight intoplanReplaySnapshotPath's on-disk path (and used byexportReplaySnapshot). So a../..-ladencommitShaescaped the repo directory (path traversal) — e.g.commitSha: "../../../../../../tmp/evil-worktree"resolved outside the repos dir.Fix: enforce that a commit SHA is 7-40 hex chars (
/^[0-9a-f]{7,40}$/i) — the identical format check the siblingreplay-task-generation.tsalready applies — so a malformed or traversal value throwsinvalid_commit_shabefore it can reachpath.join. No behavior change for real SHAs.Tests
commitShathrow; a genuine 40-hex SHA still resolves inside the snapshot subdir).test/unit/miner-store-seam-rollout.test.ts(which round-tripssaveSnapshot/getSnapshotthrough the same validated path).Validation
miner-replay-snapshot+miner-store-seam-rollout); a fulltest/unit/miner-*sweep shows zero new failures vsmain(41 vs main's 43 — all pre-existing Windows-onlypath.joinseparator artifacts that pass on Linux CI). Roottsc --noEmitclean; the changed line's throw + pass branches are both covered. No secrets/reward terms.Closes #7796