| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| getgrav/grav | composer | < 1.8.0-beta.27 | 1.8.0-beta.27 |
The vulnerability is a path traversal issue within the user creation functionality of Grav. When a new user is created via the admin panel, the provided username is used to generate the filename for the user's account YAML file. The root cause of the vulnerability is the failure to properly sanitize this username before using it in file path operations.\n\nAn attacker with privileges to create users could supply a username containing path traversal sequences, such as ../newuser or ..\\newuser. The application would then concatenate this malicious username with the base directory for user accounts (e.g., user/accounts/), resulting in a path like user/accounts/../newuser. This resolves to user/newuser.yaml, allowing the attacker to write a file outside of the intended directory.\n\nThis could be exploited to overwrite critical configuration files (like system.yaml), leading to system misconfiguration or denial of service. It could also be used to overwrite another user's account file by crafting a username like ../accounts/victim_username, enabling an account takeover by changing the victim's password hash or email address.\n\nThe patch addresses this by introducing validation at multiple layers. The new User::isValidUsername and AbstractFilesystemStorage::validateKey functions explicitly check for and block path traversal sequences (..), directory separators (/, \\), and other dangerous characters in usernames and storage keys before they are used in any filesystem operations.
Grav\Common\User\DataUser\User::savesystem/src/Grav/Common/User/DataUser/User.php
Grav\Framework\Flex\Storage\FolderStorage::saveRowsystem/src/Grav/Framework/Flex/Storage/FolderStorage.php
Grav\Common\Flex\Types\Users\UserObject::savesystem/src/Grav/Common/Flex/Types/Users/UserObject.php
Grav\Framework\Flex\Storage\AbstractFilesystemStorage::validateKeysystem/src/Grav/Framework/Flex/Storage/AbstractFilesystemStorage.php