Re: [PATCH net-next v2] net: WireGuard secure network tunnel

From: Dmitry Vyukov
Date: Wed Dec 18 2019 - 06:37:45 EST


On Wed, Dec 18, 2019 at 11:57 AM Jason A. Donenfeld <Jason@xxxxxxxxx> wrote:
>
> Hi Dmitry,
>
> On Wed, Dec 18, 2019 at 11:13 AM Dmitry Vyukov <dvyukov@xxxxxxxxxx> wrote:
> > Does it really do "verbose debug log"? I only see it is used for
> > self-tests and debug checks:
>
> Yes, it does, via net_dbg and co. People with the Linux "dynamic
> debugging" feature turned also get the log by twiddling with some file
> at runtime.
>
> > In different contexts one may enable different sets of these.
> > In particular in fuzzing context one absolutely wants additional debug
> > checks, but not self tests and definitely no verbose logging. CI and
> > various manual scenarios will require different sets as well.
> > If this does verbose logging, we won't get debug checks as well during
> > fuzzing, which is unfortunate.
> > Can make sense splitting CONFIG_WIREGUARD_DEBUG into 2 or 3 separate
> > configs (that's what I see frequently). Unfortunately there is no
> > standard conventions for anything of this, so CIs will never find your
> > boot tests and fuzzing won't find the additional checks...
>
> I agree that it might make sense to split this up at some point, but
> for now I think it might be a bit overkill. Both the self-tests and
> debug tests are *very* light at the moment. Down the road if these
> become heavier, I think it'd probably be a good idea, but for the time
> being it'd mostly be more complexity for nothing.
>
> Another more interesting point, though, you wrote
> > and definitely no verbose logging.
>
> Actually with WireGuard, I think that's not the case. The WireGuard
> logging has been written with DoS in mind. You /should/ be able to
> safely run it on a production system exposed to the wild Internet, and
> while there will be some additional things in your dmesg, an attacker
> isn't supposed to be able to totally flood it without ratelimiting or
> inject malicious strings into it (such as ANSI escape sequence). In
> other words, I consider the logging to be fair game attack surface. If
> your fuzzer manages to craft some nasty sequence of packets that
> tricks some rate limiting logic and lets you litter all over dmesg
> totally unbounded, I'd consider that a real security bug worth
> stressing out about. So from the perspective of letting your fuzzers
> loose on WireGuard, I'd actually like to see this option kept on.

This is the case even with CONFIG_WIREGUARD_DEBUG turned on, right? Or without?

Well, it may be able to trigger unbounded printing, but that won't be
detected as a bug and won't be reported. To be reported it needs to
fall into a set of predefined bug cases (e.g. "BUG:" or "WARNING:" on
console). Unless of course it triggers total stall/hang. But I'm
afraid it will just dirty dmesg, make reading crashes harder and slow
down everything without benefit. O(1) output per test is generally not
OK in heavy stressing scenario, even if it's overall bounded and rate
limited.