Skip to content

fix/batches: prevent Git commondir config bypass - #1371

Merged
cbrnrd merged 1 commit into
mainfrom
carterbrainerd-vuln-153-gitcommondir-bypasses-git-config-restoration-and-achieves
Sep 9, 2026
Merged

fix/batches: prevent Git commondir config bypass#1371
cbrnrd merged 1 commit into
mainfrom
carterbrainerd-vuln-153-gitcommondir-bypasses-git-config-restoration-and-achieves

Conversation

@cbrnrd

@cbrnrd cbrnrd commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Problem

A batch container can create a .git/commondir file that points Git to an attacker-controlled directory. The existing metadata restoration only restores .git/config and .git/config.worktree, so host-side Git commands can still read malicious configuration from the redirected directory. A malicious clean filter can then run code on the host outside the container.

This fixes VULN-153.

Solution

Snapshot .git/commondir with the other trusted Git control files and restore it before every host-side Git command. If the original repository did not have a commondir file, an injected file is removed before Git runs.

The regression test creates an attacker-controlled common directory with a malicious clean filter and verifies that diff generation uses the trusted Git configuration instead.

Verification Evidence

  • go test ./internal/batches/workspace -count=1
  • go test ./internal/batches/...
  • git diff --check

@cbrnrd
cbrnrd marked this pull request as ready for review September 8, 2026 14:38
@cbrnrd
cbrnrd requested a review from a team September 8, 2026 14:39

cbrnrd commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Sep 9, 1:26 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Sep 9, 1:27 PM UTC: Graphite rebased this pull request as part of a merge.
  • Sep 9, 1:33 PM UTC: @cbrnrd merged this pull request with Graphite.

@cbrnrd
cbrnrd force-pushed the carterbrainerd-vuln-153-gitcommondir-bypasses-git-config-restoration-and-achieves branch from 42849c6 to e0faaad Compare September 9, 2026 13:27
@cbrnrd
cbrnrd merged commit 4d07a31 into main Sep 9, 2026
8 checks passed
@cbrnrd
cbrnrd deleted the carterbrainerd-vuln-153-gitcommondir-bypasses-git-config-restoration-and-achieves branch September 9, 2026 13:33
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.

3 participants