Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 2/2] git-r3.eclass: Explicitly warn about unsecure protocols
Date: Sat, 19 Aug 2017 08:25:53
Message-Id: 20170819082502.27716-2-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 1/2] git-r3.eclass: Update docs to discourage unsafe protocols by "Michał Górny"
1 Explicitly warn about any URI that uses an unsecure protocol (git, http)
2 even if it's a fallback URI. This is necessary because an attacker may
3 block HTTPS connections, effectively forcing the fallback to
4 the unsecure protocol.
5 ---
6 eclass/git-r3.eclass | 11 ++++++++++-
7 1 file changed, 10 insertions(+), 1 deletion(-)
8
9 diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
10 index 42b586811368..1eb0baedc67f 100644
11 --- a/eclass/git-r3.eclass
12 +++ b/eclass/git-r3.eclass
13 @@ -570,6 +570,15 @@ git-r3_fetch() {
14
15 [[ ${repos[@]} ]] || die "No URI provided and EGIT_REPO_URI unset"
16
17 + local r
18 + for r in "${repos[@]}"; do
19 + if [[ ${r} == git:* || ${r} == http:* ]]; then
20 + ewarn "git-r3: ${r%%:*} protocol in unsafe and may be subject to MITM attacks"
21 + ewarn "(even if used only as fallback). Please use https instead."
22 + ewarn "[URI: ${r}]"
23 + fi
24 + done
25 +
26 local -x GIT_DIR
27 _git-r3_set_gitdir "${repos[0]}"
28
29 @@ -582,7 +591,7 @@ git-r3_fetch() {
30 fi
31
32 # try to fetch from the remote
33 - local r success saved_umask
34 + local success saved_umask
35 if [[ ${EVCS_UMASK} ]]; then
36 saved_umask=$(umask)
37 umask "${EVCS_UMASK}" || die "Bad options to umask: ${EVCS_UMASK}"
38 --
39 2.14.1

Replies