Описание
Authenticated (user role) SQL injection in OrderAndPaginate (GHSL-2023-270)
Summary
The OrderAndPaginate function is used to order and paginate data. It is defined as follows:
By using DefaultQuery, the "desc" and "id" values are used as default values if the query parameters are not set. Thus, the order and sort_by query parameter are user-controlled and are being appended to the order variable without any sanitization.
The same happens with SortOrder, but it doesn't seem to be used anywhere.
This issue was found using CodeQL for Go: Database query built from user-controlled sources.
Proof of Concept
Based on this setup using
uozi/nginx-ui:v2.0.0-beta.7. In order to exploit this issue, we need to find a place where theOrderAndPaginatefunction is used. We can find it in theGET /api/dns_credentialsendpoint.
The PagingList function is defined as follows:
And the PagingListData function is defined as follows:
Using the following request, an attacker can retrieve arbitrary values by checking the order used by the query. That is, the result of the comparison will make the response to be ordered in a specific way.
You can notice the order change by changing =1 to =2, and so the comparison will return false and the order will be updated_at instead of id.
Impact
This issue may lead to Information Disclosure
Ссылки
- https://github.com/0xJacky/nginx-ui/security/advisories/GHSA-h374-mm57-879c
- https://nvd.nist.gov/vuln/detail/CVE-2024-22196
- https://github.com/0xJacky/nginx-ui/commit/ec93ab05a3ecbb6bcf464d9dca48d74452df8a5b
- https://github.com/0xjacky/nginx-ui/blob/04bf8ec487f06ab17a9fb7f34a28766e5f53885e/model/model.go#L278-L287
- https://github.com/0xjacky/nginx-ui/blob/04bf8ec487f06ab17a9fb7f34a28766e5f53885e/model/model.go#L91
- https://github.com/0xjacky/nginx-ui/blob/04bf8ec487f06ab17a9fb7f34a28766e5f53885e/model/model.go#L99C4
Пакеты
github.com/0xJacky/Nginx-UI
< 2.0.0.beta.9
2.0.0.beta.9
Связанные уязвимости
Nginx-UI is an online statistics for Server Indicators Monitor CPU usage, memory usage, load average, and disk usage in real-time. This issue may lead to information disclosure. By using `DefaultQuery`, the `"desc"` and `"id"` values are used as default values if the query parameters are not set. Thus, the `order` and `sort_by` query parameter are user-controlled and are being appended to the `order` variable without any sanitization. This issue has been patched in version 2.0.0.beta.9.
Уязвимость пользовательского интерфейса Nginx UI сервера nginx, позволяющая нарушителю получить несанкционированный доступ к защищаемой информации