Strange behavior when a peer has the same key as the interface

Vojtěch Káně vojtech.kane at
Fri Sep 3 07:24:38 UTC 2021


I would like to report a strange behavior of the Wireguard Linux kernel 
implementation — when you try to create a peer whose public key matches 
the public key of the interface, the call returns success, but nothing 
is done.

I don't have an opinion (and relevant deep understanding of the crypto 
involved) whether such a call should succeed or not. Especially since 
it's 99% not what you want. I came across this issue by mistake anyway. 
However I think an error should be returned when such a peer is rejected.

Steps to reproduce:

`wg genkey > priv`

`wg pubkey > pub < priv`

`ip link add wg type wireguard`

`wg set wg private-key priv`

`wg set wg peer $(cat pub) allowed-ips`


The return code is 0.

`wg show wg` does not print any peer.

The same happens when using the wgctrl golang library.


Vojtěch Káně

More information about the WireGuard mailing list