Page MenuHomeVyOS Platform

Wireguard: Need a valid error if the public-key is invalid base64
Open, Requires assessmentPublicBUG

Description

A traceback error is received if an incorrect public is provided:

set int wireguard wg01 peer to-wg02 public-key '//3/sDdozmikDxtYPw0MMYeuM2WPX7cgLnSH6L5+BQU='

vyos@vyos# commit
[ interfaces wireguard wg01 ]
VyOS had an issue completing a command.

We are sorry that you encountered a problem while using VyOS.
There are a few things you can do to help us (and yourself):
- Contact us using the online help desk if you have a subscription:
  https://support.vyos.io/
- Make sure you are running the latest version of VyOS available at:
  https://vyos.net/get/
- Consult the community forum to see how to handle this issue:
  https://forum.vyos.io
- Join us on Slack where our users exchange help and advice:
  https://vyos.slack.com

When reporting problems, please include as much information as possible:
- do not obfuscate any data (feel free to contact us privately if your
  business policy requires it)
- and include all the information presented below

Report time:      2025-03-14 18:08:07
Image version:    VyOS 1.4.1
Release train:    sagitta

Built by:         VyOS Networks Iberia S.L.U.
Built on:         Thu 19 Dec 2024 16:39 UTC
Build UUID:       857ab426-c3d8-4254-b23a-0ad62a45ecc7
Build commit ID:  98c72c5c45a7a1-dirty

Architecture:     x86_64
Boot via:         installed image
System type:      KVM guest

Hardware vendor:  QEMU
Hardware model:   Standard PC (i440FX + PIIX, 1996)
Hardware S/N:
Hardware UUID:    898574b0-c264-4c85-8693-da1c745bfbf9

Traceback (most recent call last):
  File "/usr/libexec/vyos/conf_mode/interfaces_wireguard.py", line 129, in <module>
    apply(c)
  File "/usr/libexec/vyos/conf_mode/interfaces_wireguard.py", line 120, in apply
    wg.update(wireguard)
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/wireguard.py", line 220, in update
    self._cmd(cmd.format(**peer_config))
  File "/usr/lib/python3/dist-packages/vyos/ifconfig/control.py", line 52, in _cmd
    return cmd(command, self.debug)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/utils/process.py", line 155, in cmd
    raise OSError(code, feedback)
PermissionError: [Errno 1] failed to run command: wg set wg01 listen-port 51820 fwmark 0 private-key /tmp/tmp6aba_vo8 peer {} preshared-key /dev/null allowed-ips 192.168.200.0/24 endpoint 10.0.1.2:51820
returned:
exit code: 1

noteworthy:
cmd 'nft --check delete element inet vrf_zones ct_iface_map { "wg01" }'
returned (out):

returned (err):
Error: Could not process rule: No such file or directory
delete element inet vrf_zones ct_iface_map { wg01 }
                                             ^^^^
cmd 'wg set wg01 listen-port 51820 fwmark 0 private-key /tmp/tmp6aba_vo8 peer {} preshared-key /dev/null allowed-ips 192.168.200.0/24 endpoint 10.0.1.2:51820'
returned (out):

returned (err):
Key is not the correct length or format: `{}'

[[interfaces wireguard wg01]] failed
Commit failed
[edit]
vyos@vyos# compare commands

set interfaces wireguard wg01 address '10.100.1.1/30'
set interfaces wireguard wg01 peer to-wg02 address '10.0.1.2'
set interfaces wireguard wg01 peer to-wg02 allowed-ips '192.168.200.0/24'
set interfaces wireguard wg01 peer to-wg02 port '51820'
set interfaces wireguard wg01 peer to-wg02 public-key
set interfaces wireguard wg01 port '51820'
set interfaces wireguard wg01 private-key 'iJJyEARGK52Ls1GYRCcFvPuTj7WyWYDo//BknoDU0XY='

This format gives an error:

vyos@vyos# set int wireguard wg01 peer to-wg02 public-key '//XMrlPykaxhdAAiSjhtPlvi30NVkvLQliQuKP7AI7CyI='




  Key is not base64-encoded
  Value validation failed
  Set failed

Details

Version
1.4.1
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)