Synology DSM Auth API Pre-Auth SQL Injection via Escape Truncation (CVE-2026-76954)
Published: 2026-11-25 • Researcher: Lê Hiếu (googlesky), repository owner; credited by the vendor: Nguyễn Bá Nam Dũng (@greengrass19000), Hà Thế Long (LongHT), Viettel Cyber Security Research Lab (@vcslab), and Warisse Valentin (Aytio)
- Severity
- Critical
- CVE
- CVE-2026-76954 / Synology-SA-26:19
- Category
- web
- Affected product
- Synology DiskStation Manager (DSM) Auth API — libsyno-pam-login.so.7.0 (SynoPamKeyImpl::DBEscapeStrings), writing to syno-pam-key.db through libsynodb.so
- Affected versions
- DSM before 7.2.1-69057-13, before 7.2.2-72806-10, before 7.3.2-86009-5, and before 7.4.1-90080-1 (NVD). The upstream lab confirms 7.2.1-69057-12, 7.2.2-72806, 7.3.2-86009 and 7.4.1-90080 as vulnerable
- Disclosed
- 2026-11-25
- Patch status
- Unverified
Tags
References
- https://nvd.nist.gov/vuln/detail/CVE-2026-76954
- https://www.synology.com/en-global/security/advisory/Synology_SA_26_19
- https://github.com/googlesky/CVE-2026-76954
- https://www.cve.org/CVERecord?id=CVE-2026-76954
- https://lab.viettelcybersecurity.com/advisories/cve-2026-76954
- https://www.sqlite.org/c3ref/mprintf.html
Archive entry
intelseclab/poc-archiveOn this page
Metadata
| Field | Value |
|---|---|
| Date Added | 2026-11-25 |
| Last Updated | 2026-11-19 |
| Author / Researcher | Lê Hiếu (googlesky), repository owner; credited by the vendor: Nguyễn Bá Nam Dũng (@greengrass19000), Hà Thế Long (LongHT), Viettel Cyber Security Research Lab (@vcslab), and Warisse Valentin (Aytio) |
| CVE / Advisory | CVE-2026-76954 / Synology-SA-26:19 |
| Category | web |
| Severity | Critical |
| CVSS Score | 9.8 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H) |
| Status | PoC (lab-only differential) |
| Tags | SQLi, CWE-89, Synology DSM, Auth API, pre-auth, unauthenticated, escape-truncation, stacked-SQL, sqlite, PAM |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | Synology DiskStation Manager (DSM) Auth API — libsyno-pam-login.so.7.0 (SynoPamKeyImpl::DBEscapeStrings), writing to syno-pam-key.db through libsynodb.so |
| Versions Affected | DSM before 7.2.1-69057-13, before 7.2.2-72806-10, before 7.3.2-86009-5, and before 7.4.1-90080-1 (NVD). The upstream lab confirms 7.2.1-69057-12, 7.2.2-72806, 7.3.2-86009 and 7.4.1-90080 as vulnerable |
| Language / Platform | C/C++ proprietary DSM libraries; Linux x86_64 on Synology NAS; lab images run Ubuntu 22.04 containers |
| Authentication Required | No |
| Network Access Required | Yes |
Summary
Synology DSM’s Auth API builds a SQLite INSERT for the per-device login key database and escapes each string field through a shared fixed 4096-byte buffer. The SQLite backend doubles single quotes and then truncates the escaped result with snprintf, so an input whose escaped form is exactly 4096 bytes loses one quote of a doubled pair at the cut. That odd quote count escapes the string literal in the generated statement, and the next attacker-controlled pre-auth field is parsed as raw SQL and executed as a stacked statement. An unauthenticated network attacker can read or write files and cause denial of service according to the vendor advisory; the public PoC demonstrates the split-quote primitive and a stacked CREATE TABLE against the real, unmodified DSM libraries.
Vulnerability Details
Root Cause
Each of the seven string fields written by SynoPamKeyImpl::Save (id, user, scope, key, attribute1, attribute2, extrainfo) is escaped by SynoPamKeyImpl::DBEscapeStrings, which in the affected builds calls SYNODBEscapeStringEX with a fixed 4096-byte global buffer. The SQLite backend in libsynodb.so implements that escape as sqlite3_mprintf("%q", input) followed by snprintf(out, 4096, "%s", escaped). Because %q doubles every single quote, an input of 4094 A characters plus one quote escapes to 4096 bytes, and snprintf keeps only 4095: 4094 A characters plus a lone quote.
SynoPamKeyImpl::Save then builds the INSERT with the escaped values as template constants. The dangling quote pairs with the template’s next quote, which swallows the comma separator, closes the string literal at the following template quote, and leaves the attacker-supplied user body as raw SQL. SYNODBExecute runs the statement through sqlite3_get_table, which executes stacked statements. The fixed builds replace the fixed-buffer escape with SYNODBEscapeStrAllocEX, which allocates 2*len+1 bytes and never truncates — the fix is a single call-site change, confirmed by the upstream function-by-function comparison of the vulnerable and fixed libraries.
Attack Vector
The device_id parameter of an Auth API login is attacker-controlled before authentication. It flows through SynoPAMLogin_V2, into the syno-otp-trust-device-id PAM environment entry, through pam_syno_otp.so in the webui PAM stack, and into SynoPamKey::SetID / SynoPamKey::Save, which writes a row to /usr/syno/etc/private/session/syno-pam-key.db. A login request whose device_id is 4094 A characters plus a single quote and whose user field starts with ,1,1,1,1,1,1,1); <SQL>; -- completes the eight-column VALUES list, terminates the INSERT, executes the injected statement, and comments out the remaining template.
The archived lab exposes this pre-auth path as POST /login and feeds the fields into the real library through a driver that calls the same exported SynoPamKey::* symbols. On a live DSM device the equivalent fields must reach the same pre-auth login path; the repository does not ship a turnkey client for the production HTTP API.
Impact
Arbitrary SQL execution in syno-pam-key.db, including stacked statements. The PoC’s observable impact is creation of the poc_marker table; arbitrary CREATE, DROP, INSERT and similar statements are equally possible within the database. The vendor advisory describes the impact as reading and writing arbitrary files and denial of service. Because the database holds per-device login keys used by the trust-device PAM stack, tampering with its rows can affect device-trust records. No memory corruption or code execution is involved, and the impact is bounded by the SQLite file and the privileges of the PAM/auth process.
Environment / Lab Setup
OS: Linux x86_64 with Podman (the scripts call podman; rootless or rootful)
Target: Container running the real, unmodified Synology DSM 7.2.2-72806
libsyno-pam-login.so.7.0 and libsynodb.so, plus the fixed
7.2.2-72806-10 build; libraries reconstructed from public firmware
Attacker: python:3.12-slim PoC runner container on the cve202676954lab network
Tools: podman, python3 (stdlib only), g++, sqlite3, curl
Limits: each container is bounded to --cpus 2 --memory 4gSetup Steps
| |
Use run-lab.sh rather than make: the committed Makefile still points at the pre-restructure lab/src/harness/Dockerfile path, so its build target does not match the current tree. The firmware must be downloaded from Synology’s public CDN; the proprietary libraries are not redistributed in the repository.
Proof of Concept
Step-by-Step Reproduction
- Prepare and build the lab —
./run-lab.sh preparereconstructs the vulnerable and fixedlibsyno-pam-login.so.7.0plus the sharedlibsynodb.sofrom public DSM firmware, then./run-lab.sh buildbuilds the Ubuntu-based lab image and the Python PoC runner. - Start both services —
./run-lab.sh upstartscve202676954-vulnandcve202676954-fixedon the dedicatedcve202676954labbridge network. The vulnerable container selectslibsyno-pam-login-vuln.so, the fixed one selectslibsyno-pam-login-fixed.so. - Send the crafted login — the payload sets
device_idto 4094Acharacters plus a single quote (escaped length 4096, truncated to 4095) anduserto the injection body that closes the VALUES list and appends a stacked statement. - Observe the generated SQL and database state — the lab’s
LD_PRELOADshim logs every statement handed tosqlite3_get_table; the service also reports the child exit code and whetherpoc_markerexists. - Confirm the differential — the vulnerable library creates
poc_marker; the fixed library stores the same payload as data and never creates the table.
Exploit Code
See
exploit/exploit.py(standalone full-chain runner) andpoc/cve202676954.py(four-mode PoC with documented exit codes). The lab harness is inlab/.
Minimal payload shape:
| |
| |
Expected Output
Vulnerable build (7.2.2-72806, truncated escape):
| |
Fixed build (7.2.2-72806-10, full-length escaping) stores the payload as data, leaves the literal balanced (sql_len=4281), and reports marker=False, exit code 1.
Detection & Indicators of Compromise
- SQL handed to
sqlite3_get_tablefor the key database with an unbalanced quote and a stacked statement, typically a longINSERT OR REPLACE INTO key(...)(around 4280 bytes when the exploit fires) followed by; CREATE TABLE,; DROP,; ATTACHor similar. - Auth API login requests with an oversized
device_id(near or above 4095 bytes, often a long run of one character ending in a quote) or with SQL metacharacters inuser/ sibling fields. - Unexpected table or row changes in
/usr/syno/etc/private/session/syno-pam-key.db, or a key table row whoseidis exactly 4095/4096 bytes. - PAM/
webuiauthentication errors or crashes clustered with the above, especially on DSM builds older than the fixed versions.
Example SQL trace (lab LD_PRELOAD shim):
| |
Example IDS rule (tune to the deployed Auth API encoding):
| |
The lab service accepts JSON on /login; production DSM request encoding and logging are documented in the references. Treat alerts as triage signals and confirm against the database state.
Remediation
| Action | Detail |
|---|---|
| Patch | Upgrade DSM to 7.2.1-69057-13, 7.2.2-72806-10, 7.3.2-86009-5 or 7.4.1-90080-1 (or later). The fix replaces the fixed-buffer escape with an allocating escape that never truncates. |
| Workaround | Synology publishes no software workaround for CVE-2026-76954; the advisory requires upgrading. Reduce exposure by keeping the DSM Auth API and management interface off the public internet and restricting them to trusted networks. |
| Config Hardening | If the login path is exposed through a reverse proxy or WAF, cap device_id and the sibling escaped fields (strictly below 4000 bytes in the upstream tests) and bound the escaped length, not just the raw length; a naive 4096-byte cap does not stop the injection. Monitor writes to syno-pam-key.db and PAM/authentication logs. |
References
Notes
Auto-ingested from https://github.com/googlesky/CVE-2026-76954 on 2026-11-25.
Review verdict: this is a genuine proof of concept, not a detector or scanner. It exploits the truncating escape with the real, unmodified Synology libraries and reports confirmed database impact (a stacked CREATE TABLE poc_marker), with a benign control and a vulnerable-versus-fixed differential across all four affected branches. The upstream repository is MIT licensed (Copyright 2026 Lê Hiếu); the archived files retain attribution and the upstream README is included as upstream-README.md. The exploit scripts carry a research-only header added during ingestion.
Limitations: the PoC is lab-bound. It drives a purpose-built service that exposes the pre-auth device_id/user fields over POST /login and calls the exported SynoPamKey::* symbols through a C++ driver; it does not ship a client for the production DSM HTTP Auth API, so a real target must be reachable through the vendor’s actual login path. The proprietary libraries are not redistributed: prepare downloads roughly 1.5 GB of public firmware and recovers archive constants at build time, which requires network access and Podman. The committed Makefile still references a pre-restructure lab/src/harness/Dockerfile path, so use run-lab.sh. Expected output above is transcribed from the upstream evidence/ captures (not copied into this entry). No exploit code was executed during ingestion, and nothing here was tested against a live DSM device.
| |