Skip to content

fix(server): reject code-executing git transports in the repo remote route - #126

Merged
Aayam Bansal (aayambansal) merged 1 commit into
mainfrom
fix/repo-git-transport-safety
Jul 7, 2026
Merged

Aayam Bansal (aayambansal) merged 1 commit into
mainfrom
fix/repo-git-transport-safety

Conversation

@aayambansal

Copy link
Copy Markdown
Member

Audit finding #4 (High, security). POST /api/repo/remote passed the remote url unvalidated to git remote add/set-url origin <url> in an attacker-chosen directory; a later push/fetch uses it. Git's ext::/fake:: helper transports execute shell commands, and a leading - risks argument injection — so an allowed-origin page could set the origin to ext::sh -c "…" → command execution.

  • assertSafeRemoteUrl (exported, unit-tested) allows only http(s) / ssh / git@ remotes and rejects ext::/fake:: and leading--.
  • Hardened the git spawn env with protocol.ext.allow=never / protocol.fake.allow=never (via GIT_CONFIG_*) as defense in depth even if a URL slips past validation.

Tests

test/server/repo-remote-url.test.ts: accepts normal https/ssh/git@ remotes; rejects ext::/fake::, leading--, file://, and non-URLs.

Note: this is one piece of a broader server-auth gap (the local server has no per-caller auth token) — see the audit; the full fix needs coordinated SPA changes and is called out separately.

…route

POST /api/repo/remote passed the remote url straight to
git remote add/set-url origin <url> in an attacker-chosen directory. Git's
ext::/fake:: helper transports run shell commands, and a leading '-' allows
argument injection — so an allowed-origin page could set the origin to
ext::sh -c '...' and a later push/fetch would execute it.

Validate the url (assertSafeRemoteUrl: only http(s)/ssh/git@ schemes; reject
ext::/fake:: and leading '-'), and harden the git spawn env with
protocol.ext.allow=never / protocol.fake.allow=never as defense in depth. (#4)
@vercel

vercel Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openscience Ready Ready Preview, Comment Jul 7, 2026 3:58am

Request Review

@aayambansal
Aayam Bansal (aayambansal) merged commit 8ca305b into main Jul 7, 2026
11 checks passed
@aayambansal
Aayam Bansal (aayambansal) deleted the fix/repo-git-transport-safety branch July 7, 2026 03:59
Aayam Bansal (aayambansal) added a commit that referenced this pull request Jul 8, 2026
…route (#126)

POST /api/repo/remote passed the remote url straight to
git remote add/set-url origin <url> in an attacker-chosen directory. Git's
ext::/fake:: helper transports run shell commands, and a leading '-' allows
argument injection — so an allowed-origin page could set the origin to
ext::sh -c '...' and a later push/fetch would execute it.

Validate the url (assertSafeRemoteUrl: only http(s)/ssh/git@ schemes; reject
ext::/fake:: and leading '-'), and harden the git spawn env with
protocol.ext.allow=never / protocol.fake.allow=never as defense in depth. (#4)

This branch was successfully deployed

1 active deployment
Preview — 7cffb95c Deployed Jul 7, 2026 by vercel[bot]
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.

1 participant