Skip to content

fix(forge): close six low-severity audit findings and read admin passwords from stdin - #363

Merged
tonibergholm-codento merged 15 commits into
mainfrom
fix/forge-hardening
Nov 20, 2026
Merged

tonibergholm-codento merged 15 commits into
mainfrom
fix/forge-hardening

Conversation

@tonibergholm-codento

Copy link
Copy Markdown
Collaborator

A security audit of sc-forge found no critical or high issue. It did find six low-severity ones, which this PR fixes:

  1. A reader could hold off default-branch changes. Every dumb-protocol GET registered as a writer, so a read-only user's slow GET blocked PATCH default_branch and run-time lock cleanup. Now only receive-pack registers as a writer.
  2. Password checks could queue without a bound. Password verification waited for the Argon2 gate with no timeout, on the blocking pool every API route shares. It now waits at most 2 s, then answers 503 with Retry-After, and refunds exactly that attempt's reservation, so the rate limit stays correct.
  3. Private organisations were detectable. GET /orgs/{o}, GET /orgs/{o}/repos and GET /users/{u}/orgs/{o}/permissions answered differently for a private org than for a missing one. A non-member now gets the missing-org answer. A collaborator of a repository inside the org still sees that repository. Gitea 1.22 records the leaking answers, so this adds three departures. The conformance checker gained two keys to pin them: body (exact JSON, compared recursively) and absent_headers.
  4. Forwarded-for could be steered. Entries that failed to parse, such as ip:port, non-UTF-8 values or repeated header fields, were skipped. Behind such a proxy the walk could land on a client-chosen entry. The header is now read once, in order, from all raw values. ip:port and [v6]:port parse, an unparseable entry stops the walk, and dispatch and the access log use the same result.
  5. Admin passwords appeared in argv (sc-forge admin: read passwords from stdin instead of argv #337). sc-forge admin user create and change-password take --password-stdin. --password still works.
  6. A test knob shipped in release. SC_FORGE_MERGE_PAUSE_MS is now read only in debug builds, like the other test knobs.

Unchanged by decision, recorded in the threat model: listing and creating repositories need no repository scope (Gitea's requirement is unrecorded, #316), and tokens never expire and survive a password change (Gitea 1.22 parity).

Proof: each fix has a test that fails without it:

  • only_receive_pack_registers_as_a_writer
  • a_busy_password_gate_answers_503_and_refunds_the_attempt (at source cap 1)
  • a_refund_gives_back_exactly_its_own_reservation
  • private_org_permissions_are_hidden_from_outsiders (byte-identical answers)
  • forwarded_for_ports_are_parsed_and_junk_stops_the_walk
  • repeated_and_non_utf8_forwarded_for_fields_are_one_ordered_chain
  • admin_passwords_can_come_from_stdin_but_not_both_ways

cargo test -p scl-forge passes, and forge-check.sh passes 24/24 with selftest ok.

Reviewed with sol-loop: 2 rounds with gpt-6.2-sol. Sol verdict: changes requested on one item, declined. If a caller's last readable repository in a private org is revoked between the count and the page query, the caller can still get 200 []. That only tells them the org exists, which they knew while they had access.

Closes #337.

Created with Claude Opus 5.5 and Claude Sonnet 5.5 in Claude Code.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 73a59e42-1e26-4662-93c3-acce4b7f34d5
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T09:40:49.430397Z 5598738 New commits
🔒 Security Review ✅ Completed 2026-11-20T09:43:51.554248Z 5598738 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment thread crates/forge/tests/e2e_a.rs Fixed
Comment thread crates/forge/tests/e2e_a.rs Fixed

@tonibergholm tonibergholm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed: sol-loop (2 rounds; one race item declined with reason in the description), required checks and conformance green, CodeQL clean, Codex review has no findings.

@tonibergholm-codento
tonibergholm-codento merged commit ad2d96c into main Nov 20, 2026
11 checks passed
@tonibergholm-codento
tonibergholm-codento deleted the fix/forge-hardening branch November 20, 2026 09:51
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.

sc-forge admin: read passwords from stdin instead of argv

3 participants