Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Chromium IndexedDB on LevelDB

From ReverseEngineering.wiki
Format
License BSD-3-Clause
On this wiki Facts · Code · Notes · Topics

How Chromium and Electron store IndexedDB in a LevelDB directory (IndexedDB/<origin>.indexeddb.leveldb): every key starts with a packed database/object-store/index id prefix, global and per-database metadata live under id 0, records under index id 1, with UTF-16BE strings and a custom comparator.

Overview

Chromium (Chrome, Edge, Electron, CEF apps) keeps each origin's IndexedDB in a LevelDB directory (see Format:LevelDB database); the coding scheme is documented in content/browser/indexed_db/docs/leveldb_coding_scheme.md in the chromium repository. Values are serialized by V8 and Blink, so the record payload is not JSON. Electron apps: Library:Electron; embedded browsers: Library:Chromium Embedded Framework. Chromium also uses a custom comparator for these databases, so a generic bytewise reader may order keys wrongly (it still reads every entry).

Primitive types

Byte; Bool (one byte); Int (int64 >= 0, 8 bytes little-endian); VarInt (7 bits per byte, little-endian, high bit means more); String (UTF-16BE, length implicit); StringWithLength (VarInt count of code units, then UTF-16BE); Binary (VarInt byte length, then bytes); Double (IEEE754, host endianness).

IDBKey: first byte is the type: 0 null, 1 string (StringWithLength), 2 date (Double), 3 number (Double), 4 array (VarInt count, then keys), 6 binary.

Key prefix

Every key begins with «database id, object store id, index id». The first byte packs the lengths: top 3 bits = length of database id minus 1, next 3 bits = object store id length minus 1, low 2 bits = index id length minus 1; then the ids in little-endian (1-8, 1-8 and 1-4 bytes). Id 0 is reserved for metadata.

Global metadata (prefix 0,0,0)

Second part is a type byte: 0 schema version, 1 maximum allocated database id, 2 data format version (V8 serialization version in the high 32 bits, Blink in the low 32), 3 recovery blob journal, 4 active blob journal, 5 earliest sweep time, 201 database name entry «origin StringWithLength, name StringWithLength» mapping to the database id. 100 (free list) is obsolete.

Database metadata (prefix id,0,0)

Type byte then value: 0 origin name, 1 database name, 3 max object store id, 4 integer version (VarInt), 5 blob number generator. Object store metadata is «id,0,0,50, store id (VarInt), type»: 0 name, 1 key path, 2 auto increment, 4 last version number, 5 max index id, 7 key generator current number. Index metadata «id,0,0,100, store id, index id, type»: 0 name, 1 unique flag, 2 key path, 3 multi-entry flag.

Records

  • «db, store, 1, primary key (IDBKey)»: version (VarInt) followed by the serialized script value.
  • «db, store, 2, key»: exists entry, version (VarInt).
  • «db, store, 3, key»: external object (blob/file) table.
  • «db, store, index id >= 30, index key, sequence VarInt, primary key»: index data; value is version plus primary key.

Reversing notes

  • Blob/File payloads live in separate files next to the LevelDB directory (blob number in the ExternalObject entry); the entries are only references.
  • To dump a store: find its id via the 0,0,50 keys, iterate prefix «db,store,1», skip the version VarInt, hand the rest to a V8 ValueDeserializer (format version in the data-format key). Unverified: tag layout of the V8/Blink envelope.

See also

Format:Chromium Local Storage on LevelDB, Format:SQLite database file, Format:Snappy