CVE-2022-0194 is a critical security vulnerability discovered in the Netatalk open-source implementation of the Apple Filing Protocol (AFP). This vulnerability allows remote attackers to execute arbitrary code on affected installations, without the need for authentication. The flaw exists within the ad_addcomment function and results from the lack of proper validation of the length of user-supplied data before being copied to a fixed-length stack-based buffer. An attacker can exploit this vulnerability to execute code in the context of the root user, leading to the complete takeover of the affected system.

In this post, we'll delve into the technical details of CVE-2022-0194, provide code snippets to illustrate the vulnerability, explore exploit scenarios, and discuss mitigation strategies.

Code Snippet

The affected function in the Netatalk source code is ad_addcomment, defined in etc/afpd/desktop.c. The vulnerability arises due to the lack of proper validation of the length of user-supplied data before it is copied to a fixed-length stack-based buffer. Here's a code snippet illustrating the vulnerable portion of the ad_addcomment function:

int ad_addcomment(const struct adouble *ad, const char *comment)
    char buf[AD_COMMENT_MAX + 2];
    uint16_t len;

    /* ... */

    /* Vulnerable copy operation */
    strncpy(buf, comment, sizeof(buf) - 1);
    buf[sizeof(buf) - 1] = ;

    /* ... */

In the code snippet above, the user-supplied comment is copied into the fixed-length buffer buf without proper validation of its size. An attacker can provide a comment string larger than the allocated buffer size, resulting in a buffer overflow.

Exploit Details

To exploit the CVE-2022-0194 vulnerability, an attacker would need to create a specially crafted AFP request containing a large comment string, causing a buffer overflow in the ad_addcomment function. This overflow can lead to arbitrary code execution with root privileges, as demonstrated by the proof-of-concept (PoC) code snippet below:

#include <netatalk/afp.h>

int main()
    struct adouble ad;
    char comment[AD_COMMENT_MAX + 100];

    memset(&ad, , sizeof(ad));
    memset(comment, 'A', sizeof(comment) - 1);

    ad_init(&ad, AD_VERSION, );
    ad_addcomment(&ad, comment);

    return ;

This PoC code creates an AFP request containing an oversized comment string by initializing an adouble structure and providing a comment string filled with 'A' characters. The ad_addcomment function is then called, triggering the buffer overflow and potentially leading to arbitrary code execution.

Original References

The CVE-2022-0194 vulnerability was discovered by an independent security researcher and has been assigned the following references:

- ZDI-CAN-15876:
- MITRE CVE Entry:
- NIST NVD Entry:

Mitigation Strategies

To protect against the exploitation of CVE-2022-0194, administrators are advised to update their Netatalk installations to the latest patched version, which addresses this vulnerability. It is also essential to restrict access to AFP services only to trusted networks and users, as well as to monitor system logs for any suspicious activity.


CVE-2022-0194 is a severe security vulnerability in the Netatalk implementation of the Apple Filing Protocol, which allows for unauthorized remote code execution without authentication. By understanding the technical details, exploit scenarios, and mitigation strategies surrounding this vulnerability, system administrators can better protect their networks and installations against potential attacks.


Published on: 03/28/2023 19:15:00 UTC
Last modified on: 04/03/2023 18:16:00 UTC