The vulnerability exists in the WebDAV drive backend of zrok, specifically within the davServer.Dir type's methods for handling file operations. The root cause is the failure to properly handle symbolic links when resolving file paths. The vulnerable functions (OpenFile, Stat, Mkdir, RemoveAll, and Rename) used a lexical path normalization function, d.resolve(name), which did not check for or correctly handle symlinks. This allowed an attacker, who could convince a local user to create a malicious symlink within the WebDAV root directory, to traverse outside of this restricted directory.
When a WebDAV request was made to a path containing such a symlink, the zrok process would follow it, granting access to files and directories on the host filesystem with the same permissions as the zrok process. This could lead to arbitrary file reads, writes, and deletions, resulting in a high impact on confidentiality and integrity.
The patch addresses this vulnerability by introducing a new, more secure path resolution function called resolveBoundedPath. This function carefully resolves paths segment by segment, explicitly checking for symbolic links. If a symlink is found, it ensures that the target of the symlink resolves to a path that is still within the intended WebDAV root directory. If a symlink attempts to break out of this sandbox, the operation is denied with a permission error. All the vulnerable file operation methods were updated to use this new secure path resolution function, effectively closing the path traversal vulnerability.