Skip to main content
EPSS 0.6%top 54%

Nginx UI: Authenticated (user role) SQL injection in `OrderAndPaginate` (GHSL-2023-270) (CVE-2024-22196)

0
High
Published: 01/11/2024 (01/11/2024, 16:27:06 UTC)
Source: GCVE Database
Product: github.com/0xJacky/Nginx-UI

Description

### Summary The [`OrderAndPaginate`](https://github.com/0xjacky/nginx-ui/blob/04bf8ec487f06ab17a9fb7f34a28766e5f53885e/model/model.go#L99C4) function is used to order and paginate data. It is defined as follows: ```go func OrderAndPaginate(c *gin.Context) func(db *gorm.DB) *gorm.DB { return func(db *gorm.DB) *gorm.DB { sort := c.DefaultQuery("order", "desc") order := fmt.Sprintf("`%s` %s", DefaultQuery(c, "sort_by", "id"), sort) db = db.Order(order) ... } } ``` By using [`DefaultQuery`](https://github.com/0xjacky/nginx-ui/blob/04bf8ec487f06ab17a9fb7f34a28766e5f53885e/model/model.go#L278-L287), 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`](https://github.com/0xjacky/nginx-ui/blob/04bf8ec487f06ab17a9fb7f34a28766e5f53885e/model/model.go#L91), but it doesn't seem to be used anywhere. ```go func SortOrder(c *gin.Context) func(db *gorm.DB) *gorm.DB { return func(db *gorm.DB) *gorm.DB { sort := c.DefaultQuery("order", "desc") order := fmt.Sprintf("`%s` %s", DefaultQuery(c, "sort_by", "id"), sort) return db.Order(order) } } ``` This issue was found using CodeQL for Go: [Database query built from user-controlled sources](https://codeql.github.com/codeql-query-help/go/go-sql-injection/). #### Proof of Concept > Based on [this setup](https://github.com/0xJacky/nginx-ui/blob/04bf8ec487f06ab17a9fb7f34a28766e5f53885e/README.md?plain=1#L210) using `uozi/nginx-ui:v2.0.0-beta.7`. In order to exploit this issue, we need to find a place where the `OrderAndPaginate` function is used. We can find it in the `GET /api/dns_credentials` endpoint. ```go func GetDnsCredentialList(c *gin.Context) { cosy.Core[model.DnsCredential](c).SetFussy("provider").PagingList() } ``` The `PagingList` function is defined as follows: ```go func (c *Ctx[T]) PagingList() { data, ok := c.PagingListData() if ok { c.ctx.JSON(http.StatusOK, data) } } ``` And the `PagingListData` function is defined as follows: ```go func (c *Ctx[T]) PagingListData() (*model.DataList, bool) { result, ok := c.result() if !ok { return nil, false } result = result.Scopes(c.OrderAndPaginate()) ... } ``` 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. ```http GET /api/dns_credentials?sort_by=(CASE+WHEN+(SELECT+1)=1+THEN+id+ELSE+updated_at+END)+ASC+--+ HTTP/1.1 Host: 127.0.0.1:8080 Authorization: <<JWT TOKEN> ``` 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`

CVSS v3.1

Score 7.0high

Attack Vector
Network
Attack Complexity
High
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
Low
Availability
Low
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:L

Affected software

Goghsa
github.com/0xJacky/Nginx-UI
Affected versions
<1.9.10-0.20231219195202-ec93ab05a3ec

Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.

AI-Powered Analysis

Machine-generated threat intelligence

AILast updated: 07/06/2026, 23:51:23 UTC

Technical Analysis

The OrderAndPaginate function in github.com/0xJacky/Nginx-UI uses user-supplied query parameters 'sort_by' and 'order' to build an SQL ORDER BY clause without sanitization, resulting in an authenticated SQL injection vulnerability (CWE-89). This allows attackers to inject arbitrary SQL code into the ordering clause of database queries. The vulnerability is exploitable via the GET /api/dns_credentials endpoint, enabling attackers to influence query ordering and potentially disclose information. The issue was identified using CodeQL analysis. No official patch or fix has been referenced in the available data.

Potential Impact

An attacker with authenticated user privileges can exploit this SQL injection vulnerability to manipulate database query ordering, potentially leading to unauthorized information disclosure. The vulnerability impacts confidentiality (high), integrity (low), and availability (low) as per the CVSS vector provided. There is no evidence of known exploits in the wild at this time.

Mitigation Recommendations

Patch status is not yet confirmed — check the vendor advisory for current remediation guidance. Until an official fix is available, restrict user input for 'sort_by' and 'order' parameters to a whitelist of allowed values to prevent injection. Avoid directly embedding user input into SQL queries without proper sanitization or parameterization.

Pro Console: star threats, build custom feeds, automate alerts via Slack, email & webhooks.Upgrade to Pro

Technical Details

Gcve Source
db.gcve.eu
Osv Id
GHSA-h374-mm57-879c
Osv Schema Version
1.4.0
Aliases
["CVE-2024-22196"]
Ecosystems
["Go"]
Database Specific Severity
HIGH
Cvss Version
3.1

Threat ID: 6a4c342027e9c797195f9923

Added to database: 07/06/2026, 23:02:56 UTC

Last enriched: 07/06/2026, 23:51:23 UTC

Last updated: 09/10/2026, 19:36:47 UTC

Views: 22

Community Reviews

0 reviews

Crowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.

Sort by
Loading community insights…

Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.

Actions

PRO

Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.

Please log in to the Console to use AI analysis features.

Need more coverage?

Upgrade to Pro Console for AI refresh and higher limits.

For incident response and remediation, OffSeq services can help resolve threats faster.

Latest Threats

Breach by OffSeqOFFSEQFRIENDS — 25% OFF

Check if your credentials are on the dark web

Instant breach scanning across billions of leaked records. Free tier available.

Scan now
OffSeq TrainingCredly Certified

Lead Pen Test Professional

Technical5-day eLearningPECB Accredited
View courses