binutils is vulnerable to CVE-2021-20197 (and various others)

DoneSubmitted by Léo Le Bouter.
Details
3 participants
  • Léo Le Bouter
  • Maxim Cournoyer
  • Maxime Devos
Owner
unassigned
Severity
normal
L
L
Léo Le Bouter wrote on 26 Mar 2021 21:41
(address . bug-guix@gnu.org)
669bea321d23f39ac5bb902dc930f4056f07ec78.camel@zaclys.net
CVE-2021-20197 18:15
There is an open race window when writing output in the following
utilities in GNU binutils version 2.35 and earlier:ar, objcopy, strip,
ranlib. When these utilities are run as a privileged user (presumably
as part of a script updating binaries across different users), an
unprivileged user can trick these utilities into getting ownership of
arbitrary files through a symlink.

For the two versions packaged in GNU Guix we have:

$ ./pre-inst-env guix lint -c cve binutils@2.33
gnu/packages/base.scm:584:2: binutils@2.33.1: probably vulnerable to
CVE-2020-35493, CVE-2020-35494, CVE-2020-35495, CVE-2020-35496, CVE-
2020-35507

$ ./pre-inst-env guix lint -c cve binutils@2.34
gnu/packages/base.scm:571:2: binutils@2.34: probably vulnerable to CVE-
2020-16590, CVE-2020-16591, CVE-2020-16592, CVE-2020-16593, CVE-2020-
16599

Because they are also build tools for GNU Guix itself, we can't fix
this in grafts, a review of each and every CVE can be made to evaluate
whether we must fix it for GNU Guix's internal usage can be made, but
also we should update it and not use any vulnerable version anywhere so
we can be certain we didnt miss anything.

Can binutils be upgraded just like that? Or must it be upgraded in
tandem with GCC and friends?

Thank you,
Léo
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEFIvLi9gL+xax3g6RRaix6GvNEKYFAmBeRvAACgkQRaix6GvN
EKZ8kRAAmAZr1kxoMaGXvAHujdj5yLe4s9U1+YqhBaUr4KI3bU0WKWZfy/+8vERb
aDx453sxQFvIRW0g9DpwsJzL9n0+oft+g9C1KYaLgp63w6lhp0cdtkGKDJdYaJyE
UulAS/F9W0OrWvp0uDeUikeBuAtniJ8lweApZn6VeMcfQ/WCIIMJ39lZ48mbKYhZ
UZXnyQGAEi4Jt+I7pEeoi+TBPeDIuN4YU4mivBiMMgrLnWZdEP1jKywBa5Lukb6G
xMlmpkMdye8m8sTbuAmfZJ2IXvjcpwE3NgU05q6n6vOvuHyLuhSJJ5uOltob9I04
HD1UeQOTGvaaDqNBFPpiM5v3abKJKv4ZjHD/MMXdUykAzAsDs93Ls7J5QF6avmu/
ysfJpJNDNSy90Kld3e6VqO4P181Q3+kIVkzyeqbHOe6Md+FVuc7wMNl/oPy92H10
zfcduy1klfSqqgPAUidL75Voti90mttPhAX7SYn7J2nwt0W2NJpbindrXhJwTX0j
hbMAJDs0Osh+6StB3BDSsLknx3SN/Frj0UGf8UlelovASAarO9CmJ6W/w/5JPRkK
Yk/Npe2iejEzj+GbRhTZH9W5UMchdyoWS5UZw0eY2ArT/g0xdtdqdteKovnla4b0
wai92AvvIuubGc7FeyA5qs788L8u4zhaPrYWiaVQQORUejGvzNM=
=jnN8
-----END PGP SIGNATURE-----


L
L
Léo Le Bouter wrote on 26 Mar 2021 21:55
(address . control@debbugs.gnu.org)
be44114ad75ba55c847243744ba8f47e2915606a.camel@zaclys.net
tags 47420 + security
quit
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEFIvLi9gL+xax3g6RRaix6GvNEKYFAmBeSigACgkQRaix6GvN
EKbr7BAAiMH8HQj4/CCrK2F5ZB5gBefvHEhlglk6HxWECwUrbnmkySEdCECh/3jQ
6fDkXk6i0AKcP+BahRBpBUd5HANMYUvJk0aYNSoXozjFoxrLhEcWHLJ5bbTbhWTY
auFFCXpD1FmNUDDuEMzO5MeltcSoiOnJG5rIHX+Y7Kwvr5U4yFQNTNunDS1/kHQS
juSvUMBRYwc22yNhfTXabswVOVwBXpcQUqnqgNWqpPslwoDve5IwCqN9ichkJnQg
qWakYlAUR/6mcJDXH44C0whIHeH2/R0b0EwzvDWJpUPDNvrSTiRufJtP7l0IaORP
P1XL3Y2A00HMmWMxntr1a7Qq1pmL+MC1SSSyh4NFf8vgyIpk71eMPJkF2j9CkUEz
aOJJacNRjAqzPIGL0i2NlcWbNQT2PTDqAKPMKQMHz1fV+uu51ow3V6xbxuBP4kkI
LQlZ4b36NX0vMlEDw0085+IlPQ6SocXIsMY9H/pqe6QuKAa2XMQRM9j4jazCp+CK
ofNbWJAEX8V8Lkyy8g9NYcOZHJdKmnXqwdEW5Ptw7boFIBKXBpCz76JJlWLba124
kyi5wsiLerD4fnYv0tFPs7FxedOFnlCU8cs3f/aLacdtFNnmUC0Mb70OqcM62HgE
yYXnfwqfAuJXLn7crDsBhJ236EPMo8TV04KeQEp6bL7508WkFpI=
=8/r1
-----END PGP SIGNATURE-----


L
L
Léo Le Bouter wrote on 26 Mar 2021 22:56
(address . 47420@debbugs.gnu.org)
229d740c124ef1133bdaa032222302ac99e398a8.camel@zaclys.net
Another:

CVE-2021-20284 18:15
A flaw was found in GNU Binutils 2.35.1, where there is a heap-based
buffer overflow in _bfd_elf_slurp_secondary_reloc_section in elf.c due
to the number of symbols not calculated correctly. The highest threat
from this vulnerability is to system availability.
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEFIvLi9gL+xax3g6RRaix6GvNEKYFAmBeWJAACgkQRaix6GvN
EKYitxAAjjGVBnGZwORJcGfl4CN1J3kXS9Zzitt/E8VFzDYu20cardGBCyi86K7O
lxCYS3/7OEZgwy1TFPfwTomBJU4AHQPSmqEOBaRPFXoL0q1s82qQlzHh/s1j65uL
7hp/zSU2C+8IJmY9E93k1jgWx9CGP7fr9RkRvGl9tpAPmk3n9ctzBtyLO9Xn5eRy
mbV7DWWgbMTHwbeZfohpTrRSTSOuQI+wYxG33WzfRhjDYOwyUXhbI8av/CEFuVEc
FlekTEgMzqfDduRAHLUEenIIj5nGX0WsZUjVz24a15jmjUFB5NjCszVxceOe4n6B
9uiZaLVplAQjPYijQKV30yMJJjckvk5eZOyt+fsJN4EWFtLon9i7246+XM8sjfbB
S4cZFveNxBWr8CbdJ5A+1iF9MyT7x2XM/BgatwAgzirYCd4RkjTrcXAVCgoj+ZVM
JBY+QtPKO2lQHTU2fQxyf5u9t7cXNCybmHv5lUXe4XujtJ1T5MSBm06Krwnc535B
aN2q6POjSM5cD51twR0AM0rnQk+e4r5/N6Ky4Mt0ZXZL7r5QSRSbfUYGDdkrlxz6
y+AP0EoAD9vofEnzdXv8UznwPi0/HG3I+/0WqVqsYey5BvV1FEqjteWDh42mxvmp
nR4wfOy6yBN1VCzBOwWBQVMRrzMHthunOxil240CKBoujwhXbzA=
=htsO
-----END PGP SIGNATURE-----


M
M
Maxime Devos wrote on 27 Mar 2021 00:00
d12edf9cd3c7a6779c25ccd40411c16292406e8d.camel@telenet.be
On Fri, 2021-03-26 at 21:41 +0100, Léo Le Bouter via Bug reports for GNU Guix wrote:
Toggle quote (8 lines)
> CVE-2021-20197 18:15
> There is an open race window when writing output in the following
> utilities in GNU binutils version 2.35 and earlier:ar, objcopy, strip,
> ranlib. When these utilities are run as a privileged user (presumably
> as part of a script updating binaries across different users), an
> unprivileged user can trick these utilities into getting ownership of
> arbitrary files through a symlink.

At first I thought -- why would anyone run the binutils as root (or other
privileged user)? Isn't it only used for *compiling* stuff? But then
I looked at the actual bug report:


Apparently creating temporary files isn't done quite correctly.
IIUC, on a shared guix system, a malicious user could use this bug
to change the binary that would normally result from the innocent
user running "./configure && make" into something controlled
by the malicious user.

Question: if I run "guix environment guix", do I get the packages
normally used for building guix as-is, or the grafted versions?
When I run "guix environment emacs", I see two lines "applying $N grafts",
so I assume the latter.

Toggle quote (15 lines)
> For the two versions packaged in GNU Guix we have:
>
> $ ./pre-inst-env guix lint -c cve binutils@2.33
> gnu/packages/base.scm:584:2: binutils@2.33.1: probably vulnerable to
> CVE-2020-35493, CVE-2020-35494, CVE-2020-35495, CVE-2020-35496, CVE-
> 2020-35507
>
> $ ./pre-inst-env guix lint -c cve binutils@2.34
> gnu/packages/base.scm:571:2: binutils@2.34: probably vulnerable to CVE-
> 2020-16590, CVE-2020-16591, CVE-2020-16592, CVE-2020-16593, CVE-2020-
> 16599

> Because they are also build tools for GNU Guix itself, we can't fix
> this in grafts,

No, see next comment.

Toggle quote (5 lines)
> a review of each and every CVE can be made to evaluate
> whether we must fix it for GNU Guix's internal usage can be made, but
> also we should update it and not use any vulnerable version anywhere so
> we can be certain we didnt miss anything.

Guix itself only use binutils in the build containers, which (I presume)
have their own temporary directories, so this shouldn't be
relevant to Guix itself. However, grafts are still important for
*developers*. See my first comment block.

Toggle quote (3 lines)
> Can binutils be upgraded just like that? Or must it be upgraded in
> tandem with GCC and friends?

I don't know, I guess you'll just have to try and read the release notes.
In any case, upgrading packages seems a good idea (as long as it doesn't
cause world-rebuild or bootstrapping issues of course), even if there
weren't any security issues -- perhaps something to do on core-updates?.

Thanks for looking into these potential security issues,

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYIADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYF5nmBccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7k+PAQDTGO4qOQLRqmaQr72wSZvWxDNQ
AsiSw2Kt30W4AoVzVQEA6Oho2QtrfIFFs/vF6Ijq/WJOkVtHeZeqcInN6HzeEQU=
=aPRn
-----END PGP SIGNATURE-----


M
M
Maxim Cournoyer wrote on 23 Mar 03:31 +0100
(name . Maxime Devos)(address . maximedevos@telenet.be)
87czid1jth.fsf@gmail.com
Hi,

Maxime Devos <maximedevos@telenet.be> writes:

Toggle quote (9 lines)
> On Fri, 2021-03-26 at 21:41 +0100, Léo Le Bouter via Bug reports for GNU Guix wrote:
>> CVE-2021-20197 18:15
>> There is an open race window when writing output in the following
>> utilities in GNU binutils version 2.35 and earlier:ar, objcopy, strip,
>> ranlib. When these utilities are run as a privileged user (presumably
>> as part of a script updating binaries across different users), an
>> unprivileged user can trick these utilities into getting ownership of
>> arbitrary files through a symlink.

Our current version of binutilsis now 2.37, immune to the CVE reported
here.

Thanks for the report!

Closing.

Maxim
Closed
?
Your comment

This issue is archived.

To comment on this conversation send email to 47420@debbugs.gnu.org