[Bug]: GET /js/../<anything> returns 500 (NotPermittedException from JsController::getJs) instead of 404
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
Línea de trabajo
El fallo comienza en getJs() en core/Controller/JsController.php, alrededor de la línea 56, donde se llama a AppData::getFolder() con el appName proporcionado por el usuario. Ese método solo captura NotFoundException, así que la NotPermittedException de una ruta con .. escapa como un 500. Puedes capturar NotPermittedException junto a ella y devolver una NotFoundResponse, o rechazar appName y fileName que contengan .. antes de la búsqueda. Está terminado cuando curl --path-as-is https://<host>/js/../.htpasswd devuelve 404 y no se registra ninguna entrada de nivel 3, y las pruebas existentes de JsController siguen pasando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Bug description
A request whose path is /js/../<something> reaches OC\Core\Controller\JsController::getJs() with appName = "..". AppData::getFolder('..') throws OCP\Files\NotPermittedException: Invalid path "/appdata_<instanceid>/js/..". getJs() only catches NotFoundException, so the exception isn't handled and the client gets HTTP 500 (logged at level 3) instead of a 404.
The path check itself works (nothing outside the js app-data folder is read), so this isn't a security problem. The only issue is the status code and the error-level log entry. Vulnerability scanners send paths like this all the time (ours did: GET /js/../.htpasswd), so every scan leaves 500s and errors in nextcloud.log. That looks like a server fault and sets off "5xx from the web server" alerts.
The same code is still on master (core/Controller/JsController.php, getJs(): catch (NotFoundException $e) only).
Steps to reproduce
curl --path-as-is -s -o /dev/null -w '%{http_code}\n' 'https://<nextcloud>/js/../.htpasswd'
(--path-as-isstops curl from collapsing the..; scanners send it raw.)- See
500, and in nextcloud.log an error at level 3 with url/js/../.htpasswd.
In our case Apache first refused /.htpasswd itself (the stock <FilesMatch "^\.ht"> deny), and the ErrorDocument 403 /index.php/error/403 from Nextcloud's .htaccess handed the request to Nextcloud with the original request URI. So Nextcloud's router matched /js/{appName}/{fileName} with appName = "..". Any other /js/../<x> that ends up in index.php should take the same path.
Expected behavior
404 (NotFoundResponse), as for any other missing js file, with no error in the log. For example, also catch NotPermittedException in getJs() (the getFolder() call and getFile()), or reject appName / fileName values containing .. before touching app data.
Nextcloud Server version
35 (35.0.3)
Operating system
Other (Ubuntu 26.04.1 LTS)
PHP engine version
PHP 8.4 (8.4.28, php-fpm)
Web server
Apache (supported)
Database engine version
MySQL (9.7.4)
Nextcloud Logs
{"level":3,"app":"index","method":"GET","url":"/js/../.htpasswd","version":"35.0.3.2",
"message":"Invalid path \"/appdata_<instanceid>/js/..\"",
"exception":{"Exception":"OCP\\Files\\NotPermittedException","Message":"Invalid path \"/appdata_<instanceid>/js/..\"",
"File":"lib/private/Files/Node/Folder.php","Line":62,
"Trace":[
"OC\\Files\\Node\\Folder->getFullPath",
"OC\\Files\\Node\\LazyFolder->__call lib/private/Files/Node/LazyFolder.php:67",
"OC\\Files\\Node\\LazyFolder->getFullPath lib/private/Files/Node/LazyFolder.php:419",
"OC\\Files\\Node\\LazyFolder->get lib/private/Files/Node/LazyFolder.php:121",
"OC\\Files\\AppData\\AppData->getFolder lib/private/Files/AppData/AppData.php:105",
"OC\\Core\\Controller\\JsController->getJs core/Controller/JsController.php:56",
"OC\\AppFramework\\Http\\Dispatcher->executeController lib/private/AppFramework/Http/Dispatcher.php:198",
"OC\\AppFramework\\Http\\Dispatcher->dispatch lib/private/AppFramework/Http/Dispatcher.php:86",
"OC\\AppFramework\\App::main lib/private/AppFramework/App.php:138",
"OC\\Route\\Router->match lib/private/Route/Router.php:324",
"OC::handleRequest lib/OC.php:1235"]}}
(trimmed: trace shortened, instance id, host and addresses removed)
Additional info
Found by a scheduled outside-in vulnerability scan of our own instance.
- Lenguaje dominante
- PHP
- Estrellas
- 37.6k
- Forks
- 5.4k
- Merge medio
- 1 d 16 h
- PR fusionados (30 d)
- 660
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de nextcloud/server
-
35-feedback
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
[Bug]:Posiblemente ocupada @lazerg la tomó hoy. Abierto0. Needs triage 35-feedback bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Link share editor: "Custom permissions" is checked for a new link sharePosiblemente ocupada @lazerg la tomó hoy. Abierto0. Needs triage bug feature: sharing regression
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
0. Needs triage 35-feedback bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
Todos los issues de nextcloud/server
Issues similares
-
bug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
quantum-php/framework#692 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 70/100
ajeetraina/awesome-docker-sbx#559 ·
-
PHP 8.6 supportAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Saisie des adressesAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
pantaflex44/Tiquettes#116 · 1 comentario ·
-
dependencies enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
novalo-dev/Prestashop-MCP-Server#329 ·
Los mantenedores suelen responder en 1 día