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 <matt@mattmccutchen.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matt McCutchen committed
Nov 14, 2016 at 13:20 UTC
235ec24352e151bed37063a004b9800ee0debd74
6 files changed
+51
-22
Documentation/config.txt
+14
-3
@@ -2787,6 +2787,11 @@ is omitted from the advertisements but `refs/heads/master` and
2787
`refs/namespaces/bar/refs/heads/master` are still advertised as so-called
2788
"have" lines. In order to match refs before stripping, add a `^` in front of
2789
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.
2795
2796
transfer.unpackLimit::
2797
When `fetch.unpackLimit` or `receive.unpackLimit` are
@@ -2796,7 +2801,7 @@ transfer.unpackLimit::
2801
uploadarchive.allowUnreachable::
2802
If true, allow clients to use `git archive --remote` to request
2803
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
2805
linkgit:git-upload-archive[1] for more details. Defaults to
2806
`false`.
2807
@@ -2810,13 +2815,19 @@ uploadpack.allowTipSHA1InWant::
2815
When `uploadpack.hideRefs` is in effect, allow `upload-pack`
2816
to accept a fetch request that asks for an object at the tip
2817
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.
2822
2823
uploadpack.allowReachableSHA1InWant::
2824
Allow `upload-pack` to accept a fetch request that asks for an
2825
object that is reachable from any ref tip. However, note that
2826
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.
2831
2832
uploadpack.keepAlive::
2833
When `upload-pack` has started `pack-objects`, there may be a
Documentation/git-fetch.txt
+2
@@ -141,6 +141,8 @@ The first command fetches the `maint` branch from the repository at
141
objects will eventually be removed by git's built-in housekeeping (see
142
linkgit:git-gc[1]).
143
144
+include::transfer-data-leaks.txt[]
145
+
146
BUGS
147
----
148
Using --recurse-submodules can only fetch new commits in already checked
Documentation/git-pull.txt
+2
@@ -228,6 +228,8 @@ If you tried a pull which resulted in complex conflicts and
228
would want to start over, you can recover with 'git reset'.
229
230
231
+include::transfer-data-leaks.txt[]
232
+
233
BUGS
234
----
235
Using --recurse-submodules can only fetch new commits in already checked
Documentation/git-push.txt
+2
@@ -552,6 +552,8 @@ Commits A and B would no longer belong to a branch with a symbolic name,
552
and so would be unreachable. As such, these commits would be removed by
553
a `git gc` command on the origin repository.
554
555
+include::transfer-data-leaks.txt[]
556
+
557
GIT
558
---
559
Part of the linkgit:git[1] suite
Documentation/gitnamespaces.txt
+1
-19
@@ -61,22 +61,4 @@ For a simple local test, you can use linkgit:git-remote-ext[1]:
61
git clone ext::'git --namespace=foo %s /tmp/prefixed.git'
62
----------
63
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
new
+30
@@ -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.