Impact
If a system designer has deployed the Erlang/OTP SFTP server and configured the root option expecting it to restrict file access to a specific directory, the implementation fails to properly validate path boundaries. The SFTP server uses string prefix matching rather than path component validation, allowing authenticated users to access sibling directories that share a common name prefix with the configured root directory.
For example, if the SFTP server is configured with {root, "/home/user1"}, an authenticated attacker can access files in /home/user10/, /home/user123/, or /home/user1_backup/ because these paths share the string prefix /home/user1.
File paths in SFTP requests are validated using simple string prefix matching via lists:prefix/2, so paths containing sibling directory names that start with the root directory name can bypass the intended access restrictions and reach directories outside the configured root.
Note that Erlang/OTP SFTP server configurations that do not use the root option allow remote file access anywhere on the system with absolute or relative file paths, which is a known property of the SFTP protocol. This cannot be considered a vulnerability in itself.
For a system to be vulnerable, the system designer must have configured the root option under the assumption that it provides complete directory isolation. The option's name suggests security isolation, but the implementation only performs string prefix matching without proper path component validation.
The system must also be reachable from untrusted hosts and contain confidential or precious data readable or writable by the OS user running the SFTP server (the Erlang VM). For an Erlang/OTP SFTP server without the root option, these points would be design considerations inherent to the SFTP protocol.
Workarounds
- Use OS-level chroot to run the Erlang VM/SFTP server process in an isolated filesystem environment
- Ensure that no sensitive or precious data is readable or writable by the OS user running the Erlang VM
- Ensure that the SFTP server port on the machine running the Erlang/OTP SFTP server is not reachable from untrusted machines
- Use directory naming conventions that avoid common prefixes (e.g.,
/home/users/alice/ instead of /home/user1/)
Affected/Unaffected Versions
A version larger than or equal to one of the listed patched versions is unaffected; otherwise, a version that satisfies an expression listed under affected versions is affected, and if it does not, it is unaffected.
The documentation of the OTP version scheme describes how versions should be compared. Note that versions used prior to OTP 17.0, when the new OTP version scheme was introduced, are never listed since it is not well defined how to compare those versions.
In the case of this vulnerability, versions prior to OTP 17.0 are also affected.
Credits
Thanks to Luigino Camastra at Aisle Research for finding and responsibly disclosing this vulnerability to the Erlang/OTP project.
Impact
If a system designer has deployed the Erlang/OTP SFTP server and configured the
rootoption expecting it to restrict file access to a specific directory, the implementation fails to properly validate path boundaries. The SFTP server uses string prefix matching rather than path component validation, allowing authenticated users to access sibling directories that share a common name prefix with the configured root directory.For example, if the SFTP server is configured with
{root, "/home/user1"}, an authenticated attacker can access files in/home/user10/,/home/user123/, or/home/user1_backup/because these paths share the string prefix/home/user1.File paths in SFTP requests are validated using simple string prefix matching via
lists:prefix/2, so paths containing sibling directory names that start with the root directory name can bypass the intended access restrictions and reach directories outside the configured root.Note that Erlang/OTP SFTP server configurations that do not use the
rootoption allow remote file access anywhere on the system with absolute or relative file paths, which is a known property of the SFTP protocol. This cannot be considered a vulnerability in itself.For a system to be vulnerable, the system designer must have configured the
rootoption under the assumption that it provides complete directory isolation. The option's name suggests security isolation, but the implementation only performs string prefix matching without proper path component validation.The system must also be reachable from untrusted hosts and contain confidential or precious data readable or writable by the OS user running the SFTP server (the Erlang VM). For an Erlang/OTP SFTP server without the
rootoption, these points would be design considerations inherent to the SFTP protocol.Workarounds
/home/users/alice/instead of/home/user1/)Affected/Unaffected Versions
A version larger than or equal to one of the listed patched versions is unaffected; otherwise, a version that satisfies an expression listed under affected versions is affected, and if it does not, it is unaffected.
The documentation of the OTP version scheme describes how versions should be compared. Note that versions used prior to OTP 17.0, when the new OTP version scheme was introduced, are never listed since it is not well defined how to compare those versions.
In the case of this vulnerability, versions prior to OTP 17.0 are also affected.
Credits
Thanks to Luigino Camastra at Aisle Research for finding and responsibly disclosing this vulnerability to the Erlang/OTP project.