LWN: Comments on "The risks of embedded bare repositories in Git" https://lwn.net/Articles/892755/ This is a special feed containing comments posted to the individual LWN article titled "The risks of embedded bare repositories in Git". en-us Fri, 24 Oct 2025 10:58:13 +0000 Fri, 24 Oct 2025 10:58:13 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net The risks of embedded bare repositories in Git https://lwn.net/Articles/893255/ https://lwn.net/Articles/893255/ NYKevin <div class="FormattedComment"> Yes, I&#x27;m aware of that.<br> <p> I guess my concern is that a user might have a setup like this:<br> <p> 1. The user regularly clones untrusted Git repositories, for whatever reason.<br> 2. If a repository containes a .git directory (actually checked in, not in the root of the repo), then the user (or some software acting on behalf of the user) will avoid cloning that repo, because they don&#x27;t want to deal with the possibility of corrupt/malicious sub-repositories.<br> 3. Bare repositories don&#x27;t contain a .git directory, so this doesn&#x27;t work.<br> </div> Sun, 01 May 2022 18:31:05 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893189/ https://lwn.net/Articles/893189/ timon <div class="FormattedComment"> <font class="QuotedText">&gt; If a bare repo is literally just a directory with magic contents</font><br> <p> Well, any git repo is just a directory with magic contents. Instead of `git init foo` you could do a minimal git init by hand and get a working repository:<br> <p> mkdir -p foo/.git/objects<br> mkdir -p foo/.git/refs<br> echo &#x27;ref: refs/heads/main&#x27; &gt; foo/.git/HEAD<br> </div> Sat, 30 Apr 2022 13:31:14 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893166/ https://lwn.net/Articles/893166/ NYKevin <div class="FormattedComment"> Now I&#x27;m wondering if a malicious user could construct an invalid bare repo in such a way that it causes Git to segfault and/or execute arbitrary code. If a bare repo is literally just a directory with magic contents, that seems like a possible outcome...<br> </div> Fri, 29 Apr 2022 22:39:02 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893145/ https://lwn.net/Articles/893145/ glasserc It's a little surprising that Git still considers it a bare repository even after changing the <code>core.bare</code> setting to false! Glen Choo writes in the <a href="https://lwn.net/ml/git/kl6lsfqpygsj.fsf@chooglen-macbookpro.roam.corp.google.com/">original post</a> that apparently Git considers a directory a bare repository if it has subdirectories called "HEAD", "refs/" and "objects/". TIL! Fri, 29 Apr 2022 18:39:49 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893131/ https://lwn.net/Articles/893131/ johill <div class="FormattedComment"> It does in fact not even like to check out such a repo, saying<br> <p> &quot;error: invalid path &#x27;inner/.git/config&#x27;&quot;<br> <p> or such things.<br> </div> Fri, 29 Apr 2022 14:42:06 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893070/ https://lwn.net/Articles/893070/ mathstuf <div class="FormattedComment"> Full repos show up as submodules which go through `clone` and therefore do not pull a config file. Maybe one could craft a tree to commit a non-bare repository, but the tooling would likely barf as it would expect a submodule or try to convert it to one at some point.<br> </div> Fri, 29 Apr 2022 12:13:25 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893061/ https://lwn.net/Articles/893061/ marcH <div class="FormattedComment"> True - except web sandboxing (Javascript / WebAssembly etc.) has stood the test of time.<br> <p> Javascript did really blur that line and created something new and intermediate between &quot;just looking&quot; and &quot;running&quot; but it produced something useful and incredibly popular and... it worked.<br> </div> Fri, 29 Apr 2022 06:09:30 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893060/ https://lwn.net/Articles/893060/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; &quot;git clone&quot; can actually verify that what it received is consistent, </font><br> <p> You can but do you actually verify every time?<br> <p> When my &quot;neighbour&quot; tells me &quot;take a quick _look_ at this project&quot; she won&#x27;t give me a SHA1 to make sure I&#x27;m looking at the exact same, audited and &quot;safe&quot; version of the project clone that she has right now. Because I&#x27;m _just looking_ so that would be overkill and overhead. If she wants me to _use_ the project then it&#x27;s a totally different story and then yes she will probably point me at a specific git tag, maybe even a signed one.<br> <p> <font class="QuotedText">&gt; whereas for a Word document via the email I can&#x27;t even easily check it&#x27;s the same thing my neighbour got.</font><br> <p> For a Word document you must indeed trust that the server you&#x27;re downloading it from has not been hacked in the meantime which is in theory not required for git but it that really a huge security difference in practice? Also, you neighbor will likely have sent you the Word doc by email directly :-)<br> <p> I think all these &quot;secure transport&quot; differences are fairly minor and TBH mostly off-topic compared to the very sneaky loss of a safe &quot;read only&quot; mode. Even non-technical users tend to understand the security difference between merely reading media and running code. I think anything blurring that conceptually simple et very useful line is doing users and security a great disservice - as Office macros did for many years.<br> </div> Fri, 29 Apr 2022 05:45:01 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893056/ https://lwn.net/Articles/893056/ Alan.Stern Maybe I'm dumb, but I don't see why the article concentrates on the dangers of embedded <em>bare</em> repositories. Isn't any embedded repository just as potentially dangerous, whether it is bare or not? Fri, 29 Apr 2022 02:32:19 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893055/ https://lwn.net/Articles/893055/ pabs <div class="FormattedComment"> Yep, that is where the idea came from; I&#x27;m one of the upstream maintainers of myrepos, and use it regularly, although not the mrtrust feature.<br> </div> Fri, 29 Apr 2022 02:25:34 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893054/ https://lwn.net/Articles/893054/ pabs <div class="FormattedComment"> Right, although that doesn&#x27;t solve the issue that k3ninho mentions; running arbitrary unreviewed code (which developers do a lot) could update the list of trusted directories. You would need to use bubblewrap or another container solution to prevent random code from touching the list of trusted dirs.<br> </div> Fri, 29 Apr 2022 02:24:27 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893044/ https://lwn.net/Articles/893044/ NYKevin <p> See also: JavaScript. <p> "The by-design purpose of JavaScript was to make the monkey dance when you moused over it. " - <a href="https://softwareengineering.stackexchange.com/a/221658/">Eric Lippert</a> Thu, 28 Apr 2022 19:30:13 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893029/ https://lwn.net/Articles/893029/ kleptog <div class="FormattedComment"> I think I didn&#x27;t make myself clear. I wasn&#x27;t saying that an untrusted Git repository is any safer than an untrusted Word document; it&#x27;s obviously not.<br> <p> What I&#x27;m saying is that the social and technical mechanisms around how Git repositories are usually managed means that the default level of trust for many Git repositories is much much higher than that of a random Word document. &quot;git clone&quot; can actually verify that what it received is consistent, whereas for a Word document via the email I can&#x27;t even easily check it&#x27;s the same thing my neighbour got.<br> </div> Thu, 28 Apr 2022 15:44:07 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893026/ https://lwn.net/Articles/893026/ mathstuf <div class="FormattedComment"> For prior art along these lines, see myrepos&#x27; `.mrtrust` file. <a href="https://myrepos.branchable.com/">https://myrepos.branchable.com/</a><br> </div> Thu, 28 Apr 2022 14:47:37 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893022/ https://lwn.net/Articles/893022/ MrWim <div class="FormattedComment"> I believe the suggestion was that you have a *local* list of repositories on your computer that *you* trust. It could be `~/.gittrusted` for example. It might look like:<br> <p> Projects/linux<br> Projects/foo<br> Projects/bar<br> <p> So then when you run `git status` in Projects/linux the hooks will be run, while if you run it in ~/Downloads/my-dodgy-project no hooks will be run.<br> </div> Thu, 28 Apr 2022 14:19:00 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/893023/ https://lwn.net/Articles/893023/ jwarnica <div class="FormattedComment"> The Word document could be prose instructions on how to format a drive.<br> <p> The embedded macro might actually do it, automatically.<br> <p> A git repository might be of, say, `shred`. Or a bunch of .md files instructing you how to use shred. And have a git-whatever that formats your drive.<br> <p> Its not different, at all.<br> </div> Thu, 28 Apr 2022 14:18:02 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/892884/ https://lwn.net/Articles/892884/ MrWim <div class="FormattedComment"> Exactly, that&#x27;s what I meant by:<br> <p> <font class="QuotedText">&gt; It might come embedded inside a [...] tarball.</font><br> </div> Thu, 28 Apr 2022 12:20:01 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/892882/ https://lwn.net/Articles/892882/ pbonzini <div class="FormattedComment"> It is not essential for git repositories. Git repositories need not be code repositories.<br> </div> Thu, 28 Apr 2022 11:34:51 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/892879/ https://lwn.net/Articles/892879/ k3ninho <div class="FormattedComment"> <font class="QuotedText">&gt;I feel like the right solution is to have a list of trustworthy repositories configured in your global git config and only allow running commands from them.</font><br> Sure, give me the web address of the shell script to update the whitelist and I&#x27;ll curl-pipe-sudo-bash it right away.<br> <p> Oops.<br> <p> K3n.<br> </div> Thu, 28 Apr 2022 11:13:10 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/892878/ https://lwn.net/Articles/892878/ Karellen <div class="FormattedComment"> What? Not all git repos are hosted on github<br> <p> But also, we&#x27;re not talking about running `make`. We&#x27;re talking running something only a bit more complex than `git status`, or even just `cd`ing into a subdirectory for the purposes of running `ls` or `cat readme.md` - except your fancy shell prompt runs some `git` commands to figure out the current branch and whether any changes have been made, in the background, and suddenly you&#x27;re run attacker-controlled code.<br> </div> Thu, 28 Apr 2022 10:25:22 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/892877/ https://lwn.net/Articles/892877/ geert <div class="FormattedComment"> The git repository might be inside a tarball.<br> </div> Thu, 28 Apr 2022 10:04:05 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/892873/ https://lwn.net/Articles/892873/ kleptog <div class="FormattedComment"> The big difference being that when you look at a Git repository you&#x27;re looking at something that many other people have already used and has possibly even been scanned by various public scanners and built using buildbots.<br> <p> This is quite different to Word documents received via the email. If I received a Git repository in the email I wouldn&#x27;t trust running make in it either.<br> </div> Thu, 28 Apr 2022 09:56:04 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/892872/ https://lwn.net/Articles/892872/ MrWim <div class="FormattedComment"> Or a central list of hooks that are deemed &quot;safe&quot; that could run in any git repo. A malicious git repo might not be embedded inside another one afterall. It might come embedded inside a hg repo or tarball. Just because it&#x27;s on your filesystem doesn&#x27;t mean it can be trusted.<br> <p> Generally speaking actions that feel safe should be made safe. Extracting a tarball, cloning a git repo, `cd`ing to a directory, `cat`ing a file all feel rather pedestrian - and if there are subtle security issues with them it&#x27;s the software that needs to be fixed.<br> </div> Thu, 28 Apr 2022 09:27:04 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/892870/ https://lwn.net/Articles/892870/ taladar <div class="FormattedComment"> I wouldn&#x27;t say it is the exact same problem since code as content is essential for source code repositories but not essential for office documents.<br> </div> Thu, 28 Apr 2022 08:49:21 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/892866/ https://lwn.net/Articles/892866/ marcH <div class="FormattedComment"> <font class="QuotedText">&gt; There are plenty of other pitfalls when using untrusted Git repositories, but those are already well-known; simply using make or the build script for an untrusted project is a leap of faith unless the repository is carefully scrutinized, for example. </font><br> <p> This type of problem happens every single time some &quot;convenience&quot; feature violates the &quot;but I&#x27;m just looking&quot; assumption.<br> <p> Blurring the line between &quot;just looking&quot; and running code is EXACTLY the same problem as <a href="https://docs.microsoft.com/en-us/deployoffice/security/internet-macros-blocked">https://docs.microsoft.com/en-us/deployoffice/security/in...</a> which Linux people have been using for decades to laugh at Microsoft&#x27;s approach to security.<br> <p> We never learn.<br> </div> Thu, 28 Apr 2022 07:48:28 +0000 The risks of embedded bare repositories in Git https://lwn.net/Articles/892861/ https://lwn.net/Articles/892861/ pabs <div class="FormattedComment"> I feel like the right solution is to have a list of trustworthy repositories configured in your global git config and only allow running commands from them.<br> </div> Thu, 28 Apr 2022 02:46:35 +0000