Skip to content

Commit 235ec24

Browse files
mattmccutchengitster
authored andcommitted
doc: mention transfer data leaks in more places
The "SECURITY" section of the gitnamespaces(7) man page described two ways for a client to steal data from a server that wasn't intended to be shared. Similar attacks can be performed by a server on a client, so adapt the section to cover both directions and add it to the git-fetch(1), git-pull(1), and git-push(1) man pages. Also add references to this section from the documentation of server configuration options that attempt to control data leakage but may not be fully effective. Signed-off-by: Matt McCutchen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0b65a8d commit 235ec24

File tree

6 files changed

+51
-22
lines changed

6 files changed

+51
-22
lines changed

Documentation/config.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2787,6 +2787,11 @@ is omitted from the advertisements but `refs/heads/master` and
27872787
`refs/namespaces/bar/refs/heads/master` are still advertised as so-called
27882788
"have" lines. In order to match refs before stripping, add a `^` in front of
27892789
the ref name. If you combine `!` and `^`, `!` must be specified first.
2790+
+
2791+
Even if you hide refs, a client may still be able to steal the target
2792+
objects via the techniques described in the "SECURITY" section of the
2793+
linkgit:gitnamespaces[7] man page; it's best to keep private data in a
2794+
separate repository.
27902795

27912796
transfer.unpackLimit::
27922797
When `fetch.unpackLimit` or `receive.unpackLimit` are
@@ -2796,7 +2801,7 @@ transfer.unpackLimit::
27962801
uploadarchive.allowUnreachable::
27972802
If true, allow clients to use `git archive --remote` to request
27982803
any tree, whether reachable from the ref tips or not. See the
2799-
discussion in the `SECURITY` section of
2804+
discussion in the "SECURITY" section of
28002805
linkgit:git-upload-archive[1] for more details. Defaults to
28012806
`false`.
28022807

@@ -2810,13 +2815,19 @@ uploadpack.allowTipSHA1InWant::
28102815
When `uploadpack.hideRefs` is in effect, allow `upload-pack`
28112816
to accept a fetch request that asks for an object at the tip
28122817
of a hidden ref (by default, such a request is rejected).
2813-
see also `uploadpack.hideRefs`.
2818+
See also `uploadpack.hideRefs`. Even if this is false, a client
2819+
may be able to steal objects via the techniques described in the
2820+
"SECURITY" section of the linkgit:gitnamespaces[7] man page; it's
2821+
best to keep private data in a separate repository.
28142822

28152823
uploadpack.allowReachableSHA1InWant::
28162824
Allow `upload-pack` to accept a fetch request that asks for an
28172825
object that is reachable from any ref tip. However, note that
28182826
calculating object reachability is computationally expensive.
2819-
Defaults to `false`.
2827+
Defaults to `false`. Even if this is false, a client may be able
2828+
to steal objects via the techniques described in the "SECURITY"
2829+
section of the linkgit:gitnamespaces[7] man page; it's best to
2830+
keep private data in a separate repository.
28202831

28212832
uploadpack.keepAlive::
28222833
When `upload-pack` has started `pack-objects`, there may be a

Documentation/git-fetch.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ The first command fetches the `maint` branch from the repository at
141141
objects will eventually be removed by git's built-in housekeeping (see
142142
linkgit:git-gc[1]).
143143

144+
include::transfer-data-leaks.txt[]
145+
144146
BUGS
145147
----
146148
Using --recurse-submodules can only fetch new commits in already checked

Documentation/git-pull.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ If you tried a pull which resulted in complex conflicts and
228228
would want to start over, you can recover with 'git reset'.
229229

230230

231+
include::transfer-data-leaks.txt[]
232+
231233
BUGS
232234
----
233235
Using --recurse-submodules can only fetch new commits in already checked

Documentation/git-push.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,8 @@ Commits A and B would no longer belong to a branch with a symbolic name,
552552
and so would be unreachable. As such, these commits would be removed by
553553
a `git gc` command on the origin repository.
554554

555+
include::transfer-data-leaks.txt[]
556+
555557
GIT
556558
---
557559
Part of the linkgit:git[1] suite

Documentation/gitnamespaces.txt

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,4 @@ For a simple local test, you can use linkgit:git-remote-ext[1]:
6161
git clone ext::'git --namespace=foo %s /tmp/prefixed.git'
6262
----------
6363

64-
SECURITY
65-
--------
66-
67-
Anyone with access to any namespace within a repository can potentially
68-
access objects from any other namespace stored in the same repository.
69-
You can't directly say "give me object ABCD" if you don't have a ref to
70-
it, but you can do some other sneaky things like:
71-
72-
. Claiming to push ABCD, at which point the server will optimize out the
73-
need for you to actually send it. Now you have a ref to ABCD and can
74-
fetch it (claiming not to have it, of course).
75-
76-
. Requesting other refs, claiming that you have ABCD, at which point the
77-
server may generate deltas against ABCD.
78-
79-
None of this causes a problem if you only host public repositories, or
80-
if everyone who may read one namespace may also read everything in every
81-
other namespace (for instance, if everyone in an organization has read
82-
permission to every repository).
64+
include::transfer-data-leaks.txt[]

Documentation/transfer-data-leaks.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
SECURITY
2+
--------
3+
The fetch and push protocols are not designed to prevent one side from
4+
stealing data from the other repository that was not intended to be
5+
shared. If you have private data that you need to protect from a malicious
6+
peer, your best option is to store it in another repository. This applies
7+
to both clients and servers. In particular, namespaces on a server are not
8+
effective for read access control; you should only grant read access to a
9+
namespace to clients that you would trust with read access to the entire
10+
repository.
11+
12+
The known attack vectors are as follows:
13+
14+
. The victim sends "have" lines advertising the IDs of objects it has that
15+
are not explicitly intended to be shared but can be used to optimize the
16+
transfer if the peer also has them. The attacker chooses an object ID X
17+
to steal and sends a ref to X, but isn't required to send the content of
18+
X because the victim already has it. Now the victim believes that the
19+
attacker has X, and it sends the content of X back to the attacker
20+
later. (This attack is most straightforward for a client to perform on a
21+
server, by creating a ref to X in the namespace the client has access
22+
to and then fetching it. The most likely way for a server to perform it
23+
on a client is to "merge" X into a public branch and hope that the user
24+
does additional work on this branch and pushes it back to the server
25+
without noticing the merge.)
26+
27+
. As in #1, the attacker chooses an object ID X to steal. The victim sends
28+
an object Y that the attacker already has, and the attacker falsely
29+
claims to have X and not Y, so the victim sends Y as a delta against X.
30+
The delta reveals regions of X that are similar to Y to the attacker.

0 commit comments

Comments
 (0)