Security Advisory

CVE-2022-35737: SQLite printf Huge-String Overflow

Last updated:
  • CVE-2022-35737

CVE-2022-35737 is an improper array-index validation (CWE-129) in SQLite's printf-family functions: a string argument longer than about 2 billion bytes formatted with %q, %Q or %w overflows a signed counter. SQL cannot reach it; an application must pass the huge string through the C API. NVD scores it 7.5.

Vulnerability summary

CVSS base score

7.5

High severity

EPSS score (FIRST)

23.6%

Probability of exploitation in the wild in the next 30 days

CISA KEV catalog

No

Not listed

Published

Vulnerability ID: CVE-2022-35737 · Source: NVD

Affected components

ComponentCPEVersion range
SQLitecpe:2.3:a:sqlite:sqlite:*:*:*:*:*:*:*:*>= 1.0.12, < 3.39.2 (NVD); fixed in 3.39.2 (2022-07-21)
Siemens SIMATIC S7-1500 CPU 1518(F)-4 PN/DP MFP and SIPLUS variant (GNU/Linux subsystem)—>= V3.1.0, < V3.1.5; fixed in V3.1.5 (Siemens SSA-398330)

What does this mean for affected devices?

NVD's description: "SQLite 1.0.12 through 3.39.x before 3.39.2 sometimes allows an array-bounds overflow if billions of bytes are used in a string argument to a C API." NVD's Primary score is CVSS v3.1 7.5 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H), matched by the CISA ADP score, with CWE-129. The record was published on 2022-08-03 (NVD). The SQLite 3.39.2 release notes (2022-07-21) say the release applies "fixes for CVE-2022-35737".

How is it reached?

Not through SQL. The SQLite Vulnerabilities page says the bug "is only accessible when using some of the C-language APIs provided by SQLite", "cannot be reached using SQL nor can it be reached by providing SQLite with a corrupt database file", and needs "very long string inputs (greater than 2 billion bytes in length)". Trail of Bits, who disclosed it on 2022-10-25, traced it to sqlite3_str_vappendf(), the formatter behind sqlite3_snprintf() and sqlite3_mprintf(): with the %q, %Q or %w escapes, a large input overflows a signed integer. They confirmed denial of service in all cases and code execution on 64-bit builds compiled without stack canaries; with the ! flag they could also make the call loop nearly forever. They found it through PHP's PDO SQLite quoting function, which passed a 64-bit length to SQLite.

Does it matter on a device?

Rarely, but it is the one SQLite CVE class that does not need attacker SQL, as our SQLite firmware guide notes. A daemon that quotes request data with sqlite3_mprintf("%q", ...) and accepts multi-gigabyte input would be exposed; Trail of Bits describes the bug as exploitable on 64-bit systems, and most small devices cap request sizes far below 2 GB. Siemens lists the CVE for the GNU/Linux subsystem of the SIMATIC S7-1500 CPU 1518(F)-4 PN/DP MFP and SIPLUS S7-1500 CPU 1518-4 PN/DP MFP from V3.1.0, fixed in V3.1.5 (SSA-398330), with the same 7.5 score. The same advisory lists the CLI flaw CVE-2022-46908. The memory corruption fix guide covers length checks on size arguments; related SQLite pages are CVE-2018-20346 and CVE-2023-7104.

How do you fix or mitigate it?

Ship SQLite 3.39.2 or later, or the vendor firmware that contains it. In application code, cap input length before formatting, and prefer bound parameters to %q quoting, which removes the call path altogether. The Debian security tracker rates the issue "unimportant" for its packages and lists 3.39.2-1 as the fixed upstream version in unstable.

CVE-2022-35737 is not in the CISA KEV catalog as of 2026-11-18 (catalog version 2026.11.17). FIRST EPSS gives it 0.23575, the 97.8th percentile, in the 2026-11-17 dataset (CISA KEV, FIRST EPSS).

How to fix this class of issueThis advisory's weakness class is Memory corruption. Our practical guide covers how to detect, fix, verify and disclose it: How to fix memory corruption in embedded firmware.

Evidence

  • NVD: SQLite 1.0.12 through 3.39.x before 3.39.2, array-bounds overflow with billions of bytes in a string argument to a C API; Primary CVSS v3.1 7.5 AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H, CISA ADP 7.5; CWE-129; published 2022-08-03. — NVD
  • SQLite 3.39.2 (2022-07-21): "Apply fixes for CVE-2022-35737". — SQLite release log
  • SQLite Vulnerabilities page: only reachable through some C APIs, not through SQL or a corrupt database file; needs strings over 2 billion bytes. — SQLite
  • Trail of Bits (2022-10-25): introduced in 1.0.12, fixed in 3.39.2; %q/%Q/%w in sqlite3_str_vappendf; DoS confirmed, code execution confirmed without stack canaries on 64-bit; found via PHP PDO SQLite quoting. — Trail of Bits
  • Siemens SSA-398330: SIMATIC S7-1500 CPU 1518(F)-4 PN/DP MFP and SIPLUS S7-1500 CPU 1518-4 PN/DP MFP >= V3.1.0 < V3.1.5 affected; update to V3.1.5; CVSS 7.5. — Siemens ProductCERT
  • Debian: sqlite3 fixed 3.39.2-1 in unstable, urgency unimportant. — Debian security tracker
  • CVE-2022-35737 is not in the CISA KEV catalog, version 2026.11.17 (1,782 entries), checked 2026-11-18. — CISA KEV
  • EPSS 0.23575, percentile 0.97841, dataset 2026-11-17. — FIRST EPSS

Related advisories

Sources

  1. NVD
  2. SQLite 3.39.2 release notes
  3. SQLite: Vulnerabilities
  4. Trail of Bits: Stranger Strings (CVE-2022-35737)
  5. Siemens SSA-398330: S7-1500 CPU 1518 MFP GNU/Linux subsystem
  6. Debian security tracker
  7. CISA KEV
  8. FIRST EPSS

Frequently asked questions

Can CVE-2022-35737 be triggered with SQL or a crafted database?

No. The SQLite project says it is reachable only through some C-language interfaces with string arguments over 2 billion bytes, not through SQL or a corrupt database file (per the SQLite Vulnerabilities page).

Which SQLite functions are involved in CVE-2022-35737?

Trail of Bits traced it to the printf-family formatter used by sqlite3_snprintf() and sqlite3_mprintf() when the format uses %q, %Q or %w. They confirmed a crash in all cases and code execution on 64-bit builds without stack canaries (per Trail of Bits).

Which Siemens devices are affected by CVE-2022-35737?

Siemens SSA-398330 lists the GNU/Linux subsystem of the SIMATIC S7-1500 CPU 1518(F)-4 PN/DP MFP and the SIPLUS S7-1500 CPU 1518-4 PN/DP MFP from V3.1.0 before V3.1.5, fixed in V3.1.5 (per Siemens ProductCERT).

Is CVE-2022-35737 in the CISA KEV catalog?

No, not as of 2026-11-18 (catalog version 2026.11.17). FIRST EPSS gives it 0.23575, the 97.8th percentile, in the 2026-11-17 dataset (per CISA KEV and FIRST EPSS).