Netatalk Security Advisory
- Subject
- afpd daemon vulnerable to symlink redirection
- CVE ID
- CVE-2022-22995
- Date of Publishing
- 2023/10/05
- Affected Netatalk Versions
- 3.1.0 - 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.
The vulnerable code was introduced with Netatalk 3.0alpha3. As part of the upgrade path from Netatalk 3.0 (and earlier) to Netatalk 3.1, it attempts to automatically move any existing .AppleDesktop directory from the root of the shared volume to the shared CNID database directory.
Patch Availability
Apply the patch with git hash 9eb6d9d to hotfix your local Netatalk deployment.
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.
CVSS Calculation
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H (7.2)
Workaround
Either one of the following measures will prevent the exploit. Both can be used in tandem for an extra layer of protection.
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 for said file sharing service.
Credits
- Vulnerability found and reported by:
- Corentin BAYET (@OnlyTheDuck), Etienne HELLUY-LAFONT and Luca MORO (@johncool__) from Synacktiv
- Patch developed by:
- Daniel Markstedt of the Netatalk team