All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Hannes Frederic Sowa" <hannes@stressinduktion.org>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: "Toke Høiland-Jørgensen" <toke@redhat.com>,
	Netdev <netdev@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Jean-Philippe Aumasson" <jeanphilippe.aumasson@gmail.com>,
	"Linux Crypto Mailing List" <linux-crypto@vger.kernel.org>,
	"Erik Kline" <ek@google.com>,
	"Fernando Gont" <fgont@si6networks.com>,
	"Lorenzo Colitti" <lorenzo@google.com>,
	"Hideaki Yoshifuji" <hideaki.yoshifuji@miraclelinux.com>
Subject: Re: [PATCH RFC v1 2/3] ipv6: move from sha1 to blake2s in address calculation
Date: Fri, 14 Jan 2022 18:41:58 +0100	[thread overview]
Message-ID: <3db9c306-ea22-444f-b932-f66f800a7a28@www.fastmail.com> (raw)
In-Reply-To: <CAHmME9pR+qTn72vyANq8Nxx0BtGy7a_+dRvZS_F7RCag8Rvxng@mail.gmail.com>

Hello,

On Fri, Jan 14, 2022, at 17:07, Jason A. Donenfeld wrote:
> On Thu, Jan 13, 2022 at 12:15 PM Hannes Frederic Sowa
> <hannes@stressinduktion.org> wrote:
>> > I'm not even so sure that's true. That was my worry at first, but
>> > actually, looking at this more closely, DAD means that the address can
>> > be changed anyway - a byte counter is hashed in - so there's no
>> > guarantee there.
>>
>> The duplicate address detection counter is a way to merely provide basic
>> network connectivity in case of duplicate addresses on the network
>> (maybe some kind misconfiguration or L2 attack). Such detected addresses
>> would show up in the kernel log and an administrator should investigate
>> and clean up the situation.
>
> I don't mean to belabor a point where I'm likely wrong anyway, but
> this DAD business has kept me thinking...
>
> Attacker is hanging out on the network sending DAD responses, forcing
> those counters to increment, and thus making SHA1(stuff || counter)
> result in a different IPv6 address than usual. Outcomes:
> 1) The administrator cannot handle this, did not understand the
> semantics of this address generation feature, and will now have a
> broken network;
> 2) The administrator knows what he's doing, and will be able to handle
> a different IPv6 address coming up.
>
> Do we really care about case (1)? That sounds like emacs spacebar
> heating https://xkcd.com/1172/. And case (2) seems like something that
> would tolerate us changing the hash function.

Taking a step back, there is the base case where we don't have duplicate
addresses on the network nor an attack is on-going. We would break those
setups with that patch. And those are the ones that matter most. In
particular those stable-random addresses are being used in router
advertisements for announcing the next-hop/default gateway on the
broadcast domain. During my time in IPv6 land I have seen lots of setups
where those automatic advertisements got converted into static
configuration for the sake of getting hands on a cool looking IPv6
address on another host (I did that as well ;) ). In particular, in the
last example, you might not only have one administrator at hand to
handle the issue, but probably multiple roles are involved (host admin
and network admin maybe from different organizations - how annoying -
but that's a worst case scenario).

Furthermore most L2 attacks nowadays are stopped by smarter switches or
wifi access points(?) anyway with per-port MAC learning and other
hardening features. Obviously this only happens in more managed
environments but probably already also at smaller home networks
nowadays. Datacenters probably already limit access to the Layer 2 raw
network in such a way that this attack is probably not possible either.
Same for IoT stuff where you probably have a point-to-point IPv6
connection anyway.

The worst case scenario is someone upgrading their kernel during a
trip away from home, rebooting, and losing access to their system. If we
experience just one of those cases we have violated Linux strict uAPI
rules (in my opinion). Thus, yes, we care about both, (1) and (2) cases.

I don't think we can argue our way out of this by stating that there are
no guarantees anyway, as much as I would like to change the hash
function as well.

As much as I know about the problems with SHA1 and would like to see it
removed from the kernel as well, I fear that in this case it seems hard
to do. I would propose putting sha1 into a compilation unit and
overwrite the compiler flags to optimize the function optimized for size
and maybe add another mode or knob to switch the hashing algorithm if
necessary.

>> Afterwards bringing the interface down and
>> up again should revert the interface to its initial (dad_counter == 0)
>> address.
>
> Except the attacker is still on the network, and the administrator
> can't figure it out because the mac addresses keep changing and it's
> arriving from seemingly random switches! Plot twist: the attack is
> being conducted from an implant in the switch firmware. There are a
> lot of creative different takes on the same basic scenario. The point
> is - the administrator really _can't_ rely on the address always being
> the same, because it's simply out of his control.

This is a very pessimistic scenario bordering a nightmare. I hope the
new hashing algorithm will protect them. ;)

> Given that the admin already *must* be prepared for the address to
> change, doesn't that give us some leeway to change the algorithm used
> between kernels?
>
> Or to put it differently, are there _actually_ braindead deployments
> out there that truly rely on the address never ever changing, and
> should we be going out of our way to support what is arguably a
> misreading and misdeployment of the feature?

Given the example above, users might hardcode this generated IP address
as a default gateway in their configs on other hosts. This is actually a
very common thing to do.

> (Feel free to smack this line of argumentation down if you disagree. I
> just thought it should be a bit more thoroughly explored.)

I haven't investigated recent research into breakage of SHA1, I mostly
remember the chosen-image and collision attacks against it. Given the
particular usage of SHA1 in this case, do you think switching the
hashing function increases security? I am asking because of the desire
to decrease the instruction size of the kernel, but adding a switch
will actually increase the size in the foreseeable future (and I agree
with Toke that offloading this decision to distributions is probably
not fair).

Maybe at some point the networking subsystem will adapt a generic knob
like LD_ASSUME_KERNEL? ;)

Bye,
Hannes

  parent reply	other threads:[~2022-01-14 17:44 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-12 13:12 [PATCH RFC v1 0/3] remove remaining users of SHA-1 Jason A. Donenfeld
2022-01-12 13:12 ` [PATCH RFC v1 1/3] bpf: move from sha1 to blake2s in tag calculation Jason A. Donenfeld
2022-01-12 22:56   ` Toke Høiland-Jørgensen
2022-01-13  1:33     ` Alexei Starovoitov
2022-01-13 12:27       ` Jason A. Donenfeld
2022-01-13 22:45         ` Alexei Starovoitov
2022-01-14  8:33           ` Geert Uytterhoeven
2022-01-14 14:12           ` Jason A. Donenfeld
2022-01-14 15:08             ` Ard Biesheuvel
2022-01-14 15:20               ` Jason A. Donenfeld
2022-01-14 15:36                 ` Geert Uytterhoeven
2022-01-14 15:59                 ` David Laight
2022-01-14 16:19               ` Alexei Starovoitov
2022-01-14 16:34                 ` Jason A. Donenfeld
2022-01-14 23:04     ` Jeffrey Walton
2022-01-12 13:12 ` [PATCH RFC v1 2/3] ipv6: move from sha1 to blake2s in address calculation Jason A. Donenfeld
2022-01-12 15:49   ` Jason A. Donenfeld
2022-01-12 23:05   ` Toke Høiland-Jørgensen
2022-01-12 23:31     ` Jason A. Donenfeld
2022-01-13 11:15       ` Hannes Frederic Sowa
2022-01-13 12:06         ` Ard Biesheuvel
2022-01-13 12:22           ` Jason A. Donenfeld
2022-01-13 12:29             ` Ard Biesheuvel
2022-01-13 13:30           ` Toke Høiland-Jørgensen
2022-01-13 13:40             ` Ard Biesheuvel
2022-01-13 13:45             ` Jason A. Donenfeld
2022-01-13 13:50               ` Ard Biesheuvel
2022-01-13 13:54                 ` Jason A. Donenfeld
2022-01-13 16:18                   ` Toke Høiland-Jørgensen
2022-01-14 16:07         ` Jason A. Donenfeld
2022-01-14 16:57           ` Toke Høiland-Jørgensen
2022-01-14 17:41           ` Hannes Frederic Sowa [this message]
2022-01-14 17:58             ` Jason A. Donenfeld
2022-01-12 13:12 ` [PATCH RFC v1 3/3] crypto: sha1_generic - import lib/sha1.c locally Jason A. Donenfeld
2022-01-12 18:50 ` [PATCH RFC v1 0/3] remove remaining users of SHA-1 David Sterba
2022-01-12 18:57   ` Jason A. Donenfeld
2022-01-13  3:24 ` Sandy Harris
2022-01-13  8:08   ` Ard Biesheuvel
2022-01-13 17:28   ` Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3db9c306-ea22-444f-b932-f66f800a7a28@www.fastmail.com \
    --to=hannes@stressinduktion.org \
    --cc=Jason@zx2c4.com \
    --cc=ardb@kernel.org \
    --cc=ek@google.com \
    --cc=fgont@si6networks.com \
    --cc=geert@linux-m68k.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=hideaki.yoshifuji@miraclelinux.com \
    --cc=jeanphilippe.aumasson@gmail.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.