Skip to content

Commit 779ea93

Browse files
chooglengitster
authored andcommitted
Documentation: define protected configuration
For security reasons, there are config variables that are only trusted when they are specified in certain configuration scopes, which are sometimes referred to on-list as 'protected configuration' [1]. A future commit will introduce another such variable, so let's define our terms so that we can have consistent documentation and implementation. In our documentation, define 'protected configuration' as the system, global and command config scopes. As a shorthand, I will refer to variables that are only respected in protected configuration as 'protected configuration only', but this term is not used in the documentation. This definition of protected configuration is based on whether or not Git can reasonably protect the user by ignoring the configuration scope: - System, global and command line config are considered protected because an attacker who has control over any of those can do plenty of harm without Git, so we gain very little by ignoring those scopes. - On the other hand, local (and similarly, worktree) config are not considered protected because it is relatively easy for an attacker to control local config, e.g.: - On some shared user environments, a non-admin attacker can create a repository high up the directory hierarchy (e.g. C:\.git on Windows), and a user may accidentally use it when their PS1 automatically invokes "git" commands. `safe.directory` prevents attacks of this form by making sure that the user intended to use the shared repository. It obviously shouldn't be read from the repository, because that would end up trusting the repository that Git was supposed to reject. - "git upload-pack" is expected to run in repositories that may not be controlled by the user. We cannot ignore all config in that repository (because "git upload-pack" would fail), but we can limit the risks by ignoring `uploadpack.packObjectsHook`. Only `uploadpack.packObjectsHook` is 'protected configuration only'. The following variables are intentionally excluded: - `safe.directory` should be 'protected configuration only', but it does not technically fit the definition because it is not respected in the "command" scope. A future commit will fix this. - `trace2.*` happens to read the same scopes as `safe.directory` because they share an implementation. However, this is not for security reasons; it is because we want to start tracing so early that repository-level config and "-c" are not available [2]. This requirement is unique to `trace2.*`, so it does not makes sense for protected configuration to be subject to the same constraints. [1] For example, https://lore.kernel.org/git/[email protected]/ [2] https://lore.kernel.org/git/[email protected]/ Signed-off-by: Glen Choo <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5f5af37 commit 779ea93

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Documentation/config/uploadpack.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ uploadpack.packObjectsHook::
4949
`pack-objects` to the hook, and expects a completed packfile on
5050
stdout.
5151
+
52-
Note that this configuration variable is ignored if it is seen in the
53-
repository-level config (this is a safety measure against fetching from
54-
untrusted repositories).
52+
Note that this configuration variable is only respected when it is specified
53+
in protected configuration (see <<SCOPES>>). This is a safety measure
54+
against fetching from untrusted repositories.
5555

5656
uploadpack.allowFilter::
5757
If this option is set, `upload-pack` will support partial

Documentation/git-config.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ specifying the path of a file with the `--file` option, or by specifying a
341341
configuration scope with `--system`, `--global`, `--local`, or `--worktree`.
342342
For more, see <<OPTIONS>> above.
343343

344+
[[SCOPES]]
344345
SCOPES
345346
------
346347

@@ -379,6 +380,18 @@ Most configuration options are respected regardless of the scope it is
379380
defined in, but some options are only respected in certain scopes. See the
380381
respective option's documentation for the full details.
381382

383+
Protected configuration
384+
~~~~~~~~~~~~~~~~~~~~~~~
385+
386+
Protected configuration refers to the 'system', 'global', and 'command' scopes.
387+
For security reasons, certain options are only respected when they are
388+
specified in protected configuration, and ignored otherwise.
389+
390+
Git treats these scopes as if they are controlled by the user or a trusted
391+
administrator. This is because an attacker who controls these scopes can do
392+
substantial harm without using Git, so it is assumed that the user's environment
393+
protects these scopes against attackers.
394+
382395
[[ENVIRONMENT]]
383396
ENVIRONMENT
384397
-----------

0 commit comments

Comments
 (0)