The code base from which FreeBSD 13 was derived saw a controversial removal of code implementing the WireGuard VPN protocol, developed at the request of Netgate without consulting the original WireGuard developers, and already included in stable releases of the pfSense distribution. After reviewing the code with Jason A. Donenfeld, the author of the original WireGuard, it became clear that the proposed WireGuard implementation for FreeBSD was a prime example of subpar code, rife with buffer overflows and violating the GPL license.
The implementation revealed catastrophic flaws in the cryptographic code, with part of the WireGuard protocol missed, and errors that led to kernel crashes and bypassing of protective methods; fixed-size buffers were used for input data. The quality of the code is further highlighted by the presence of stubs instead of checks that always returned a value of 'true', as well as forgotten debug printf statements outputting encryption parameters, and the use of sleep to prevent race conditions.
Certain parts of the code, such as the crypto_xor function, were transferred from the WireGuard implementation developed for Linux in violation of the GPL license. As a result, Jason Donenfeld, along with Kyle Evans and Matt Dunwoodie (the author of the WireGuard port for OpenBSD), took it upon themselves to redo the problematic implementation and completely replaced the entire code of the developer hired by Netgate within a week. The revised version was released as a separate set of patches, placed in the WireGuard project repository, and has not yet been included in FreeBSD.
Interestingly, nothing initially foreshadowed trouble. The company Netgate, which wanted to implement WireGuard in the pfSense distribution, hired Matthew Macy, who is well-versed in the FreeBSD kernel and network stack, and who has experience in debugging and developing network drivers for this operating system. Macy was given a flexible schedule without deadlines or interim checks. Developers who collaborated with Macy on FreeBSD described him as a talented and professional programmer, who made no more mistakes than others and reacted appropriately to criticism. The poor quality of the WireGuard implementation code for FreeBSD came as a surprise to them.
After 9 months of work in December of last year, Macy added his implementation to the HEAD branch without completing reviews and testing by external participants, which was used to build the release of FreeBSD 13. The development was carried out without communication with the developers of the original WireGuard and ports for OpenBSD and NetBSD. In February, Netgate integrated WireGuard into the stable release pfSense 2.5.0 and began shipping firewalls based on it. After issues were identified, the WireGuard code was removed from pfSense.
Critical vulnerabilities were discovered in the added code, which were exploited in 0-day exploits, but Netgate initially denied the existence of vulnerabilities and attempted to blame the developer of the original WireGuard for assaults and bias, which negatively affected its reputation. The port developer initially dismissed the quality complaints as exaggerated, but after being shown the errors, acknowledged that a critical issue was the lack of proper code quality review in FreeBSD, as the problems went unnoticed for many months (Netgate representatives indicated that public reviews had started as early as August 2020, but individual FreeBSD developers noted that the review in Phabricator was closed by Macy without completion and with disregard for comments). The FreeBSD Core Team responded to the incident with a promise to modernize the code review processes.
Matthew Maisey, the developer of the problematic port for FreeBSD, commented on the situation by stating that he made a grave mistake by taking on the work without being ready to implement the project. He attributes the resulting outcome to emotional burnout and issues stemming from post-COVID syndrome. However, Maisey did not find the resolve to withdraw from the commitments he had already made and instead attempted to see the project through to completion.
Maisey's condition may also have been affected by a recent prison sentence he received for illegal actions in an attempt to evict tenants from a house he purchased, whose occupants were unwilling to leave voluntarily. Together with his wife, they sawed through the ceiling beams and created holes in the floors to make the house uninhabitable, as well as trying to intimidate the tenants by breaking into occupied apartments and removing belongings (the act was classified as burglary). To avoid accountability for his actions, Maisey and his wife fled to Italy but were extradited to the US, where he served more than four years in prison.
Source: opennet.ru
