{"thread":{"id":"66715","subject":"[PATCH] Documentation: clarify Git's security boundary","startedAt":"2026-10-30T12:12:50Z","lastAt":"2026-11-01T18:31:47Z","messageCount":2,"participants":["Johannes Schindelin via GitGitGadget","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"556915","messageId":"pull.2286.git.1793362370899.gitgitgadget@gmail.com","threadId":"66715","inReplyTo":null,"subject":"[PATCH] Documentation: clarify Git's security boundary","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-10-30T12:12:50Z","receivedAt":"2026-10-30T12:12:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Toon Claes <toon@iotcl.com>\n\nLike so many other open source projects, the Git project has seen an\never-increasing flood of security reports. Many of those reports\ndescribe valid bugs yet are redirected from the git-security mailing\nlist because they are deemed \"not vulnerabilities\". While some Git\ncontributors seem to have a very concrete idea how to discern between\nbugs that constitute vulnerabilities (and hence must be fixed in secret,\nto keep Git users safe) from bugs that can be fixed in the open, most\nreporters must be quite puzzled because the Git project provides no\nclear document to help define the security boundaries Git tries to\nguarantee.\n\nOf course, there _are_ hints and bits and pieces of documentation: Git's\nsecurity guidance has accumulated across individual fixes. Some might be\ntempted to describe the boundary as \"before clone\" versus \"after clone\",\nbut history establishes a more precise distinction. e69ac42fcc8 (docs:\ndocument security issues around untrusted .git dirs, 2024-04-16)\nexplains why cloned content can generally be inspected with `git log`:\nrepository-local hooks and configuration are not copied, whereas an\nuntrusted `.git` directory remains unsafe. 779ea9303a7 (Documentation:\ndefine protected configuration, 2022-07-14) likewise ties trust to\nconfiguration scope rather than timing alone.\n\nState the governing principle in one place: Git's security boundary\nconcerns unexpected or implicit execution of attacker-controlled code. A\ntheoretical opportunity to inspect repository contents is not consent to\nexecute them. Conversely, explicitly choosing an execution-capable\nmechanism is materially different. Execution after clone is therefore\nnot inherently a vulnerability.\n\nThis distinction underlies 4cd1cf31efe (Git 2.20.2, 2019-12-04), which\ndescribes CVE-2019-19604 as code running during recursive clone plus a\nsubmodule update \"without the user explicitly having asked for that\".\na1d4f67c12ac (transport: make protocol.file.allow be user by default,\n2022-07-29) likewise contrasts direct user action with recursion lacking\nuser input. e4930e86c0d (t5510: verify that D/F confusion cannot lead to\nan RCE, 2024-03-24) similarly frames remote code execution as code run\nby an operation not expected to run it.\n\nTiming remains relevant when it removes any meaningful choice.\n873a466ea3f (clone: drop the protections where hooks aren't run,\n2024-05-20) notes that clone-time hook execution leaves no chance to\ninspect first. Conversely, 8d1a7448206 (setup.c: create\nsafe.bareRepository, 2022-07-14) addresses post-clone use of embedded\nbare repositories. Together these cases show why timing alone cannot\ndefine the boundary.\n\nAssisted-by: GPT-5.6 Sol\nHelped-by: Patrick Steinhardt <ps@pks.im>\nHelped-by: Junio C Hamano <gitster@pobox.com>\nCo-authored-by: Johannes Schindelin <johannes.schindelin@gmx.de>\nSigned-off-by: Toon Claes <toon@iotcl.com>\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n    Documentation: clarify Git's security boundary\n    \n    This documents Git's security boundary, a topic that came up on the\n    git-security mailing list. Since the discussion there has run its course\n    and nobody objected to making it public, here it is as a regular series.\n    \n    Toon rewrote the document almost from scratch after reviewing it, and\n    Patrick and Junio both shaped it substantially; the trailers carry the\n    formal credit.\n    \n    Patrick floated the idea of a git --safe mode. I think this is a good\n    idea, but since this document describes the status quo, it deliberately\n    leaves that idea out.\n    \n    It is related to a discussion that Stolee tried to start on the\n    git-security list years ago (but which unfortunately did not get any\n    traction, something that now bites us with the onslaught of AI-assisted,\n    reports, and I don't mean the easily dismissed slop, I mean\n    well-crafted, well-argued reports that would have benefited from a clear\n    documentation of Git's security boundary, something that I hereby aim to\n    provide).\n    \n    A --safe flag would have to enumerate every execution-capable mechanism\n    -- hooks, core.fsmonitor, core.sshCommand, core.pager, core.editor,\n    core.hooksPath, uploadpack.packObjectsHook, protocol.*.allow,\n    safe.bareRepository, safe.directory, submodule recursion,\n    include.path/includeIf, aliases, and so on. That list would be a\n    snapshot of today's attack surface, and it would rot as new mechanisms\n    appear; the failure mode therefore would provide a false sense of\n    safety. Instead, the --safe mode would require substantial refactoring\n    so that there is a central registry of config settings and hooks, all\n    with documented safety levels.\n    \n    Git's history bears this out: the set of execution-capable things is\n    discovered incrementally (CVE-2019-19604, protocol.file.allow,\n    safe.bareRepository, the clone-time hook protections dropped in\n    873a466ea3f), so a flag promising safety would need re-auditing each\n    time one is found.\n    \n    An alternative would be a narrower variant that is more defensible:\n    per-operation switches that refuse execution-capable configuration, each\n    with a narrow, auditable contract. The LOCAL DISK ACCESS and PROTECTED\n    CONFIGURATION sections already point at what a user can do today\n    (--no-local, safe.directory, safe.bareRepository).\n    \n    I am sure that listing these options invites a lengthy discussion, and I\n    hope that it will not distract from getting this security boundary\n    documentation from being finalized in a timely manner so that we have\n    firmer ways to deal with security reports. It is easier to point to an\n    official document stating that a Git config modified in one's worktree\n    by an attacker is outside of what Git promises (if such a document\n    exists) than trying to argue based on historical (public) record what\n    constitutes a vulnerability in Git or not. Therefore having this\n    document will be quite helpful, I expect, in dealing with the reports on\n    the git-security mailing list.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2286%2Fdscho%2Fgit-security-boundary-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2286/dscho/git-security-boundary-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/2286\n\n Documentation/Makefile                 |   1 +\n Documentation/git.adoc                 |   3 +\n Documentation/gitsecurityboundary.adoc | 184 +++++++++++++++++++++++++\n Documentation/meson.build              |   1 +\n SECURITY.md                            |   4 +\n command-list.txt                       |   1 +\n 6 files changed, 194 insertions(+)\n create mode 100644 Documentation/gitsecurityboundary.adoc\n\ndiff --git a/Documentation/Makefile b/Documentation/Makefile\nindex f8dea4b395..577673221e 100644\n--- a/Documentation/Makefile\n+++ b/Documentation/Makefile\n@@ -62,6 +62,7 @@ MAN7_TXT += gitpacking.adoc\n MAN7_TXT += gitnamespaces.adoc\n MAN7_TXT += gitremote-helpers.adoc\n MAN7_TXT += gitrevisions.adoc\n+MAN7_TXT += gitsecurityboundary.adoc\n MAN7_TXT += gitsubmodules.adoc\n MAN7_TXT += gittutorial-2.adoc\n MAN7_TXT += gittutorial.adoc\ndiff --git a/Documentation/git.adoc b/Documentation/git.adoc\nindex 6f0075f918..dfea97025d 100644\n--- a/Documentation/git.adoc\n+++ b/Documentation/git.adoc\n@@ -1124,6 +1124,9 @@ unmerged version of a file when a merge is in progress.\n SECURITY\n --------\n \n+See linkgit:gitsecurityboundary[7] for a broader discussion of Git's\n+security model.\n+\n Some configuration options and hook files may cause Git to run arbitrary\n shell commands. Because configuration and hooks are not copied using\n `git clone`, it is generally safe to clone remote repositories with\ndiff --git a/Documentation/gitsecurityboundary.adoc b/Documentation/gitsecurityboundary.adoc\nnew file mode 100644\nindex 0000000000..fd67824d23\n--- /dev/null\n+++ b/Documentation/gitsecurityboundary.adoc\n@@ -0,0 +1,184 @@\n+gitsecurityboundary(7)\n+======================\n+\n+NAME\n+----\n+gitsecurityboundary - Git's security boundary\n+\n+SYNOPSIS\n+--------\n+gitsecurityboundary\n+\n+DESCRIPTION\n+-----------\n+\n+Git encounters data in repositories that is not controlled by the user. That\n+data must be treated as untrusted. It is considered safe to clone an untrusted\n+Git repository and inspect its contents using Git commands like\n+linkgit:git-log[1].\n+\n+Git repository configuration and hooks are not covered by this guarantee: the\n+user is responsible for reviewing them to determine whether they are trusted.\n+\n+Crucially, copies of untrusted repositories (e.g. obtained via `.zip` or other\n+archives) **must** be sanitized first and Git commands must only be run on this\n+sanitized clone.\n+\n+SANITIZED CLONE\n+---------------\n+\n+A `.git` directory contains active metadata, not merely repository content. It\n+may contain configuration and hooks that cause Git to run arbitrary commands.\n+Most Git commands should therefore *not* be run in an untrusted `.git` directory\n+or the working tree that surrounds it.\n+\n+This distinction matters for repositories retrieved as filesystem copies or\n+archives. A repository obtained through git-clone(1) sanitizes this metadata,\n+while extracting an archive that contains a `.git` directory doesn't have these\n+protections. To create a sanitized copy, clone the untrusted repository with:\n+\n+------------\n+git clone --no-local <untrusted-repository> <clean-copy>\n+------------\n+\n+This creates a full clone of the untrusted repository, but excludes all\n+configuration and hooks that might cause harmful code to run when some Git\n+commands are executed.\n+\n+Note that `--no-local` is required here: a local clone (the default when the\n+source is given as a path) bypasses the transport layer and hardlinks the\n+source repository's object database instead of copying it, so it does not\n+sanitize the repository.\n+\n+This is also the way to turn an untrusted local repository into a trusted one:\n+there is no way to verify by inspection that the binary files in an untrusted\n+object database are safe, so the repository must be re-cloned through the\n+transport layer rather than trusted in place.\n+\n+Serving an untrusted repository to `git clone` still exposes\n+linkgit:git-upload-pack[1] to that repository. For additional isolation,\n+`upload-pack` can be run as an unprivileged user where the platform permits it.\n+\n+REPOSITORY CONTENTS UNTRUSTED\n+-----------------------------\n+\n+Creating a sanitized clone avoids copying configuration and hooks from the\n+potentially evil repository. But it does not make contents in the repository\n+trustworthy. The user is still responsible for inspecting the repository data\n+before executing or installing any of the data inside.\n+\n+After cloning, Git commands intended to inspect repository contents should not\n+unexpectedly execute those contents. If the user reviews and explicitly enables\n+a hook, filter, helper, or other program supplied by the repository, the user\n+has extended trust to that program.\n+\n+UNEXPECTED CODE EXECUTION\n+-------------------------\n+\n+Git protects against remote code execution, thus an attacker shall not be able\n+to run malicious code as part of a Git operation (that is not expected to run\n+that code). For example, it is considered a security vulnerability when a bug in\n+git-clone(1) writes an executable hook into the new repository and runs that\n+hook.\n+\n+It doesn't matter at which point this code runs. Whether it's at the end of the\n+clone, or another Git command that's used on the repository.\n+\n+By using Git commands on a repository to inspect its contents, the user does not\n+consent to execute that content. Explicitly running a checked-out script is\n+different from passing a repository-supplied filename to a Git command that is\n+expected only to inspect it.\n+\n+This principle is not new; it has guided individual fixes over the years:\n+\n+* e69ac42fcc8 (docs: document security issues around untrusted .git dirs,\n+  2024-04-16) explains why cloned content can generally be inspected with\n+  `git log`: repository-local hooks and configuration are not copied, whereas\n+  an untrusted `.git` directory remains unsafe.\n+\n+* 779ea9303a7 (Documentation: define protected configuration, 2022-07-14) ties\n+  trust to configuration scope rather than to when the code runs.\n+\n+* 4cd1cf31efe (Git 2.20.2, 2019-12-04) describes CVE-2019-19604 as code running\n+  during recursive clone plus a submodule update \"without the user explicitly\n+  having asked for that\".\n+\n+* a1d4f67c12ac (transport: make protocol.file.allow be user by default,\n+  2022-07-29) contrasts direct user action with recursion lacking user input.\n+\n+* e4930e86c0d (t5510: verify that D/F confusion cannot lead to an RCE,\n+  2024-03-24) frames remote code execution as code run by an operation not\n+  expected to run it.\n+\n+* 873a466ea3f (clone: drop the protections where hooks aren't run, 2024-05-20)\n+  notes that clone-time hook execution leaves no chance to inspect first.\n+\n+* 8d1a7448206 (setup.c: create `safe.bareRepository`, 2022-07-14) addresses\n+  post-clone use of embedded bare repositories.\n+\n+Together these cases show why the point at which code runs cannot by itself\n+define the boundary.\n+\n+READING AND WRITING OUTSIDE THE REPOSITORY\n+------------------------------------------\n+\n+Git also protects against repository contents causing Git to read from or write\n+to paths outside the repository's working tree. This is not about files the user\n+or platform explicitly asks Git to use, such as configuration files or paths\n+given on the command line. It is about paths stored in the repository payload\n+that lead Git outside the worktree, for example through a symlink or a\n+path-traversing filename.\n+\n+This differs from LOCAL DISK ACCESS: there, the attacker already controls the\n+local disk. Here, the attacker uses Git's processing of untrusted repository\n+contents to reach paths the user did not intend to expose.\n+\n+By inspecting repository contents, the user does not consent to these side\n+effects.\n+\n+USER INTENT AND RECURSION\n+-------------------------\n+\n+Some potentially dangerous mechanisms are allowed when selected directly by the\n+user but restricted when reached indirectly. For example, a protocol may be\n+configured with the `user` policy so that it can be used directly but not by\n+recursive submodule initialization, which runs clone or fetch operations\n+without additional user input. See `protocol.allow` in linkgit:git-config[1].\n+User input establishes intent only when the user selects the mechanism that can\n+execute code. A repository-controlled argument does not become trusted merely\n+because it is passed through a command the user invoked.\n+\n+PROTECTED CONFIGURATION\n+-----------------------\n+\n+Git treats system, global, and command-scope configuration as protected\n+configuration, and assumes that the user or a trusted administrator controls\n+these scopes. Repository-local configuration does not receive that\n+presumption, so options that affect security may be respected only in\n+protected configuration and ignored otherwise. See \"Protected configuration\"\n+in linkgit:git-config[1] for the authoritative list.\n+\n+LOCAL DISK ACCESS\n+-----------------\n+\n+Git does not consider an adversary who can already write to the local disk to\n+be within its security boundary. Such an attacker can modify the Git\n+executable, the user's configuration, or the repository itself, and can\n+therefore cause harm without exploiting Git. The boundary described here\n+concerns data that Git consumes from a repository the user does not control,\n+not data that an attacker can place on the user's own filesystem.\n+\n+SEE ALSO\n+--------\n+\n+linkgit:git[1],\n+linkgit:git-clone[1],\n+linkgit:git-config[1],\n+linkgit:git-upload-pack[1],\n+linkgit:githooks[5],\n+linkgit:gitmodules[5]\n+\n+GIT\n+---\n+\n+Part of the linkgit:git[1] suite\ndiff --git a/Documentation/meson.build b/Documentation/meson.build\nindex f4854f802d..f5b1c03627 100644\n--- a/Documentation/meson.build\n+++ b/Documentation/meson.build\n@@ -205,6 +205,7 @@ manpages = {\n   'gitnamespaces.adoc' : 7,\n   'gitremote-helpers.adoc' : 7,\n   'gitrevisions.adoc' : 7,\n+  'gitsecurityboundary.adoc' : 7,\n   'gitsubmodules.adoc' : 7,\n   'gittutorial-2.adoc' : 7,\n   'gittutorial.adoc' : 7,\ndiff --git a/SECURITY.md b/SECURITY.md\nindex c720c2ae7f..1a21e4c9d1 100644\n--- a/SECURITY.md\n+++ b/SECURITY.md\n@@ -10,6 +10,10 @@ vulnerability, it is recommended to send the report to\n git-security@googlegroups.com (and obviously not to discuss the\n issue anywhere else).\n \n+See the [security boundary\n+documentation](https://git-scm.com/docs/gitsecurityboundary) for a\n+discussion of what Git considers to be within its security boundary.\n+\n Vulnerabilities are expected to be discussed _only_ on that\n list, and not in public, until the official announcement on the\n Git mailing list on the release date.\ndiff --git a/command-list.txt b/command-list.txt\nindex 63ae2a67c9..4dfba75150 100644\n--- a/command-list.txt\n+++ b/command-list.txt\n@@ -242,6 +242,7 @@ gitprotocol-v2                          developerinterfaces\n gitremote-helpers                       guide\n gitrepository-layout                    userinterfaces\n gitrevisions                            userinterfaces\n+gitsecurityboundary                     guide\n gitsubmodules                           guide\n gittutorial                             guide\n gittutorial-2                           guide\n\nbase-commit: a018953688f1b10bddf91bff8747068f5f4746a4\n-- \ngitgitgadget\n\n"},{"id":"557087","messageId":"xmqqy0bcz9m4.fsf@gitster.g","threadId":"66715","inReplyTo":"pull.2286.git.1793362370899.gitgitgadget@gmail.com","subject":"Re: [PATCH] Documentation: clarify Git's security boundary","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-01T18:31:47Z","receivedAt":"2026-11-01T18:31:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> +Serving an untrusted repository to `git clone` still exposes\n> +linkgit:git-upload-pack[1] to that repository. For additional isolation,\n> +`upload-pack` can be run as an unprivileged user where the platform permits it.\n\nThis tricky thing is often forgotten, but it is nice to see it\nmentioned.  'git help upload-pack' also mentions this facility.\nOverall the document was a pleasant read.\n\nThanks.\n\n"}]}