Skip to content

fix(miner): write acceptance criteria safely#5322

Draft
JSONbored wants to merge 1 commit into
mainfrom
codex/propose-fix-for-acceptance-criteria-vulnerability
Draft

fix(miner): write acceptance criteria safely#5322
JSONbored wants to merge 1 commit into
mainfrom
codex/propose-fix-for-acceptance-criteria-vulnerability

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • The previous writer called writeFileSync on a fixed path inside the prepared worktree and would follow symlinks, allowing a malicious repository to cause arbitrary writable files to be clobbered outside the worktree.
  • Harden the writer to refuse symlink-following writes and to fail-closed when a pre-existing entry exists at the fixed path.

Description

  • Replace the direct writeFileSync(join(workingDirectory, ACCEPTANCE_CRITERIA_FILENAME), ...) with a safe sequence that resolves the worktree root via realpathSync, composes the output path, verifies containment, and creates the file with openSync(... O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW, 0o600) before writing via the file descriptor and closing it (added closeSync, openSync, realpathSync, and fsConstants imports) in packages/gittensory-miner/lib/coding-task-spec.js.
  • Add an assertContainedPath check to ensure the computed output path remains inside the resolved worktree and throw if not.
  • Add regression tests in test/unit/miner-coding-task-spec.test.ts that verify a pre-existing acceptance-criteria.json symlink is not followed (outside file not clobbered) and that an existing file at the path is not overwritten, and update test imports accordingly.

Testing

  • Ran git diff --check and it passed.
  • Built the miner with npm run build:miner and the build succeeded.
  • Ran the focused unit tests with npx vitest run test/unit/miner-coding-task-spec.test.ts and all tests in that file passed.
  • npm audit --audit-level=moderate could not be completed in this environment (registry returned 403) and is noted as a non-blocking environment limitation.

Codex Task

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 12, 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
gittensory-ui 4c976dd Commit Preview URL

Branch Preview URL
Jul 12 2026, 01:58 PM

@superagent-security

Copy link
Copy Markdown
Contributor

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

@JSONbored JSONbored self-assigned this Jul 12, 2026
@JSONbored JSONbored marked this pull request as draft July 12, 2026 14:04
@gittensory-orb gittensory-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 12, 2026
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.36%. Comparing base (738c8ca) to head (4c976dd).
⚠️ Report is 30 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5322   +/-   ##
=======================================
  Coverage   94.36%   94.36%           
=======================================
  Files         474      474           
  Lines       40096    40096           
  Branches    14620    14620           
=======================================
  Hits        37836    37836           
  Misses       1585     1585           
  Partials      675      675           
Flag Coverage Δ
shard-1 46.25% <ø> (-0.15%) ⬇️
shard-2 34.75% <ø> (+0.01%) ⬆️
shard-3 30.97% <ø> (-1.14%) ⬇️
shard-4 32.92% <ø> (+0.89%) ⬆️
shard-5 33.54% <ø> (-0.16%) ⬇️
shard-6 45.08% <ø> (+0.30%) ⬆️

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gittensory-orb

gittensory-orb Bot commented Jul 12, 2026

Copy link
Copy Markdown

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-12 21:15:27 UTC

2 files · 2 blockers · readiness 89/100 · CI green · unstable

⏸️ Suggested Action - Manual Review

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.

2. Maintainer requires a linked issue — Link the relevant issue (for example `Closes #123`) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers No AI review summary
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
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 (draft PR; no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 44 registered-repo PR(s), 36 merged, 435 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 44 PR(s), 435 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence.
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: not available
  • Official Gittensor activity: 44 PR(s), 435 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Mark ready when done.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
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.
[BETA] Chat with Gittensory

Ask Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

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

Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands

🟩 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 Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant