Skip to content
Memory corruption Advisory Advanced CVE-2019-5018

Sqlite3 Window Function Remote Code Execution Vulnerability

A use-after-free flaw in SQLite's window function handling allows a crafted SQL query to free a window partition and then reuse it, causing a crash and potentially enabling code execution if the freed memory is controlled.

Cory Duplantis Follow

Originally disclosed on Cisco Talos

High 8.1 View original

An exploitable use after free vulnerability exists in the window function functionality of Sqlite3 3.26.0. A specially crafted SQL command can cause a use after free vulnerability, potentially resulting in remote code execution.

Cory Duplantis, on Cisco Talos

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the window rewrite logic deletes an expression that owns a window object, which in turn deletes the window's partition list, but the same partition list is later reused without being cleared.

Impact

The vulnerability results in a denial of service, and if an attacker can control the freed memory, there is an opportunity to corrupt more data, potentially leading to code execution.

What the attacker needed

Ability to send a crafted SQL query

The fix

The vendor patched the vulnerability.

How it was found

  1. Prepare a SQL statement that uses a window function with an aggregate function and a partition clause.
  2. Run the statement through the sqlite3 shell using the provided proof-of-concept initialisation file.
  3. Observe the crash when the freed partition is accessed again.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

SQLite is a database engine used in many apps. A use-after-free bug means the program frees a piece of memory but keeps using it, which can crash the program or let an attacker run their own code if they can control that memory.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Cory Duplantis

View all

35 more disclosed reports, best first.

More from Cisco Talos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.