Page MenuHomeVyOS Platform

vyos-domain-resolver: UnicodeError from getaddrinfo() is not caught, the resolver crashes
Open, NormalPublicBUG

Description

fqdn_resolve() catches only OSError. For a name with an empty label (a..b) or a label longer than 63 characters, getaddrinfo() raises UnicodeError from the idna codec, which is not an OSError. The resolver loop has no other handler, so the service crashes, restarts until the start limit and stays failed, and the sets of every other domain group and FQDN rule stop updating.

Such names pass the domain validator and commit:

set firewall group domain-group BAD address 'a..b'
set firewall group domain-group GOOD address 'good.example.net'
set firewall ipv4 input filter rule 10 source group domain-group GOOD
set firewall ipv4 input filter rule 10 action accept
UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)
                 vyos-domain-resolver   restarts  GOOD set filled
1.5.1            active                 0         yes (2/2)
rolling          failed                 5         no  (0/2)

Cause
T9210: 4d621da33 (https://github.com/vyos/vyos-1x/pull/5401) narrowed the bare except: in fqdn_resolve() (python/vyos/firewall.py) to gaierror; 53083d91e (https://github.com/vyos/vyos-1x/pull/5406) widened it to OSError. 1.5.1's bare except: skipped these names.

Suggested fix
Catch UnicodeError (or ValueError) in fqdn_resolve() and skip the name, as 1.5.1 did; optionally also refuse empty/over-long labels in the validator. One bad name should not stop resolution of the others.

Details

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