Potential directory traversal in OC\Files\Node\Folder::getFullPath
The getFullPath method in Nextcloud's Folder class validates a path before normalising it, so a path containing backslashes can bypass the check and become a directory traversal after normalisation. An attacker could use this to create files or folders outside their own space and overwrite other users' data.
Originally disclosed on HackerOne
- Triaged in under an hour
- Fixed in 55 days
- Disclosed after 6 months
Summary by the program
https://github.com/nextcloud/security-advisories/security/advisories/GHSA-273v-9h7x-p68v
The report
https://github.com/nextcloud/server/blob/67551f379f3105d117b9d19095dd381450fe40dd/lib/private/Files/Node/Folder.php#L68-L73 is validating and normalizing the string in the wrong order.
Validation checks for /../ kind of situations and normalizePath later on replaces \ with /, so it would be possible to get /../ again.
public function getFullPath($path) {
if (!$this->isValidPath($path)) {
throw new NotPermittedException('Invalid path');
}
return $this->path . $this->normalizePath($path);
}
Impact
The function seems to be used in newFile() and newFolder() items, allowing to create paths outside of ones own space and overwriting stuff from others.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the path validation is performed before normalisation, so a path that looks safe before normalisation can become a traversal sequence afterwards.
Impact
The function is used in newFile() and newFolder(), so an attacker could create paths outside their own space and overwrite other users' files.
What the attacker needed
Access to create files or folders
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you upload or create a file, the server checks the path to make sure you are not trying to escape your own folder using '..'. Here the check happens before the path is cleaned up, so a cleverly written path can sneak past the check and end up pointing outside your area.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.