Economy IT security
exarch fixes a symbolic link flaw found by Webcracy
Liam Giannini of Webcracy discovered a vulnerability in the exarch library that allowed files to be written outside the extraction folder by exploiting a symbolic link already present in the destination. The flaw, fixed in version 0.8.0, affected TAR and ZIP archives and was rated moderate severity.
Webcracy, the software company based in the Locarno region, reported a vulnerability in the open source library exarch, used to safely extract TAR and ZIP archives. It was discovered by Liam Giannini, the company's co-founder and an ethical hacker. The issue, catalogued as GHSA-9r5q-fvpf-p55p and published on 2 November, was fixed in version 0.8.0.
exarch has a core written in Rust, also distributed as a Python package and as a Node.js package. It presents itself as a safer alternative to libraries such as Python's tarfile, with one precise guarantee: extracted files always stay inside the chosen destination folder.
In versions from 0.6.1 up to but excluding 0.8.0, that guarantee could be bypassed. exarch rejected symbolic links contained in an archive, but did not account for a symbolic link already present in the destination folder before extraction. To speed up the process, the library kept a cache of folders it had already created, and a flaw in the function used to create them allowed a symbolic link mistaken for a real folder to end up in that cache too. An archive with two ordinary entries, a folder followed by a file inside it, was enough to make the file get written outside the destination, following the link.
A necessary condition limits the risk
The flaw affected both TAR and ZIP archives under the default configuration; extracting 7z files was not affected because it did not use that cache. In the worst case, an attacker could write, or under certain conditions overwrite, files outside the chosen folder, with consequences ranging from altering configurations to code execution by other components. However, the symbolic link must already exist in the destination, and the attacker must know its name: that is why the vulnerability was rated moderate severity, under category CWE-59.
Webcracy identified the problem by analysing the source code of exarch 0.6.1 and confirmed it with two regression tests written for the purpose, on Linux with Rust 1.98.0. Along with the report, the company also proposed a minimal fix, which passed both the new tests and the project's existing 801 unit tests and 136 integration tests.
exarch's maintainer accepted the report and, in pull request #816, went beyond the proposed patch: the folder cache was removed and a check was introduced that verifies every component of the path on every write. Since that version, extraction fails by default if any symbolic link is present in the destination, unless explicitly allowed. The following version, 0.9.0, released on 5 November, added a further protection that the maintainer had identified as still needed: anchoring writes to directory descriptors, to close the remaining time window between verification and writing.
Anyone using exarch in a version earlier than 0.8.0 should update, checking the breaking changes noted in the release notes. The same research team had already reported a flaw in the open source helpdesk software FreeScout last October.
Comments
There are no comments yet. Yours can be the first voice.

