Security Advisory

CVE-2022-46908: SQLite CLI --safe Bypass

Last updated:
  • CVE-2022-46908

CVE-2022-46908 is a flaw in the --safe option of the sqlite3 command-line shell, not in the SQLite library: from 3.37.0 through 3.40.0 a script run with --safe could still call writefile() and readfile(). NVD scores it 7.3 as a local issue. SQLite 3.40.1 fixes it.

Vulnerability summary

CVSS base score

7.3

High severity

EPSS score (FIRST)

0.5%

Probability of exploitation in the wild in the next 30 days

CISA KEV catalog

No

Not listed

Published

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

Affected components

ComponentCPEVersion range
SQLite command-line shell (sqlite3)cpe:2.3:a:sqlite:sqlite:*:*:*:*:*:*:*:*>= 3.37.0, < 3.40.1 (NVD); the library is not affected
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)
Siemens TeleControl Server Basic V3—before V3.1.2; fixed in V3.1.2 (Siemens SSA-556635)

What does this mean for affected devices?

NVD's description: "SQLite through 3.40.0, when relying on --safe for execution of an untrusted CLI script, does not properly implement the azProhibitedFunctions protection mechanism, and instead allows UDF functions such as WRITEFILE." NVD's Primary score is CVSS v3.1 7.3 (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L), matched by the CISA ADP score; NVD records the weakness as NVD-CWE-Other. The CPE range is 3.37.0 up to, not including, 3.40.1, and the record was published on 2022-12-12 (NVD).

What is --safe and what went wrong?

The --safe option arrived in SQLite 3.37.0 to disable "dot-commands and SQL statements that might cause side-effects that extend beyond the single database file named on the command-line", so that a script from an unknown source can be run without risk. On 2022-12-04 a user showed on the SQLite forum that sqlite3 --safe on 3.40.0 still ran writefile() and readfile(). The 3.40.1 release notes (2022-12-28) say the release fixes "the --safe command-line option to the CLI such that it correctly disallows the use of SQL functions like writefile() that can cause harmful side-effects."

Does it matter on a device?

Only where firmware ships the sqlite3 shell and something feeds it scripts from outside while relying on --safe. The SQLite Vulnerabilities page says the bug "does not exist in the SQLite library", is not an issue "as long as the user does not depend on the --safe option", and that "it is debatable whether or not this is a security issue." Siemens lists it in SSA-398330 for the GNU/Linux subsystem of the SIMATIC S7-1500 CPU 1518(F)-4 PN/DP MFP, fixed in V3.1.5, and in SSA-556635 for TeleControl Server Basic V3, fixed in V3.1.2, both at 7.3. A scanner hit on libsqlite3 alone is not a hit; check for the shell binary. OpenWrt packages the shell separately as sqlite3-cli (Makefile). The SQLite firmware guide covers this split; related SQLite pages are CVE-2022-35737, CVE-2023-7104 and CVE-2019-19646.

How do you fix or mitigate it?

Update the shell to 3.40.1 or later, or apply the vendor firmware. Better still, leave the CLI out of production images and do not run untrusted SQL scripts on a device at all; --safe is a convenience, not a sandbox.

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

How to fix this class of issueNo dedicated SoftWSP guide covers this weakness class; the fix is usually the vendor patch or firmware update referenced above. Our related guide explains how to plan and verify it: NIST SP 800-40 Rev. 4: enterprise patch management planning, explained.

Evidence

  • NVD: SQLite through 3.40.0 with --safe for an untrusted CLI script does not implement azProhibitedFunctions properly and allows WRITEFILE; Primary CVSS v3.1 7.3 AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:L, CISA ADP 7.3; NVD-CWE-Other; CPE >= 3.37.0 < 3.40.1; published 2022-12-12. — NVD
  • SQLite 3.37.0: adds the --safe command-line option. — SQLite release log
  • SQLite forum 2022-12-04: sqlite3 3.40.0 --safe still runs writefile() and readfile(). — SQLite forum
  • SQLite 3.40.1 (2022-12-28): fix --safe so it disallows SQL functions like writefile(). — SQLite release log
  • SQLite Vulnerabilities page: not a bug in the core library; not an issue unless relying on --safe; debatable whether a security issue. — SQLite
  • Siemens SSA-398330: S7-1500 CPU 1518(F)-4 PN/DP MFP >= V3.1.0 < V3.1.5, fix V3.1.5, CVSS 7.3. — Siemens ProductCERT
  • Siemens SSA-556635 (2024-04-09): TeleControl Server Basic V3 affected, update to V3.1.2, CVSS 7.3. — Siemens ProductCERT
  • OpenWrt packages libs/sqlite3 builds the shell as a separate sqlite3-cli package. — OpenWrt packages
  • CVE-2022-46908 is not in the CISA KEV catalog, version 2026.11.17 (1,782 entries), checked 2026-11-18. — CISA KEV
  • EPSS 0.00455, percentile 0.40020, dataset 2026-11-17. — FIRST EPSS

Related advisories

Sources

  1. NVD
  2. SQLite forum: --safe does not prevent writefile()
  3. SQLite 3.40.1 release notes
  4. SQLite 3.37.0 release notes
  5. SQLite: Vulnerabilities
  6. Siemens SSA-398330
  7. Siemens SSA-556635: TeleControl Server Basic
  8. OpenWrt packages: sqlite3 Makefile
  9. CISA KEV
  10. FIRST EPSS

Frequently asked questions

Does CVE-2022-46908 affect the SQLite library?

No. The SQLite project says the bug is in the --safe option of the command-line shell and does not exist in the library. A device that links libsqlite3 but does not ship the sqlite3 shell is not exposed (per the SQLite Vulnerabilities page).

Which versions of the sqlite3 shell are affected by CVE-2022-46908?

NVD lists 3.37.0, the release that introduced --safe, up to but not including 3.40.1. SQLite 3.40.1 fixed --safe so it blocks functions like writefile() (per NVD and the SQLite release log).

Which Siemens products list CVE-2022-46908?

Siemens SSA-398330 lists the GNU/Linux subsystem of the SIMATIC S7-1500 CPU 1518(F)-4 PN/DP MFP, fixed in V3.1.5, and SSA-556635 lists TeleControl Server Basic V3, fixed in V3.1.2 (per Siemens ProductCERT).

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

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