Netatalk Security Advisory
- Subject
- afpd daemon vulnerable to symlink redirection
- CVE ID
- CVE-2022-22995
- Date of Publishing
- 2023/10/05
- Affected Versions
- Netatalk 3.1.0 through 3.1.17
- Summary
- When configured with AppleDouble v2, afpd can be tricked to move files to an arbitrary location
Description
The create_appledesktop_folder function of netatalk can be used to unsafely move files outside the shared volume using the "mv" system utility. The create_appledesktop_folder function is called when netatalk is configured to use the legacy AppleDouble v2 format of file system meta data.
By using the features of another file sharing protocol, like SMB, an attacker could abuse this primitive to create an arbitrary symbolic link and move it outside the share. The attacker could then reuse the created symlink to write arbitrary files on the targeted system. On the targeted device where it was demonstrated, writing arbitrary files on the system resulted in a remote code execution.
Patch Availability
A patch addressing this vulnerability has been published at: https://github.com/Netatalk/netatalk/commit/9eb6d9d0ac17dca210ccbf05476a925a6b379dfb.diff
Additionally, Netatalk 3.1.18 has been released which contains the security patch. Netatalk administrators are advised to upgrade to this version or apply the patch as soon as possible.
CVSSv3 Calculation
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H (7.2)
Workaround
Configure Netatalk to use the Extended Attributes AppleDouble format: add "appledouble = ea" to the appropriate section in afp.conf
When a shared volume is accessed by another file sharing service such as Samba, make sure that ".AppleDesktop" is on the veto file list.
Credits
Credits to finding and demonstrating the exploit goes to:
Corentin BAYET (@OnlyTheDuck), Etienne HELLUY-LAFONT and Luca MORO (@johncool__) from Synacktiv.
Patch contributed by: Daniel Markstedt of the Netatalk Team.