Skip to content

fix(review): close SSRF and lockfile-tamper detection gaps - #7826

Merged
loopover-orb[bot] merged 3 commits into
mainfrom
claude/security-bugs-analysis-3c7281
Jul 21, 2026
Merged

fix(review): close SSRF and lockfile-tamper detection gaps#7826
loopover-orb[bot] merged 3 commits into
mainfrom
claude/security-bugs-analysis-3c7281

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • SSRF bypass in safe-url.ts: ipv6IsPrivateOrLocal only recognized the IPv4-mapped IPv6 form (::ffff:a.b.c.d), not the older, ffff:-less IPv4-compatible form (::a.b.c.d). new URL() normalizes both to the same bracket-free hex shape, so https://[::169.254.169.254] (cloud metadata) and https://[::127.0.0.1] (loopback) both passed the guard as "safe." Generalized the existing hex-pair-to-IPv4 conversion to make the ffff: marker optional, applied identically to the byte-identical engine twin.
  • Lockfile tamper-detector evasion: scanPackageLockPatch tracked "which package entry am I in" purely by watching for that entry's opening "node_modules/<pkg>": { line in the diff text. git's default 3-line context doesn't guarantee that line survives when a changed resolved/integrity/version field sits deeper into the entry — when it doesn't, the change was silently dropped instead of flagged. Added a fallback "unattributed entry" bucket for a tracked-field change with no known active entry, gated so the existing deliberate-skip case (a malformed "node_modules/" key) still behaves exactly as before.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • This PR only touches src/review/content-lane/safe-url.ts, its byte-identical engine twin, src/review/lockfile-tamper.ts, and their unit tests — no workflows, MCP, workers, or UI code changed, so actionlint, test:workers, build:mcp, test:mcp-pack, and the ui:* checks are out of scope. Also ran npm run engine-parity:drift-check (passes — the two safe-url.ts copies stay byte-identical) and confirmed 100% line+branch coverage on all three changed source files via the lcov report.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

UI Evidence

N/A — backend-only change, no visible UI/frontend/docs surface touched.

Notes

  • Both issues were filed maintainer-only (self-host only, no live hosted/multi-tenant exposure at the time of filing) with the fix direction already scoped in the issue text; this PR fixes both directly rather than opening them to contributors, per each issue's own note.

Closes #7777
Closes #7778

…7777)

ipv6IsPrivateOrLocal in safe-url.ts recognized the IPv4-mapped IPv6 form
(::ffff:a.b.c.d, normalized by new URL() to ::ffff:7f00:1) but not the older,
ffff:-less IPv4-compatible form (::a.b.c.d, normalized the same bracket-free
way to ::7f00:1). A URL like https://[::169.254.169.254] (cloud metadata) or
https://[::127.0.0.1] (loopback) passed the guard as a public host.

Generalize the existing hex-pair-to-IPv4 conversion to treat "ffff:" as
optional, so both encodings are checked the same way. Applied identically to
the byte-identical engine twin (packages/loopover-engine/src/review/safe-url.ts)
to keep engine-parity:drift-check passing.

Closes #7777
#7778)

scanPackageLockPatch tracked which package-lock entry a line belonged to only
by watching for that entry's own opening "node_modules/<pkg>": { line in the
diff. git's default 3-line context doesn't guarantee that line survives when
a changed resolved/integrity/version field sits deeper into the entry -- when
it doesn't, currentEntryKey stayed null for the whole hunk and the change was
silently dropped instead of flagged.

Add a fallback "unattributed entry" bucket for a tracked-field change with no
known active entry, gated by a new insideRejectedBlock flag so the existing
deliberate-skip case (a malformed "node_modules/" key with nothing after the
marker) still behaves exactly as before.

Closes #7778
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 21, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
loopover-ui f03cff9 Commit Preview URL

Branch Preview URL
Jul 21 2026, 02:03 PM

@JSONbored JSONbored self-assigned this Jul 21, 2026
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.57%. Comparing base (a811c12) to head (f03cff9).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7826      +/-   ##
==========================================
- Coverage   88.65%   88.57%   -0.09%     
==========================================
  Files         730      725       -5     
  Lines       76959    76426     -533     
  Branches    22791    22764      -27     
==========================================
- Hits        68229    67695     -534     
+ Misses       7684     7681       -3     
- Partials     1046     1050       +4     
Flag Coverage Δ
control-plane ?
shard-1 53.19% <4.54%> (-0.02%) ⬇️
shard-2 50.74% <45.45%> (-0.01%) ⬇️
shard-3 51.40% <95.45%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/loopover-engine/src/review/safe-url.ts 100.00% <100.00%> (ø)
src/review/content-lane/safe-url.ts 100.00% <100.00%> (ø)
src/review/lockfile-tamper.ts 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 21, 2026
@loopover-orb

loopover-orb Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-21 14:33:06 UTC

6 files · 1 AI reviewer · no blockers · readiness 98/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR fixes two real gaps: the SSRF regex in ipv6IsPrivateOrLocal only matched the `ffff:`-mapped IPv6 form, letting the ffff-less IPv4-compatible form (e.g. `[::127.0.0.1]`, `[::169.254.169.254]`) fall through to `return false`; the fix generalizes the regex to `(?:ffff:)?` identically in both engine twins, and both edits are covered by new tests exercising both the reject and public-IP accept branches. The lockfile-tamper fix adds an 'unattributed entry' fallback bucket when a resolved/integrity/version change's own header line falls outside git's 3-line diff context, correctly gated by insideRejectedBlock so the existing deliberate-skip case (container/rejected keys) is untouched, and is exercised by tests covering the fallback creation, non-merge into later real entries, and the off-registry/version-only sub-cases. Both fixes are narrowly scoped, address plausible real vulnerabilities, and are well-tested; the tests genuinely exercise the new branches rather than fabricating unreachable states.

Nits — 5 non-blocking

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7777, #7778
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (2 linked issues).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 21 registered-repo PR(s), 14 merged, 347 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 21 PR(s), 347 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: significant
Linked issue satisfaction

Addressed
The regex in ipv6IsPrivateOrLocal was generalized from /^::ffff:.../ to /^::(?:ffff:)?.../, exactly the fix the issue prescribed, applied to both the main and engine-twin copies of safe-url.ts, with tests confirming ::127.0.0.1 and ::169.254.169.254 are now rejected.

Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, Ruby, Go, JavaScript, MDX, Shell, Solidity
  • Official Gittensor activity: 21 PR(s), 347 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Treat this as maintainer-lane context rather than normal contributor-lane activity.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask 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.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

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.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 0ff0b8f into main Jul 21, 2026
15 checks passed
@loopover-orb
loopover-orb Bot deleted the claude/security-bugs-analysis-3c7281 branch July 21, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

1 participant