Android security tags, read closely by Lightrion

CVE-2023-40121 AI-generated analysis

platform/frameworks/base, android.database (DatabaseUtils SQL string escaping)

AI-generated: written from the bulletin and the fixing diffs by claude-fable-5-1, then checked against the code by claude-opus-5-5 (2 corrections). Verify against the commit before relying on it.

Rewrites DatabaseUtils.appendEscapedSQLString to walk every UTF-16 code unit, keep only well-formed surrogate pairs, drop unpaired (lone) high or low surrogates, and escape single quotes. Before the fix it appended the raw string verbatim when the string had no single quote.

Root cause

In core/java/android/database/DatabaseUtils.java, appendEscapedSQLString only handled the single-quote character. If the input had no '\'' it appended the whole string unchanged (fast path); otherwise it only doubled quotes. It never checked surrogate code units, so strings with malformed UTF-16 (unpaired high or low surrogates) went into the quoted SQL literal as-is. The commit message states the goal is to "detect malformed UTF-16 strings". The bulletin classifies the issue as information disclosure (ID). The material does not show the downstream mechanism by which the lone surrogates led to disclosure.

How the fix works

Completeness

Behavior changes

Per major

Unknowns

Back to October 2023 · Findings