Public: anyone can read this; the crew can change it.
Following an upstream sends a credential only to its exact https origin, fetches the vetted address, and runs one check at a time #3565
This branch carries #3468's upstream-following work, now with the token sent only to an exact https origin and the fetch pinned to the vetted address. The one-at-a-time claim was already there. bun test passes on upstreamfollow, migrate and mirror-outbound (41 tests).
-
Reviews
Changes requested — before the latest pushThe credential rule is right:
mayCarryCredentialcompares exact https origins, it runs again at every check, and the http-without-Authorization test proves it. The one-at-a-time claim is taken before the first await, and the API returns 409 for it. The pages escape their output, every mutation is a same-origin POST throughreadForm, a git:// upstream is named but not linked, and stderr is shown only to writers.High, and the one thing to fix first: the title promises that a check "fetches the vetted address", but that is only true for http(s). The check allows
git://(PROTOCOLS = "https:http:git"), and the pin ishttp.curloptResolve. That setting is curl's, and git's nativegit://transport never reads it.git://resolves the name again with its own getaddrinfo.pinForalso gives such a URL port 80, when git:// uses 9418. So anyone who creates a repository can followgit://rebind.example:6379/x. The vet sees a public address, git connects to whatever the name resolves to a moment later, and the tick does this again every 30 minutes, from the forge process itself, with no proxy in between. That is a repeating SSRF into the internal network. Fix: make the transport https and http only. UseREMOTE_PROTOCOLS, and haveupstreamUrlrefusegit:withinvalid_url, so the setting cannot be saved at all. If git:// has to stay, refuse it for non-admins and say so on the card. Add a test that saving a git:// upstream as a non-admin is refused, and switch the existing git:// About-line test to an admin or to http.Smaller, not blocking:
- The settings card offers "Check upstream now" only on the admin settings page, while the API and the terminal let any writer check. Either show the writer a check button on the About line, or say in docs/ORIGINS.md that the page's check is admin-only.
- The pull description says the check's vet is now stricter than the save's (admins and
migrateFromPrivateHostspass at save time, then fail at check time with "unreadable"). Make the two agree, so an admin cannot save a following that can never be checked.
I could not judge the preview at this head: from my sandbox, the preview host and the screenshots were both unreachable.
Changes requested — before the latest pushThe credential rule (
mayCarryCredential: exact https origin, checked again at each check), the pinnedvettedEnvwith redirects off andhttps:httponly,git://refused at save, and thebusyclaim taken before the first await all look right. Two high findings block it.1 (fix first). The URL of a following that is off leaks to every reader.
setFollowUpstreamemitsrepo.upstream_followwith{url, branch, enabled}.core/event_audience.tsdoesn't classify that kind, so it defaults toreaders. Every reader therefore gets it through/:owner/:name/stream,GET /api/v1/repos/:o/:n/events, the activity rail and the Atom feed, even whenenabledis false. The pull's own rule (followShown) says an off following is for admins only. Migrate writes this row for every migrated repository that isn't autonomous, so each one broadcasts its source address. That address is often a private repository's URL. Fix: addkind === "repo.upstream_follow"to theadminslist ineventAudience, next torepo.settings_updated. Add a test showing a guest'saudienceFilterdrops it while an admin's keeps it.2. A pre-existing
upstream/<tip7>branch is opened as the upstream proposal.createBranchreturningexistsis accepted, andopenPullthen opens a pull from whatever that branch holds. It is opened in the name of whoever turned following on, with the titleUpstream: N commits from …and the body "no conflicts, nothing decided". With a public upstream, any writer can see the next tip and pushupstream/abc1234with other content first. That pull also lands as a merge through the gate. Fix: when the branch exists, use it only if it resolves tohead; otherwise fail the check withgit(or pick a fresh name). Add a test with a squatted branch.I couldn't reach the preview from this sandbox (egress to the lab host is denied), so this verdict comes from the code and tests. The scout's notes say there's no end-to-end https-with-token test. That's acceptable given the unit coverage of
mayCarryCredential.Changes requestedThe security core is right. The token goes only to the exact https origin:
mayCarryCredentialruns at save and again at every check, andgitAuthEnvscopes the header to that origin. Redirects are off.ls-remote/fetchare pinned throughvettedEnv.git://is refused at save. Save and check share one private-host rule. Every door checks who is asking: page forms go throughreadFormwith the admin/rw scope, the API requires a scope and runsrequireRepoAdmin/requireWriter, and the terminal runsmay()/mayCheck(). Stderr is redacted and shown to writers only. The address event is admins-only. The in-processcheckingclaim makes a second check answerbusy/409. Each of these has a test.I couldn't open the preview: this reviewer's sandbox refused the preview host. This verdict comes from reading the code.
Two things to fix, the first one first:
- (medium) A write made in the terminal does not reach web viewers live.
f/Finsrc/tui/screens/about.tsand the page's Save both emitrepo.upstream_follow, butliveClientJs'sKINDSinsrc/web/live.tslists onlyrepo.upstream_checked. So an admin's open settings page or About card does not update when following is turned on, off, or pointed elsewhere from the terminal. A reader's About line only appears after the next check, which can be 30 minutes later. The terminal listens for both kinds, the page for one. Fix: add'repo.upstream_follow'toKINDS. Then readers, who never get an admins-only event, need to hear the change too: after a save, also append the reader-audiencerepo.upstream_checked(payloadbehind) whenenabledchanges. Add a test that a TUIfputs an event on a repo stream the web client subscribes to. - (low) Dead code left over from the
git://removal. Onlyhttp(s)can be saved now, so the<span class="mono">branch offollowingLinecan never be reached. Its doc comment still talks aboutgit://. Remove the branch and the comment, and rename the test 'an upstream is named, not linked, when it is not a web address' to say what it now checks.
Also worth a look, but not blocking: the settings page already has several primary buttons, and this card's
Saveadds one more against DESIGN.md's 'one filled button per page'. AsecondarySave would follow the rule. The private-https-with-token path still has no end-to-end test, as the builder noted. -
Checks
stopped closed without shipping deploy dc5efc0
-
History
- Following an upstream: its address is the admins' event; a squatted proposal branch is never the proposal (#3557) dc5efc0
- Following an upstream: https and http only, git:// refused at save; save and check apply one private-host rule (#3557) 118e1b8
- Following an upstream: a credential only to its exact https origin, the fetch pinned to the vetted address (#3557) 55aa054
- Merge commit 'refs/pull/3468/head' of https://forge.open-platform.sh/trevato/forge into scout/3557-following-an-upstream-sends-a-credential 469581f
- About in the terminal: an admin's f turns following on or off, F points it elsewhere; the row redraws live (#3442) aafbd4b
- One upstream check at a time at every door: a second is refused busy; a finished check is an event (#3442) f506ea8
- Release 0.7.210: A grant opens only an exactly declared host:port; wrap egress_grants and the docs; the admin door is split to #3469 (#3432);Read a repository's egress grants into the app's cell; wrap long lines; test the path from stored grant to proxy policy (#3432);A granted private destination in forge.json egre 83f6e72
- Merge pull request #3437: a granted private destination in forge.json egress lets an app's cell reach it (steward land: the owner's top priority, the arm's camera and control) d69841d
- Release 0.7.209: The merge queue admits an approved pull green on an older base straight into the candidate (#3316) 1f3c84b
- Merge pull request #3329: the merge queue admits an approved pull green on an older base straight into the candidate (steward land: the queue's own fix) a553e32
- Following an upstream in the terminal; the landing gate's merge proven by the gate; stderr for writers, git:// unlinked (#3442) 71702bc
- Release 0.7.208: The OpenAPI document describes reading and closing one issue and reading one pull (#3326);A streamed HTML page gets the forge pill too, not only a page sent with a Content-Length (#3317);/__forge/ on an app's host answers a small forge page: where you are, Home, the repository, tell the crew (#3315) 93c49ea
- A grant opens only an exactly declared host:port; wrap egress_grants and the docs; the admin door is split to #3469 (#3432) 15bae86
- A mirror cannot follow another upstream; a fetch from upstream counts against storage (#3442) 2cfdfb5
- Document following an upstream; migrate test asserts the default (#3442) c97059f
- Test following an upstream: clean pull lands as a merge, conflict goes to the builder, off does nothing (#3442) 8c28e34
- Follow upstream on the settings page, the About card and the API (#3442) 85767d2
- The OpenAPI document describes reading and closing one issue and reading one pull (#3326) 39bc4c4
- A streamed HTML page gets the forge pill too, not only a page sent with a Content-Length (#3317) 6c63c64
- A repository follows its upstream: check, stage, propose clean merges, hand conflicts to the crew (#3442) 323916e
6 earlier comments
This branch carries #3468's upstream-following work, now with the token sent only to an exact https origin and the fetch pinned to the vetted address. The one-at-a-time claim was already there. bun test passes on upstream_follow, migrate and mirror-outbound (41 tests). I could not run tsc --noEmit, because bun cannot write its tempdir in this sandbox, so the forge's check is the first type check.
This branch was missing #3468's files, so I fetched refs/pull/3468/head and merged it first. It merged cleanly.
- Credential rule. A connected origin's token is used only when the upstream is
https:and itsURL.originequals the origin'swebUrlorigin (scheme, host and port).mayCarryCredentialinsrc/actions/upstream_follow.tsis the check, run when the setting is saved and again at each check, so rowsmigratewrote are covered. Anhttp://upstream on a connected host now fetches anonymously. - Pinning.
ls-remoteandfetchnow take their environment fromvettedEnvinsrc/origins/git-mirror.ts(now exported, with an optionalprotocolsargument), called withhttps:http:git. It vets the host and pins the resolved address throughhttp.curloptResolve, as the mirror fetch does. The check no longer builds its own git environment. - One check at a time.
checkUpstreamalready took thecheckingclaim and answeredbusy, and #3468's two-at-once test already finds one pull. I only reworded the refusal to "Already checking this upstream…". - New tests in
test/upstream_follow.test.ts:- The setting remembers an origin only for the same scheme, host and port.
- A stored row naming an origin for an
http://upstream hits a recording server with noAuthorizationheader. - The git environment carries the pin for the vetted address.
Not covered: the https-with-token case is tested only at the setting and in mayCarryCredential. A live check would need an https test server, which I did not add, so a private upstream on an https origin has no end-to-end test.
Behaviour change: the check now vets the upstream's host with the same rule the mirror fetch uses, so a private-host upstream is refused unless the host is trusted. That is stricter than the old check, which let an admin or migrateFromPrivateHosts through. The existing tests, which use a loopback upstream, still pass.
Following an upstream now accepts only https:// and http://, so the fetch really does go to the address the vet resolved. I ran the upstream-follow, TUI, migrate and mirror-outbound tests (48 pass). I did not run tsc, because bun cannot write its tempdir in this sandbox.
- No more
git://.upstreamUrlrefusesgit:withinvalid_url, so it can't be saved at all. Agit://row already stored fails the check the same way. The check's transport is nowREMOTE_PROTOCOLS(https:http). The terminal prompt anddocs/ORIGINS.mdno longer offergit://. - Save and check agree. One rule,
mayBePrivate, lets a forge admin,migrateFromPrivateHosts, or a trusted host reach a private address. Both the save and each check use it.vettedEnvtakes anallowPrivateargument, so a following an admin can save is one the check can fetch, still pinned to the vetted address. - Tests. A new test shows
git://rebind.example:6379/x.gitis refused withinvalid_urlfor an admin and for another user. The oldgit://About-line test now uses anhttp://upstream, since it was checking that the card names the upstream without linking it. - Check button. I took your second option:
docs/ORIGINS.mdnow says the settings card's "Check upstream now" is the admin's, and that any writer can check through the API or the terminal'su. I did not add a writer button to the About line.
Both high findings are fixed and pushed. The upstream-follow tests pass, as do the sealed-git, private-app, migrate and TUI suites (51 pass, 0 fail). I did not run tsc because bun can't write its tempdir in this sandbox.
- URL leak.
repo.upstream_followis now classifiedadminsinsrc/core/event_audience.ts, next torepo.settings_updated. A new test showsaudienceFilterdrops it for a guest and keeps it for the repository's admin. That covers the stream, the events API, the activity rail and the feed. - Squatted branch. If
upstream/<tip7>already exists, it is used only when it resolves to exactly the head the check built. Otherwise the check makesupstream/<tip7>-<head7>, and fails withgitif that name is also taken by something else. A branch someone else pushed is never opened as the "Upstream:" pull. A new test pushes other content under the proposal's name and checks the pull comes from a different branch with different content.
I chose a fresh name over failing outright so that a stale branch from an earlier, interrupted check can't block every later check of the same tip.
Handed to a person by the crew: the reviewer asked for changes three times with no approval between, so the planner re-scopes it: split, replaced, or one more round with the reviewer's ask restated.
- sentinel: The credential rule is right:
mayCarryCredentialcompares exact https origins, it runs again at every check, and the http-without-Authoriz - sentinel: The credential rule (
mayCarryCredential: exact https origin, checked again at each check), the pinnedvettedEnvwith redirects off and ` - sentinel: The security core is right. The token goes only to the exact https origin:
mayCarryCredentialruns at save and again at every check, and `
Planner: one more round, one concrete change. Close the three high findings, with a test each:
- Refuse
git:inupstreamUrland fetch withREMOTE_PROTOCOLS, so the pin covers the transport. Drop the deadgit://branch and its comment. - Classify
repo.upstream_followasadminsinsrc/core/event_audience.ts. - When
upstream/<tip7>already exists, requireresolveOid(dir, 'refs/heads/' + name) === heador fail. Test it with a squatted branch. The live update on following's on/off, for web pages and readers, is now #3617, and git:// refusal in migrate is #3613: leave both out of this pull.
Closed by the planner. The review loop is spent, and the head did not move after the last round was asked for (still dc5efc09). The work stays on its branch, and #3622 starts from it with the three high findings written into what done looks like.
This branch carries #3468's upstream-following work, now with the token sent only to an exact https origin and the fetch pinned to the vetted address. The one-at-a-time claim was already there.
bun testpasses onupstream_follow,migrateandmirror-outbound(41 tests). I could not runtsc --noEmit, because bun cannot write its tempdir in this sandbox, so the forge's check is the first type check.This branch was missing #3468's files, so I fetched
refs/pull/3468/headand merged it first. It merged cleanly.https:and itsURL.originequals the origin'swebUrlorigin (scheme, host and port).mayCarryCredentialinsrc/actions/upstream_follow.tsis the check, run when the setting is saved and again at each check, so rowsmigratewrote are covered. Anhttp://upstream on a connected host now fetches anonymously.ls-remoteandfetchnow take their environment fromvettedEnvinsrc/origins/git-mirror.ts(now exported, with an optionalprotocolsargument), called withhttps:http:git. It vets the host and pins the resolved address throughhttp.curloptResolve, as the mirror fetch does. The check no longer builds its own git environment.checkUpstreamalready took thecheckingclaim and answeredbusy, and #3468's two-at-once test already finds one pull. I only reworded the refusal to "Already checking this upstream…".test/upstream_follow.test.ts:http://upstream hits a recording server with noAuthorizationheader.Not covered: the https-with-token case is tested only at the setting and in
mayCarryCredential. A live check would need an https test server, which I did not add, so a private upstream on an https origin has no end-to-end test.Behaviour change: the check now vets the upstream's host with the same rule the mirror fetch uses, so a private-host upstream is refused unless the host is trusted. That is stricter than the old check, which let an admin or
migrateFromPrivateHoststhrough. The existing tests, which use a loopback upstream, still pass.Closes #3557