Block direct HTTPS git clone/fetch paths so repos go through git-gate #226
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Repro
From this Codex workspace on 2026-06-10, a direct HTTPS clone of the upstream Gitea repo succeeded:
The existing
/home/node/bot-bottlecheckout had an origin pointed at a local mirror URL (http://127.0.0.17:59066/bot-bottle.git), but a direct HTTPS clone fromgitea.dideric.iswas still possible. That bypass is the behavior we want to close.Expected
Git clone/fetch traffic should not be able to go directly over normal HTTPS egress to forge hosts. Clone/fetch/push for declared repos should be forced through the bot-bottle git-gate/mirror path, where the gate owns upstream credentials and refresh/scanning policy.
Code audit before filing
I checked the current repo for logic that should already enforce this. Relevant findings:
HTTP_PROXY/HTTPS_PROXYto the egress sidecar (bot_bottle/backend/docker/compose.py).insteadOfrules only for declared SSH upstream URLs and optional SSH aliases (bot_bottle/git_gate.py). It does not rewritehttps://gitea.dideric.is/...URLs.bot_bottle/manifest_git.py), so HTTPS URLs are outside git-gate's declared upstream matching.is_git_push_request()inbot_bottle/egress_addon_core.py, used bybot_bottle/egress_addon.py). It deliberately returns false forgit-upload-pack, which is the clone/fetch path.tests/unit/test_egress_addon_core.pyassertsservice=git-upload-packand/git-upload-packare not considered blocked git push requests.docs/prds/0010-cred-proxy.mdsays receive-pack is blocked but upload-pack/fetch is allowed. That appears to conflict with the desired policy now.Likely fix direction
Add an egress-side detector for smart HTTP Git upload-pack endpoints (
/info/refs?service=git-upload-packand paths ending/git-upload-pack) and block them for forge hosts that should be served by git-gate, or introduce a more explicit route policy for git-over-HTTP so API access to the same host can remain allowed while clone/fetch cannot. Update tests that currently assert upload-pack is allowed.Policy direction from follow-up discussion: keep HTTPS Git access possible, but make it explicit instead of an accidental consequence of host allowlisting. Proposed shape: add a per-egress-route
git.fetch: trueoption. Default behavior should block smart HTTP Git fetch/clone (git-upload-pack) and continue blocking push (git-receive-pack). A route that needs read-only research clones can opt in withgit.fetch: true; push should stay blocked for now unless we add a separate, very explicit policy later.