mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-06 05:53:25 +01:00
docs: rewrite the RFCs as an outline of the decisions (#681)
21 RFCs repeated the code's names, steps, lists, and version history, so one rename touched eleven of them; eight short ones now keep only what was decided and why, and change only when a decision does.
This commit is contained in:
1 parent
2c3ac7f1d2
commit
c86f54a010
31 files changed
+240
-3287
No files matched your search
@@ -41,7 +41,7 @@ go mod verify
|
||||
|
||||
## Chrome ABE Payload (Windows only)
|
||||
|
||||
Chrome 127+ cookies (v20) decrypt via a C payload reflectively injected into `chrome.exe`. Sources in `internal/abe/native/`; design in [RFC-016](rfcs/016-chrome-abe-integration.md).
|
||||
Chrome 127+ cookies (v20) decrypt via a C payload reflectively injected into `chrome.exe`. Sources in `internal/abe/native/`.
|
||||
|
||||
```bash
|
||||
make payload # build the DLL (needs zig: brew install zig)
|
||||
@@ -56,13 +56,13 @@ make payload-clean # rm internal/abe/payload/*.bin
|
||||
## Code Conventions
|
||||
|
||||
- **Platform code**: use build tags (`_darwin.go`, `_windows.go`, `_linux.go`)
|
||||
- **C payload**: all sources in `internal/abe/native/` are first-party (no vendored C). See RFC-016 §9.2 for why Stephen Fewer's reflective loader was rejected.
|
||||
- **C payload**: all sources in `internal/abe/native/` are first-party (no vendored C); `rfcs/003-secrets.md` says why.
|
||||
- **Error handling**: `fmt.Errorf("context: %w", err)` for wrapping, never `_ =` to ignore errors
|
||||
- **Logging**: `log.Debugf` for record-level diagnostics, `log.Infof` for user-facing progress/status, `log.Warnf` for unexpected conditions. Extract methods should return errors, not log them.
|
||||
- **Naming**: follow Go conventions and the settled names in `rfcs/004-naming-decisions.md` — `browser.Browser` not `BrowserConfig`, `Extract` not `BrowsingData`; spell names out (`extractors`, `snapshotDir`, `profile`), leaving only `i`/`j`, `err`, `ctx`, `ok`, `t`/`tb`, `id`, `iv`, `db`, `fd`, `n`, and one-letter receivers short (`varnamelen` enforces it)
|
||||
- **Naming**: follow Go conventions and the naming rules in `rfcs/001-architecture.md`; spell names out (`extractors`, `snapshotDir`, `profile`), leaving only `i`/`j`, `err`, `ctx`, `ok`, `t`/`tb`, `id`, `iv`, `db`, `fd`, `n`, and one-letter receivers short (`varnamelen` enforces it)
|
||||
- **Comments**: none by default; when one is needed, one line of at most 120 characters that says why, never what the code does (up to 3 lines only when the reason cannot fit); a comment on a declaration starts with its name (`// AssertJSONFallback checks …`)
|
||||
- **Tests**: `internal/browser/browsertest` builds real fixture files (SQLite, JSON, LevelDB, plist) into a `t.TempDir()` — never a live browser, never a database mock; goldens live in each package's `testdata/` and `HBD_UPDATE_GOLDEN=1 go test ./...` regenerates them
|
||||
- **Architecture**: see `rfcs/README.md` — design RFCs 000–011, format and technique RFCs 013–021
|
||||
- **Architecture**: see `rfcs/README.md` — eight short RFCs on the decisions behind the design; an RFC changes only when a decision does, never for a refactor
|
||||
|
||||
## Key Constraints
|
||||
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
# RFC-000: Goals & Constraints
|
||||
|
||||
## Context
|
||||
|
||||
HackBrowserData extracts and decrypts local browser data (passwords, cookies, history, bookmarks, and related artifacts) from Chromium-based browsers, Firefox, and Safari across Windows, macOS, and Linux. It is MIT-licensed, widely used, and was presented at DEF CON. Its structure is a redesign of a codebase that worked but had grown in layers:
|
||||
|
||||
- a `Browser` interface whose constructor discovers profiles and whose `Extract` does acquisition, key retrieval, decryption, and result assembly in one call, re-implemented per browser;
|
||||
- per-OS `platformBrowsers()` lists of `types.BrowserConfig`, joined by key to a separate Windows `winutil.Table`, plus `ChromiumYandex` / `ChromiumOpera` kinds switched on across files;
|
||||
- discovery, validation, and output concerns tangled into the command handlers (`-c` and `-f` are checked only after discovery and the keychain prompt).
|
||||
|
||||
The redesign is of the _structure_. The decryption and acquisition techniques are published and sit behind stable package boundaries; the design is how the program is assembled around them.
|
||||
|
||||
## Goals
|
||||
|
||||
1. **Reference-grade architecture.** A newcomer should be able to read `internal/app` top to bottom and understand the whole run. The pipeline is explicit, not emergent.
|
||||
2. **Operator experience.** Usage errors fail before any browser is touched or any keychain prompt appears. Every browser/data-type pair yields a reported outcome. Secrets are retrieved only when the requested output needs them. Output is deterministic.
|
||||
3. **Compatibility.** Nobody's command line, script, or output parser has to change (see the contract below).
|
||||
4. **Code quality that lasts.** Adding a browser, a data type, or an output format is a single, documented, test-covered motion. No hidden coupling between stages.
|
||||
5. **Showcase readiness.** The tree, the names, and the data flow are good enough to put on a slide.
|
||||
|
||||
## Non-goals
|
||||
|
||||
- **No new capability.** No new browsers beyond those already supported, no new bypasses, no new decryption techniques. The work is organizational and qualitative.
|
||||
- **No interface changes.** No renamed commands or flags, no new defaults, no new exit codes, no output schema changes. Additive, opt-in surface is allowed only where a DECIDED item calls for it ([RFC-009](009-cli-surface.md)).
|
||||
- **No network features.** The tool stays fully offline. No telemetry, no update checks, no remote anything.
|
||||
- **No GUI.** CLI only.
|
||||
- **No public library API.** The module is consumed through its CLI. Everything below `cmd/` lives in `internal/` (see [RFC-002](002-package-layout.md)); the module path does not change and there is no v2.
|
||||
|
||||
## The compatibility contract (DECIDED)
|
||||
|
||||
The external interface is frozen at v1.1.0: every item below behaves exactly as it did there, and a compatibility test suite pins it ([RFC-011](011-testing-and-quality.md)).
|
||||
|
||||
| Surface | Frozen as |
|
||||
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Commands | `dump` (also the no-subcommand default, with its flags mirrored on the root), `dumpkeys`, `archive`, `restore`, `list`, `version` |
|
||||
| Flags | every flag's name, shorthand, type, and default, on every command ([RFC-009](009-cli-surface.md)) |
|
||||
| Default selection | `-b all`, `-c all`, `-f json`, `-d results` |
|
||||
| Output files | one `<category>.<ext>` per non-empty category (`password.csv`, `cookie.json`, …); `--zip` packs them into `<dir>/<basename(dir)>.zip` |
|
||||
| Formats | `csv` (UTF-8 BOM), `json` (two-space indent, v1.1.0's HTML escaping), `cookie-editor` |
|
||||
| Fields | snake_case keys and columns, `browser` and `profile` first, then v1.1.0's fields in v1.1.0's order |
|
||||
| Browser, profile | `browser` = the display name (`Chrome`, `Microsoft Edge`); `profile` = v1.1.0's profile name ([RFC-003](003-core-types.md)) |
|
||||
| `keys.json` | dump version `"2"`, v1.1.0's schema, readable by v1.1.0 |
|
||||
| Archive | zip layout `<browser-key>/<User Data layout>`, readable by v1.1.0 `restore` |
|
||||
| Exit status | `0` when the run completes (including partial results and "no browsers found"); `1` when it cannot start or finish |
|
||||
|
||||
Not part of the contract: log lines and the human-readable summary on stderr, and row order where v1.1.0's order is unspecified or wrong. Output differs from v1.1.0 only for listed bug fixes where v1.1.0's output was wrong — Firefox history order, Firefox bookmark fields, Safari bookmark IDs, Firefox logins from a profile whose key cannot be recovered, Yandex logins and cards whose data key cannot be recovered, the `browser` value `restore` sets, CocCoc cookies on a Windows machine that also has Yandex, and the `--zip` archive's file mode ([RFC-008](008-output-and-export.md)); each is called out where it is fixed.
|
||||
|
||||
## Hard constraints
|
||||
|
||||
| Constraint | Reason |
|
||||
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Builds on **Go 1.20** | Windows 7 support. No `log/slog`, `slices`, `maps`, `cmp`, or any stdlib addition from 1.21+. |
|
||||
| Dependency **pins** | `modernc.org/sqlite` v1.31.1, `tidwall/gjson` < v1.19, `golang.org/x/term` < v0.30, `golang.org/x/sys` at v0.30.0 — later releases raise their `go` directive above 1.20 ([RFC-010](010-dependencies.md)). |
|
||||
| **Compatible interface** | The contract above. |
|
||||
| **MIT** license | Project licensing; third-party license hygiene per [RFC-010](010-dependencies.md). |
|
||||
| **Windows / macOS / Linux** | Existing supported matrix; no platform regressions. |
|
||||
| Fully **offline** | Security tool run on evidence; it must not emit traffic. |
|
||||
|
||||
## Guiding principles
|
||||
|
||||
These are the invariants every later RFC is built on.
|
||||
|
||||
- **One explicit pipeline.** A run is a fixed sequence of stages (see [RFC-001](001-architecture-and-pipeline.md)). Stages do not call back into each other; data flows one way.
|
||||
- **Snapshot-first.** Acquisition copies the browser's files into a snapshot; every parser reads only from the snapshot, never from the live profile, and acquisition is a stage with its own contract ([RFC-007](007-snapshot-and-acquisition.md)). A dump captures one user data dir at a time and removes its copies before the next, so copied secrets never outlive the extractions that read them.
|
||||
- **Lazy secrets.** Keys are retrieved, and the macOS login keychain is opened, on the first decrypt that needs them, not at discovery time. A run that only touches non-secret data never prompts: `dump -b chrome -c history` on macOS opens no keychain.
|
||||
- **Outcome per extraction.** Each extraction, one (user data dir, profile, data-type) unit, produces an outcome — `ok`, `partial`, `absent`, `unsupported`, or `error` — and the run reports all of them, together with any failure above an extraction, such as a user data dir that cannot be read. A single failure never aborts the rest.
|
||||
- **Wire names follow Go names.** JSON keys and CSV columns are the snake_case form of the Go field names, enforced by lint. Because output is frozen, the record field names are frozen with it. (DECIDED)
|
||||
- **`internal/` only.** No `pkg/`, no root-level library. With no exported Go API there is no Go-level compatibility to keep; the CLI contract above is the only compatibility obligation.
|
||||
|
||||
## What success looks like
|
||||
|
||||
- `go build ./cmd/hack-browser-data/` on a clean Go 1.20 toolchain, cross-compiling to all three OSes.
|
||||
- The same snapshot produces the output files v1.1.0 produced, byte for byte, except for the listed bug fixes.
|
||||
- Every command's flag set — names, shorthands, types, defaults — matches v1.1.0's, plus the additive `--keychain-pw-stdin`.
|
||||
- A usage error (`-f bogus`) exits `1` before discovery and before any keychain prompt.
|
||||
- A run with no decryptable targets still exits `0` and reports `absent`/`unsupported` honestly.
|
||||
- Adding a plain Chromium fork touches the browser table and nothing structural.
|
||||
- The dependency set is justified line-by-line in [RFC-010](010-dependencies.md).
|
||||
@@ -0,0 +1,41 @@
|
||||
# RFC-000: Goals & Constraints
|
||||
|
||||
HackBrowserData is an MIT-licensed, cross-platform security-research tool. Its structure serves the goals below, within the constraints that follow.
|
||||
|
||||
## Goals
|
||||
|
||||
1. **A reference-grade architecture.** A newcomer can read the pipeline top to bottom and understand the whole run.
|
||||
2. **A good operator experience.** Usage errors fail before anything is touched, every requested browser and data type gets a reported outcome, secrets are fetched only when the output needs them, and output is deterministic.
|
||||
3. **Compatibility.** No command line, script, or output parser has to change.
|
||||
4. **Quality that lasts.** Adding a browser, a data type, or an output format is one small, tested change.
|
||||
|
||||
## Non-goals
|
||||
|
||||
- **No new capability.** No targets, bypasses, or techniques beyond those already published.
|
||||
- **No interface changes** beyond additive, opt-in ones.
|
||||
- **No network.** The tool stays fully offline: no telemetry, no update checks.
|
||||
- **No GUI and no library API.** The CLI is the only way in.
|
||||
|
||||
## Hard constraints
|
||||
|
||||
- **Go 1.20,** for Windows 7: no newer language or standard-library features, and no dependency that needs them.
|
||||
- **MIT,** on Windows, macOS, and Linux, fully offline.
|
||||
|
||||
## The compatibility contract
|
||||
|
||||
The external interface is a contract with existing users, and tests pin it:
|
||||
|
||||
- **Commands and flags** keep their names, shorthands, types, and defaults.
|
||||
- **Output** keeps one file per non-empty category, its formats, its field names and order, and the browser and profile values.
|
||||
- **`keys.json` and archives** stay readable across releases, by older and newer versions alike.
|
||||
- **Exit status** is `0` when the run completes, however partial its results, and `1` when it cannot start or finish.
|
||||
|
||||
Log lines and the summary on stderr are not part of the contract. Output changes only to fix output that was wrong, and each such fix is announced in the release notes.
|
||||
|
||||
## Guiding principles
|
||||
|
||||
- One explicit pipeline, with data flowing one way ([RFC-001](001-architecture.md)).
|
||||
- Snapshot-first: no parser reads a live profile ([RFC-004](004-snapshots.md)).
|
||||
- Lazy secrets: nothing secret is touched until a requested output needs it ([RFC-003](003-secrets.md)).
|
||||
- An outcome for every extraction, and no failure that aborts the rest ([RFC-001](001-architecture.md)).
|
||||
- Everything below the command is internal: the CLI is the only compatibility obligation.
|
||||
@@ -1,125 +0,0 @@
|
||||
# RFC-001: Architecture & Pipeline
|
||||
|
||||
## The shape of a run
|
||||
|
||||
A run is a one-way pipeline of seven stages. Each stage takes the previous stage's output and produces the next stage's input. No stage reaches backward. The orchestration lives in `internal/app`; the stages themselves are implemented by the packages named below.
|
||||
|
||||
```
|
||||
┌───────────┐
|
||||
argv ───▶ │ Validate │ flags → app.Options; no browser files touched, nothing created
|
||||
└─────┬─────┘
|
||||
▼
|
||||
┌───────────┐
|
||||
│ Discover │ which user data dirs and profiles exist on this machine
|
||||
└─────┬─────┘
|
||||
▼
|
||||
┌───────────┐
|
||||
│ Plan │ user data dirs × profiles × requested categories
|
||||
└─────┬─────┘ → Extractions (+ Skipped, with reasons) + the union of files
|
||||
▼
|
||||
┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ Execute, once per user data dir ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
|
||||
┌───────────┐
|
||||
│ Capture │ copy the user data dir's planned files into a temporary snapshot
|
||||
└─────┬─────┘
|
||||
▼
|
||||
┌───────────┐
|
||||
│ Extract │ parse snapshot files → records; secrets fetched lazily
|
||||
└─────┬─────┘ (first decrypt in a key scope triggers retrieval)
|
||||
▼
|
||||
┌───────────┐
|
||||
│ Export │ append each extraction's records to the output files,
|
||||
└─────┬─────┘ then remove the snapshot and take the next user data dir
|
||||
┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
|
||||
▼
|
||||
┌───────────┐
|
||||
│ Report │ every result → summary on stderr
|
||||
└───────────┘
|
||||
```
|
||||
|
||||
## Stage contracts
|
||||
|
||||
### 1. Validate
|
||||
|
||||
Turns parsed flags into a typed `app.Options`: which categories, which browser, the `-p` override, output directory, format, `--zip`, and how the keychain password is supplied. Rejects bad input here — an unknown format, category, or browser ID, or an output directory that cannot be created, fails now with exit status `1` (v1.1.0's status, except for an unknown browser ID, which there found nothing and exited `0`; [RFC-009](009-cli-surface.md)), **before** any browser is discovered and **before** any keychain prompt. v1.1.0 checked `-c` and `-f` only after discovery and the prompt; validating first designs that ordering bug out.
|
||||
|
||||
Validate touches no browser files and creates nothing: the output-directory check only confirms that `-d` is a directory or that its nearest existing ancestor is a writable directory. For `restore`, reading `--keys` is part of Validate, because `-b` there is checked against the dump's vaults ([RFC-009](009-cli-surface.md)). `-p` combined with `-b all` is ignored, as in v1.1.0, but with a warning rather than silently.
|
||||
|
||||
**In:** parsed flags. **Out:** a validated `app.Options`. **Owner:** `cmd/hack-browser-data` (flag wiring) + `app.Validate` (rules).
|
||||
|
||||
### 2. Discover
|
||||
|
||||
Enumerates which supported browsers are present and which profiles each one has, on this OS. Produces `browser.UserDataDir` values — one per data directory found, so two Arc packages are two user data dirs — each holding its `Profile` list. Discovery is read-only metadata work: it stats files and directories; it does not open databases or touch secrets. The one exception is Safari, which lists its named profiles only inside `SafariTabs.db`: its Discover captures that single file into a temporary snapshot and reads the copy, never the live database ([RFC-005](005-browser-definitions.md)). A user data dir that exists but cannot be read is not dropped: it comes back as an `error` result for that browser ([RFC-005](005-browser-definitions.md)).
|
||||
|
||||
**In:** `app.Options` + `browser.Supported()`, this OS's rows. **Out:** an `app.Discovery` — the user data dirs found, plus the failures. **Owner:** `app.Discover`, which dispatches on `Browser.Base` to `internal/browser/{chromium,firefox,safari}`.
|
||||
|
||||
### 3. Plan
|
||||
|
||||
The cross product. For each user data dir, each profile, and each requested category, the profile's `Extractors` say whether the category is supported and which source files it needs. Plan turns that into a flat list of `Extraction`s, a `Skipped` list with a reason for every requested pair that can't run (`unsupported` by this browser, `absent` on disk, `error` when a file cannot be checked) plus Discover's failures, and the union of files to capture, deduplicated by user data dir and path — so a file two categories share (Chromium `History` feeds both history and downloads) is copied once (v1.1.0 copied it twice). Plan only stats files; it opens nothing. A `Plan` is plain data, with no functions inside, so `list` prints it and tests compare it.
|
||||
|
||||
**In:** an `app.Discovery` + `app.Options`. **Out:** `app.Plan{Dirs, Files, Extractions, Skipped}`. **Owner:** `app.NewPlan`.
|
||||
|
||||
### 4–6. Capture, Extract, Export — once per user data dir
|
||||
|
||||
`app.Execute` runs the next three stages one user data dir at a time. It captures the dir's files into a temporary snapshot, runs the dir's extractions — each extraction's records go to Export as it finishes — and removes the snapshot before it captures the next dir. At most one user data dir's copies of `Login Data`, `Cookies`, and the like are on disk at once, close to v1.1.0's per-profile session; a run-long snapshot directory would keep every browser's copies until the end, and peak disk use would be all of them together. `archive` is the one exception: it captures every user data dir into one snapshot directory, because the zip of that directory is what it produces ([RFC-007](007-snapshot-and-acquisition.md)).
|
||||
|
||||
#### 4. Capture
|
||||
|
||||
Copies the user data dir's planned files into its snapshot, a subdirectory named by the dir's ID ([RFC-007](007-snapshot-and-acquisition.md)). After Capture, the live browser profile is never read again. Capture owns the awkward realities of reading files a running browser holds open — the Windows locked-file fallback, SQLite `-wal`/`-shm` sidecars, LevelDB lock files — so every parser downstream reads plain, stable files. Capture keeps going when a file fails: a file that vanished since Plan turns its extraction into `absent`, one that failed to copy turns its extraction into `error`, and every other extraction runs.
|
||||
|
||||
**In:** the user data dir's share of `Plan.Files`. **Out:** the dir's `snapshot.Snapshot`, inside a `snapshot.Dir`. **Owner:** `internal/snapshot`.
|
||||
|
||||
#### 5. Extract
|
||||
|
||||
For each extraction, open its source files _from the snapshot_ and parse them into records. Secrets are lazy: each is retrieved once per key scope, by the first record that needs it — the user data dir for Chromium (`ProfileSnapshot.MasterKeys`), the profile for Firefox, the run for the macOS login keychain ([RFC-006](006-key-retrieval-and-crypto.md)); later extractions in the same scope reuse it. A run that only asked for bookmarks and history never retrieves a key, never opens the keychain, and never prompts.
|
||||
|
||||
A record whose secret can't be recovered is still emitted with that field empty (as in v1.1.0) and reported as a record-level problem, which makes the extraction `partial`.
|
||||
|
||||
**In:** the user data dir's extractions + its snapshot. **Out:** records and record-level problems, through a `browser.Collector`. **Owner:** `internal/browser/*` extractors + `internal/masterkey` + `internal/keychain` + `internal/crypto`.
|
||||
|
||||
#### 6. Export
|
||||
|
||||
Appends each extraction's records, as it finishes, to the frozen output files and formats ([RFC-008](008-output-and-export.md)): one file per non-empty category, field names frozen, rows in a deterministic order defined once per category.
|
||||
|
||||
**In:** records + `app.Options`. **Out:** files on disk (and the `--zip` archive). **Owner:** `internal/export`.
|
||||
|
||||
### 7. Report
|
||||
|
||||
Collects every result — each extraction's, and each failure that concerns a whole browser or user data dir — and prints a summary on stderr. The summary is additive: it is not part of the compatibility contract, and it never changes the exit status.
|
||||
|
||||
**In:** an `app.Summary`. **Out:** the summary. **Owner:** `app.Report`.
|
||||
|
||||
## The outcome model
|
||||
|
||||
Every extraction resolves to exactly one outcome. This is the single most important quality lever in the design: it replaces "an error was logged somewhere" with "the run completed and told you precisely what it got."
|
||||
|
||||
| Outcome | Meaning | Example |
|
||||
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
|
||||
| `ok` | Ran with no record-level problems. A source with no rows is `ok` with zero records, not `absent`. | 224 cookies decrypted. |
|
||||
| `partial` | Ran and emitted records, but reported record-level problems — a secret that could not be recovered, a row that could not be parsed. | 224 cookies, 4 with an empty value. |
|
||||
| `absent` | Supported, but a required source wasn't on disk, or none of its optional ones was; an unreadable one is `error`. | Browser installed, no `Login Data` file. |
|
||||
| `unsupported` | This browser can't produce this category. | Firefox credit cards. |
|
||||
| `error` | Failed as a whole: the extractor returned an error, a source failed to copy, or problems were reported and no record could be emitted. | Snapshot copy failed. |
|
||||
|
||||
`partial` is first-class, not an afterthought: a few undecryptable rows are normal in the field and must not look like total failure.
|
||||
|
||||
A failure that concerns a whole browser or user data dir rather than one extraction — Discover could not read it, key retrieval failed — is reported once, as an `error` result that names only the user data dir. The extractions it touches still get their own outcomes: after a failed key retrieval, passwords and cookies are still emitted with their encrypted fields empty, so those extractions end `partial`.
|
||||
|
||||
## Exit status (compatibility contract)
|
||||
|
||||
| Status | Meaning |
|
||||
| ------ | ------------------------------------------------------------------------------------------------------------ |
|
||||
| `0` | The run completed. Every result — including `partial`, `error`, and "no browsers found" — is in the summary. |
|
||||
| `1` | The run could not start or finish: a usage error, an unreadable `--keys`, an output write failure. |
|
||||
|
||||
This is v1.1.0's behavior, frozen. `absent` and `unsupported` are not failures — asking all browsers for all categories and getting honest "not here" answers is a successful run. Finer exit codes (separate usage and partial statuses) are DEFERRED; if ever added, they must be opt-in.
|
||||
|
||||
## Why a pipeline
|
||||
|
||||
In v1.1.0 each browser package re-implemented the orchestration: Chromium, Firefox, and Safari each copied files into a session, switched on the requested categories, and assembled results inside `Extract`, and per-fork special cases (`p.kind == types.ChromiumYandex`) sat inside the Chromium switch. Bugs lived where nothing else checked them: Firefox sorted history ascending while the other browsers sorted descending, and the archive keyed files by browser key alone, so a second Arc user data dir was dropped.
|
||||
|
||||
Splitting the run into named stages means:
|
||||
|
||||
- Each concern is implemented and tested **once**, not per browser.
|
||||
- A browser contributes only what is browser-specific: where its files are (Discover) and how to parse them (Extract). Everything else is shared machinery.
|
||||
- The `Plan` is a value you can print, which is all `list` is.
|
||||
- Failures are localized to an extraction and reported, never fatal to the run.
|
||||
@@ -0,0 +1,40 @@
|
||||
# RFC-001: Architecture
|
||||
|
||||
## The pipeline
|
||||
|
||||
A run is a fixed, one-way sequence of stages, and no stage reaches back:
|
||||
|
||||
1. **Validate** — turn the flags into options, and reject bad input before anything is touched.
|
||||
2. **Discover** — find each browser's data directories and their profiles.
|
||||
3. **Plan** — cross directories, profiles, and requested categories into extractions, record why each skipped one cannot run, and list the files to copy.
|
||||
4. **Capture** — copy one directory's planned files into a temporary snapshot.
|
||||
5. **Extract** — parse the snapshot into records, fetching a secret only when a record needs it.
|
||||
6. **Export** — append each extraction's records to the output files.
|
||||
7. **Report** — summarize every outcome.
|
||||
|
||||
Capture, Extract, and Export run once per data directory, so at most one directory's copies are on disk at a time. Every command is a cut of this pipeline: `list` stops after discovery, `list --detail` counts records instead of exporting them, `archive` captures and zips, `dumpkeys` retrieves keys only, and `restore` extracts from a snapshot it is given.
|
||||
|
||||
**Why.** When each browser runs the whole flow itself, every concern is solved several times, and bugs hide where nothing else checks them. Named stages implement each concern once; a browser contributes only where its files are and how to read them.
|
||||
|
||||
## Outcomes
|
||||
|
||||
Every extraction — one category from one profile of one data directory — ends in exactly one outcome: `ok`, `partial` (records came out, with record-level problems), `absent` (nothing on disk), `unsupported` (the browser cannot produce it), or `error`. A failure that concerns a whole directory is reported once, on its own. No failure aborts the rest of the run, and outcomes never change the exit status. `partial` is first-class, because a few unreadable rows are normal in the field and must not look like total failure.
|
||||
|
||||
## Layers
|
||||
|
||||
- The command layer wires flags into the pipeline and holds what lives as long as the process: signals, the console window, the data a restore reads.
|
||||
- The pipeline orchestrates, and it is the only place that knows every browser base.
|
||||
- Each browser base knows its own discovery and file formats.
|
||||
- Shared services sit below them: secret retrieval, pure crypto primitives, snapshot capture, and export.
|
||||
- Platform code sits at the bottom, behind build tags.
|
||||
|
||||
Dependencies point down only. Interfaces live with their consumer, nothing registers itself at init time, and a new dependency edge is a reviewed decision. All code below the command is internal: there is no library API to keep compatible, so the code can be reshaped freely.
|
||||
|
||||
## Naming
|
||||
|
||||
- A name is judged at its call site, qualified by its package, and never repeats the package's name.
|
||||
- A name says what a thing is, not its role or its shape, and one concept has one word.
|
||||
- Names are spelled out; only Go's universal idioms stay short, and lint enforces it.
|
||||
- The domain's words: a **browser** is a row of the browser table; its **base** is what it is built on (Chromium, Firefox, or Safari); a **user data dir** is a browser's data directory, where an installation would be the program; and a **profile**, an **extraction**, a **snapshot**, a **record**, and a **category** mean what they say.
|
||||
|
||||
**Rejected:** "engine" for the base, which means the renderer; "origin" or "owner" for where a record came from, which are web and access-control terms; and "job" for an extraction, which suggests a worker pool that does not exist.
|
||||
@@ -0,0 +1,23 @@
|
||||
# RFC-002: Browsers
|
||||
|
||||
## Decision
|
||||
|
||||
The supported browsers are a data table, not code. A row says what a browser is called, what it is built on — its base: Chromium, Firefox, or Safari — and where it keeps its data on each OS; the base decides how that data is read. A plain fork is a new row and nothing else.
|
||||
|
||||
## Why
|
||||
|
||||
Facts spread across several lists drift apart, and fork checks scattered across files are easy to miss. One table is auditable at a glance, and base behavior is written three times in total, not once per browser.
|
||||
|
||||
## Rules
|
||||
|
||||
- **The name is the identity.** The base is the only classification. A release channel that keeps its own data, such as a beta, is its own row.
|
||||
- **Exceptions stay inside their base.** A fork that stores data its own way gets an override inside its base, keyed by name, never a new classification.
|
||||
- **One table serves every OS.** The browsers supported here are the rows with data on this OS, while restore may look up any row, so data taken on one OS restores on another.
|
||||
- **Discovery reports; it never guesses.** Every matching data directory counts. One that exists but cannot be read is an error, not absence, and a profile counts only when it holds data some category reads.
|
||||
- **Tests keep facts in step.** Facts that must agree across languages, such as the Windows payload's own browser table, are checked by tests, not by review.
|
||||
|
||||
## Rejected
|
||||
|
||||
- **One type per browser:** the same logic implemented again and again.
|
||||
- **An enum of products:** every fork would become a code change.
|
||||
- **Self-registering browsers:** hidden coupling at init time.
|
||||
@@ -1,81 +0,0 @@
|
||||
# RFC-002: Package Layout
|
||||
|
||||
## The tree
|
||||
|
||||
Everything except the command entrypoint lives under `internal/`. The entrypoint stays thin — the frozen cobra command tree and a call into `app`.
|
||||
|
||||
```
|
||||
cmd/hack-browser-data/ main; cobra commands and flags (the frozen CLI surface); flags → app.Options
|
||||
internal/
|
||||
app/ Validate, Discover, NewPlan, Execute, Report; dispatches on browser.Base to the base packages
|
||||
browser/ Browser, Base, Platform (Supported, Lookup); UserDataDir, UserDataDirID, Profile, DiscoverOptions;
|
||||
FileSpec, Extractor, ProfileSnapshot, Collector
|
||||
chromium/ Chromium discovery, extractors, key input, archive files, per-fork overrides (Yandex, Opera family)
|
||||
firefox/ Firefox discovery, extractors, per-profile key derivation
|
||||
safari/ Safari discovery and extractors
|
||||
category/ Category: the data categories (the -c values and the output file names)
|
||||
record/ record types (Login, Cookie, …) and the Record interface; field names frozen by the output contract
|
||||
masterkey/ Chromium key Set, Retriever, RetrieveAll, keys.json Dump; OS secret stores by build tag
|
||||
crypto/ pure decrypt primitives over bytes (AES-CBC/GCM, 3DES, PBKDF2, ASN.1 PBE)
|
||||
snapshot/ snapshot Dir and Snapshot, Capture, zip transport, the copier
|
||||
export/ Writer; csv / json / cookie-editor encoders; --zip packaging
|
||||
zipfile/ the one zip writer, for --zip and archive: a temp file renamed into place
|
||||
sqlitex/ thin modernc.org/sqlite helpers (open read-only by path, query)
|
||||
timeconv/ browser epoch conversions (Chromium/WebKit, Unix, Firefox, Core Data)
|
||||
winapi/ Windows only: syscall wrappers, DPAPI, locked-file copy, executable lookup
|
||||
abe/ Windows only: App-Bound Encryption bridge — native/ C sources, payload/, injector/
|
||||
keychain/ macOS only: the user's login keychain — one handle per run, opened on first use
|
||||
log/ leveled logging (Debugf/Infof/Warnf)
|
||||
```
|
||||
|
||||
The technique internals (the ABE payload, reflective injection, DPAPI and keychain specifics) sit behind `masterkey`, `keychain`, `winapi`, and the ABE unit by build tag. Their _mechanics_ are documented in the format and technique RFCs (013–021) and are out of scope for the design RFCs — here they are just packages with a contract ([RFC-006](006-key-retrieval-and-crypto.md)).
|
||||
|
||||
**The ABE unit lives in `internal/abe/`, as one unit.** `native/` holds the first-party C sources and `Makefile.frag` and no Go files, since Go rejects C files in a package that does not use cgo; `native/bootstrap/` is the layout package generated from them; `payload/` embeds the built `.bin`, which `make payload` writes there because `//go:embed` only reaches files in the embedding package's directory or below; and `injector/` loads it. `make payload` builds the payload and `make gen-layout` regenerates the layout package.
|
||||
|
||||
## Dependency direction
|
||||
|
||||
Dependencies point downward and are listed exhaustively; anything not listed is forbidden.
|
||||
|
||||
| Package | May import (project-internal) |
|
||||
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
|
||||
| `cmd/hack-browser-data` | `app`, plus `browser` and `category` for help-text vocabulary (`-b` names, `-c` categories), `log` |
|
||||
| `app` | every package below |
|
||||
| `browser/chromium`, `browser/firefox`, `browser/safari` | `browser`, `category`, `record`, `masterkey`, `crypto`, `snapshot`, `sqlitex`, `timeconv`, `log` |
|
||||
| `export` | `category`, `record` |
|
||||
| `browser` | `category`, `record`, `masterkey`, `snapshot` |
|
||||
| `masterkey` | `crypto`, `winapi`, `abe`, `keychain`, `log` |
|
||||
| `snapshot` | `winapi`, `log` |
|
||||
| `abe` | `winapi`, `log` |
|
||||
| `record` | `category` |
|
||||
| `sqlitex`, `winapi` | `log` |
|
||||
| `category`, `crypto`, `timeconv`, `keychain`, `log` | nothing |
|
||||
|
||||
`abe` stands for the ABE unit's Go packages, `abe/injector` and `abe/payload`.
|
||||
|
||||
Four rules keep the graph acyclic and its seams honest:
|
||||
|
||||
- **The base dispatch lives in `app`.** The base packages import `browser` for `Browser`, `UserDataDir`, and `Extractor`, so `browser` cannot call them back; `app` switches on `Browser.Base`. Init-time self-registration is ruled out by the `gochecknoinits` linter, and an explicit switch reads better on stage anyway.
|
||||
- **`snapshot` speaks strings.** A `snapshot.File` names its user data dir by ID (`UserDataDirID`, a plain string) and its path relative to that directory; it never holds a `browser.UserDataDir`, because `browser.ProfileSnapshot` holds a `snapshot.Snapshot`.
|
||||
- **`crypto` takes bytes.** Primitives receive raw keys and blobs; they never see a `masterkey.Set`, because `masterkey` is the package that calls them.
|
||||
- **Interfaces live with their consumer.** `browser` declares the `Collector` its extractors use, and `app` implements it; `masterkey` and `browser/safari` each declare the one-method `LoginKeychain` they read. Constructors elsewhere return concrete types (`*snapshot.Dir`, `*export.Writer`).
|
||||
|
||||
Review keeps the table, not a tool: a change that needs an edge the table does not list — say, `crypto` importing `browser` — updates the table first, in the same pull request.
|
||||
|
||||
## Why `internal/` and nothing else (DECIDED)
|
||||
|
||||
v1.1.0 kept packages at the module root (`browser/`, `crypto/`, `filemanager/`, `log/`, `masterkey/`, `output/`, `types/`, `utils/...`), and its CLAUDE.md said "no `pkg/` + `internal/`." This design reverses that one decision and keeps the "keep it simple" spirit by using `internal/` _instead of_ a split, not in addition to one.
|
||||
|
||||
Reasons:
|
||||
|
||||
1. **No Go-API burden.** Anything importable by path becomes a de-facto public API that external users pin to. HBD has no intended library consumers — it is a CLI. `internal/` makes that explicit and compiler-enforced, so packages can be renamed and reshaped freely. The CLI contract ([RFC-000](000-goals-and-constraints.md)) is the only compatibility obligation, and it is unaffected.
|
||||
2. **A clear seam.** `cmd/` is the only thing outside `internal/`. The boundary between "the program's entrypoint" and "the program" is visible in the tree.
|
||||
3. **It is still flat.** We are not introducing `pkg/` as well. There is exactly one home for library code, and it is `internal/`.
|
||||
|
||||
Trade-off accepted: the module stops being importable as a library. The module path stays `github.com/moond4rk/hackbrowserdata` and releases continue as v1.x; there is no v2 (DECIDED).
|
||||
|
||||
## Package sizing and naming rules
|
||||
|
||||
- A package exists because it owns a _concept_, not because a file got long. `timeconv` and `category` are tiny on purpose. A package with nothing to own is not created — there is no `cli` (flags belong to `cmd`, rules to `app`) and no `textenc` (the CSV BOM is three bytes in `export`).
|
||||
- A concept with per-OS implementations lives in one package with `_windows.go` / `_darwin.go` / `_linux.go` files; callers import one package and get the right implementation at build time. A concept that exists on only one OS — the locked-file copy, the ABE bridge, the macOS login keychain — lives in its own package whose files are all built for that OS: `winapi`, `abe`, and `keychain`.
|
||||
- `winapi`, not `platform/windows`: a package named `windows` would collide with `golang.org/x/sys/windows`, which it imports, so every file would need an alias. `log` and `crypto` keep their v1.1.0 names although the standard library has packages of the same names: both are internal, and no file needs both.
|
||||
- No `utils` grab-bag. The v1.1.0 tree was redistributed to named homes: `utils/sqliteutil` → `sqlitex`; `utils/fileutil` and `filemanager` → `snapshot` (copy, zip transport) and `export` (`--zip`); `utils/{winapi,winutil}` → `winapi`; `utils/injector` and `crypto/windows/` → `abe`, moved as one unit; `types` → `category`, `record`, and `browser`; `output` → `export`; `log` → `internal/log`.
|
||||
@@ -1,380 +0,0 @@
|
||||
# RFC-003: Core Types
|
||||
|
||||
This RFC fixes the shape of the central types; their names and the alternatives behind them are in [RFC-004](004-naming-decisions.md). Go 1.20 — no generics-stdlib helpers, but ordinary type parameters are available and used sparingly where they remove real duplication.
|
||||
|
||||
Two rules apply to every type below:
|
||||
|
||||
- **Interfaces live with their consumer; constructors return concrete types.** `browser` declares the `Collector` its extractors use, and `app` implements it. `snapshot.Temp` returns a `*snapshot.Dir`, `export.NewWriter` a `*export.Writer`, and `browser.NewProfileSnapshot` a `ProfileSnapshot`, not interfaces.
|
||||
- **An enum's zero value is its default or "none", never a real non-default choice.** `category.Category`, `browser.Base`, and `app.Outcome` start at 1, so a forgotten field never reads as `Password` or `OutcomeOK`. `export.Format`'s zero is `JSON`, the `-f` default. `masterkey.Version` is a string whose zero is `""`.
|
||||
|
||||
## Discovery types — `internal/browser`
|
||||
|
||||
```go
|
||||
// DiscoverOptions is what discovery is handed: everything it would otherwise read from the environment.
|
||||
type DiscoverOptions struct {
|
||||
Home string // the user's home directory, resolved once by app; tests pass a temp dir
|
||||
ProfilePath string // the -p value, already validated; "" when not given (RFC-009)
|
||||
}
|
||||
|
||||
// UserDataDirID names one user data dir: Browser.Name for the first one of a Browser, then "-2", "-3"… appended
|
||||
// for further ones, in Path order. It is its own type so that it cannot be passed where a Browser.Name belongs.
|
||||
type UserDataDirID string
|
||||
|
||||
// UserDataDir is one browser data directory found on this machine: Chromium's "User Data",
|
||||
// Firefox's Profiles directory, Safari's data under ~/Library.
|
||||
type UserDataDir struct {
|
||||
ID UserDataDirID // "chrome", "arc", "arc-2" — also the snapshot and archive directory name
|
||||
Browser Browser // which browser it belongs to (RFC-005)
|
||||
Path string // absolute path; every FileSpec path resolves under it
|
||||
Profiles []Profile
|
||||
}
|
||||
|
||||
// Profile is one profile within a user data dir.
|
||||
type Profile struct {
|
||||
Name string // the output's `profile` value (see below)
|
||||
Dir string // relative to UserDataDir.Path; "" when the user data dir itself is the profile (flat layout)
|
||||
}
|
||||
```
|
||||
|
||||
`UserDataDir` is Chromium's own term (`--user-data-dir`): the directory holding `Local State` and the profile directories, as opposed to the program installation that holds the executable. HBD uses it for every base's data root — the directory a base's file specs resolve under — even where the browser has no such word: Firefox's `Profiles` directory, and Safari's `~/Library` (below). A machine can have several for one browser — Arc's two MSIX packages on Windows each have one — and `restore` works on a copied one that was never installed here, which is why the type is not called `Installation` ([RFC-004](004-naming-decisions.md)).
|
||||
|
||||
An ID and a name sit side by side and must not be confused: `dir.ID` (`arc-2`) names the directory, `dir.Browser.Name` (`arc`) names the browser. The `-b` value, a `keys.json` vault's `browser` key, and the per-fork overrides use `Browser.Name`; the snapshot and archive layout use the `UserDataDirID`. On a machine with one Arc the two are equal, so a mix-up would pass every test there — the separate type makes it a compile error instead.
|
||||
|
||||
`Profile.Name` is frozen by the output contract ([RFC-000](000-goals-and-constraints.md)): for Chromium the directory's base name (`Default`, `Profile 1` — what Chromium's `Profile::GetBaseName()` returns, not the display name `Local State` keeps in `profile.info_cache`); for Firefox the directory name (`97nszz88.default-release`); for Safari, `default` or the named profile's title (deduplicated with a `-N` suffix, the UUID when untitled). It is never a path.
|
||||
|
||||
Safari has no single data directory — History lives under `~/Library/Safari`, cookies under `~/Library/Containers/com.apple.Safari/…` or `~/Library/Cookies` — so its user data dir is `~/Library`, the nearest common ancestor. The default profile's `Dir` is `Safari`; a named profile's is its own directory, `Containers/com.apple.Safari/Data/Library/Safari/Profiles/<UUID>`.
|
||||
|
||||
## Extractor contract — `internal/browser`
|
||||
|
||||
```go
|
||||
// FileSpec is one file or directory an extractor needs: where to look for it, not the file itself.
|
||||
type FileSpec struct {
|
||||
Paths []string // candidates in priority order, relative to the profile dir — or to the user data dir when Shared
|
||||
IsDir bool // a directory (LevelDB, Session Storage), copied whole
|
||||
Shared bool // belongs to the whole user data dir, not one profile: Local State
|
||||
Optional bool // the extraction still runs without it
|
||||
}
|
||||
|
||||
// CandidatePaths are the Paths for a profile, relative to the user data dir, in priority order.
|
||||
func (s FileSpec) CandidatePaths(profile Profile) []string
|
||||
|
||||
// Extractor declares the file specs a category needs and how to parse them.
|
||||
type Extractor struct {
|
||||
FileSpecs []FileSpec
|
||||
Extract func(ctx context.Context, profileSnapshot ProfileSnapshot, out Collector) error
|
||||
}
|
||||
|
||||
// Extractors maps each category a profile supports to its extractor.
|
||||
type Extractors map[category.Category]Extractor
|
||||
```
|
||||
|
||||
File specs are static data: a base package declares them once per category and never rewrites them per profile. `FileSpec.CandidatePaths` joins a profile-scoped path with the profile's `Dir` and leaves a `Shared` one as it is, for Plan and `ProfileSnapshot.Path` alike; Plan captures the union once per user data dir — so `Local State`, or the Chromium `History` file that feeds both history and downloads, is copied once however many extractions need it. Safari is the exception: a named profile's files sit under two directories named for its UUID, so `safari.Extractors` builds each profile's file specs from its `Dir`, and reaches files elsewhere under `~/Library` with `..` from there.
|
||||
|
||||
An extraction is `absent` when a required file spec has no candidate on disk, or when all its file specs are optional and none of the profile's own is there: a shared one such as `Local State` never makes an extraction present by itself. A candidate that cannot be checked — permission denied — makes the extraction an `error` instead, and its profile stays through discovery so the error is reported. An extractor that reads no file — Safari's passwords, which come from the login keychain — always runs. Chromium passwords are two optional file specs — `Login Data` (store `local`) and `Login Data For Account` (store `account`) — which reproduces v1.1.0's output, including a profile that only ever synced passwords, without a special case.
|
||||
|
||||
`Extractor` / `Extractors` are **DECIDED**.
|
||||
|
||||
### ProfileSnapshot and Collector
|
||||
|
||||
```go
|
||||
// ProfileSnapshot is what an extractor is handed for one extraction: its profile's view of the user data dir's
|
||||
// snapshot, and the dir's keys.
|
||||
type ProfileSnapshot struct {
|
||||
Profile Profile // the extraction's profile; profile-scoped file specs resolve under its Dir
|
||||
snapshot snapshot.Snapshot
|
||||
masterKeys func(ctx context.Context) masterkey.Set
|
||||
}
|
||||
|
||||
// NewProfileSnapshot is how app hands a profile its share; tests pass a fixture Snapshot and a fake masterKeys.
|
||||
func NewProfileSnapshot(dirSnapshot snapshot.Snapshot, profile Profile, masterKeys func(context.Context) masterkey.Set) ProfileSnapshot
|
||||
|
||||
// Path returns the captured path of fileSpec: its first candidate present in the snapshot. A candidate that was
|
||||
// never captured is skipped; one whose copy failed returns that copy's error.
|
||||
func (ps ProfileSnapshot) Path(fileSpec FileSpec) (string, error)
|
||||
|
||||
// MasterKeys returns the user data dir's Chromium keys, one per version. The first call in a dir retrieves them and
|
||||
// later calls reuse the result; a version that could not be retrieved is absent from the Set.
|
||||
func (ps ProfileSnapshot) MasterKeys(ctx context.Context) masterkey.Set
|
||||
|
||||
// Collector receives one extraction's output. It sets Browser and Profile on every record, so no extractor can omit
|
||||
// them.
|
||||
type Collector interface {
|
||||
Add(row record.Record) // one parsed record
|
||||
Fail(err error) // one record-level problem: a secret that could not be recovered, or a row dropped as unparseable
|
||||
}
|
||||
```
|
||||
|
||||
An extractor reads from its `FileSpecs` and hands its records to the `Collector`. It emits records as it reads them; it does not accumulate slices. A record whose secret can't be recovered is emitted anyway with that field empty, as in v1.1.0, and reported through `Fail`, which records the problem and lets the extraction continue, like `testing.T.Error`; the extraction ends `partial`. An extractor never logs errors: it returns extraction-level errors and reports record-level ones. Base-specific context an extractor needs (Safari's profile UUID for filtering downloads and the run's login keychain, the Yandex override) is captured when the base package builds the profile's `Extractors`, not passed through the `ProfileSnapshot`.
|
||||
|
||||
`MasterKeys` takes a context because its first call may block — on a secret-store lookup, or on macOS on the login keychain's no-echo password prompt — and Ctrl-C cancels the run's context ([RFC-009](009-cli-surface.md)). It returns no error: the dir's call-once in `app` keeps the retrieval error and reports it once, as the user data dir's `error` result ([RFC-001](001-architecture-and-pipeline.md)), and a record whose key is missing is emitted with that field empty and reported through `Fail`. Every `ProfileSnapshot` of one user data dir shares that call-once; `masterKeys` is nil for Firefox and Safari, whose extractors never call it.
|
||||
|
||||
There is no separate `Secrets` handle ([RFC-004](004-naming-decisions.md)), and the login password is not on `ProfileSnapshot` at all: it opens one resource, the login keychain, and that resource is what gets handed out (below).
|
||||
|
||||
## Pipeline values — `internal/app`
|
||||
|
||||
```go
|
||||
// Extraction is one unit of work: one category of data from one profile of one user data dir. It is pure data —
|
||||
// the extractor is looked up when it runs — so a Plan prints as it is and compares with reflect.DeepEqual in tests.
|
||||
type Extraction struct {
|
||||
UserDataDirID browser.UserDataDirID // which user data dir
|
||||
Profile string // Profile.Name; "" in a result about a whole browser or user data dir
|
||||
Category category.Category // zero in a result about a whole browser or user data dir
|
||||
}
|
||||
|
||||
// Discovery is what Discover found: the user data dirs, plus an error result for each browser whose data could
|
||||
// not be read — reported, never mistaken for absence.
|
||||
type Discovery struct {
|
||||
Dirs []browser.UserDataDir
|
||||
Failed []Result
|
||||
}
|
||||
|
||||
type Plan struct {
|
||||
Dirs []browser.UserDataDir // the discovered dirs, in output order
|
||||
Files []snapshot.File // union of files to capture, deduplicated by (user data dir, path)
|
||||
Extractions []Extraction // what will run, in output order (RFC-008)
|
||||
Skipped []Result // requested but can't run: unsupported, absent, unreadable, or Discovery.Failed
|
||||
}
|
||||
|
||||
func Discover(options Options) Discovery
|
||||
func NewPlan(discovery Discovery, options Options) Plan
|
||||
```
|
||||
|
||||
`Plan` is a plain value: printable, testable, and all `list` prints. `restore` builds its `Discovery` from the snapshot directory it opens instead of from the machine ([RFC-007](007-snapshot-and-acquisition.md)).
|
||||
|
||||
## Outcome & Summary — `internal/app`
|
||||
|
||||
```go
|
||||
type Outcome int
|
||||
|
||||
const (
|
||||
OutcomeOK Outcome = iota + 1
|
||||
OutcomePartial
|
||||
OutcomeAbsent
|
||||
OutcomeUnsupported
|
||||
OutcomeError
|
||||
)
|
||||
|
||||
type Result struct {
|
||||
Extraction
|
||||
Outcome Outcome
|
||||
Count int // records emitted
|
||||
Failed int // Collector.Fail calls
|
||||
Err error // set when Outcome == OutcomeError
|
||||
}
|
||||
|
||||
// Summary is what a run reports: every result, in output order.
|
||||
type Summary struct {
|
||||
Results []Result
|
||||
}
|
||||
|
||||
// Execute runs Capture, Extract, and Export one user data dir at a time (RFC-001). Its error means the run could
|
||||
// not finish — an output write failure; every other failure is a Result.
|
||||
func Execute(ctx context.Context, plan Plan, options Options) (Summary, error)
|
||||
```
|
||||
|
||||
The outcome follows from the counts: `OutcomeOK` when nothing failed — zero records included, since an empty file is not absent; `OutcomePartial` when records were emitted and some failed; `OutcomeError` when the extractor returned an error, a file failed to copy, or failures were reported with no record emitted. `Summary` starts with `Plan.Skipped`, so the report covers what never ran as well as what did.
|
||||
|
||||
The exit status is not derived from `Summary`: it is `0` whenever the run completes and `1` when it cannot start or finish ([RFC-001](001-architecture-and-pipeline.md)). `Summary` feeds the report only.
|
||||
|
||||
The stage functions are `Validate`, `Discover`, `NewPlan`, `Execute`, and `Report`; the values they produce are `Options`, `Discovery`, `Plan`, and `Summary`. No function shares a name with a type, which Go would reject.
|
||||
|
||||
## Categories — `internal/category`
|
||||
|
||||
What kind of browser data something is. Every stage speaks it: the CLI parses `-c` into it, a base package keys its `Extractors` by it, the planner crosses it with profiles, and the exporter names its files after it.
|
||||
|
||||
```go
|
||||
// Category is one kind of browser data. The zero Category means "none".
|
||||
type Category int
|
||||
|
||||
const (
|
||||
Password Category = iota + 1
|
||||
Cookie
|
||||
Bookmark
|
||||
History
|
||||
Download
|
||||
CreditCard
|
||||
Extension
|
||||
LocalStorage
|
||||
SessionStorage
|
||||
)
|
||||
|
||||
// String returns "password", "cookie", "bookmark", "history", "download", "creditcard",
|
||||
// "extension", "localstorage", "sessionstorage" — also the -c values and the output file names.
|
||||
func (c Category) String() string
|
||||
|
||||
func All() []Category // every category, in the order above
|
||||
func Parse(s string) (Category, error) // the inverse of String, for -c
|
||||
func Names() []string // every category's String, in All's order
|
||||
```
|
||||
|
||||
The package is tiny on purpose, like `timeconv`: it exists so that `category.Cookie` and `record.Cookie` can each mean exactly what they say ([RFC-004](004-naming-decisions.md)). There is no `Category.Sensitive()`: with `-c all` as the frozen default, nothing would consume it.
|
||||
|
||||
## Record types — `internal/record`
|
||||
|
||||
A record is one row of output — one saved login, one cookie, one history entry — and it has the same type whichever browser produced it.
|
||||
|
||||
```go
|
||||
// Login is one saved password: a URL, a user name, and a password together, as Chromium's "Login Data"
|
||||
// and Firefox's logins.json keep them.
|
||||
type Login struct {
|
||||
Browser string `json:"browser" csv:"browser"`
|
||||
Profile string `json:"profile" csv:"profile"`
|
||||
URL string `json:"url" csv:"url"`
|
||||
Username string `json:"username" csv:"username"`
|
||||
Password string `json:"password" csv:"password"`
|
||||
CreatedAt time.Time `json:"created_at" csv:"created_at"`
|
||||
Store Store `json:"store" csv:"store"`
|
||||
}
|
||||
|
||||
// Store names the Chromium password database a Login came from.
|
||||
type Store string
|
||||
|
||||
const (
|
||||
StoreLocal Store = "local" // Login Data
|
||||
StoreAccount Store = "account" // Login Data For Account
|
||||
)
|
||||
|
||||
// Record is a record of any category: one row of output. The pipeline's Collector calls SetBrowserAndProfile on each
|
||||
// record it is handed, so the two fields every record starts with are never left to an extractor.
|
||||
type Record interface {
|
||||
Category() category.Category
|
||||
SetBrowserAndProfile(browser, profile string)
|
||||
}
|
||||
```
|
||||
|
||||
| Category | Record type | v1.1.0 type |
|
||||
| ------------------------- | ----------------------- | ----------------------- |
|
||||
| `category.Password` | `record.Login` | `types.LoginEntry` |
|
||||
| `category.Cookie` | `record.Cookie` | `types.CookieEntry` |
|
||||
| `category.Bookmark` | `record.Bookmark` | `types.BookmarkEntry` |
|
||||
| `category.History` | `record.History` | `types.HistoryEntry` |
|
||||
| `category.Download` | `record.Download` | `types.DownloadEntry` |
|
||||
| `category.CreditCard` | `record.CreditCard` | `types.CreditCardEntry` |
|
||||
| `category.Extension` | `record.Extension` | `types.ExtensionEntry` |
|
||||
| `category.LocalStorage` | `record.LocalStorage` | `types.StorageEntry` |
|
||||
| `category.SessionStorage` | `record.SessionStorage` | `types.StorageEntry` |
|
||||
|
||||
Every record type starts with two flat source fields, `Browser string` (the display name) and `Profile string` (`Profile.Name`), followed by v1.1.0's fields with v1.1.0's names, tags, and order. `LocalStorage` and `SessionStorage` declare the same fields separately, so each is its own type with its own category. Records are used by pointer — `out.Add(&record.Cookie{…})` — because `SetBrowserAndProfile` sets the fields in place. There is no `Origin`/`Owner` umbrella type ([RFC-004](004-naming-decisions.md)).
|
||||
|
||||
Only the type names changed from v1.1.0. Field names are wire names — each field's snake_case form, enforced by lint — and because the output is frozen, so are they ([RFC-008](008-output-and-export.md)). `Store` is a named string type with v1.1.0's two values, which changes nothing on the wire.
|
||||
|
||||
## Master key — `internal/masterkey`
|
||||
|
||||
```go
|
||||
// Version is a Chromium ciphertext's version prefix.
|
||||
type Version string
|
||||
|
||||
const (
|
||||
V10 Version = "v10"
|
||||
V11 Version = "v11"
|
||||
V20 Version = "v20"
|
||||
)
|
||||
|
||||
// Set holds one Chromium user data dir's key per version. Its JSON form is the keys.json
|
||||
// "keys" object: {"v10": …, "v11": …, "v20": …}.
|
||||
type Set map[Version][]byte
|
||||
|
||||
// Retriever obtains one version's key from one OS secret store. Implementations are
|
||||
// build-tagged and return ErrNotApplicable when they don't apply to this user data dir.
|
||||
type Retriever interface {
|
||||
Version() Version
|
||||
Retrieve(ctx context.Context, loc Locator) ([]byte, error)
|
||||
}
|
||||
|
||||
// RetrieveAll runs this OS's retrievers in order. Per version the first key wins and later retrievers for that
|
||||
// version are not tried; a version's error is reported only when all its retrievers fail. Versions are
|
||||
// independent, so a v20 failure never discards a v10 key.
|
||||
func RetrieveAll(ctx context.Context, loc Locator) (Set, error)
|
||||
```
|
||||
|
||||
`Set` / `RetrieveAll` are **DECIDED** ([RFC-004](004-naming-decisions.md)). Because `Version` is a string type, `encoding/json` writes a `Set` with the same `"v10"` keys as v1.1.0, sorted, and no marshaling code. Key scopes, retriever order, and laziness are in [RFC-006](006-key-retrieval-and-crypto.md).
|
||||
|
||||
## Login keychain — `internal/keychain`
|
||||
|
||||
```go
|
||||
// PasswordFunc yields the macOS login password. app builds it from --keychain-pw, --keychain-pw-stdin, or the prompt
|
||||
// (RFC-009); outside this package it is the only place the password exists.
|
||||
type PasswordFunc func(ctx context.Context) (string, error)
|
||||
|
||||
// Keychain is the user's login keychain. It opens on first use, at most once per run.
|
||||
type Keychain struct{ /* unexported */ }
|
||||
|
||||
// ErrLocked reports that no usable password was supplied, so the keychain yields metadata only.
|
||||
var ErrLocked = errors.New("login keychain is locked")
|
||||
|
||||
func New(path string, password PasswordFunc) *Keychain // no I/O: building one never prompts
|
||||
|
||||
func (k *Keychain) GenericPassword(ctx context.Context, account string) ([]byte, error) // ErrLocked when locked
|
||||
func (k *Keychain) InternetPasswords(ctx context.Context) ([]keychainbreaker.InternetPassword, error) // secrets empty when locked
|
||||
func (k *Keychain) Err() error // why it is locked; nil if open or never used
|
||||
```
|
||||
|
||||
The login keychain belongs to the user, not to a profile or a user data dir, so one handle serves the whole run. On macOS `app` builds it and hands it to its two consumers: the Chromium `v10` retriever, through `masterkey.Locator`, and the Safari password extractor, which `safari.Extractors` captures for the default profile. Each consumer declares the one method it reads (`masterkey.LoginKeychain`, `safari.LoginKeychain`), so its tests need no real keychain. Opening the keychain is the password check: a missing or wrong password leaves it locked — metadata only, as in v1.1.0 — and `Err` gives the reason, which the reporter prints once. The package builds only on macOS ([RFC-002](002-package-layout.md)); elsewhere, and in `restore`, there is no handle. Retrieval order and laziness are in [RFC-006](006-key-retrieval-and-crypto.md).
|
||||
|
||||
## Snapshot — `internal/snapshot`
|
||||
|
||||
```go
|
||||
// File is one file or directory a plan wants captured.
|
||||
type File struct {
|
||||
UserDataDirID string // the user data dir's ID ("chrome", "arc-2"); also the snapshot it lands in
|
||||
UserDataDirPath string // absolute path of the user data dir it is copied from
|
||||
RelativePath string // slash-separated path relative to UserDataDirPath, and to the snapshot
|
||||
IsDir bool
|
||||
}
|
||||
|
||||
// Dir is a snapshot directory: one Snapshot per user data dir.
|
||||
type Dir struct{ /* unexported */ }
|
||||
|
||||
func Temp() (*Dir, error) // a new temporary snapshot directory, mode 0700
|
||||
func Open(path string) (*Dir, error) // an existing one, used in place (restore --data-dir)
|
||||
func Unzip(archivePath string) (*Dir, error) // restore transport into a temporary snapshot directory; rejects entries that escape it
|
||||
|
||||
func (d *Dir) Capture(ctx context.Context, files []File) error // copies what it can; per-file failures surface through Snapshot.Path
|
||||
func (d *Dir) Snapshot(userDataDirID string) Snapshot
|
||||
func (d *Dir) Zip(archivePath string) error // archive: temp file beside it, renamed into place on success
|
||||
func (d *Dir) Close() error // removes a temporary snapshot directory; leaves an opened one in place
|
||||
|
||||
// Snapshot is one user data dir's snapshot: the read-only view of the files captured from it.
|
||||
type Snapshot struct{ /* unexported */ }
|
||||
|
||||
// Path returns rel's absolute path inside the snapshot: fs.ErrNotExist when the file was never captured or had
|
||||
// vanished before Capture reached it, or the copy's error when capturing it failed.
|
||||
func (s Snapshot) Path(rel string) (string, error)
|
||||
```
|
||||
|
||||
`Capture` returns an error only when it cannot go on — a cancelled context, an unwritable snapshot directory. A single file's failure is kept and handed back by `Snapshot.Path`, so it ends that file's extractions as `error` without stopping the rest. `snapshot` cannot import `browser` (`browser.ProfileSnapshot` holds a `snapshot.Snapshot`), so a `File` names its user data dir with a plain string, `UserDataDirID`. `Snapshot` hands out real paths because `modernc.org/sqlite` and `goleveldb` open files by path, and SQLite needs its `-wal` file beside the database. The snapshot is therefore always a directory; zip is only a transport format ([RFC-007](007-snapshot-and-acquisition.md)).
|
||||
|
||||
## Export — `internal/export`
|
||||
|
||||
```go
|
||||
// Format is the -f value. Its zero value is JSON, the default.
|
||||
type Format int
|
||||
|
||||
const (
|
||||
JSON Format = iota
|
||||
CSV
|
||||
CookieEditor
|
||||
)
|
||||
|
||||
func ParseFormat(s string) (Format, error) // "json", "csv", "cookie-editor"
|
||||
|
||||
// Writer appends each extraction's records to the per-category output files, in plan order.
|
||||
type Writer struct{ /* unexported */ }
|
||||
|
||||
func NewWriter(dir string, f Format, zip bool) (*Writer, error)
|
||||
func (w *Writer) Write(c category.Category, records []record.Record) error // one extraction's records; the writer sorts them (RFC-008)
|
||||
func (w *Writer) Close() error // finishes every file; with --zip, packs them
|
||||
func (w *Writer) Output() Output // what a clean Close left: the files, their counts, the zip
|
||||
|
||||
// Output is what a clean Close left in the output dir; app prints the "Exported to" lines from it.
|
||||
type Output struct {
|
||||
Dir string
|
||||
Files []File // each category file, in category order
|
||||
Zip string // the archive the files were packed into, with --zip
|
||||
}
|
||||
|
||||
type File struct {
|
||||
Name string
|
||||
Count int // records written
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,26 @@
|
||||
# RFC-003: Secrets
|
||||
|
||||
## Boundaries
|
||||
|
||||
- **Secret retrieval** lives in one layer: talking to the OS stores (DPAPI and App-Bound Encryption on Windows, the Keychain on macOS, the Secret Service on Linux) and the portable keys file. It knows nothing about browsers or records.
|
||||
- **Cryptography** is pure functions over bytes: no OS calls, no blob formats, testable with fixed vectors.
|
||||
- **Blob formats** belong to each browser base, which decides which key decrypts what.
|
||||
- **The macOS login keychain** is one resource for the whole run, opened at most once. Its consumers get the opened keychain, never the password.
|
||||
|
||||
## Scopes
|
||||
|
||||
Secrets live at different levels, so they are fetched at different levels: per data directory for Chromium's master keys, per profile for Firefox, whose key is derived from the profile's own files, and per run for the macOS login keychain.
|
||||
|
||||
## Lazy retrieval
|
||||
|
||||
A secret is fetched by the first record that needs it, once per scope, and then reused. A run that asks only for history or bookmarks never retrieves a key and never prompts. A retrieval failure is reported once for its scope; records that needed the secret are still written, with that field empty, and count as `partial`.
|
||||
|
||||
## Key versions
|
||||
|
||||
Chromium keys come in versions, and each version is retrieved independently: one failing never discards another. Within a version, the first strategy that works wins. The cipher is chosen from the key at run time rather than from the build's OS, so keys exported on one machine decrypt that machine's data on any OS.
|
||||
|
||||
## Never
|
||||
|
||||
- **No secret in a log line,** ever.
|
||||
- **No new technique.** Only existing, published methods sit behind these boundaries.
|
||||
- **No vendored loader.** The Windows payload is first-party code. The common third-party loader was rejected because it crashes on Windows internals it walks too far and depends on brittle structure layouts.
|
||||
@@ -1,283 +0,0 @@
|
||||
# RFC-004: Naming Decisions
|
||||
|
||||
This is the one place the naming discussion lives. Each item keeps its rationale and the alternatives rejected, so the decisions are auditable rather than bare assertions.
|
||||
|
||||
Go naming principles applied throughout:
|
||||
|
||||
- **The package name is part of the identifier.** `category.Cookie` already says "the cookie category," so a `Category` prefix or a `record.Record`-style stutter is redundant. Names are judged at the call site, not in isolation.
|
||||
- **A qualified name reads as what it is.** `category.Cookie` is a category and `record.Cookie` is a cookie record; neither needs a suffix to tell it from the other, because each lives in the package that means it.
|
||||
- **A name says what a thing is, not how it is built or used, or what it resembles.** `ProfileSnapshot`, not `Input`; `Snapshot`, not `Tree`.
|
||||
- **One concept, one name.** A user data dir's location is a `Path`, its identity a `UserDataDirID`, a ciphertext's prefix a `Version` — in code and in prose alike.
|
||||
- **Values are nouns, stages are verbs.** A Go package cannot hold a type and a function of the same name, so the pipeline's values (`Plan`, `Summary`) and the stages that produce them (`NewPlan`, `Execute`) never share a word.
|
||||
- **Names are spelled out.** A variable is named for what it holds — `extractors`, `snapshotDir`, `profile` — never `ex`, `d`, or `p` (item 10).
|
||||
|
||||
Internal Go names are free to change; anything the user can see — commands, flags, file names, field names, `keys.json` keys — is frozen by the compatibility contract ([RFC-000](000-goals-and-constraints.md)), whatever the Go name behind it.
|
||||
|
||||
## Settled (DECIDED)
|
||||
|
||||
| Name | Decision |
|
||||
| -------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `internal/` for all non-`cmd` code | [RFC-002](002-package-layout.md). |
|
||||
| `browser.Extractor` / `browser.Extractors` | The thing that declares its files and parses them. |
|
||||
| `masterkey.Set` / `masterkey.RetrieveAll` | The key collection and the function that fills it. |
|
||||
| Wire names = snake_case of Go field names | No second vocabulary; lint-enforced; frozen with the output. [RFC-008](008-output-and-export.md). |
|
||||
| `browser` stays `browser` (not `engine`) | "Engine" means a web rendering engine (Blink/Gecko/WebKit) and misleads. |
|
||||
| `browser.Supported()` / `browser.Lookup` | This OS's browsers / any row of the whole table. No `catalog` package. |
|
||||
| `category.Category` with bare values; records `record.Login`, `record.Cookie`…; sum type `record.Record` | Categories and records in separate packages, so neither needs a suffix; no `model` package; the sum type takes its package's name, as `category.Category` does. |
|
||||
| Per-record source: flat `Browser` + `Profile` | No `Origin`/`Owner` type; the fields hold v1.1.0's output values. |
|
||||
| `browser.ProfileSnapshot` | What an extractor is handed: its profile's view of the snapshot and the user data dir's keys (`Path`, `MasterKeys`); no `Secrets` handle, not `Input`. |
|
||||
| `keychain.Keychain` | The run's macOS login keychain: one handle, opened on first use; consumers get the handle, never the password. |
|
||||
| `browser.Collector` (`Add`, `Fail`) | What an extractor hands its records and record-level problems to; not `Sink`, not `Emit`. |
|
||||
| `masterkey.Locator` / `chromium.KeyLocator` | Where one user data dir's keys are found, and the function that builds it; not `RetrieveInput`. |
|
||||
| `Base` enum; product identity in `Browser.Name` | No `Variant` enum; channel is folded into rows, not modelled. |
|
||||
| `browser.UserDataDir` with a `UserDataDirID` | Not `Installation`; the ID has its own type, named for the directory it identifies. |
|
||||
| `app` stages and values | `Validate`, `Discover`, `NewPlan`, `Execute`, `Report`; `Options`, `Discovery`, `Plan`, `Extraction`, `Summary`. |
|
||||
| `browser.Browser` with `Name` and `DisplayName` | A row of the browser table, named for its package as `category.Category` is; not `Def`, and not `ID` for the `-b` value. |
|
||||
| `browser.FileSpec` | Where an extractor looks for one file; it becomes a `snapshot.File` once found. Not `Source`. |
|
||||
| `Record.SetBrowserAndProfile` | An exported method on every record; no sealed `stamp` method and no `record.Stamp` wrapper. |
|
||||
| Spelled-out names | Only Go's fixed idioms stay short; a name that would shadow its package takes its role (item 10). |
|
||||
| `snapshot.Dir` / `snapshot.Snapshot` | A snapshot directory and one user data dir's snapshot inside it, a snapshot being one user data dir's copy as in Chromium; not `FS`, `Tree`, or `Copy`. |
|
||||
| `winapi`, `abe`; `log` and `crypto` kept | Windows-only packages; not `platform/windows`. |
|
||||
| `timeconv` and `sqlitex` functions | `timeconv.Chromium`, `UnixMicro`, `UnixMilli`, `Unix`, `CoreData`, each named for the encoding it reads; `sqlitex` exports `CountRows` and `QueryRows` only. |
|
||||
| CLI names unchanged | `-c/--category` selects `category.Category` values; `-p/--profile-path` and `dumpkeys` stay. [RFC-009](009-cli-surface.md). |
|
||||
|
||||
## Item-by-item detail
|
||||
|
||||
### 1. The supported-browser table — `browser.Supported()` and `browser.Lookup`
|
||||
|
||||
**Decision.** The table lives in `browser`, where it belongs; there is no `catalog` package.
|
||||
|
||||
```go
|
||||
browser.Supported() []browser.Browser // the browsers HBD supports on the running OS, in table order
|
||||
browser.Lookup(name string) (Browser, bool) // any row of the whole table, whatever the OS
|
||||
```
|
||||
|
||||
`Supported()` is exactly what its callers need: Discover walks it, `-b` is validated against it, and the help text lists it. It reads as "the browsers that are supported," and on macOS that list must not contain `qq` or `sogou`, which have no macOS row. `restore` needs the other view — a vault taken on Windows can name a Windows-only fork — so it resolves names with `Lookup`, which searches the whole table. No caller needs the whole table as a list; tests that do read the package's unexported table.
|
||||
|
||||
**`Browser`, not `Def`.** A row of the table is a browser, so the type is `browser.Browser`, named for its package as `category.Category` and `snapshot.Snapshot` are. `Def` was an abbreviation a reader had to decode, and `Definition` would still name the table entry rather than the thing it describes. Outside the package a variable holding one cannot be called `browser`, which would shadow the package, so it is named for its role: `supportedBrowser`, `chromiumBrowser`, `restoredBrowser`.
|
||||
|
||||
**Alternatives rejected.**
|
||||
|
||||
| Option | Why not |
|
||||
| --------------------------------------- | ------------------------------------------------------------------------------------------- |
|
||||
| `catalog.All()` | "all of the catalog" says nothing about _what_; the `catalog` noun doesn't pull its weight. |
|
||||
| `registry.All()` | "registry" is implementation jargon; same empty `All()`. |
|
||||
| `catalog.Browsers()` | keeps the `catalog` noun. |
|
||||
| `browser.Known()` | an honest name for the whole table, but no caller wants the whole table as a list. |
|
||||
| `Supported()` returning every OS's rows | the name would promise "supported here" and deliver "known anywhere." |
|
||||
|
||||
### 2. Per-record source — flat `Browser` + `Profile`, no umbrella type
|
||||
|
||||
**Decision.** Each record carries two flat fields — `Browser string` and `Profile string` — not a wrapper type. `Browser` holds `Browser.DisplayName` (`Chrome`, `Microsoft Edge`), and `Profile` holds `Profile.Name` (`Default`, or a Safari profile's title) — exactly the values v1.1.0's `browser` and `profile` columns carry. Putting `Browser.Name` (`chrome`) there would change every row, which the compatibility contract rules out.
|
||||
|
||||
**Why no umbrella type.** `Owner` is wrong (it implies possession/ACLs). `Origin` is worse in this domain: "origin" is already the Web-platform term (`scheme://host:port`), so `cookie.Origin` reads as "the site this cookie belongs to," not "where I pulled it from" — the same collision that got `engine` rejected. `Provenance` is the DFIR term but reads heavy. The browser domain has no clean single noun for "(browser, profile) a datum came from", so the record carries a `browser` and a `profile` column, as v1.1.0's output already did.
|
||||
|
||||
**`Profile` holds the name, never a path.** This keeps local absolute paths out of exported data and keeps archives portable across hosts. It does not collide with the `browser.Profile` type or with `Profile.Dir` (the path) — a field named `Profile` of type `string` lives in a different namespace from the type.
|
||||
|
||||
**Setting them.** The fields are exported so `encoding/json` serializes them, but extractors don't set them: the pipeline's `Collector` calls `SetBrowserAndProfile` on every record it is handed. The method is exported, so `Record` is not sealed: the packages are internal and have no library API, so an unexported sealing method protected nothing, and it needed an exported `Stamp` wrapper just to be callable.
|
||||
|
||||
On the wire: `browser` and `profile` keys in JSON; leading `browser` / `profile` columns in CSV.
|
||||
|
||||
**Alternatives rejected.**
|
||||
|
||||
| Option | Why not |
|
||||
| ----------------- | ---------------------------------------------------------------- |
|
||||
| `Origin` type | collides with Web-platform "origin" in a browser-data tool. |
|
||||
| `Provenance` type | accurate (DFIR) but heavy, and still an invented umbrella. |
|
||||
| `Source` type | says nothing about what it holds, the fault that also renamed the extractor's files to `FileSpec`. |
|
||||
|
||||
### 3. The extractor's input — `browser.ProfileSnapshot`
|
||||
|
||||
**Decision.** An extractor is handed a `browser.ProfileSnapshot`: its profile's view of the user data dir's snapshot, plus the dir's Chromium keys. It is a concrete type with two methods, built by `app` through `NewProfileSnapshot`:
|
||||
|
||||
```go
|
||||
func (ps ProfileSnapshot) Path(fileSpec FileSpec) (string, error) // where fileSpec was captured in the snapshot
|
||||
func (ps ProfileSnapshot) MasterKeys(ctx context.Context) masterkey.Set // this user data dir's Chromium keys; the first call retrieves
|
||||
```
|
||||
|
||||
**Why `ProfileSnapshot`.** It names what the extractor holds — one profile's share of the snapshot — where `Input` named only a role: every function has inputs. `ps.Path(loginData)` and `ps.MasterKeys(ctx)` read as what they return.
|
||||
|
||||
**Why no `Secrets` handle.** A `Secrets` interface wrapping the keys and the macOS login password was considered. Master keys and the login password have nothing in common but being secret; the domain has no clean noun for both, and inventing one is the fault item 2 rejects for `Origin` and `Owner`. Without the password (item 8), `Secrets` would be a one-method interface that `app` implements and every extractor reaches through; the method sits better on the value the extractor already holds. The laziness stays where it was — a per-user-data-dir call-once in `app`, passed in as a function — so extractors depend on having keys, not on how they are fetched.
|
||||
|
||||
**Why no error.** `MasterKeys` returns only the `Set`. A retrieval failure concerns the whole user data dir, so `app`'s call-once reports it once, as that dir's `error` result; the extractor finds the version's key missing and reports the affected records through `Collector.Fail`, as it would any secret it cannot recover.
|
||||
|
||||
**Alternatives rejected.**
|
||||
|
||||
| Option | Why not |
|
||||
| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `browser.Input` | names a role, not a thing. |
|
||||
| `browser.Secrets{MasterKeys, KeychainPassword}` | an invented umbrella over two unrelated secrets (item 2's rule); the password does not belong on the extractor's input at all (item 8). |
|
||||
| `masterkey.Lazy` | names a strategy, not what the extractor holds. |
|
||||
| `masterkey.Keys{Set()}` | `in.Keys.Set()` reads as a setter in Go (`flag.Value.Set`, `http.Header.Set`), and `masterkey.Keys` stutters. |
|
||||
|
||||
### 4. Browser classification — `Base`, with product identity in `Name`
|
||||
|
||||
Anchored in Chromium's own vocabulary (`install_modes.h` calls the product axis _brand_; the older `BrowserDistribution` called it _distribution_).
|
||||
|
||||
**Decision.**
|
||||
|
||||
- **`Base`** is the single classification enum: `Chromium`, `Firefox`, `Safari`. It is the "what is this built on" axis — "Chromium-based" — and it decides the storage/decryption model and which base package handles it. What these browsers share is the **Chromium platform/codebase**, not the rendering engine (Blink), which is exactly why `engine` would be both a collision and imprecise.
|
||||
- **Product/brand identity lives in `Browser.Name`** (a string, e.g. `"chrome"`, `"edge"`). There is **no `Variant` enum.** Modelling the product axis as an enum would force a code change for every new fork, which fights the "add a fork = add a data row" goal ([RFC-005](005-browser-definitions.md)); a string `ID` keeps forks as pure data. The few forks with their own on-disk format (Yandex, the Opera family) get an override inside the Chromium package keyed by `Browser.Name` — still no enum, and a plain fork stays a pure row.
|
||||
- **Channel** (stable/beta/dev/canary) is a separate axis in Chromium (install modes), but HBD gives it no field, because nothing dispatches on it: a channel that keeps its own user data dir is simply its own row, whose `Name` names product and channel together (`chrome-beta`).
|
||||
- **`Name` and `DisplayName`, not `ID` and `Name`.** The `-b` value (`chrome`) is the browser's name as the CLI and `keys.json` spell it, and `browser.Names()` lists them for `-b` as `category.Names()` does for `-c`; what records carry (`Microsoft Edge`) is the `DisplayName`. `ID` said nothing about what the string was, beside a `UserDataDir.ID` it often equals.
|
||||
|
||||
**Alternatives rejected.**
|
||||
|
||||
| Axis | Option | Why not |
|
||||
| ------- | ------------------------ | --------------------------------------------------------------------------------- |
|
||||
| base | `Family` | common informal word, but not domain-native; `Base` reads "Chromium-based". |
|
||||
| base | `Engine` | rejected project-wide; also imprecise (renderer ≠ storage model). |
|
||||
| base | `Platform` | means OS, not codebase — it is the per-OS half of a `Browser` (item 6), not the base. |
|
||||
| product | `Variant` / `Brand` enum | a per-fork enum fights "fork = data row"; identity belongs in `Name`. |
|
||||
| channel | a `Channel` field | nothing reads it; the row and its `Name` already say it. |
|
||||
|
||||
### 5. Data categories and records — `category` and `record`
|
||||
|
||||
**Decision.** Two small packages, each with bare names:
|
||||
|
||||
```go
|
||||
category.Password, category.Cookie, category.Bookmark, category.History,
|
||||
category.Download, category.CreditCard, category.Extension,
|
||||
category.LocalStorage, category.SessionStorage
|
||||
|
||||
record.Login, record.Cookie, record.Bookmark, record.History,
|
||||
record.Download, record.CreditCard, record.Extension,
|
||||
record.LocalStorage, record.SessionStorage
|
||||
```
|
||||
|
||||
A category says what kind of data is meant; a record is one row of that data. The two share their nouns — a cookie category, a cookie record — so in one package one of them would need a suffix, and a reader of `record.Cookie` would take a category for a record. In two packages each qualified name reads as what it is: `extractors[category.Cookie]`, `out.Add(&record.Cookie{…})`, and `-c cookie` → `category.Parse` → `category.Cookie` → `cookie.json`. The `Category.String()` values (`password`, `creditcard`, `localstorage`, …) are the `-c` values and the output file names, so they are frozen.
|
||||
|
||||
**Why `Category`, not `Kind`.** The CLI already calls it a category — `-c/--category`, "data categories" in the help text — and so did v1.1.0's code (`types.Category`), so one concept keeps one name from the flag to the type. "Kind" already means other things here: the frozen `kind` field of a `keys.json` vault (`chromium-yandex`), v1.1.0's `types.BrowserKind`, and `masterkey.ABEKind`. The constants stay bare: the `CategoryCookie` prefix is what fought the package name, not the type's name. The type reads `category.Category`, the accepted Go form for a package's main type (`time.Time`); a variable holding one is `c`, since `category` would shadow the package. Numbering starts at 1, so the zero `Category` means "none": a result about a whole user data dir has no category, and an unset field never reads as `Password`.
|
||||
|
||||
**Why `Login` for the password record.** The category is `password`, a frozen `-c` value, but the record holds a URL, a user name, and a password together — Chromium's "Login Data", Firefox's `logins.json`, v1.1.0's `LoginEntry` — and a `record.Password` with a `Password` field would read `p.Password`. Every other record shares its category's name.
|
||||
|
||||
**Why `Record` for the sum type.** Every record type implements `record.Record`, so `record.Cookie` reads as a kind of `record.Record`. The type takes its package's name for the reason `category.Category` does — the accepted Go form for a package's main type (`time.Time`); `Item` said nothing about what it holds.
|
||||
|
||||
**Alternatives rejected.**
|
||||
|
||||
| Option | Why not |
|
||||
| -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
|
||||
| `record.Kind` beside `record.CookieItem`… in one package | `record.Cookie` would be a category, not a record, and every record would carry an `Item` suffix. |
|
||||
| `Category` + `CategoryCookie`… | the prefix repeats the package's meaning at every call site. |
|
||||
| `Kind` | a Go-insider word, and "kind" already names a vault's browser variant and the ABE dispatch. |
|
||||
| `record.Password` | `p.Password` stutters; the row is a login. |
|
||||
| package `model` | says nothing about what it models. |
|
||||
| sum type `record.Item` | says nothing about what it holds; the `time.Time` form that gives `category.Category` gives `record.Record`. |
|
||||
|
||||
### 6. The data-directory type — `browser.UserDataDir`, not `Installation`
|
||||
|
||||
**Decision.** The type for one browser data directory found on a machine is `browser.UserDataDir`, identified by a `browser.UserDataDirID`.
|
||||
|
||||
**Why not `Installation`.** In both Chromium and Firefox, an "installation" is the _program_ — the executable and its files. The thing this type holds is the _data_ directory: Chromium's `User Data` (the `--user-data-dir` the browser documents), Firefox's `Profiles` directory, Safari's data under `~/Library`. Three reasons `Installation` is wrong for it:
|
||||
|
||||
1. It collides with the program sense already in the table: `Platform.Exe` and `ExeFallbacks` point at the _installation_. One document should not use "install" for two different things.
|
||||
2. A machine can have several data directories for one installed program (Arc's two MSIX packages), so "one installation" misdescribes the count.
|
||||
3. In `restore` the directory was copied from another host and was never installed here at all.
|
||||
|
||||
`UserDataDir` is Chromium's own term, and it already appeared in v1.1.0's code (`BrowserConfig.UserDataDir`) and in the frozen `keys.json` field `user_data_dir` — so the type name aligns with a word the codebase and the output already use. Firefox and Safari have no such word; for them it means the directory their files resolve under ([RFC-003](003-core-types.md)).
|
||||
|
||||
**Why `UserDataDirID` is its own type, spelled out.** A user data dir's ID (`arc-2`) and its browser's `Name` (`arc`) are equal for the first directory of every browser, so code that passes one where the other belongs passes every test on a machine with one Arc. As distinct types, the mix-up does not compile. The name says which directory it identifies: `DirID` could as well have meant a `Profile.Dir`, a `snapshot.Dir`, or the output directory.
|
||||
|
||||
**Supporting names.**
|
||||
|
||||
| Name | What it names | Why this name |
|
||||
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `UserDataDir.ID` (`UserDataDirID`) | `chrome`, `arc`, `arc-2` — one per data directory found | Distinguishes two user data dirs of one `Browser`; also the snapshot and archive directory name. |
|
||||
| `UserDataDir.Browser` | the directory's `Browser` | A field named for its type, the Go norm. The record's `Browser string` is another package's field and holds this one's `DisplayName`. |
|
||||
| `UserDataDir.Path` | its absolute path | The one word for a user data dir's location; `Root` was rejected as a second word for it. |
|
||||
| `Platform.UserDataDirs` | where one browser's user data dirs live on one OS | Each match becomes a `UserDataDir`; `Roots` would be another word for the same thing. |
|
||||
| `Platform` fields | `UserDataDirs`, `KeychainLabel`, `Exe`, `ExeFallbacks`, `ABE` | The per-OS half of a `Browser`; absorbs `winutil.Entry`. `Platform` means OS here (where `Base` means codebase), so the two never collide. |
|
||||
| `browser.FileSpec` / `browser.Collector` | where an extractor's file is looked for / what it hands its records to | `FileSpec` describes a file, candidate paths and flags, that becomes a `snapshot.File` once found, as `ast.TypeSpec` describes a type; `Source`, `DataFile`, `InputFile`, and `Artifact` named nothing specific, a role, or a build output. `Collector` says what it does with records, where `Sink` is dataflow jargon. `Add` is Go's verb for putting something into a container (`Emit` is event-framework vocabulary); `Collector.Fail` is what makes `partial` countable. |
|
||||
| `FileSpec.Shared` | a file of the whole user data dir (`Local State`) | Explicit data; the alternative made correctness depend on the order of builder calls ([RFC-005](005-browser-definitions.md)). |
|
||||
| `browser.DiscoverOptions` | the home dir and `-p` handed to Discover | v1.1.0's name; kept. |
|
||||
| `masterkey.Version` | `v10`, `v11`, `v20` | Chromium's own word (`kEncryptionVersionPrefix`); a string type, so a `Set` marshals to the same `"v10"` keys as v1.1.0 with no extra code. "Tier" is not used. |
|
||||
| `masterkey.ABEKind` | `ABENone`, `ABEChromeBase`, `ABEEdge`, `ABEAvast` | v1.1.0's `winutil.ABEKind`, moved to the package that consumes it. |
|
||||
| `masterkey.Locator` | where one user data dir's keys are found: the `Local State` copy, the keychain label, the Windows `Exe` and `ABE` kind, the run's login keychain | Names what it holds; `RetrieveInput` named only a role, the fault item 3 rejects in `Input`, and `Hints` sounds optional. `chromium.KeyLocator` builds one. |
|
||||
|
||||
### 7. Pipeline and package names — `app`, `snapshot`, `winapi`
|
||||
|
||||
**`app`: nouns for values, verbs for stages.** `Validate` produces `Options`, `Discover` a `Discovery`, `NewPlan` a `Plan`, `Execute` a `Summary`, and `Report` writes the summary out. `Run` is not used as a type name: in Go it reads as a verb (`cmd.Run`, `t.Run`).
|
||||
|
||||
**`Options`, not `Request`.** `Validate` turns the raw `Flags` into typed values, so its result is the run's options, as `browser.DiscoverOptions` holds discovery's; in Go, `Request` reads as `http.Request`.
|
||||
|
||||
**`Extraction`, not `Job`.** A plan's unit of work is one extraction: one category of data from one profile of one user data dir. `Job` beside `Result` is the vocabulary of Go's worker-pool idiom — `jobs` and `results` channels — so a reader looks for goroutines and a queue that do not exist. `Extraction` names what HBD does, extract browser data, and pairs with `Extract` and `Extractor` without suggesting concurrency. It sits one package away from `browser.Extractors`, a near-homonym, which the package names keep apart.
|
||||
|
||||
**`snapshot.Dir` and `snapshot.Snapshot`, not `snapshot.FS`, `snapshot.Tree`, or `snapshot.Copy`.** A Go reader takes `FS` for `io/fs.FS`; this type is not one, and it returns operating-system paths because SQLite and LevelDB open files by path. A `Snapshot` is one user data dir's snapshot, in Chromium's own sense of the word: its `downgrade::SnapshotManager` takes a snapshot by copying selected files of one user data dir. A `Dir` is the snapshot directory that holds one `Snapshot` per user data dir, and `Dir.Snapshot(userDataDirID)` returns one — a method named for what it returns, as `http.Request.Cookie(name)` is. `ProfileSnapshot` is then one profile's share of a `Snapshot`, so the vocabulary closes. Both are concrete types, and the snapshot directory's lifecycle — created with mode `0700`, removed by `Close` — lives in `Dir`'s methods rather than in free functions over a named string. `Zip` and `Unzip` are the transport pair.
|
||||
|
||||
**`winapi` and `abe`, not `platform/windows`.** A package named `windows` would collide with `golang.org/x/sys/windows`, which it imports, so every file would need an alias. `winapi` is v1.1.0's name; the ABE bridge is its own unit, `abe`.
|
||||
|
||||
**`log` and `crypto` keep their names.** Both share a name with a standard-library package, but both are internal and no file needs both, and both are v1.1.0's names.
|
||||
|
||||
**Alternatives rejected.**
|
||||
|
||||
| Option | Why not |
|
||||
| ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `type Plan` + `func Plan`, `type Run` | a type and a function can't share a name; `Run` reads as a verb. |
|
||||
| `Job`, `Task` | Go's worker-pool vocabulary (`jobs` / `results` channels); readers look for a queue. |
|
||||
| `Request` | reads as `http.Request`; the value is the validated flags. |
|
||||
| `Target` | reads as an attack target in a security tool. |
|
||||
| `Unit`, `Item`, `Entry` | `Unit` and `Item` say nothing; `…Entry` named v1.1.0's record types. |
|
||||
| `snapshot.FS` | reads as `io/fs.FS`. |
|
||||
| `snapshot.Tree` | a metaphor for its shape, not a name for what it holds. |
|
||||
| `snapshot.Files` | collides with `snapshot.File`, a capture request, and `Plan.Files`. |
|
||||
| `snapshot.Copy` | reads as a verb in Go (`io.Copy`, the `copy` builtin), next to `Capture`, the method that does copy. |
|
||||
| `Dir.CopyOf`, `Dir.Get`, `Dir.Lookup`, `Dir.Sub` | `CopyOf` reads as making a copy (Java's `Arrays.copyOf`); `Get` and `Lookup` say less than a method named for what it returns; `Sub` brings back the subtree metaphor (`fs.Sub`). |
|
||||
| `type Dir string` with free functions | the snapshot directory's lifecycle belongs on the type. |
|
||||
| `platform/windows` | collides with `golang.org/x/sys/windows`. |
|
||||
| `logx` | renames v1.1.0's package for no reader's benefit, and `crypto` would then need the same treatment. |
|
||||
|
||||
### 8. The macOS login keychain — `keychain.Keychain`
|
||||
|
||||
**Decision.** The login keychain is a resource with one owner, the macOS-only package `internal/keychain`. `keychain.New(path, password)` returns a `*keychain.Keychain` that opens on first use, at most once per run. The macOS Chromium `v10` retriever and the Safari password extractor receive the handle; the password itself goes only from `keychain.PasswordFunc` into the keychain. The type reads `keychain.Keychain`, the accepted Go form for a package's main type (`time.Time`), as `category.Category` does.
|
||||
|
||||
**Why a handle, not a password.** In v1.1.0 the password traveled as a string — through `DiscoverOptions`, a setter interface, the retriever constructor, and four Safari function signatures — and every consumer reopened the keychain to use it. A password that was checked and then passed on as a string has to be trusted downstream; an opened keychain carries its own answer: open, or locked with a reason. The keychain belongs to the user, so its scope is the run; as a method on the per-profile extractor input it would put a run-scoped, macOS-only concept on a cross-platform, per-profile type. Each consumer declares the one method it uses — `masterkey.LoginKeychain`, `safari.LoginKeychain` — under the same name, since both name the same thing.
|
||||
|
||||
**Alternatives rejected.**
|
||||
|
||||
| Option | Why not |
|
||||
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `ProfileSnapshot.KeychainPassword(ctx)` | hands out the credential instead of the resource; every consumer reopens the keychain; a macOS-only method on every extractor's input. |
|
||||
| a password function in the `masterkey.Locator` | a second path for the same secret, beside the extractor input. |
|
||||
| `keychain.Login` | collides with `record.Login`, a saved login. |
|
||||
| `masterkey.Keychain` | `masterkey` holds Chromium keys; Safari's saved logins are not keys. |
|
||||
|
||||
### 9. Leaf helpers — `timeconv` and `sqlitex`
|
||||
|
||||
**`timeconv`: one function per stored encoding, named for what the caller holds.** `Chromium` reads `base::Time`, microseconds since 1601; `CoreData` reads `CFAbsoluteTime`, seconds since 2001; `UnixMicro`, `UnixMilli`, and `Unix` read the three Unix units Firefox stores, named after the `time` functions they wrap. Not `WebKit`: in this tool WebKit is Safari's engine, and Safari's timestamps are Core Data's.
|
||||
|
||||
**`sqlitex` exports `CountRows` and `QueryRows` only.** The row-callback helper behind them, v1.1.0's `sqliteutil.QuerySQLite`, has no other caller, and as an export it would read `sqlitex.QuerySQLite`.
|
||||
|
||||
### 10. Spelled-out names
|
||||
|
||||
**Decision.** A variable, parameter, or field is named for what it holds: `for dataCategory, extractor := range defaultExtractors`, `snapshotDir, err := snapshot.Temp()`. Go's own guidance prefers short names in short scopes, but a reader of this code, human or agent, should not have to decode `c`, `e`, `ex`, or `d`, whose type is often not on the same line.
|
||||
|
||||
- **What stays short.** The idioms every Go reader knows: `i` and `j` as indexes, `err`, `ctx`, `ok`, `t` and `tb` in tests, the terms `id` and `iv`, `db` for a database handle, `fd` for a file descriptor, `n` for a count, and one-letter method receivers, whose type is on the same line.
|
||||
- **Package names.** A variable cannot take the name of its package — `browser`, `category`, `record`, `keychain` — without shadowing it, so it takes its role: `supportedBrowser`, `dataCategory`, `row`, `loginKeychain`.
|
||||
- **Enforcement.** `varnamelen` rejects a one- or two-letter name used beyond the next line; `max-distance: 1` is the strictest it allows. The Windows API and ABE packages are excluded until they get their own pass.
|
||||
|
||||
## Summary table
|
||||
|
||||
| Concept | Decision | Rejected |
|
||||
| ----------------------- | ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
||||
| Supported-browser table | `browser.Supported()` (this OS) + `browser.Lookup` (whole table) | `catalog.All()`, `registry.All()`, `browser.Known()` |
|
||||
| Per-record source | flat `Browser` + `Profile`, set by `SetBrowserAndProfile` | `Owner`, `Origin`, `Provenance`, `Source` types |
|
||||
| Extractor input | `browser.ProfileSnapshot{Path, MasterKeys}` | `browser.Input`, `browser.Secrets`, `masterkey.Lazy`, `masterkey.Keys{Set}` |
|
||||
| macOS login keychain | `keychain.Keychain`: one per run, opened on first use | `ProfileSnapshot.KeychainPassword`, a password function in the `Locator`, `keychain.Login`, `masterkey.Keychain` |
|
||||
| Browser base | `Base` (Chromium / Firefox / Safari) | `Family`, `Engine`, `Platform` |
|
||||
| Browser product | `Browser.Name` (no enum); format overrides keyed by name | `Variant` / `Brand` enum |
|
||||
| Data categories | `category.Category` + bare `category.Cookie`…; zero is "none" | `record.Kind`, `CategoryCookie`…, `model` |
|
||||
| Records | `record.Login`, `record.Cookie`…; sealed `record.Record` | `record.CookieItem`, `record.Password`, `record.Item` |
|
||||
| Data directory | `browser.UserDataDir`, identified by a `UserDataDirID` | `Installation` |
|
||||
| Extractor output | `browser.Collector` (`Add` + `Fail`) | `browser.Sink`, `Emit`, an `Emit` func, `Output`, `Recorder` |
|
||||
| Key retrieval input | `masterkey.Locator`, built by `chromium.KeyLocator` | `masterkey.RetrieveInput`, `Hints` |
|
||||
| Pipeline values | `Options`, `Discovery`, `Plan`, `Summary` | `type Run` |
|
||||
| Unit of work | `app.Extraction{UserDataDirID, Profile, Category}` | `Job`, `Task`, `Target`, `Unit` |
|
||||
| Snapshot | `snapshot.Dir` + `snapshot.Snapshot`, returned by `Dir.Snapshot(userDataDirID)` | `snapshot.FS`, `snapshot.Tree`, `snapshot.Copy`, `snapshot.Files`, `Dir.CopyOf`, `type Dir string` |
|
||||
| Browser row | `browser.Browser` (`Name`, `DisplayName`) | `Def`, `Definition`, `ID` |
|
||||
| Extractor's file | `browser.FileSpec` | `Source`, `DataFile`, `InputFile`, `Artifact`, `File` |
|
||||
| Validated flags | `app.Options` | `Request` |
|
||||
| Variable names | spelled out; only Go's fixed idioms stay short | `c`, `e`, `ex`, `d`, `def` |
|
||||
| Windows packages | `winapi`, `abe` | `platform/windows` |
|
||||
| Leaf helpers | `timeconv.Chromium`…`CoreData`; `sqlitex.CountRows`, `QueryRows` | `timeconv.WebKit`, an exported `sqlitex.QuerySQLite` |
|
||||
|
||||
The only cross-row couplings: the `category` package and the bare record names are one decision, and the flat `Browser`/`Profile` source replaces every mention of `Origin`.
|
||||
@@ -0,0 +1,21 @@
|
||||
# RFC-004: Snapshots
|
||||
|
||||
## Snapshot-first
|
||||
|
||||
No parser reads a live profile. Capture copies the files a plan needs into a temporary snapshot, and every parser reads only the copy. A running browser changes and locks its files; a copy gives stable bytes, keeps locked-file handling in one place, and lets every parser be tested with a fixture file instead of a browser.
|
||||
|
||||
## Lifetime
|
||||
|
||||
A dump captures one data directory at a time and removes its copies before the next, so copied secrets never outlive the extractions that read them, and disk use stays at one directory's worth. Temporary copies are private to the user and always removed — on success, on error, and on Ctrl-C. Capture only ever reads the browser's files.
|
||||
|
||||
## Failures stay local
|
||||
|
||||
A file that cannot be copied fails only the extractions that need it, and a file that vanished since planning makes them `absent`. The rest of the run goes on.
|
||||
|
||||
## Archive and restore
|
||||
|
||||
`archive` is "capture, then zip", and `restore` is "open or unzip, then extract": the same pipeline, not special modes.
|
||||
|
||||
- **The layout is the format.** An archive holds one directory per data directory, with the browser's own relative paths inside. Older versions read it too, and restore rebuilds the directories and profiles from it alone, with no manifest.
|
||||
- **A zip is only transport.** It is written to a temp file and renamed into place, so a failed archive never leaves a partial file; unzipping refuses any entry that would land outside its directory.
|
||||
- **Only Chromium is archived.** Firefox and Safari keep no portable key.
|
||||
@@ -1,147 +0,0 @@
|
||||
# RFC-005: Browser Definitions
|
||||
|
||||
## The table
|
||||
|
||||
HBD knows a fixed set of browsers. Each is a `browser.Browser`: a static description of how the browser is classified and how it appears on each OS. The table is data, not code — adding a plain fork is adding a row.
|
||||
|
||||
```go
|
||||
type Browser struct {
|
||||
Name string // CLI -b value and keys.json vault key; also the first user data dir's UserDataDirID: "chrome"
|
||||
DisplayName string // set on every record: "Chrome"
|
||||
Base Base // Chromium | Firefox | Safari — the only classification enum (RFC-004)
|
||||
|
||||
Darwin Platform // no UserDataDirs ⇒ not supported on that OS
|
||||
Linux Platform
|
||||
Windows Platform
|
||||
}
|
||||
|
||||
type Base int
|
||||
|
||||
const (
|
||||
Chromium Base = iota + 1
|
||||
Firefox
|
||||
Safari
|
||||
)
|
||||
|
||||
// Platform is how one browser appears on one OS.
|
||||
type Platform struct {
|
||||
UserDataDirs []string // relative to the home dir; globs allowed; every match is its own UserDataDir
|
||||
KeychainLabel string // macOS Keychain account / Linux Secret Service label; "" = none
|
||||
Exe string // Windows: the browser program's executable, used by ABE ("chrome.exe")
|
||||
ExeFallbacks []string // Windows: program paths tried when the registry has no App Paths entry
|
||||
ABE masterkey.ABEKind // Windows: App-Bound Encryption dispatch; ABENone = DPAPI only
|
||||
}
|
||||
```
|
||||
|
||||
A row, for scale:
|
||||
|
||||
```go
|
||||
{
|
||||
Name: "chrome", DisplayName: "Chrome", Base: Chromium,
|
||||
Darwin: Platform{UserDataDirs: []string{"Library/Application Support/Google/Chrome"}, KeychainLabel: "Chrome"},
|
||||
Linux: Platform{UserDataDirs: []string{".config/google-chrome"}, KeychainLabel: "Chrome Safe Storage"},
|
||||
Windows: Platform{
|
||||
UserDataDirs: []string{"AppData/Local/Google/Chrome/User Data"},
|
||||
Exe: "chrome.exe",
|
||||
ExeFallbacks: []string{`%ProgramFiles%\Google\Chrome\Application\chrome.exe`, …},
|
||||
ABE: masterkey.ABEChromeBase,
|
||||
},
|
||||
},
|
||||
```
|
||||
|
||||
The per-OS fields are what v1.1.0's code spread across three places: the `KeychainLabel` of each `types.BrowserConfig`, the `WindowsABE` flag, and the separate `winutil.Table` entry joined to it by key. Each fork's label differs per OS (Edge uses `Microsoft Edge` on macOS but `Chromium Safe Storage` on Linux), which is why the label lives in `Platform`, not on `Browser`. `UserDataDirs` names data directories; `Exe` and `ExeFallbacks` name the program installation — two different things, kept apart in name as well ([RFC-004](004-naming-decisions.md)).
|
||||
|
||||
One table serves every OS. `Browser.Platform()` returns the running OS's entry (a build-tagged one-liner). `Supported()` returns the rows whose entry has `UserDataDirs` — the per-OS list the help text shows, and exactly what `-b` accepts. `Lookup` searches the whole table, so `restore` resolves a vault's `Browser` whatever the host OS and a Windows-only fork restores on macOS ([RFC-007](007-snapshot-and-acquisition.md)).
|
||||
|
||||
Two axes, kept apart ([RFC-004](004-naming-decisions.md)). `Base` is the only enum and answers "what is this built on" — it selects the base package and the key path. Product/brand identity is just `Name` (a string), so a new fork is a new row, not a new enum constant. Release channel (stable/beta/dev/canary) gets no field, because nothing dispatches on it: each installed channel that keeps its own user data dir is its own `Browser`, with a `Name` that names product and channel together (`chrome-beta`).
|
||||
|
||||
Accessors (names per [RFC-004](004-naming-decisions.md)):
|
||||
|
||||
```go
|
||||
browser.Supported() []Browser // this OS's rows, in table order
|
||||
browser.Lookup(name string) (Browser, bool) // any row, whatever the OS
|
||||
browser.Names() []string // this OS's names, sorted, for -b's help and errors
|
||||
```
|
||||
|
||||
## How a browser produces data
|
||||
|
||||
`Browser` says _where_. `Base` says _how_. Each base package supplies two functions:
|
||||
|
||||
```go
|
||||
// one per base, in internal/browser/{chromium,firefox,safari}
|
||||
func Discover(supportedBrowser browser.Browser, options browser.DiscoverOptions) ([]browser.UserDataDir, error)
|
||||
func Extractors(dir browser.UserDataDir, profile browser.Profile) browser.Extractors
|
||||
```
|
||||
|
||||
`app` calls them through a `switch supportedBrowser.Base`. The dispatch cannot live in `browser`: the base packages import `browser` for these very types, so `browser` calling them would be an import cycle, and `gochecknoinits` rules out init-time registration. These are plain functions, not an interface named `Engine` — that word is rejected project-wide.
|
||||
|
||||
The Chromium base supplies two more, for the files no single category owns (below):
|
||||
|
||||
```go
|
||||
// internal/browser/chromium only
|
||||
func KeyLocator(dir browser.UserDataDir, dirSnapshot snapshot.Snapshot) (masterkey.Locator, error)
|
||||
func ArchiveFileSpecs() []browser.FileSpec
|
||||
```
|
||||
|
||||
Safari's `Extractors` takes one more argument, the run's login keychain, which its password extractor captures. Only the default profile's map gets a password extractor, because the keychain belongs to the user, not to one profile ([RFC-006](006-key-retrieval-and-crypto.md)). `LoginKeychain` is the one-method interface Safari declares; `*keychain.Keychain` satisfies it.
|
||||
|
||||
```go
|
||||
// internal/browser/safari only
|
||||
func Extractors(dir browser.UserDataDir, profile browser.Profile, loginKeychain LoginKeychain) browser.Extractors
|
||||
```
|
||||
|
||||
## Discovery
|
||||
|
||||
Discovery answers one question — which user data dirs and profiles exist — and nothing else. Its rules:
|
||||
|
||||
- **Explicit inputs.** Everything comes in through `DiscoverOptions`. `app` resolves the home directory once; if that fails the run stops with status `1`. v1.1.0 resolved it in a package-level variable with the error discarded, so a failure silently turned every path into a wrong absolute one, and tests could not substitute a home directory.
|
||||
- **Every match counts.** Every `UserDataDirs` entry is expanded, globs included, and **every** existing match becomes its own `UserDataDir` — as in v1.1.0, which is what keeps the user data dirs of both of a machine's Arc MSIX packages. The first one of a `Browser` gets its `Name` as the `UserDataDirID`, later ones `-2`, `-3`… in path order, so IDs are stable from run to run.
|
||||
- **Errors are not absence.** A user data dir that does not exist yields nothing. Any other failure — permission denied, a malformed glob — is returned (joined across entries, next to whatever was found) and becomes an `error` result for that browser in the summary. In v1.1.0 both the Chromium and the Firefox profile scans returned nothing on any read error, and glob errors were dropped while an unmatched pattern was kept as a literal path, so "unreadable" looked exactly like "not installed".
|
||||
- **Profiles by v1.1.0's rules.** Chromium directories holding `Preferences` or `Preferences_02` (Tencent forks), with flat-layout and copied-tree fallbacks; Firefox directories holding known data files; Safari's default profile plus its named profiles (macOS 14+). Whatever the base, a profile counts only when it holds a file some category reads, so a profile created and never used is not listed, archived, or keyed. The named profiles are listed only inside `SafariTabs.db`, so Safari's Discover captures that one file into a temporary snapshot with the snapshot copier and reads the copy, never the live database.
|
||||
- **No file checks.** Whether a category's file exists is Plan's question, answered as `absent`, or as `error` when the file cannot be checked. v1.1.0 checked every file while constructing the browser and silently dropped a profile that had none; `list` keeps that display rule (profiles with at least one data file), but the decision lives outside discovery.
|
||||
- **`-p` replaces `UserDataDirs` for one `Browser`.** When `DiscoverOptions.ProfilePath` is set, discovery reads that path instead of the table's entries, and each base interprets it by the rules in [RFC-009](009-cli-surface.md).
|
||||
|
||||
## Per-fork overrides — data stays data
|
||||
|
||||
Most Chromium forks are pure rows. A few store data their own way; v1.1.0 gave them their own `types.BrowserKind` values with `if kind == …` checks across files:
|
||||
|
||||
| Fork names | What differs | Override |
|
||||
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------- |
|
||||
| `yandex` | `Ya Passman Data` and `Ya Credit Cards`, with Yandex's own key wrapping and row format; no account-store passwords | password and credit-card file specs, extractors |
|
||||
| `opera`, `opera-gx`, `vought` | extensions under `extensions.opsettings` | extension extractor |
|
||||
|
||||
These overrides live inside `internal/browser/chromium`, in one unexported table keyed by `Browser.Name` — never by the `UserDataDirID`, which differs for a second user data dir — applied when `Extractors` builds a profile's map. No enum is involved and the browser table stays free of code. A unit test asserts that every override key resolves through `Lookup` to a Chromium `Browser`, so a typo cannot silently drop an override.
|
||||
|
||||
`keys.json` keeps writing v1.1.0's `kind` values (`chromium`, `chromium-yandex`, `chromium-opera`), derived from the same table, so v1.1.0 can still read a new dump. When reading, `restore` resolves the `Browser` from the vault's `browser` name and falls back to `kind` only for a name this build doesn't know.
|
||||
|
||||
## Shared and per-profile files
|
||||
|
||||
Most file specs belong to one profile (cookies, history) and are declared relative to the profile directory. A few belong to the whole user data dir — `Local State` above all — and are marked `Shared`, relative to the user data dir itself ([RFC-003](003-core-types.md)). Plan resolves both into paths under the user data dir and captures the union once per user data dir, so `Local State` is copied once however many profiles and categories need it. The flag is explicit on purpose: rewriting every file spec's path per profile while remembering to leave the shared ones alone would make correctness depend on the order of two builder calls.
|
||||
|
||||
Two Chromium facts concern a whole user data dir rather than one category, and both stay in the Chromium base, so `app` never spells a Chromium file name:
|
||||
|
||||
- **Key material.** The extractors that decrypt — passwords, cookies, credit cards — list `Local State` as a `Shared` file spec, so it is captured only when a decrypting category is requested. `KeyLocator` builds the dir's `masterkey.Locator` from the captured `Local State` and the `Platform` fields; on macOS `app` adds the run's login keychain, then wraps retrieval in the dir's call-once, which every `ProfileSnapshot` of the dir shares as its `MasterKeys` ([RFC-006](006-key-retrieval-and-crypto.md)).
|
||||
- **Layout markers.** `archive` also captures `Local State` and each profile's `Preferences` (or `Preferences_02`) marker, by which `restore` rediscovers every profile; `ArchiveFileSpecs` names them.
|
||||
|
||||
## Adding a browser (the whole motion)
|
||||
|
||||
For a new Chromium fork:
|
||||
|
||||
1. **Add a row** to the table in `internal/browser`: `Name`, `DisplayName`, `Base: Chromium`, and a `Platform` per OS (user data dirs, keychain label; on Windows `Exe`, `ExeFallbacks`, `ABE`).
|
||||
2. **If `ABE` is not `ABENone`**, add the fork's row to the payload's `com_iid.c` — the CLSID/IIDs and vtable slot the injected payload needs. The technique and how to mine those identifiers are in [RFC-016](016-chrome-abe-integration.md).
|
||||
3. **Only for a fork with its own on-disk format**, add an override in the Chromium package.
|
||||
4. **Nothing else.** The fork inherits the entire Chromium base: discovery, every extractor, the key path, snapshot, export, reporting.
|
||||
|
||||
For a genuinely new base (not Chromium/Firefox/Safari), you add a new `internal/browser/<base>` package implementing `Discover` + `Extractors`, a new `Base` value, and a case in `app`'s switch. This is rare — the three bases cover the field.
|
||||
|
||||
## Consistency, enforced by tests
|
||||
|
||||
Folding `winutil.Table` into `Platform` removes the Go-side join, and with it the need for v1.1.0's `TestWinUtilTableCoversABEBrowsers`: one struct cannot disagree with itself. What remains is the C side — the payload runs inside the browser process with no Go runtime, so its table stays in `com_iid.c`. A Go test inside `browser`, over the whole table, parses that file and fails when a Windows entry whose `ABE` is not `ABENone` has no row there with the same executable and ABE kind; the C table may list browsers the Go table does not, such as Avast ([RFC-011](011-testing-and-quality.md)). A mismatch fails `go test`, not production.
|
||||
|
||||
## Why a table beats per-browser types
|
||||
|
||||
The current design has per-OS `platformBrowsers()` lists of `BrowserConfig`, a `WindowsABE` flag, a Windows table joined by key, and two Chromium kinds switched on across files. The table collapses that to rows + three base packages + a short override table. The payoff:
|
||||
|
||||
- The set of supported browsers is **legible in one place** — good for the README, good for a talk slide, good for auditing coverage across all three OSes at once.
|
||||
- A plain fork is a data change, reviewable at a glance.
|
||||
- Base behavior is implemented three times total, not once per browser.
|
||||
@@ -0,0 +1,24 @@
|
||||
# RFC-005: Output
|
||||
|
||||
## Frozen
|
||||
|
||||
Everything a user sees in the output — file names, formats, field names and their order, the browser and profile values — is part of the compatibility contract ([RFC-000](000-goals.md)). Field names on the wire are the snake_case of the record fields, enforced by lint, so the record fields are frozen with the output.
|
||||
|
||||
## Deterministic
|
||||
|
||||
The same snapshot always produces byte-identical files. Order is defined once per category, in the exporter rather than in each extractor, with a stable sort, so ties keep the browser's own order instead of one nobody chose.
|
||||
|
||||
## Safe writing
|
||||
|
||||
- **Private.** Output files are readable by the user only.
|
||||
- **Streamed.** Records go to the files as each extraction finishes, so memory holds one extraction, not the whole run.
|
||||
- **Zip last.** Packing into a zip replaces the loose files only once the zip is complete, so a failure loses nothing.
|
||||
- **Only its own files.** A run packs and removes only the files it wrote.
|
||||
|
||||
## No redaction
|
||||
|
||||
What reaches export was asked for, and the default exports every category.
|
||||
|
||||
## Formats
|
||||
|
||||
Adding a format is a new encoder; nothing else in the pipeline changes.
|
||||
@@ -0,0 +1,23 @@
|
||||
# RFC-006: CLI
|
||||
|
||||
## A frozen surface
|
||||
|
||||
The commands and their flags — names, shorthands, types, and defaults — are a contract: they do not change, and anything added is opt-in. The command line is the specification, and the architecture was derived backward from it.
|
||||
|
||||
## Validate first
|
||||
|
||||
Nothing with a side effect runs until the request is valid. An unknown browser, category, or format, an unusable output directory, or an unreadable keys file fails before discovery and before any password prompt.
|
||||
|
||||
## Keychain password
|
||||
|
||||
- **Explicit input wins.** A flag or standard input comes first, then a no-echo prompt when stdin is a terminal, then none. With no password, keychain-protected data is exported as metadata only.
|
||||
- **Opening is the check.** The keychain is the password's only destination, and opening it decides whether the password works.
|
||||
- **No environment variable.** Every child process would inherit it.
|
||||
|
||||
## Reporting and stopping
|
||||
|
||||
A summary of every outcome goes to stderr. It is not part of the contract, and it never changes the exit status. Ctrl-C ends a run cleanly: copies are removed, the terminal is restored, and no half-written keys file is left behind. The process still ends the way the signal would end it.
|
||||
|
||||
## Restore
|
||||
|
||||
`restore` works from its keys file, not from the local browser table: its browser filter selects the keys file's entries, which may name browsers this OS does not have.
|
||||
@@ -1,79 +0,0 @@
|
||||
# RFC-006: Key Retrieval & Crypto
|
||||
|
||||
**Scope note.** This RFC fixes the _boundaries and contracts_ of the key-retrieval and decryption packages. It deliberately does not restate how any OS secret store is read or how any cipher is applied — those techniques are already documented in [RFC-014](014-chromium-encryption.md) (Chromium encryption), [RFC-015](015-key-retrieval-mechanisms.md) (key retrieval), [RFC-016](016-chrome-abe-integration.md) (Chrome ABE), [RFC-017](017-yandex-decryption.md) (Yandex), [RFC-019](019-firefox-encryption.md) (Firefox encryption), and [RFC-021](021-windows-locked-file-bypass.md) (Windows locked-file). Here each is simply a package with an interface.
|
||||
|
||||
## Two packages, one seam
|
||||
|
||||
- **`internal/masterkey`** owns everything that talks to an OS secret store: retrieving a Chromium user data dir's keys, one per version (DPAPI and ABE on Windows, Keychain on macOS, Secret Service on Linux), decrypting legacy per-value DPAPI blobs, and the portable `keys.json` dump. Platform code sits behind build tags; callers import one package. It knows nothing about records or browsers.
|
||||
- **`internal/crypto`** holds pure primitives over bytes: AES-CBC and AES-GCM, 3DES, PBKDF2, and the ASN.1 PBE structures Firefox's NSS uses. It takes raw keys, nonces, and ciphertexts, makes no OS calls, and imports nothing from the project — which is what keeps it unit-testable with fixed vectors. It knows no blob format: Chromium's version prefix and nonce layout belong to the Chromium base, and Yandex's to its override.
|
||||
|
||||
`masterkey` calls `crypto`; `crypto` never sees a `masterkey.Set`. A decrypt that took a `Set` would have to live in one of the two packages and call back into the other — an import cycle — so dispatch lives with the format that defines it (below).
|
||||
|
||||
A third package sits beside them on macOS only: **`internal/keychain`** owns the user's login keychain — one handle per run, opened on first use, read by the Chromium `v10` retriever and the Safari password extractor. The login password, supplied by the CLI ([RFC-009](009-cli-surface.md)), reaches no other code.
|
||||
|
||||
## Key scopes
|
||||
|
||||
Different bases keep their secrets at different levels, so "once per user data dir" is not universal:
|
||||
|
||||
| Base | Scope | Where the secret comes from | Lazy handle |
|
||||
| -------- | ------------- | ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------- |
|
||||
| Chromium | user data dir | `Local State` from the snapshot, plus the OS secret store — on macOS, that includes the run's login keychain | `ProfileSnapshot.MasterKeys` |
|
||||
| Firefox | profile | the profile's own `key4.db`, validated against its `logins.json` — no OS store, no prompt | derived inside the Firefox password extractor |
|
||||
| Safari | run | the login keychain, opened once per run | `keychain.Keychain`, captured by the Safari password extractor |
|
||||
|
||||
Two edge cases sit outside the table. Legacy Windows Chromium values without a `v10` prefix are raw DPAPI blobs, decrypted one by one through `masterkey.DecryptDPAPI` with the live user's DPAPI context — they never decrypt on another host. And on macOS the Chromium `v10` retriever and the Safari password extractor read the same login keychain, so the keychain is opened once per run and shared ([RFC-003](003-core-types.md); [RFC-009](009-cli-surface.md) defines how its password is supplied).
|
||||
|
||||
## `masterkey` contract
|
||||
|
||||
```go
|
||||
type Version string // "v10", "v11", "v20"
|
||||
type Set map[Version][]byte // JSON form = the keys.json "keys" object
|
||||
|
||||
type Retriever interface {
|
||||
Version() Version
|
||||
Retrieve(ctx context.Context, loc Locator) ([]byte, error)
|
||||
}
|
||||
|
||||
// LoginKeychain is what the macOS v10 retriever reads from the run's login keychain; *keychain.Keychain satisfies it.
|
||||
type LoginKeychain interface {
|
||||
GenericPassword(ctx context.Context, account string) ([]byte, error) // keychain.ErrLocked: no usable password
|
||||
}
|
||||
|
||||
var ErrNotApplicable = errors.New("retriever not applicable")
|
||||
|
||||
func RetrieveAll(ctx context.Context, loc Locator) (Set, error)
|
||||
func DecryptDPAPI(blob []byte) ([]byte, error) // Windows; ErrNotApplicable elsewhere
|
||||
```
|
||||
|
||||
- `Locator` tells retrieval where one user data dir's keys are: the snapshot path of `Local State`, the `KeychainLabel`, the Windows `Exe` and `ABE` kind ([RFC-005](005-browser-definitions.md)), and on macOS the run's login keychain as a `LoginKeychain` — nil elsewhere, and in `restore`. The Chromium base builds it (`chromium.KeyLocator`), because only it knows the keys come from `Local State`; `app` adds the keychain. It never carries a password: only the keychain sees one ([RFC-009](009-cli-surface.md)).
|
||||
- `RetrieveAll` runs this OS's retrievers in order. A retriever that doesn't apply returns `ErrNotApplicable` and is skipped. **Per version, the first key wins:** macOS's `v10` has three ordered strategies ([RFC-015](015-key-retrieval-mechanisms.md)), and once one succeeds the rest are not tried. A version's error is reported only when every retriever for it fails, so a strategy that failed before a later one succeeded is not an error.
|
||||
- **Versions are independent, not a chain.** A Chrome profile upgraded past version 127 carries `v20` cookies beside `v10` passwords, so a `v20` failure keeps the `v10` key, as in v1.1.0. First-success across versions is the bug [RFC-015](015-key-retrieval-mechanisms.md) records as issue #578.
|
||||
- **The macOS keychain retriever follows the handle.** With no keychain, or a locked one, it returns `ErrNotApplicable` and the next `v10` retriever runs — as in v1.1.0, where an empty or rejected password kept that retriever out of the chain. The reason is reported once, through `Keychain.Err`, not once per browser. A label missing from an open keychain is an error, reported only if every `v10` retriever fails. The retriever that runs the `security` command asks the system service instead of reading the file, so it stays separate, with its own per-label cache.
|
||||
|
||||
### Laziness
|
||||
|
||||
`app` backs `ProfileSnapshot.MasterKeys` ([RFC-003](003-core-types.md)) with a per-user-data-dir call-once that asks the Chromium base for the dir's `Locator` and runs `RetrieveAll`; it keeps the retrieval error, which is reported once as the dir's `error` result, and every extraction in the dir gets whatever keys were found. The login keychain carries its own once: on macOS `app` builds it without opening it (a build-tagged one-liner), and its first query opens it and calls the `PasswordFunc` — the only step that can prompt. Go 1.20 has no `sync.OnceValues`, so each is a `sync.Once` with its stored result. The first extractor that needs cleartext triggers them; a run that only touches non-secret data never does, so it never prompts and never performs a privileged lookup. In v1.1.0 the macOS password was resolved as soon as any Chromium or Safari browser was discovered, and Chromium's `Extract` retrieved keys before it looked at the categories — so `dump -b chrome -c history` prompted. The lazy handles design that out.
|
||||
|
||||
## Decryption dispatch
|
||||
|
||||
Chromium's blob format belongs to the Chromium base, so its dispatch lives there. The version prefix picks the key from the `Set`: `v10`, `v11`, and `v20` decrypt with their version's key; `v12` is recognized and reported as unsupported, as in v1.1.0; a blob without a prefix goes to `masterkey.DecryptDPAPI`. The key length picks the cipher — 32 bytes means AES-GCM (Windows), 16 bytes means AES-CBC (macOS, Linux). Yandex's format (per-row AAD, a wrapped data key) is handled by its override with the same primitives.
|
||||
|
||||
Choosing the cipher from the key at runtime, rather than from `GOOS` at build time, is what makes **cross-host decryption** work: a `keys.json` and an archive taken on the same machine can be decrypted on any OS ([RFC-009](009-cli-surface.md)). The keys belong to the user data dir they were taken from; they do not decrypt another machine's data.
|
||||
|
||||
## Firefox and Safari
|
||||
|
||||
Firefox doesn't use an OS secret store the way Chromium does: its key is derived from the profile's own `key4.db` with the NSS primitives in `crypto`, inside `internal/browser/firefox`, and checked against `logins.json` to pick the right candidate. Everything it needs is in the snapshot.
|
||||
|
||||
Safari's passwords live in the login keychain. The Safari password extractor reads them through the run's `keychain.Keychain`, which `safari.Extractors` captures for the default profile only: the keychain belongs to the user, so attributing it to every profile would duplicate its entries. Without a usable password the keychain stays locked and the extractor exports metadata only, as in v1.1.0.
|
||||
|
||||
The keychain is not a snapshot source. It is not a browser file and lies outside every Chromium user data dir; it lives for the run, while a snapshot lives for one user data dir, so a copy in Safari's snapshot could not serve Chromium; and a copy would put one more sensitive file on disk. The handle reads the file once, when it opens — the stable bytes the snapshot rule is for.
|
||||
|
||||
## What stays out of these packages
|
||||
|
||||
- No data-type knowledge. `crypto` imports nothing from the project; `masterkey` never imports `browser` or `record`.
|
||||
- No orchestration. Neither decides _which_ extractions run — that's the planner.
|
||||
- No logging of secrets, ever. Retrieval returns errors; the reporter decides what the operator sees, and key bytes and passwords are never in a log line.
|
||||
|
||||
## Boundary with the technique RFCs
|
||||
|
||||
The format and technique RFCs (013–021) remain the source of truth for mechanics (how ABE injection works, how DPAPI and the keychain are read, the Yandex specifics, the locked-file bypass). This RFC only guarantees that those mechanics sit behind `masterkey` and `crypto` and nowhere else, so the rest of the program — and the people reading it on stage — deal with a handful of clean functions, not six techniques.
|
||||
@@ -0,0 +1,21 @@
|
||||
# RFC-007: Quality
|
||||
|
||||
## Tests
|
||||
|
||||
- A test needs a fixture file, never a running browser or a mocked database: tests build real files in a temporary directory.
|
||||
- Goldens pin the output, and the same fixture always produces the same bytes.
|
||||
- Compatibility tests pin the frozen surface: every command's flags, the output, `keys.json`, and archives.
|
||||
- Every fixed bug gets a regression test.
|
||||
- Coverage is a signal, not a target.
|
||||
|
||||
## Lint and comments
|
||||
|
||||
Lint enforces what review would otherwise argue about: spelled-out names, the form of comments, wire names, and line length. A comment explains why, never what, and the code cites no RFC.
|
||||
|
||||
## Go 1.20
|
||||
|
||||
The module stays on Go 1.20, and CI pins that toolchain instead of following the module file, so a dependency that needs newer Go fails CI instead of passing silently. Go 1.20's own traps are covered by tests: loop variables are shared across iterations, and newer standard helpers are not there.
|
||||
|
||||
## Dependencies
|
||||
|
||||
A dependency earns its place only when writing it ourselves would cost more than auditing it. A release links permissively licensed modules only, and a module whose newer versions would raise the Go requirement is pinned below them.
|
||||
@@ -1,79 +0,0 @@
|
||||
# RFC-007: Snapshot & Acquisition
|
||||
|
||||
## The snapshot-first rule
|
||||
|
||||
No parser ever reads a live browser profile. Capture copies the files a plan needs into a **snapshot directory** — one snapshot per user data dir — and every extractor reads only from its user data dir's snapshot, through the `ProfileSnapshot` that wraps it. Capture is one stage with one contract, so:
|
||||
|
||||
- A running browser holds files open and mutates them mid-read. The snapshot is a point-in-time copy; parsers see stable bytes.
|
||||
- Locked-file handling (a Windows reality) stays in one place — the snapshot's copier — and every acquisition path uses it.
|
||||
- `archive` and `restore` are not special modes: `archive` is "capture, then zip the snapshot directory", `restore` is "unzip or open a snapshot directory, then extract from it". Same code path.
|
||||
|
||||
## Contract
|
||||
|
||||
```go
|
||||
type File struct {
|
||||
UserDataDirID string // the user data dir's ID; also the snapshot it lands in
|
||||
UserDataDirPath string // absolute path of the user data dir it is copied from
|
||||
RelativePath string // slash-separated path relative to UserDataDirPath, and to the snapshot
|
||||
IsDir bool
|
||||
}
|
||||
|
||||
type Dir struct{ /* unexported */ }
|
||||
|
||||
func Temp() (*Dir, error) // a new temporary snapshot directory, mode 0700
|
||||
func Open(path string) (*Dir, error) // an existing one, used in place
|
||||
func Unzip(src string) (*Dir, error) // into a temporary snapshot directory
|
||||
|
||||
func (d *Dir) Capture(ctx context.Context, files []File) error
|
||||
func (d *Dir) Snapshot(userDataDirID string) Snapshot // one user data dir's snapshot
|
||||
func (d *Dir) Zip(dst string) error // archive transport
|
||||
func (d *Dir) Close() error
|
||||
|
||||
type Snapshot struct{ /* unexported */ }
|
||||
|
||||
func (s Snapshot) Path(rel string) (string, error) // absolute path inside the snapshot
|
||||
```
|
||||
|
||||
`Snapshot` returns real paths, not readers: `modernc.org/sqlite` and `goleveldb` open files by path, and SQLite reads its `-wal` file from beside the database. A zip can't serve either, so the snapshot is always a directory and zip is only how it travels: `restore` unzips into a temporary directory first.
|
||||
|
||||
**Errors.** `Capture` keeps going when one file fails; it returns an error only when it cannot go on — a cancelled context, an unwritable snapshot directory. A file that vanished before Capture reached it reads back from `Snapshot.Path` as `fs.ErrNotExist`, which makes its extraction `absent`; a file whose copy failed reads back as that copy's error, which makes its extraction `error`. Every other extraction runs.
|
||||
|
||||
## Lifetime
|
||||
|
||||
`dump` captures one user data dir at a time ([RFC-001](001-architecture-and-pipeline.md)): `Execute` creates a `Temp` snapshot directory for the dir, captures its files, runs its extractions, and `Close`s it before the next dir. At most one user data dir's copies of `Login Data`, `Cookies`, and the like exist at once — close to v1.1.0's per-profile session, and far from a run-long snapshot directory holding every browser's copies until the end. `archive` captures every user data dir into one snapshot directory, because the zip of that directory is its product. `restore --data-zip` unzips into a `Temp` snapshot directory; `restore --data-dir` `Open`s the given directory, which `Close` leaves in place.
|
||||
|
||||
Because it holds those copies, a temporary snapshot directory is created with mode `0700` and always removed — on success, on error, and on cancellation (the run's context is cancelled on Ctrl-C, `SIGTERM`, or `SIGHUP`; [RFC-009](009-cli-surface.md)). The live profile still exists, so removing the copy never loses anything.
|
||||
|
||||
## Layout and user data dir identity
|
||||
|
||||
A snapshot directory is `<dir>/<user-data-dir-id>/<path relative to the user data dir>`: one subdirectory, one snapshot, per user data dir. For the first user data dir of a browser the ID is its `Browser.Name`, so the layout is exactly v1.1.0's archive layout (`<browser-key>/<User Data layout>`) and v1.1.0's `restore` reads new archives unchanged. A second one of the same browser — the second of Arc's two MSIX packages on Windows — gets `arc-2/`, where v1.1.0's archive keyed every file by browser key alone and silently dropped it.
|
||||
|
||||
An archive captures what v1.1.0's did — `Local State` and each profile's `Preferences` marker (both named by the Chromium base, [RFC-005](005-browser-definitions.md)), the requested categories' files, and the account-synced `Login Data For Account` — so `restore` rediscovers every profile from the layout alone.
|
||||
|
||||
`keys.json` joins to the archive by the vault's `browser` key, as in v1.1.0. A vault for a second user data dir carries an extra optional `id` field (`"arc-2"`) — the `UserDataDirID` on the wire, per the wire-name rule; readers that don't know the field, including v1.1.0, ignore it and restore the first one. The dump version stays `"2"`.
|
||||
|
||||
## No manifest
|
||||
|
||||
An archive holds only the layout. `restore` rebuilds user data dirs and profiles from the keys.json vaults plus that layout, which is the only way v1.1.0's archives can restore, and the same way serves every archive this version writes, so a manifest would only be a second description of the layout to keep in step with it. Restore then runs Extract → Export → Report exactly as a live run would. One thing the layout cannot carry is a flat-layout profile's original name (older Opera keeps its profile at the user data dir root): such a profile restores under its archive directory's name, as it did in v1.1.0.
|
||||
|
||||
## Copy semantics
|
||||
|
||||
- Capture only ever **reads** the browser's files; it never deletes or moves anything in a real profile.
|
||||
- A file is copied together with its SQLite `-wal` and `-shm` sidecars when they exist; a directory (LevelDB, Session Storage) is copied whole, skipping its `LOCK` file — both as in v1.1.0.
|
||||
- Chromium databases are opened as copied, `-wal` included; Firefox and Safari databases are opened with `journal_mode=off` — both as in v1.1.0.
|
||||
- `Zip` writes to a temp file beside the target and renames it into place only after the zip is closed; a failed archive leaves no partial file behind.
|
||||
- `Unzip` rejects any entry whose path would land outside the snapshot directory.
|
||||
|
||||
The `--zip` output-packing bug (originals deleted before the zip is written) is an Export concern and is fixed there ([RFC-008](008-output-and-export.md)).
|
||||
|
||||
## Locked-file handling
|
||||
|
||||
Chromium on Windows has held `Cookies` under an exclusive lock since Chrome 114, so a plain copy fails while the browser runs; on macOS and Linux file locks are advisory and never block a reader. Reading such a file is Windows-specific and lives in `winapi` (the technique itself is documented in [RFC-021](021-windows-locked-file-bypass.md)). The snapshot's copier tries a plain copy first and, on Windows only, falls back to the locked-file copy when the plain copy fails — v1.1.0's order. macOS and Linux use the plain copy. Extractors are unaware of which strategy ran.
|
||||
|
||||
## Scope
|
||||
|
||||
`archive`, `dumpkeys`, and `restore` are Chromium-only, as in v1.1.0: Firefox and Safari have no portable key in `keys.json`. Archiving them is DEFERRED; it would add capability, which this design does not.
|
||||
|
||||
## Why this is worth a dedicated stage
|
||||
|
||||
Acquisition is where the messiest real-world facts live: files that move, lock, or vanish between discovery and read. Isolating all of that in Capture, behind a read-only `Snapshot`, means the parsers downstream are pure file-in/record-out functions. That is the difference between a parser you can unit-test with a fixture file and one that needs a live browser to exercise.
|
||||
@@ -1,86 +0,0 @@
|
||||
# RFC-008: Output & Export
|
||||
|
||||
Everything a user can see in the output — file names, formats, field names, browser and profile values — is frozen by the compatibility contract ([RFC-000](000-goals-and-constraints.md)). This RFC describes how the exporter reproduces it byte for byte, and the few places where v1.1.0's output was wrong and is fixed.
|
||||
|
||||
## Contract
|
||||
|
||||
```go
|
||||
type Format int // the -f value; the zero value is JSON, the default
|
||||
|
||||
const (
|
||||
JSON Format = iota
|
||||
CSV
|
||||
CookieEditor
|
||||
)
|
||||
|
||||
func ParseFormat(s string) (Format, error) // "json", "csv", "cookie-editor"
|
||||
|
||||
type Writer struct{ /* unexported */ }
|
||||
|
||||
func NewWriter(dir string, f Format, zip bool) (*Writer, error)
|
||||
func (w *Writer) Write(c category.Category, records []record.Record) error // one extraction's records, appended in plan order
|
||||
func (w *Writer) Close() error // finishes every file; with --zip, packs them
|
||||
func (w *Writer) Output() Output // what a clean Close left: the files, their counts, the zip
|
||||
```
|
||||
|
||||
Export writes one file per non-empty category: `password.csv`, `cookie.json`, and so on — `<category>.<ext>`, where the extension is `csv` or `json` (`cookie-editor` writes `.json`). A category with no records produces no file. The output directory is created with mode `0750` and each file with `0600`, as in v1.1.0; the `--zip` archive gets `0600` too, where v1.1.0 created it `0666` before the umask, usually readable by every local user. `Close` itself prints nothing: `Output` lists the files with their record counts and the zip, and `app` prints the "Exported to" lines from it. One `-f` value per run, as in v1.1.0.
|
||||
|
||||
## Formats
|
||||
|
||||
- **`json`** (default) — one array of objects per category, two-space indent, UTF-8 without a BOM. Strings keep v1.1.0's HTML escaping: `&`, `<`, and `>` are written as `\u0026`, `\u003c`, and `\u003e`. v1.1.0's per-row `MarshalJSON` called `json.Marshal`, which escaped them even though the outer encoder turned escaping off; the records are plain structs, so the encoder leaves escaping on to produce the same bytes. Any URL with a query string shows the difference, so the export goldens catch a slip at once.
|
||||
- **`csv`** — a header row, then one row per record; UTF-8 with a 3-byte BOM so Excel reads non-ASCII correctly; times in RFC 3339 (empty when zero), booleans as `true` / `false`.
|
||||
- **`cookie-editor`** — cookies as the Cookie-Editor extension's import array (`expirationDate`, `httpOnly`, `hostOnly`, `sameSite`, …), written without HTML escaping, as in v1.1.0; every other category falls back to the `json` encoder above, as in v1.1.0.
|
||||
|
||||
Adding a format later is a new `Format` value and a new encoder; nothing else in the pipeline changes.
|
||||
|
||||
## Wire names follow Go names (DECIDED)
|
||||
|
||||
JSON keys and CSV headers are the snake_case form of the Go field names: `Cookie.IsHTTPOnly` is `is_http_only`, `Extension.HomepageURL` is `homepage_url`. `encoding/json` does not derive names on its own, so every field keeps an explicit `json` and `csv` tag, and the rule "tag = snake_case(field name)" is enforced by `tagliatelle` (`use-field-name: true`, `json: snake`, `csv: snake`). The record and `keys.json` types pass that check; the Cookie-Editor encoder is exempt, because its keys are the extension's import schema, not ours.
|
||||
|
||||
The consequence is stated plainly: since the output is frozen, **the record field names are frozen too** — a rename would change a column. A field can only be renamed together with a deliberate, announced output change, and the lint makes such a change impossible to miss in review.
|
||||
|
||||
### Browser and profile fields
|
||||
|
||||
Every record starts with two flat source fields — `Browser` and `Profile` ([RFC-003](003-core-types.md)) — serialized as the leading `browser` and `profile` keys in JSON and the leading columns in CSV, exactly as in v1.1.0. `browser` is the display name (`Chrome`, `Microsoft Edge`); `profile` is the profile name (`Default`, `Profile 1`, a Safari profile's title), never a path. The pipeline's `Collector` sets both through `SetBrowserAndProfile`, so no extractor can leave them out.
|
||||
|
||||
## Deterministic ordering
|
||||
|
||||
Output order is defined once per category, in the exporter, for every browser. Files list extractions in plan order — the browser table's order (one merged list whose per-OS projections equal v1.1.0's per-OS orders), then user data dir ID, then profiles in discovery order (directory order for Chromium and Firefox, the default profile first for Safari) — which matches v1.1.0's order. Within an extraction, records are sorted by v1.1.0's key with a stable sort (`sort.SliceStable`; Go 1.20 has no `slices`), and ties keep the order the extractor emitted them in — the source order, which a snapshot fixes — so two runs over the same snapshot produce byte-identical files:
|
||||
|
||||
| Category | Order |
|
||||
| --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
||||
| password | `created_at` descending; on a tie, local before account, the order the Chromium extractor reads its two stores in |
|
||||
| cookie, bookmark | `created_at` descending |
|
||||
| history | `visit_count` descending |
|
||||
| download | `start_time` descending |
|
||||
| creditcard, extension, localstorage, sessionstorage | source order (row order, LevelDB key order, JSON document order) |
|
||||
|
||||
Ties are not broken by a second key, because some sources lack the first: Safari bookmarks carry no creation time and Safari downloads no start time, so a tie-breaker such as `id` or `url` would replace their file order with an order nobody chose. A stable sort leaves them as the browser stored them.
|
||||
|
||||
v1.1.0 decided the order in each extractor with an unstable `sort.Slice`, so ties came out in an order nobody chose — and Firefox history sorted _ascending_ by visit count while Chromium and Safari sorted descending. The table keeps v1.1.0's keys and fixes Firefox to match the others.
|
||||
|
||||
## Streaming vs. buffering
|
||||
|
||||
Extractors emit records one at a time ([RFC-003](003-core-types.md)), but sorting needs an extraction's full set. The writer buffers one extraction's records, sorts them, appends them to that category's file, and releases them — memory is bounded by the largest single category of a single profile, where v1.1.0's writer held the whole run. The standard encoder cannot append to an open array, so the writer frames it itself: `[` before the first element, each element encoded with a two-space prefix and indent, `,` between elements, and `]` plus a newline on `Close`. Those are the bytes a single `Encode` of the whole slice produces, and the export goldens prove it ([RFC-011](011-testing-and-quality.md)).
|
||||
|
||||
## `--zip`
|
||||
|
||||
`--zip` keeps v1.1.0's result — `<dir>/<basename(dir)>.zip` with the files at its top level, and the loose files removed — but fixes the order. v1.1.0 deleted each file as soon as it was added to an in-memory zip and wrote the zip to disk last, so any failure along the way lost the output. The writer writes the zip to a temp file, closes and renames it into place, and only then deletes the originals; a failure leaves every output file where it was. It packs only the files the run wrote, where v1.1.0 packed and deleted every file in the directory, whoever wrote it.
|
||||
|
||||
## Output fixes (listed exceptions to "unchanged")
|
||||
|
||||
- **Firefox history order** — `visit_count` descending, like Chromium and Safari.
|
||||
- **Firefox bookmarks** — `folder` holds the real folder name instead of `url`, and `type` and `id` are filled; v1.1.0 always wrote `url`, empty, and `0`.
|
||||
- **Safari bookmark IDs** — unique across the whole bookmark tree; in v1.1.0 each ID was the index among its siblings, so IDs repeated across folders.
|
||||
- **Firefox logins without a key** — when a profile's key cannot be recovered (no `key4.db`, or a primary password is set), its logins are exported with empty usernames and passwords and the extraction is `partial`; v1.1.0 panicked as soon as one of those logins used the legacy cipher.
|
||||
- **Yandex logins and cards without a key** — when a profile's data key cannot be recovered (no master key, a wrong one, or a master password is set), its logins and cards are exported with empty passwords and card numbers and the extraction is `partial`, as every other store's are; v1.1.0 exported none of them.
|
||||
- **`browser` in `restore` output** — the display name (`Chrome`), as `dump` writes it; v1.1.0's `restore` wrote the vault key (`chrome`).
|
||||
- **CocCoc cookies beside Yandex** — on Windows, ABE looks for a browser's program in its own install locations before registry App Paths. CocCoc and Yandex both ship `browser.exe`, and App Paths names only one of them, so v1.1.0 requested CocCoc's key from Yandex's program and exported its `v20` cookies with empty values.
|
||||
|
||||
## Secrets in output
|
||||
|
||||
`-c all` is the default, as in v1.1.0, so a bare run exports every category, passwords and cookies included. The exporter does not redact: what reaches Export was asked for.
|
||||
|
||||
## DEFERRED
|
||||
|
||||
- **JSON without HTML escaping.** Every JSON parser reads `\u0026` and `&` as the same string, but dropping the escapes would change bytes in nearly every file, so it waits for an announced output change.
|
||||
@@ -1,81 +0,0 @@
|
||||
# RFC-009: CLI Surface
|
||||
|
||||
The command surface is v1.1.0's, unchanged: the operator's view is the spec, and the architecture is derived backward from it. This RFC records that surface, the one additive input it introduces, and the behavior fixes behind unchanged flags.
|
||||
|
||||
## Commands (unchanged)
|
||||
|
||||
| Command | Does | Flags |
|
||||
| ---------- | -------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
|
||||
| `dump` | Discover → extract → export. The default command. | `-b` `-c` `-f` `-d` `-p` `--keychain-pw` `--zip` |
|
||||
| `dumpkeys` | Write Chromium master keys as `keys.json` (stdout by default; `-o` writes the file with mode `0600`). | `-b` `-o` `--keychain-pw` |
|
||||
| `archive` | Zip the decryption-relevant Chromium files for another host. | `-b` `-c` `-o` (default `browser-data.zip`) |
|
||||
| `restore` | Decrypt an archive or copied data with a `keys.json`. | `--keys` (required, `-` = stdin), `--data-dir` \| `--data-zip` (exactly one), `-b` `-c` `-f` `-d` `--zip` |
|
||||
| `list` | Show detected browsers and profiles (columns Browser, Profile, Path); `--detail` adds a count column per category. | `--detail` |
|
||||
| `version` | Version, commit (first 8 characters), and build date, set by `-ldflags`; a build without them reads the module's VCS build info. | — |
|
||||
|
||||
`-v, --verbose` is global. `hack-browser-data` with no subcommand runs `dump`, and `dump`'s flags are mirrored onto the root, so `hack-browser-data -b chrome` keeps working (this also covers the Windows double-click case).
|
||||
|
||||
Every command is a different cut of one pipeline ([RFC-001](001-architecture-and-pipeline.md)): `list` stops after Plan; `list --detail` runs Extract with no secrets and counts what the `Collector` receives instead of exporting it; `archive` captures every user data dir into one snapshot directory and zips it; `dumpkeys` captures each user data dir's `Local State` and runs only key retrieval; and `restore` extracts from an existing snapshot directory.
|
||||
|
||||
## Core flags of `dump` (unchanged)
|
||||
|
||||
| Flag | Default | Meaning |
|
||||
| -------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `-b, --browser` | `all` | `all` or one ID from `browser.Supported()`, this OS's rows |
|
||||
| `-c, --category` | `all` | comma-separated categories: `password`, `cookie`, `bookmark`, `history`, `download`, `creditcard`, `extension`, `localstorage`, `sessionstorage` |
|
||||
| `-f, --format` | `json` | `csv`, `json`, or `cookie-editor` |
|
||||
| `-d, --dir` | `results` | output directory |
|
||||
| `-p, --profile-path` | — | custom data location for one browser (the path `chrome://version` shows, or a user data dir) |
|
||||
| `--keychain-pw` | — | macOS login password (kept for compatibility; visible in `ps` and shell history) |
|
||||
| `--zip` | `false` | pack the output files into a zip |
|
||||
|
||||
The flag names stay, and the Go names follow them: `-c/--category` selects `category.Category` values ([RFC-004](004-naming-decisions.md)). What is frozen is each flag's name, shorthand, type, and default; usage strings may be clarified — `--keychain-pw` gains a note that it is visible in `ps` — and the root command's description names Safari. `-b`'s usage string lists the running OS's IDs.
|
||||
|
||||
## Validation happens first — the ordering bug, designed out
|
||||
|
||||
v1.1.0 checked `-c` and `-f` only after discovery and after the keychain prompt, so a typo in a format wasted a prompt and a discovery pass. Here, **Validate is stage 1** ([RFC-001](001-architecture-and-pipeline.md)): an unknown format, category, or browser ID, a `-d` that cannot be created, `--data-dir` together with `--data-zip`, or an unreadable `--keys` all fail before any browser is touched and before any secret is read. These exit `1`, as in v1.1.0; only the timing changes, and a typo in `-c` or `-f` now fails even where no browser is found, where v1.1.0 stopped first at "no browsers found" with `0`. An unknown `-b`, including a browser only another OS has, is the same case: v1.1.0 found nothing and exited `0`; like a missing `-p`, it now exits `1`, because such a command line never did anything. The rule: _nothing with a side effect runs until the request is valid._
|
||||
|
||||
## `-p, --profile-path` — same meaning, the long-standing bugs fixed
|
||||
|
||||
The flag keeps its meaning and its name: a custom data location for one browser. It has never worked well, and the design fixes every known fault behind it without changing the flag.
|
||||
|
||||
- **Validated first.** In v1.1.0 a non-existent `-p` was read as an empty directory, so the run just said "no browsers found" and exited `0`. Validate now checks that the path exists and is a directory, and exits `1` with a clear message if not ([RFC-001](001-architecture-and-pipeline.md)).
|
||||
- **With `-b all`.** In v1.1.0 `-p` was silently ignored when `-b` was `all`, because the override was guarded by `name != "all"`. Validate now logs a warning that `-p` needs a specific `-b`, then ignores it as before — the run itself is unchanged. Rejecting the combination would turn v1.1.0's exit status `0` into `1`, which the contract rules out.
|
||||
- **Pointing at a Chromium profile directory.** The help text asks for the path `chrome://version` shows, which is a profile directory (`…/User Data/Default`). In v1.1.0 that directory became the whole user data dir, so the `Local State` one level up was never found and, on Windows, the keys could not be derived — `-p` effectively could not decrypt anything there. The Chromium `Discover` now looks at what it was given: a directory holding `Preferences` but no `Local State` is a profile, so its parent is the user data dir and only that profile is selected; a directory holding profile subdirectories, or a flat layout with its own `Local State`, is a user data dir, as before. Either way the keys resolve.
|
||||
- **Firefox selects only the named profile.** In v1.1.0 the Firefox override took the parent of the given directory as the Profiles root and then exported _every_ profile under it, not the one asked for. `Discover` now selects only the profile the path names. This narrows v1.1.0's output for `-b firefox -p <profile>` and is an expected diff in the extract goldens ([RFC-011](011-testing-and-quality.md)).
|
||||
- **Safari keeps its meaning.** `-b safari -p` names a Safari directory to read instead of `~/Library/Safari`, as it always has: its parent stands in for `~/Library`, so the named profiles in the container beside it are found too, and passwords still come from the login keychain.
|
||||
|
||||
Selecting profiles by name across browsers is DEFERRED; if added, it gets its own flag rather than changing `-p`.
|
||||
|
||||
## Keychain password input (DECIDED)
|
||||
|
||||
`--keychain-pw` stays, because scripts use it. One safer input is added beside it:
|
||||
|
||||
- `--keychain-pw-stdin` (on `dump` and `dumpkeys`): read the password from the first line of standard input, for piping from a secret manager.
|
||||
|
||||
Precedence, highest first:
|
||||
|
||||
1. An explicit flag — `--keychain-pw` or `--keychain-pw-stdin` (mutually exclusive).
|
||||
2. An interactive no-echo prompt (`golang.org/x/term`), only when stdin is a terminal.
|
||||
3. None: keychain-protected data is exported as metadata only, as in v1.1.0.
|
||||
|
||||
Explicit inputs win because they are the user's stated intent; the prompt is the fallback, never the first step. Validate turns the chosen input into the one `keychain.PasswordFunc` the run's login keychain is built with ([RFC-003](003-core-types.md)); no other code sees the password. The function runs when the keychain is first used, so `dump -c history` never asks ([RFC-006](006-key-retrieval-and-crypto.md)). Opening the keychain is the check: a missing or wrong password leaves it locked, keychain-protected data is exported as metadata only, as in v1.1.0, and the reason is reported once. The help text says what each input exposes: `--keychain-pw` is visible in `ps` and shell history; stdin from a secret manager leaves no trace.
|
||||
|
||||
There is no environment variable. Every child process the tool starts would inherit it — the macOS key retrieval runs the `security` command — and the inline form `VAR=… hack-browser-data` lands in shell history just like the flag. A second non-interactive input would add only a precedence level and its tests.
|
||||
|
||||
## Reporting & exit status
|
||||
|
||||
After a run, the reporter prints a per-browser, per-profile, per-category summary with each extraction's outcome and count on stderr, after the "Exported to …" lines. The summary is additive and not part of the contract. `-v` adds record-level debug lines, as in v1.1.0. The exit status is v1.1.0's: `0` when the run completes, whatever the per-extraction outcomes, and `1` when it cannot start or finish ([RFC-001](001-architecture-and-pipeline.md)).
|
||||
|
||||
**Stopping.** Ctrl-C, `SIGTERM`, and `SIGHUP` still end a run, but cleanly: the run stops before its next user data dir, file, or extraction, a waiting keychain prompt returns with the echo back on, the temporary snapshot is removed ([RFC-007](007-snapshot-and-acquisition.md)), and `dumpkeys` writes no `keys.json`. One line replaces the error, usage, and summary, and the process then ends by the same signal (on Windows, with the status Ctrl-C gives), so a calling shell or script sees what it saw in v1.1.0. A second signal ends the process at once, as the signal would without the handler.
|
||||
|
||||
## `restore` specifics (unchanged)
|
||||
|
||||
`restore`'s universe is its `keys.json`, not the local table: `-b` filters the dump's vaults, and a vault's `Browser` is resolved with `browser.Lookup`, which searches the whole table whatever the host OS ([RFC-005](005-browser-definitions.md)), so a Windows-only fork restores on macOS. Exactly one of `--data-dir` and `--data-zip` is required. A zip is extracted into a temporary snapshot directory (`snapshot.Unzip`), rejecting entries that escape it, and removed when the run ends; a `--data-dir` is opened in place (`snapshot.Open`) and never removed ([RFC-007](007-snapshot-and-acquisition.md)). The data has two layouts, as in v1.1.0: `<browser-key>/` subdirectories (the archive layout), from which every selected vault restores, or one browser's hand-copied `User Data`, which is unambiguous only when `-b` selects a single vault.
|
||||
|
||||
## DEFERRED
|
||||
|
||||
- Profile selection by name.
|
||||
- More than one `-f` value per run.
|
||||
- Machine-readable exit codes for usage errors and partial runs (opt-in only, if ever).
|
||||
- A `--quiet` switch for the summary.
|
||||
@@ -1,44 +0,0 @@
|
||||
# RFC-010: Dependencies
|
||||
|
||||
Every dependency is justified or dropped. The bar: a dependency earns its place only if replacing it with stdlib would cost materially more than the dependency costs us (in audit surface, license, and Go-1.20 compatibility). The tool runs on evidence machines and goes on stage — the dependency list is part of the audit story.
|
||||
|
||||
## Direct dependencies — keep / drop / pin
|
||||
|
||||
| Module | Decision | Rationale |
|
||||
| ------------------------------------------------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `modernc.org/sqlite` v1.31.1 | **KEEP, pinned** | Pure-Go SQLite; no cgo, so cross-compilation stays trivial. v1.32+ needs Go 1.21. Wrapped by `internal/sqlitex`. |
|
||||
| `github.com/spf13/cobra` + `pflag` | **KEEP** | Command tree and flags; the frozen CLI surface is defined with them. Confined to `cmd/`. |
|
||||
| `github.com/inconshreveable/mousetrap` | **KEEP** | Detects a launch from Explorer (double-click) so `cmd/` can hide the console and skip cobra's double-click guard; already required by cobra. |
|
||||
| `github.com/tidwall/gjson` v1.18.0 | **KEEP, pinned** | Read-only JSON probing of browser files (`Local State`, `Bookmarks`, `Secure Preferences`) without full unmarshal. v1.19+ needs Go 1.23. |
|
||||
| `github.com/syndtr/goleveldb` | **KEEP** | LevelDB reader for Local/Session Storage. No stdlib equivalent. |
|
||||
| `github.com/moond4rk/binarycookies` | **KEEP** | First-party; Safari cookie format. MIT. |
|
||||
| `github.com/moond4rk/plist` | **KEEP** | First-party fork of `howett.net/plist`; Safari plists. BSD-3 — keep Howett's notice. |
|
||||
| `github.com/moond4rk/keychainbreaker` | **KEEP** | First-party; macOS keychain files. Apache-2.0. Behind `keychain` and `masterkey` (darwin); the Safari extractor uses only its record type. |
|
||||
| `github.com/godbus/dbus/v5` + `ppacher/go-dbus-keyring` | **KEEP** | Linux Secret Service access. BSD. Behind `masterkey` (linux). |
|
||||
| `golang.org/x/sys` v0.30.0 | **KEEP, pinned** | Windows syscalls for DPAPI, locked-file copy, and the ABE bridge. Behind `winapi` and `abe`. Later releases raise the `go` directive above 1.20. |
|
||||
| `golang.org/x/term` v0.29.0 | **KEEP, pinned** | No-echo password prompt ([RFC-009](009-cli-surface.md)). v0.30+ needs Go 1.23. |
|
||||
| `github.com/otiai10/copy` | **DROP** | It links `golang.org/x/sync` into every binary, and its Windows build imports `testing` and the `github.com/otiai10/mint` assertion library from non-test code, so both ship in the release exe. Every call already goes through one wrapper; a ~50-line copier in `internal/snapshot` (files, directories, skip list) replaces it. |
|
||||
| `github.com/stretchr/testify` | **KEEP (test-only)** | Assertions in tests; never linked into the binary. |
|
||||
|
||||
`golang.org/x/text` needs no action: HBD does not import it and it is not linked into the binary. It stays in `go.mod` as `// indirect` only because goleveldb's test dependencies require it (`go mod why -m golang.org/x/text`), so dropping it is not something HBD code can do.
|
||||
|
||||
## Indirect dependencies
|
||||
|
||||
The `modernc.org/*` set (`libc`, `memory`, `mathutil`, …) comes in through `modernc.org/sqlite` and rides its pin. `go-humanize`, `golang-lru/v2`, `uuid`, `go-isatty`, `go-strftime`, `bigfft`, `snappy`, `tidwall/match` + `pretty`, `go.yaml.in/yaml/v3`, `x/sync`, `x/tools`, `x/text` are transitive. `otiai10/copy` and `otiai10/mint` are gone, and `go mod tidy` under the Go 1.20 toolchain leaves the `go` directive at 1.20.
|
||||
|
||||
## The Go 1.20 discipline
|
||||
|
||||
- `go mod tidy` and `go mod verify` must be run with the **go@1.20** toolchain (per project CLAUDE.md), or a transitive dependency silently bumps the `go` directive and breaks the Windows 7 build.
|
||||
- Any candidate dependency is checked for its own `go` directive before adoption. A library requiring 1.21+ is disqualified regardless of merit.
|
||||
- Dependabot's ignore rules (`.github/dependabot.yml`) hold every pin above; a new pin gets its rule in the same PR.
|
||||
- CI must not follow `go.mod`: with `go-version-file: go.mod`, a bump that raised the `go` directive would make CI install the newer Go and pass. Every workflow pins `go-version: '1.20.x'` instead, and lint fails when `go.mod` says anything but `go 1.20` or gains a `toolchain` line ([RFC-011](011-testing-and-quality.md)).
|
||||
|
||||
## License hygiene
|
||||
|
||||
The project is MIT; the shipped binary links only permissively licensed modules. The policy is an allowlist — MIT, BSD-2-Clause, BSD-3-Clause, Apache-2.0, ISC — applied to the modules actually linked into a release binary (`go list -deps` per GOOS) and kept by review; an automated release check is DEFERRED. The linked set is MIT (gjson and the tidwall helpers, binarycookies, go-humanize, go-isatty, go-strftime), BSD (modernc, goleveldb, godbus, go-dbus-keyring, plist, snappy, uuid, bigfft, pflag, the `x/` modules), and Apache-2.0 (cobra, mousetrap, keychainbreaker). `golang-lru/v2` (MPL-2.0) is in the module graph but not linked, and must stay unlinked.
|
||||
|
||||
BSD and Apache-2.0 require their notices in binary distributions, so each release archive ships a `THIRD_PARTY_NOTICES` file generated from the linked modules' license files.
|
||||
|
||||
## Net effect
|
||||
|
||||
Drop `otiai10/copy` (and with it `x/sync` from every binary and `testing` + `mint` from the Windows exe); make every Go-1.20 pin explicit; keep everything else. The result is a dependency list short enough to read aloud and defend — which is the goal for a showcased tool.
|
||||
@@ -1,95 +0,0 @@
|
||||
# RFC-011: Testing & Quality
|
||||
|
||||
The pipeline split ([RFC-001](001-architecture-and-pipeline.md)) exists partly so each concern can be tested in isolation, and the compatibility contract ([RFC-000](000-goals-and-constraints.md)) only holds if a test pins it. This RFC says how.
|
||||
|
||||
## Test strategy by layer
|
||||
|
||||
| Layer | How it's tested |
|
||||
| ------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `crypto` primitives | Pure functions over bytes; fixed known-answer vectors. No OS, no files. |
|
||||
| `category` | `String` / `Parse` round-trip over `All()`; the zero `Category` is "none". |
|
||||
| `record` | `SetBrowserAndProfile` sets `Browser` and `Profile`; every record type's tags equal snake_case(field name); each type's `Category()` matches the table in [RFC-003](003-core-types.md). |
|
||||
| extractors (`browser/*`) | A sanitized fixture (SQLite, JSON, plist, LevelDB) in `testdata/`, captured into a `t.TempDir()` snapshot, parsed, and compared to a golden record set. No live browser. |
|
||||
| `snapshot` | `t.TempDir()`; capture with `-wal`/`-shm` sidecars, reopen, zip round-trip, Zip-Slip rejection; a vanished file reads back as `fs.ErrNotExist` and a failed copy as its error while the rest of the capture completes; `Close` removes a temporary snapshot directory — also after an error — and leaves an opened one in place. |
|
||||
| `export` | Records in → golden `csv` / `json` / `cookie-editor` out; deterministic order; byte-identical to v1.1.0's encoder on the same records, HTML escaping included. |
|
||||
| `app` (planner/report) | Table tests over synthetic user data dirs; asserts the `Plan` with `reflect.DeepEqual`, every outcome rule, and the exit status. |
|
||||
| `masterkey` | Fake retrievers: per version the first key wins and later retrievers are not called; a version's error appears only when all its retrievers fail; a `v20` failure keeps the `v10` key. |
|
||||
| platform (`winapi`, OS retrievers in `masterkey`) | `_windows_test.go` / `_darwin_test.go` / `_linux_test.go`, run on the real OS in CI; the ABE path also on a dedicated Windows host. |
|
||||
|
||||
Principle: **a test needs a fixture file, not a running browser.** Because every parser reads through a `ProfileSnapshot` over a `snapshot.Snapshot`, a `testdata/` file is a complete input. This is what makes the extractor suite fast and runnable on any OS.
|
||||
|
||||
## Compatibility tests
|
||||
|
||||
These guard the contract; a failure means something a user can see has changed.
|
||||
|
||||
- **CLI surface.** For every command, the set of flags — name, shorthand, type, default — is compared against a golden captured from v1.1.0. One golden serves every OS and is checked on all three: none of these attributes varies by OS — only `-b`'s usage text does, and usage text is not recorded. Only the additive `--keychain-pw-stdin` is expected on top.
|
||||
- **Output parity.** Checked-in goldens pin the output of every format on the same fixture snapshots; they were captured byte-for-byte from v1.1.0's output and differ from it only by the listed output fixes ([RFC-008](008-output-and-export.md)), each pinned by its own test. The fixtures include URLs with `&` and `<`, so JSON escaping is covered.
|
||||
- **`keys.json` and archives.** A v1.1.0 `keys.json` and archive restore with the new binary; a new `keys.json` parses with v1.1.0's reader (version `"2"`, unknown fields ignored); a new archive keeps the `<browser-key>/…` layout.
|
||||
- **`list --detail` counts.** Counts from Extract-without-secrets equal v1.1.0's per-category counts on the same fixtures.
|
||||
|
||||
## Golden files
|
||||
|
||||
Export and extractor tests compare against checked-in golden outputs. Deterministic ordering is what makes goldens stable — without it, goldens would flap. Setting `HBD_UPDATE_GOLDEN=1` regenerates them on intentional changes. Goldens double as documentation of the exact output shape, useful for the README and for talks.
|
||||
|
||||
Each golden lives beside the package whose output it pins: the export goldens in `export`, `keys.json` in `masterkey`, and the `extract`, `archive`, and `restore` goldens — all of which run the pipeline — in `app`; the flag-surface and `list` goldens stay in `cmd/hack-browser-data`. Shared fixture builders are in `internal/browser/browsertest`, the comparison helpers in `internal/golden`. A golden holds what no other golden already implies: the Cookie-Editor golden holds only `cookie.json`, because every other category is asserted to match the json output byte for byte, and `restore` is asserted to match the extract output except for its `browser` value.
|
||||
|
||||
## Regression tests for the known bugs
|
||||
|
||||
Each bug designed out by this rewrite gets a test that would have caught it, so it can never silently return:
|
||||
|
||||
- **Firefox bookmark fields** (`folder` always `url`, `type` empty, `id` 0): golden assertions on a fixture with nested folders.
|
||||
- **Firefox history order**: `visit_count` descending for every browser, Firefox included.
|
||||
- **Safari bookmark IDs**: unique across the whole tree, not repeated per folder.
|
||||
- **Firefox without a key**: a profile with no `key4.db` still exports its logins with empty secrets, the extraction is `partial`, and the run goes on; a missing key makes decryption fail instead of panicking.
|
||||
- **Yandex without a key**: logins and cards still export with empty secrets, each a record-level problem, so `list --detail`, which reads no key, counts them as v1.1.0 did.
|
||||
- **Arc multi-dir**: two `arc` user data dirs yield IDs `arc` and `arc-2`, distinct snapshots, and distinct `keys.json` vaults, while overrides and the vaults' `browser` key still use `arc`.
|
||||
- **`--zip` data loss**: a failing zip write leaves every output file in place.
|
||||
- **Copies left on Ctrl-C**: a stopped run ends before its next extraction and removes its snapshot, `dumpkeys` returns no vaults, the command prints no error or usage, and the process ends by the signal.
|
||||
- **Late flag validation**: `-f bogus` exits `1` with no discovery call and no password resolution (both injected as spies).
|
||||
- **Eager secrets**: `dump -b chrome -c history` never calls `ProfileSnapshot.MasterKeys` and never opens the login keychain: a counting fake `PasswordFunc` stays at zero.
|
||||
- **JSON escaping**: a URL with `&` and `<` is written escaped in `json` and unescaped in `cookie-editor`, as in v1.1.0.
|
||||
- **Supported browsers**: `Supported()` lists only this OS's rows, and `Lookup` finds every row, so a vault for a Windows-only fork restores on macOS.
|
||||
- **macOS key order**: when the first `v10` strategy fails and a later one succeeds, the key is used and no error is reported.
|
||||
- **One keychain report**: with a locked login keychain, every macOS Chromium user data dir falls through to the next `v10` retriever, and the reason is reported once for the run, not once per browser.
|
||||
- **Unset outcome**: a `Result` whose outcome was never set does not report as `ok`.
|
||||
- **Per-dir snapshots**: a dump over two user data dirs never has both dirs' copies on disk at once.
|
||||
- **`-p` validation**: a non-existent `-p` path exits `1`, not `0` with "no browsers found".
|
||||
- **`-p` with `-b all`**: a warning is logged and no user data dir is overridden.
|
||||
- **`-p` at a Chromium profile directory**: its parent becomes the user data dir, so `Local State` is captured and keys resolve.
|
||||
- **`-p` for Firefox**: only the named profile is exported, not every sibling under it.
|
||||
- **`-p` for Safari**: names the Safari directory, whose parent stands in for `~/Library`, as in v1.1.0.
|
||||
- **Keychain password precedence**: explicit flag > prompt > none.
|
||||
- **Temp snapshot cleanup**: a run that fails mid-way leaves no copied `Login Data` or `Cookies` behind.
|
||||
- **Discovery errors are not absence**: an unreadable user data dir (permission denied) is reported as an `error` result, distinct from one that simply isn't there (nothing); a planned source that cannot be checked is an `error` too, not `absent`. The home directory comes from `DiscoverOptions`, so a `t.TempDir()` stands in.
|
||||
- **Safari discovery reads a copy**: listing Safari profiles opens a snapshot copy of `SafariTabs.db`, never the live file.
|
||||
- **Shared executable names**: when App Paths names another vendor's `browser.exe`, the browser's own install location wins.
|
||||
|
||||
## Table and payload consistency
|
||||
|
||||
- Every key in the Chromium override table resolves through `browser.Lookup` to a Chromium `Browser`.
|
||||
- Every Windows row of the table with `ABE` other than `ABENone` has a row in the payload's `com_iid.c` with the same executable and ABE kind; the test parses the C table, which may list browsers the Go table does not, such as Avast. It lives inside `browser` and reads the whole table, since `Supported()` lists only the running OS's rows. (The Go-side `winutil.Table` join, and the `TestWinUtilTableCoversABEBrowsers` that guarded it, disappear into `Platform`.)
|
||||
|
||||
## Import direction
|
||||
|
||||
The table in [RFC-002](002-package-layout.md) is kept by review, not by a linter or a test: every new import edge is either in the table or added to it in the same pull request. The compiler still rejects cycles.
|
||||
|
||||
## Go 1.20 pitfalls
|
||||
|
||||
The `go 1.20` directive constrains more than the standard library:
|
||||
|
||||
- **Loop variables are shared.** Under `go 1.20`, every closure created in a loop sees the loop variable's last value, and the per-iteration semantics of Go 1.22 apply only to modules that declare `go 1.22` or later, whatever toolchain builds them. Extractors are closures built per profile, and `go vet`'s `loopclosure` check only looks at closures started with `go`, `defer`, and the like, so it does not cover them. A two-profile fixture in every base asserts that each extraction reads its own profile's files.
|
||||
- **No 1.21+ helpers.** `sync.OnceValues`, `slices`, `maps`, `cmp`, and the `min` / `max` / `clear` builtins are unavailable: the per-dir `MasterKeys` call-once and the keychain handle each hold a `sync.Once` with stored results, and sorting uses `sort.SliceStable` with a multi-key less function.
|
||||
|
||||
## Tooling
|
||||
|
||||
- **golangci-lint v2** — the project's existing config, extended with `tagliatelle` (`case.use-field-name: true`, `case.rules: {json: snake, csv: snake}`) on the packages that own a wire format — `record` and `masterkey` (`keys.json`); the Cookie-Editor encoder and any struct that mirrors a browser's own file format stay outside it. `lll` stays at 140.
|
||||
- **gofumpt** + **goimports** with `-local github.com/moond4rk/hackbrowserdata`.
|
||||
- **CI matrix**: Go pinned to `1.20.x` (not `go-version-file`) on Windows, macOS, and Linux; build + vet + lint + test; a step that fails unless `go.mod` says `go 1.20` with no `toolchain` line. The Windows ABE path is additionally validated on a dedicated Windows host against the current cookie/key baseline, not in hosted CI.
|
||||
|
||||
## Doc hygiene
|
||||
|
||||
CLAUDE.md, the README, and the root help text describe the code as it is: the test strategy is `t.TempDir()` with real fixtures built by `internal/browser/browsertest`, every supported browser and output format is listed (Safari and `cookie-editor`'s JSON fallback included), and paths point at the current packages. No RFC citations go into source comments — traceability stays in git and in these documents.
|
||||
|
||||
## Coverage intent
|
||||
|
||||
Coverage is a signal, not a target. The intent: every extractor has at least one golden fixture, every outcome has a planner test, every designed-out bug has a regression test, and every frozen surface has a compatibility test. Those guarantees matter more than a percentage.
|
||||
@@ -1,139 +0,0 @@
|
||||
# RFC-013: Chromium Data Storage
|
||||
|
||||
**Author**: moonD4rk\
|
||||
**Status**: Living Document\
|
||||
**Created**: 2026-04-05
|
||||
|
||||
## 1. Data File Locations
|
||||
|
||||
All paths are relative to the profile directory (e.g. `~/.config/google-chrome/Default/`).
|
||||
|
||||
| Category | Candidate Paths (priority order) | Format |
|
||||
| -------------- | -------------------------------- | ----------- |
|
||||
| Password | `Login Data` | SQLite |
|
||||
| Cookie | `Network/Cookies`, `Cookies` | SQLite |
|
||||
| History | `History` | SQLite |
|
||||
| Download | `History` (same file) | SQLite |
|
||||
| Bookmark | `Bookmarks` | JSON |
|
||||
| CreditCard | `Web Data` | SQLite |
|
||||
| Extension | `Secure Preferences` | JSON |
|
||||
| LocalStorage | `Local Storage/leveldb/` | LevelDB dir |
|
||||
| SessionStorage | `Session Storage/` | LevelDB dir |
|
||||
|
||||
Cookies have two candidate paths because older Chromium versions stored cookies at `<profile>/Cookies`, while newer versions moved them to `<profile>/Network/Cookies`. The first existing path wins.
|
||||
|
||||
## 2. Browser Variants
|
||||
|
||||
### 2.1 Yandex
|
||||
|
||||
Yandex overrides two file names from the standard Chromium layout:
|
||||
|
||||
| Category | Standard Chromium | Yandex |
|
||||
| ---------- | ----------------- | ----------------- |
|
||||
| Password | `Login Data` | `Ya Passman Data` |
|
||||
| CreditCard | `Web Data` | `Ya Credit Cards` |
|
||||
|
||||
Yandex's password query selects extra columns (`username_element`, `password_element`, `signon_realm`) beyond the standard four; these columns are used to construct the per-row AAD for decryption. The URL column is `origin_url`, same as standard Chromium.
|
||||
|
||||
Yandex passwords and credit cards use Yandex's proprietary two-layer encryption (see RFC-017) and are fully supported. Cookie decryption follows standard Chromium v10/v20 paths.
|
||||
|
||||
### 2.2 Opera
|
||||
|
||||
Opera differs from standard Chromium in three ways:
|
||||
|
||||
- **Extension key**: Opera stores extension settings under `extensions.opsettings` in Secure Preferences, instead of the standard `extensions.settings`.
|
||||
- **Windows path**: Opera uses `AppData/Roaming` rather than `AppData/Local`, unlike most Chromium browsers.
|
||||
- **Flat layout**: Older Opera versions store data files directly in the user data directory without profile subdirectories (see Section 3).
|
||||
|
||||
## 3. Profile Discovery
|
||||
|
||||
Chromium supports multiple profiles (Default, Profile 1, Profile 2, ...) under a single user data directory. Profile discovery identifies which subdirectories are actual profiles versus internal directories like `Crashpad` or `ShaderCache`.
|
||||
|
||||
A directory is recognized as a profile if it contains a `Preferences` file. This convention follows Chromium's own source code -- Chromium creates a per-profile `Preferences` file on first use, making it a reliable marker even in early Chromium versions. Tencent-based browsers (QQ Browser, Sogou Explorer) use `Preferences_02` instead, which is also checked.
|
||||
|
||||
Certain directories are always skipped: `System Profile`, `Guest Profile`, and `Snapshot`.
|
||||
|
||||
**Flat layout fallback**: If no profile subdirectories are found, the user data directory itself is checked for any known source file. This handles Opera-style browsers that store data alongside `Local State` in the base directory.
|
||||
|
||||
## 4. Data Storage Formats
|
||||
|
||||
### 4.1 Passwords (Login Data -- SQLite)
|
||||
|
||||
```sql
|
||||
SELECT origin_url, username_value, password_value, date_created FROM logins
|
||||
```
|
||||
|
||||
The `password_value` column contains encrypted bytes. See [RFC-014](014-chromium-encryption.md) for decryption.
|
||||
|
||||
### 4.2 Cookies (Cookies -- SQLite)
|
||||
|
||||
```sql
|
||||
SELECT name, encrypted_value, host_key, path,
|
||||
creation_utc, expires_utc, is_secure, is_httponly,
|
||||
has_expires, is_persistent FROM cookies
|
||||
```
|
||||
|
||||
The `encrypted_value` column contains encrypted bytes. Chrome 130+ (cookie DB schema version 24) prepends `SHA256(host_key)` to the cookie value before encryption as a cross-domain replay mitigation. After decryption, the cookie value layout is:
|
||||
|
||||
```
|
||||
| SHA256(host_key) | actual cookie value |
|
||||
|------------------|---------------------|
|
||||
| 32B | remaining bytes |
|
||||
```
|
||||
|
||||
The first 32 bytes are verified against `SHA256(host_key)` and stripped if they match. If the decrypted value is shorter than 32 bytes or the hash does not match, the value is returned as-is (pre-Chrome 130 behavior).
|
||||
|
||||
### 4.3 Bookmarks (Bookmarks -- JSON)
|
||||
|
||||
A JSON file with a `roots` object containing bookmark trees (bookmark_bar, other, synced). Each node has a `type` ("url" or "folder"), `name`, `url`, and `date_added`. Folder nodes contain a `children` array, forming a recursive tree that is walked to collect all URL entries.
|
||||
|
||||
### 4.4 History (History -- SQLite)
|
||||
|
||||
```sql
|
||||
SELECT url, title, visit_count, last_visit_time FROM urls
|
||||
```
|
||||
|
||||
No encrypted fields. Results are sorted by visit count (descending).
|
||||
|
||||
### 4.5 Downloads (History -- SQLite, same file)
|
||||
|
||||
```sql
|
||||
SELECT target_path, tab_url, total_bytes, start_time, end_time, mime_type FROM downloads
|
||||
```
|
||||
|
||||
No encrypted fields. Shares the same `History` SQLite database as browsing history.
|
||||
|
||||
### 4.6 Credit Cards (Web Data -- SQLite)
|
||||
|
||||
```sql
|
||||
SELECT COALESCE(guid, ''), name_on_card, expiration_month, expiration_year,
|
||||
card_number_encrypted, COALESCE(nickname, ''), COALESCE(billing_address_id, '') FROM credit_cards
|
||||
```
|
||||
|
||||
The `card_number_encrypted` column contains encrypted bytes.
|
||||
|
||||
### 4.7 Extensions (Secure Preferences -- JSON)
|
||||
|
||||
The `Secure Preferences` file contains extension metadata under `extensions.settings` (or variant-specific keys). Each extension entry includes a `manifest` object with name, description, version, and homepage URL. System/component extensions (location 5 or 10) are filtered out.
|
||||
|
||||
Extension enabled state is determined by `disable_reasons` (modern Chrome: empty array = enabled) or `state` (older Chrome: 1 = enabled).
|
||||
|
||||
### 4.8 LocalStorage / SessionStorage (LevelDB)
|
||||
|
||||
Both use LevelDB directories, but with different key encoding schemes.
|
||||
|
||||
**LocalStorage** keys use a binary format: a `_` prefix byte, followed by the origin URL, a null separator, and a Chromium-encoded string key. The string encoding uses a format byte: `0x01` for Latin-1, `0x00` for UTF-16 LE. Values follow the same encoding. Metadata entries (`META:`, `METAACCESS:`) and `VERSION` keys are recognized but not treated as user data.
|
||||
|
||||
**SessionStorage** uses a two-pass approach. First, `namespace-<guid>-<origin>` entries map GUIDs to origins. Then, `map-<map_id>-<key_name>` entries contain the actual data with raw UTF-16 LE values (no format byte prefix).
|
||||
|
||||
## 5. Time Format
|
||||
|
||||
Chromium uses WebKit epoch timestamps: microseconds since 1601-01-01 00:00:00 UTC. This applies to `date_created`, `creation_utc`, `expires_utc`, `last_visit_time`, `start_time`, `end_time`, and `date_added`. To convert to Unix time, subtract 11644473600000000 microseconds (the offset between 1601 and 1970).
|
||||
|
||||
## Related RFCs
|
||||
|
||||
| RFC | Topic |
|
||||
| ------------------------------------------ | ------------------------------------------- |
|
||||
| [RFC-014](014-chromium-encryption.md) | Chromium encryption mechanisms per platform |
|
||||
| [RFC-015](015-key-retrieval-mechanisms.md) | Platform-specific master key retrieval |
|
||||
| [RFC-007](007-snapshot-and-acquisition.md) | Snapshot-first file acquisition |
|
||||
@@ -1,125 +0,0 @@
|
||||
# RFC-014: Chromium Encryption
|
||||
|
||||
**Author**: moonD4rk\
|
||||
**Status**: Living Document\
|
||||
**Created**: 2026-04-05
|
||||
|
||||
## 1. Overview
|
||||
|
||||
Chromium encrypts sensitive fields in three data categories: passwords (`password_value`), cookies (`encrypted_value`), and credit cards (`card_number_encrypted`). The encryption algorithm varies by platform -- macOS and Linux use AES-128-CBC with a PBKDF2-derived key, while Windows uses AES-256-GCM with a DPAPI-protected key.
|
||||
|
||||
Non-sensitive categories (history, bookmarks, downloads, extensions, storage) are stored in plaintext and do not require decryption.
|
||||
|
||||
## 2. Cipher Version Detection
|
||||
|
||||
Every encrypted value begins with a 3-byte prefix that identifies the cipher version:
|
||||
|
||||
| Prefix | Version | Meaning |
|
||||
| ------ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `v10` | CipherV10 | Chrome 80+ standard encryption (AES-GCM on Windows, AES-CBC on macOS/Linux) |
|
||||
| `v11` | CipherV11 | Linux-only: AES-CBC variant where the key comes from libsecret / kwallet. Same algorithm and parameters as `v10` — only the key source differs |
|
||||
| `v12` | CipherV12 | Chromium SecretPortal/Flatpak (xdg-desktop-portal) — recognized by the version detector so a clear error can be returned; not yet implemented |
|
||||
| `v20` | CipherV20 | Chrome 127+ App-Bound Encryption |
|
||||
| (none) | CipherDPAPI | Pre-Chrome 80 raw DPAPI encryption (Windows only, no prefix) |
|
||||
|
||||
If the ciphertext is shorter than 3 bytes or the prefix is unrecognized, it is treated as legacy DPAPI.
|
||||
|
||||
## 3. macOS Encryption
|
||||
|
||||
Chromium on macOS stores a per-browser secret in the macOS Keychain (e.g. "Chrome Safe Storage", "Brave Safe Storage"). The master key is derived from this secret via PBKDF2:
|
||||
|
||||
| Parameter | Value |
|
||||
| ---------- | ------------------ |
|
||||
| Hash | SHA-1 |
|
||||
| Salt | `saltysalt` |
|
||||
| Iterations | 1003 |
|
||||
| Key length | 16 bytes (AES-128) |
|
||||
|
||||
Decryption uses AES-128-CBC with a fixed IV of 16 space bytes (`0x20`). The ciphertext layout:
|
||||
|
||||
```
|
||||
| v10 | AES-CBC ciphertext (PKCS5 padded) |
|
||||
|-------|-------------------------------------|
|
||||
| 3B | remaining bytes |
|
||||
```
|
||||
|
||||
There are three retrieval strategies, tried in order: (1) gcoredump exploit for securityd process memory, (2) direct keychain unlock with user's login password, (3) `security` CLI command (may trigger a GUI prompt). See [RFC-015](015-key-retrieval-mechanisms.md) for details.
|
||||
|
||||
## 4. Windows Encryption
|
||||
|
||||
Chromium on Windows stores a base64-encoded encrypted key in `Local State` at `os_crypt.encrypted_key`. The key recovery process is:
|
||||
|
||||
1. Base64-decode the `encrypted_key` value
|
||||
2. Strip the 5-byte `DPAPI` ASCII prefix
|
||||
3. Decrypt via Windows `CryptUnprotectData` (DPAPI) to obtain the 256-bit master key
|
||||
|
||||
With the master key, each encrypted value is decrypted as AES-256-GCM:
|
||||
|
||||
```
|
||||
| v10 | nonce | ciphertext + auth tag (16B) |
|
||||
|-------|--------|-----------------------------|
|
||||
| 3B | 12B | remaining bytes |
|
||||
```
|
||||
|
||||
**Legacy DPAPI** — values without a `v10`/`v20` prefix (pre-Chrome 80) are passed directly to `CryptUnprotectData`:
|
||||
|
||||
```
|
||||
| DPAPI blob (no prefix) |
|
||||
|-------------------------------------|
|
||||
| variable length |
|
||||
```
|
||||
|
||||
## 5. Linux Encryption
|
||||
|
||||
Chromium on Linux has two obfuscation prefixes that share the same AES-128-CBC algorithm and PBKDF2 parameters — only the key source differs:
|
||||
|
||||
- **`v10`** — the PBKDF2 password is the hardcoded string `peanuts`. Chromium writes this prefix when no keyring backend is available (headless sessions, `--password-store=basic`, LXQt, etc.).
|
||||
- **`v11`** — the PBKDF2 password is a random string read from D-Bus Secret Service (GNOME Keyring or KDE Wallet). The libsecret/kwallet item label matches the browser's storage name (e.g. "Chrome Safe Storage", "Brave Safe Storage"). Chromium writes this prefix whenever a keyring backend is available at encrypt time. On first run, Chromium generates and stores the random password automatically.
|
||||
|
||||
Both prefixes are derived through the same PBKDF2 parameters:
|
||||
|
||||
| Parameter | Value |
|
||||
| ---------- | ------------------ |
|
||||
| Hash | SHA-1 |
|
||||
| Salt | `saltysalt` |
|
||||
| Iterations | 1 |
|
||||
| Key length | 16 bytes (AES-128) |
|
||||
|
||||
Decryption uses AES-128-CBC with a fixed IV of 16 space bytes (`0x20`) and PKCS5 padding — identical to macOS except for the PBKDF2 iteration count.
|
||||
|
||||
**Mixed v10/v11 in the same profile.** Because Chromium selects the prefix at encrypt time, a single profile may contain both versions if the keyring backend availability changed between sessions. Chromium decrypts each record independently by inspecting its prefix.
|
||||
|
||||
**kEmptyKey legacy retry.** Chromium's `DecryptString` retries any failed v10/v11 decryption with a second key, `kEmptyKey = PBKDF2("", "saltysalt", 1, 16, sha1)`. This exists to recover data corrupted by a KWallet initialization race in Chrome ~89 (see `crbug.com/40055416`), where some records were written with this zero-derived key. Chromium never uses `kEmptyKey` for encryption — it is decrypt-only. HackBrowserData mirrors this retry for parity.
|
||||
|
||||
## 6. v20 App-Bound Encryption (Chrome 127+)
|
||||
|
||||
Chrome 127 introduced App-Bound Encryption on Windows, identified by the `v20` prefix. This scheme binds the encryption key to the Chrome application identity. The key is a 32-byte AES-256 key retrieved via reflective injection into the browser process (`ABERetriever`). Ciphertext layout:
|
||||
|
||||
```
|
||||
| v20 | nonce | AES-GCM ciphertext + auth tag |
|
||||
|-------|--------|-------------------------------------|
|
||||
| 3B | 12B | remaining bytes |
|
||||
```
|
||||
|
||||
Decryption strips the version prefix (3B) and nonce (12B) and passes the remaining bytes to AES-256-GCM (`crypto.AESGCMDecrypt`); no post-decrypt header is stripped from the result.
|
||||
|
||||
## 7. Decryption Flow
|
||||
|
||||
The high-level decryption path for any encrypted Chromium value:
|
||||
|
||||
1. **Detect version** -- inspect the first 3 bytes of the ciphertext
|
||||
2. **Route by version**:
|
||||
- `v10` / `v11` -- strip prefix, call platform-specific decryption (AES-CBC on macOS/Linux, AES-GCM on Windows). On macOS/Linux, a failed AES-CBC decryption retries once with `kEmptyKey` to recover legacy crbug.com/40055416 data
|
||||
- `v12` -- SecretPortal/Flatpak — recognized, returns known-gap error (not yet implemented)
|
||||
- `v20` -- AES-256-GCM with 32-byte ABE key (retrieved via Windows reflective injection)
|
||||
- DPAPI (no prefix) -- call Windows `CryptUnprotectData` directly (Windows only; returns error on other platforms)
|
||||
3. **Return plaintext** -- the decrypted bytes are interpreted as a UTF-8 string
|
||||
|
||||
Each record is decrypted independently. A failure to decrypt one value does not prevent extraction of other records in the same database.
|
||||
|
||||
## Related RFCs
|
||||
|
||||
| RFC | Topic |
|
||||
| ------------------------------------------ | ------------------------------------------------ |
|
||||
| [RFC-013](013-chromium-data-storage.md) | Chromium data file locations and storage formats |
|
||||
| [RFC-015](015-key-retrieval-mechanisms.md) | Platform-specific master key retrieval |
|
||||
@@ -1,248 +0,0 @@
|
||||
# RFC-015: Key Retrieval Mechanisms
|
||||
|
||||
**Author**: moonD4rk\
|
||||
**Status**: Living Document\
|
||||
**Created**: 2026-04-05
|
||||
|
||||
## 1. Overview
|
||||
|
||||
Chromium-based browsers encrypt sensitive data (passwords, cookies, credit cards) using a **master key**. The master key is stored differently on each platform:
|
||||
|
||||
| Platform | Storage | Key Type |
|
||||
| -------- | ------------------------------------ | ---------------------------------- |
|
||||
| macOS | macOS Keychain | Password string → PBKDF2 → AES-128 |
|
||||
| Windows | `Local State` JSON (DPAPI-encrypted) | Raw AES-256 key |
|
||||
| Linux | GNOME Keyring / KDE Wallet via D-Bus | Password string → PBKDF2 → AES-128 |
|
||||
|
||||
Each platform may have more than one retrieval strategy. A `Retriever` returns the key for one cipher version, reading what it needs from a `Locator`; `RetrieveAll` runs the platform's retrievers and collects one key per version.
|
||||
|
||||
For Chromium encryption details (cipher versions, AES-CBC/GCM), see [RFC-014](014-chromium-encryption.md). Firefox manages its own keys via `key4.db` — see [RFC-019](019-firefox-encryption.md).
|
||||
|
||||
## 2. Retriever Interface
|
||||
|
||||
```go
|
||||
type Retriever interface {
|
||||
Version() Version // v10, v11, or v20
|
||||
Retrieve(ctx context.Context, loc Locator) ([]byte, error)
|
||||
}
|
||||
|
||||
type Locator struct {
|
||||
LocalState string // the copied Local State; "" when the user data dir has none
|
||||
KeychainLabel string // macOS Keychain account / Linux D-Bus Secret Service label
|
||||
Exe string // Windows: the program the ABE payload is injected into
|
||||
ExeFallbacks []string // Windows: programs tried when the registry has no App Paths entry
|
||||
ABE ABEKind // Windows: which elevation-service interface, or ABENone
|
||||
Keychain LoginKeychain // macOS: the run's login keychain; nil elsewhere
|
||||
}
|
||||
```
|
||||
|
||||
Each retriever reads only the fields that apply to its platform; the others are ignored. The Chromium base builds the `Locator` for a user data dir (`chromium.KeyLocator`), copying `KeychainLabel`, `Exe`, `ExeFallbacks`, and `ABE` from the browser's `Platform` row ([RFC-005](005-browser-definitions.md)) and pointing `LocalState` at the snapshot's copy.
|
||||
|
||||
`Retrieve` returns the **ready-to-use decryption key** — either the raw AES key (Windows) or the PBKDF2-derived key (macOS/Linux).
|
||||
|
||||
`RetrieveAll(ctx, loc)` runs the platform's retrievers grouped by version: within a version the first success wins and the rest are skipped, a version whose every retriever fails contributes nothing, and an error is returned only when some version yielded no key. Versions are independent, so a `v20` failure never costs the `v10` key ([RFC-006](006-key-retrieval-and-crypto.md)).
|
||||
|
||||
**Scope**: `app` calls `RetrieveAll` once per user data dir, on the first extraction that needs cleartext, and shares the result across the dir's profiles; a run that touches only non-secret data never calls it. On macOS the `Locator` carries the run's one login-keychain handle, opened at most once ([RFC-006](006-key-retrieval-and-crypto.md)).
|
||||
|
||||
## 3. macOS Key Retrieval
|
||||
|
||||
Chromium on macOS stores the encryption password in the user's login keychain under a browser-specific account name (e.g. `"Chrome"`, `"Brave"`, `"Microsoft Edge"`).
|
||||
|
||||
### 3.1 Retrieval Strategies
|
||||
|
||||
**`gcoredumpRetriever`** — exploits **CVE-2025-24204** to extract keychain secrets from `securityd` process memory. Requires root. The exploit works because the `gcore` binary holds the `com.apple.system-task-ports.read` entitlement, bypassing TCC protections:
|
||||
|
||||
1. Find `securityd` PID via `sysctl`
|
||||
2. Dump process memory via `gcore`
|
||||
3. Parse heap regions via `vmmap`, scan `MALLOC_SMALL` regions for 24-byte key pattern
|
||||
4. Try each candidate against `login.keychain-db`
|
||||
|
||||
**`keychainRetriever`** — unlocks `login.keychain-db` directly using the user's macOS login password (from `--keychain-pw` flag), powered by the [moond4rk/keychainbreaker](https://github.com/moond4rk/keychainbreaker) library which implements a full macOS Keychain file parser and decryptor in pure Go. Non-root, non-interactive.
|
||||
|
||||
**`securityRetriever`** — invokes `security find-generic-password -wa <label>`. Triggers a macOS password dialog. Last resort.
|
||||
|
||||
### 3.2 Retriever Order
|
||||
|
||||
| Priority | Strategy | Requires | Interactive? |
|
||||
| -------- | -------------------------- | -------------------- | :----------: |
|
||||
| 1 | Gcoredump (CVE-2025-24204) | Root | No |
|
||||
| 2 | Keychain password | `--keychain-pw` flag | No |
|
||||
| 3 | `security` CLI command | Nothing | Yes (dialog) |
|
||||
|
||||
### 3.3 PBKDF2 Derivation
|
||||
|
||||
All macOS strategies produce a raw password string from the keychain. This is derived into an AES-128 key via PBKDF2:
|
||||
|
||||
| Parameter | Value | Source |
|
||||
| ---------- | ------------------ | ----------------------------------------------------------------------------------------------------------------------- |
|
||||
| Salt | `"saltysalt"` | [os_crypt_mac.mm](https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_mac.mm;l=157) |
|
||||
| Iterations | 1003 | |
|
||||
| Key length | 16 bytes (AES-128) | |
|
||||
| Hash | HMAC-SHA1 | |
|
||||
|
||||
### 3.4 Keychain Labels
|
||||
|
||||
Each browser identifies its Keychain entry with a short account string — typically the browser's base name (`"Chrome"`, `"Brave"`, `"Arc"`). Edge uses `"Microsoft Edge"`. Related variants share labels rather than defining their own: Chrome Beta aliases onto `"Chrome"`, Opera GX aliases onto `"Opera"`.
|
||||
|
||||
The authoritative mapping lives in the `KeychainLabel` field of each browser's `Platform` row ([RFC-005](005-browser-definitions.md)).
|
||||
|
||||
## 4. Windows Key Retrieval
|
||||
|
||||
Chromium on Windows stores **two** master keys in `Local State` JSON: a legacy v10 key (`os_crypt.encrypted_key`, DPAPI-wrapped) and, since Chrome 127, an App-Bound Encryption v20 key (`os_crypt.app_bound_encrypted_key`, IElevator-wrapped). Both tiers can coexist on a single profile — Chrome 127+ encrypts _new_ cookies with v20 but leaves pre-existing passwords and old cookies on v10 — so the retriever layer fetches both keys independently rather than as a first-success chain (see §4.4 and issue #578).
|
||||
|
||||
### 4.1 DPAPI Background
|
||||
|
||||
Windows Data Protection API (DPAPI) is a built-in symmetric encryption service provided by `Crypt32.dll`. It uses the logged-in user's Windows credentials (derived from the user's login password) as the root key material. Applications call `CryptProtectData` to encrypt and `CryptUnprotectData` to decrypt, without needing to manage keys themselves.
|
||||
|
||||
Key characteristics:
|
||||
|
||||
- **User-scoped** — data encrypted by one Windows user cannot be decrypted by another user, even on the same machine
|
||||
- **Machine-bound** — the encrypted blob cannot be decrypted on a different machine (unless roaming credentials are used)
|
||||
- **No password prompt** — decryption is transparent to the calling process as long as it runs under the correct user session
|
||||
|
||||
### 4.2 Retrieval Flow
|
||||
|
||||
```
|
||||
Local State → os_crypt.encrypted_key (base64 string)
|
||||
|
||||
| "DPAPI" prefix | DPAPI-encrypted AES key |
|
||||
|----------------|--------------------------|
|
||||
| 5B (ASCII) | remaining bytes |
|
||||
|
||||
→ strip prefix
|
||||
→ CryptUnprotectData (Crypt32.dll)
|
||||
→ 32-byte AES-256 master key
|
||||
```
|
||||
|
||||
The implementation loads `Crypt32.dll` at runtime via `syscall.NewLazyDLL` and calls `CryptUnprotectData` with a `DATA_BLOB` structure pointing to the ciphertext. Windows internally derives the decryption key from the user's credentials and returns the plaintext master key.
|
||||
|
||||
### 4.3 No PBKDF2 Needed
|
||||
|
||||
Unlike macOS/Linux, DPAPI gives the **final AES-256 key directly**. No intermediate password, no derivation step. The key is used as-is for AES-256-GCM decryption (see [RFC-014](014-chromium-encryption.md)).
|
||||
|
||||
### 4.4 Dual-Tier Retrievers (V10 + V20)
|
||||
|
||||
Windows registers two retrievers — V10 (legacy DPAPI) and V20 (Chrome 127+ App-Bound Encryption) — which `RetrieveAll` runs independently rather than as a first-success chain. No retriever claims V11 on Windows (Chromium does not emit the v11 prefix there).
|
||||
|
||||
| Version | Retriever | Source field | Mechanism |
|
||||
| ------- | ---------------- | ---------------------------------- | --------------------------------------------------------------------------------- |
|
||||
| V10 | `dpapiRetriever` | `os_crypt.encrypted_key` | `CryptUnprotectData` (Crypt32.dll) |
|
||||
| V20 | `abeRetriever` | `os_crypt.app_bound_encrypted_key` | IElevator via reflective injection (see [RFC-016](016-chrome-abe-integration.md)) |
|
||||
|
||||
`RetrieveAll` runs each version independently — a failure on one tier does not prevent the other from succeeding, because mixed-tier Chrome profiles (upgraded from pre-127) need partial success to be useful.
|
||||
|
||||
**Why versions are independent, not a first-success chain.** A chain across tiers stops at the first key: once ABE returns a v20 key, DPAPI is never called. That is wrong for orthogonal tiers — it was the root cause of issue #578, where upgraded profiles' v10-encrypted passwords silently failed because only the v20 key was retrieved. `RetrieveAll` groups retrievers by version, so each version returns its own key, and the per-version failures are joined into one error only when a version yields nothing ([RFC-006](006-key-retrieval-and-crypto.md)).
|
||||
|
||||
**Non-ABE Chromium forks** (Opera, Vivaldi, Yandex, 360, QQ, Sogou) set `ABE: ABENone` in their `Platform` row ([RFC-005](005-browser-definitions.md)), so `Locator.ABE` is `ABENone` and the V20 retriever returns `(nil, nil)` — `RetrieveAll` treats that as "not applicable", not a failure. Their V10 DPAPI key works unchanged.
|
||||
|
||||
## 5. Linux Key Retrieval
|
||||
|
||||
### 5.1 Dual-Tier Retrievers (V10 + V11)
|
||||
|
||||
Linux registers two retrievers — one per cipher prefix that Chromium emits on this platform:
|
||||
|
||||
| Version | Prefix | Retriever | Mechanism | Chromium name |
|
||||
| ------- | ------ | ---------------- | ------------------------------------- | --------------------------------------------------------- |
|
||||
| V10 | `v10` | `posixRetriever` | PBKDF2(`"peanuts"`) | kV10Key (matches upstream `PosixKeyProvider`) |
|
||||
| V11 | `v11` | `dbusRetriever` | PBKDF2(D-Bus Secret Service password) | kV11Key (matches upstream `FreedesktopSecretKeyProvider`) |
|
||||
|
||||
No retriever claims V20 on Linux (App-Bound Encryption is Windows-only). v12 (Chromium's `SecretPortalKeyProvider`, Flatpak/xdg-desktop-portal) is a separate tier not yet implemented — see the `CipherV12` case in `decryptValue`.
|
||||
|
||||
**`dbusRetriever`** — queries the D-Bus Secret Service API (provided by `gnome-keyring-daemon` or `kwalletd`). Iterates all collections and items, looking for a label matching the browser's storage name. Claims V11 because Chromium emits the v11 prefix only when keyring access succeeds.
|
||||
|
||||
**`posixRetriever`** — uses the hardcoded `"peanuts"` password that Chromium derives into a fixed 16-byte AES-128 key (kV10Key). Claims V10 because Chromium emits the v10 prefix for data encrypted with this key. Always succeeds deterministically.
|
||||
|
||||
### 5.2 Why Two Versions, Not a Chain
|
||||
|
||||
A profile can carry **both** v10 and v11 ciphertexts if the host has moved between keyring-equipped and headless sessions — e.g. a laptop that was once used in a headless shell then later in a full desktop session. A first-success chain would stop at the first key: if D-Bus worked, peanuts was never tried, leaving v10 ciphertexts undecryptable. `RetrieveAll` keeps the versions independent, so both keys are fetched.
|
||||
|
||||
The split mirrors the Windows V10/V20 fix (§4.4) and the root-cause logic of issue #578: distinct cipher prefixes map to distinct key sources, so the retriever layer must produce both keys independently rather than picking "one winning" key.
|
||||
|
||||
### 5.3 PBKDF2 Derivation
|
||||
|
||||
Both strategies produce a password, derived via PBKDF2 with notably weaker parameters than macOS:
|
||||
|
||||
| Parameter | Value | Source |
|
||||
| ---------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Salt | `"saltysalt"` | [os_crypt_linux.cc](https://source.chromium.org/chromium/chromium/src/+/main:components/os_crypt/os_crypt_linux.cc;l=100) |
|
||||
| Iterations | **1** | |
|
||||
| Key length | 16 bytes (AES-128) | |
|
||||
| Hash | HMAC-SHA1 | |
|
||||
|
||||
A single iteration makes PBKDF2 essentially a keyed HMAC — no real key-stretching. Combined with the well-known fallback password `"peanuts"`, Linux Chromium encryption is trivial to break without the keyring.
|
||||
|
||||
### 5.4 Keychain Labels
|
||||
|
||||
Linux D-Bus labels follow a `"<name> Safe Storage"` convention, but many browsers alias onto a small shared set rather than defining their own. The three distinct labels are `"Chrome Safe Storage"`, `"Chromium Safe Storage"`, and `"Brave Safe Storage"` — everything else maps onto one of these.
|
||||
|
||||
The authoritative mapping lives in the `KeychainLabel` field of each browser's `Platform` row ([RFC-005](005-browser-definitions.md)).
|
||||
|
||||
## 6. Platform Summary
|
||||
|
||||
| Platform | Retrievers (slots populated) | PBKDF2 | Key Size |
|
||||
| -------- | ------------------------------------------------------------------------------- | :-------------: | -------- |
|
||||
| macOS | V10 = gcoredump → keychain* → security | 1003 iterations | AES-128 |
|
||||
| Windows | V10 = dpapiRetriever; V20 = abeRetriever (Chrome 127+) | No | AES-256 |
|
||||
| Linux | V10 = posixRetriever ("peanuts" kV10Key); V11 = dbusRetriever (keyring kV11Key) | 1 iteration | AES-128 |
|
||||
|
||||
\* Only included when a non-empty password resolves — either via `--keychain-pw` flag or an interactive TTY prompt.
|
||||
|
||||
## 7. Safari Credential Extraction
|
||||
|
||||
Safari is **not** a consumer of the `Retriever` interface. It has its own credential-extraction path in `internal/browser/safari/extract_password.go`, which uses [keychainbreaker](https://github.com/moond4rk/keychainbreaker) directly to list `InternetPassword` records from `login.keychain-db`.
|
||||
|
||||
This is a deliberate architectural choice, not an oversight. The following sections explain why.
|
||||
|
||||
### 7.1 Why Safari Does Not Share the Chromium Chain
|
||||
|
||||
| Aspect | Chromium chain | Safari direct access |
|
||||
| ------------------- | ----------------------------------- | ------------------------------------ |
|
||||
| Output | A 16-byte AES-128 key | A list of `InternetPassword` records |
|
||||
| Use case | Decrypt Login Data DB | Records _are_ the credentials |
|
||||
| Number of consumers | 10+ Chromium variants | 1 (Safari only) |
|
||||
| Failure mode | Hard fail (no key → cannot decrypt) | Soft fail (degrade to metadata-only) |
|
||||
| Caching benefit | High (multi-profile, multi-browser) | None (single browser, single call) |
|
||||
|
||||
Forcing Safari through the `Retriever` interface would require returning a different type than `[]byte`, contradicting the interface's documented purpose as the _master-key_ abstraction. Forcing it through a parallel "InternetPassword chain" would be over-engineering for a single consumer that has no fallback strategies worth chaining.
|
||||
|
||||
Note the "failure mode" row in particular: Chromium _must_ have a master key or extraction fails entirely, so it needs a chain of escalating strategies. Safari can degrade gracefully — if the keychain cannot be unlocked, metadata-only export (URLs and usernames, no plaintext passwords) is still useful output, so a single "try keychainbreaker, warn on failure" is sufficient.
|
||||
|
||||
### 7.2 The General Rule
|
||||
|
||||
> **Each browser package owns its own credential-acquisition strategy. `masterkey` exists only to share retrieval logic across the Chromium variant family. New browser implementations should follow Safari's and Firefox's example — own your credential code.**
|
||||
|
||||
Evidence the rule is already in force:
|
||||
|
||||
- **Firefox** (`internal/browser/firefox/firefox.go`) does not import `masterkey` or `keychainbreaker`. It derives keys from `key4.db` via internal NSS PBE. See RFC-019.
|
||||
- **Safari** (`internal/browser/safari/extract_password.go`) uses `keychainbreaker` directly for `InternetPassword` records.
|
||||
- **Chromium variants** all go through `masterkey` because they share one retrieval path and the per-user-data-dir caching ([RFC-006](006-key-retrieval-and-crypto.md)).
|
||||
|
||||
Future contributors adding a new macOS browser that reads credentials from the Keychain should add their access logic to that browser's package, not extend `masterkey`. Only extend `masterkey` if the new browser is a Chromium variant that fits the existing per-version retrievers.
|
||||
|
||||
### 7.3 Where the `--keychain-pw` Password Goes
|
||||
|
||||
Validate turns the chosen input (`--keychain-pw`, `--keychain-pw-stdin`, a terminal prompt, or none) into one `keychain.PasswordFunc` ([RFC-009](009-cli-surface.md)). On macOS `app` builds the run's single login-keychain handle with it; the handle opens lazily, at most once, and the `PasswordFunc` runs only then ([RFC-006](006-key-retrieval-and-crypto.md)). Two consumers read through that one handle, each declaring the single method it needs:
|
||||
|
||||
| Consumer | Interface | Reaches it through |
|
||||
| ---------------- | ------------------------- | ------------------------------------------ |
|
||||
| Chromium `v10` | `masterkey.LoginKeychain` | `Locator.Keychain` |
|
||||
| Safari passwords | `safari.LoginKeychain` | the extractor built by `safari.Extractors` |
|
||||
|
||||
Both interfaces name the same thing — the open-or-locked keychain — under the same method, so neither consumer sees a password string: an opened keychain carries its own answer, open or locked with a reason ([RFC-004](004-naming-decisions.md)).
|
||||
|
||||
Opening the handle is itself the password check: a missing or wrong password leaves it locked, `Keychain.Err` gives the reason, and the reporter prints it once ([RFC-006](006-key-retrieval-and-crypto.md)). There is no separate validation pass, and the keychain opens at most once per run — a run that reads only non-secret data never opens it at all.
|
||||
|
||||
## References
|
||||
|
||||
- **macOS**: [os_crypt_mac.mm](https://source.chromium.org/chromium/chromium/src/+/master:components/os_crypt/os_crypt_mac.mm;l=157)
|
||||
- **Windows**: [os_crypt_win.cc](https://source.chromium.org/chromium/chromium/src/+/main:components/os_crypt/os_crypt_win.cc)
|
||||
- **Linux**: [os_crypt_linux.cc](https://source.chromium.org/chromium/chromium/src/+/main:components/os_crypt/os_crypt_linux.cc;l=100)
|
||||
- **CVE-2025-24204**: [Exploit PoC](https://github.com/FFRI/CVE-2025-24204/tree/main/decrypt-keychain), [Apple advisory](https://support.apple.com/en-us/122373)
|
||||
- **DPAPI**: [CryptUnprotectData](https://learn.microsoft.com/en-us/windows/win32/api/dpapi/nf-dpapi-cryptunprotectdata)
|
||||
|
||||
## Related RFCs
|
||||
|
||||
| RFC | Topic |
|
||||
| ------------------------------------- | ------------------------------------------- |
|
||||
| [RFC-014](014-chromium-encryption.md) | Chromium encryption mechanisms per platform |
|
||||
| [RFC-019](019-firefox-encryption.md) | Firefox NSS encryption and key derivation |
|
||||
@@ -1,325 +0,0 @@
|
||||
# RFC-016: Chrome App-Bound Encryption Integration
|
||||
|
||||
**Author**: moonD4rk\
|
||||
**Status**: Living Document\
|
||||
**Created**: 2026-04-17\
|
||||
**Last updated**: 2026-04-19
|
||||
|
||||
## 1. Overview
|
||||
|
||||
Chrome 127+ introduced **App-Bound Encryption (ABE)** on Windows. The `Local State` key that decrypts `v10`-era cookies/passwords is no longer a user-bound DPAPI blob; it is now an _app-bound_ blob that only a legitimate `chrome.exe` / `msedge.exe` / `brave.exe` process can unwrap via the `elevation_service` COM RPC (`IElevator::DecryptData`).
|
||||
|
||||
This RFC documents how HackBrowserData integrates ABE support end-to-end while keeping the project **pure Go by default, cross-platform, zero disk footprint at runtime, and zero cost for non-Windows contributors.**
|
||||
|
||||
Related RFCs:
|
||||
|
||||
- [RFC-014](014-chromium-encryption.md) — cipher versions (v10, v11, v20)
|
||||
- [RFC-015](015-key-retrieval-mechanisms.md) — `Retriever` / `RetrieveAll`
|
||||
- [RFC-021](021-windows-locked-file-bypass.md) — other Windows-specific handling
|
||||
|
||||
### 1.1 Compatibility contract
|
||||
|
||||
| Component | Contract |
|
||||
| ------------- | -------------------------------------- |
|
||||
| Go toolchain | **1.20** (pinned; Go 1.21+ drops Win7) |
|
||||
| Windows host | Any Win10 1909+ (PE loader + UCRT) |
|
||||
| Chrome family | Any v127+ (ABE introduced) |
|
||||
| zig toolchain | 0.13+ (for `make payload`) |
|
||||
| Target arch | x86_64 only (x86 / ARM64 reserved) |
|
||||
|
||||
## 2. The constraint that shapes the design
|
||||
|
||||
`elevation_service` verifies the caller:
|
||||
|
||||
1. The calling process's main executable must be a **legitimate browser binary** (path in `Program Files`, signed by the browser vendor).
|
||||
2. Process integrity is checked via other sandbox gates.
|
||||
|
||||
Consequence: **the code that issues the `IElevator::DecryptData` COM call must be running inside a `chrome.exe` / `msedge.exe` / `brave.exe` process**. A plain Go process, even elevated, is refused.
|
||||
|
||||
The architecture therefore ships a small native payload, injects it into a freshly-spawned browser process, has it invoke the COM RPC, and hands the 32-byte master key back to the Go side. Everything else (v20 AES-GCM decrypt, DB iteration, JSON output) is already Go.
|
||||
|
||||
## 3. Architecture
|
||||
|
||||
End-to-end flow when `hack-browser-data.exe` encounters a v20 Chromium cookie on Windows:
|
||||
|
||||
**Stage 1 — Our process** (`hbd.exe`, `CGO_ENABLED=0`)
|
||||
|
||||
```
|
||||
masterkey.RetrieveAll(ctx, loc) // v10 dpapiRetriever, v20 abeRetriever
|
||||
→ abeRetriever.Retrieve(ctx, loc):
|
||||
reads Local State → extracts APPB-prefixed blob
|
||||
resolves browser exe: install locations, then App Paths
|
||||
→ internal/abe/injector.Reflective.Inject(exePath, payload, env)
|
||||
```
|
||||
|
||||
**Stage 2 — Payload preparation** (still our process)
|
||||
|
||||
1. Read the embedded payload via `//go:embed abe_extractor_amd64.bin` (~75 KB).
|
||||
2. Prepare a remote Bootstrap parameter block with the scratch pointer and 5 × `uintptr` function pointers (see §4.4).
|
||||
3. Look up `Bootstrap`'s **raw file offset** (not RVA) via `debug/pe`.
|
||||
|
||||
**Stage 3 — Spawn + inject** (still our process, target is newly spawned)
|
||||
|
||||
```
|
||||
CreateProcessW(browser.exe, CREATE_SUSPENDED)
|
||||
VirtualAllocEx(target, RW, sizeOf(payload))
|
||||
WriteProcessMemory(payload bytes)
|
||||
VirtualProtectEx(target, payload, RX)
|
||||
FlushInstructionCache(target, payload) // required before the region is executed
|
||||
VirtualAllocEx(target, RW, sizeof(BootstrapScratch))
|
||||
VirtualAllocEx(target, RW, sizeof(BootstrapParams))
|
||||
CreateRemoteThread(target, remoteBase + bootstrapFileOffset, paramsBase)
|
||||
```
|
||||
|
||||
The browser's own primary thread is created suspended and never resumed — only our remote thread runs, so no Chromium UI is ever created and no `--user-data-dir` isolation is needed to survive `ProcessSingleton`. Process-wide loader init still happens, because the first thread to run in the process goes through `LdrInitializeThunk`.
|
||||
|
||||
**Stage 4 — Inside the remote `browser.exe`**
|
||||
|
||||
The remote thread runs `Bootstrap` (C), our self-written reflective DLL loader. On return it calls the payload's `DllMain`:
|
||||
|
||||
```
|
||||
Bootstrap → see §4.1 (7 helpers + orchestrator)
|
||||
↓ calls DllMain(DLL_PROCESS_ATTACH, scratchBase)
|
||||
DoExtractKey → see §4.2
|
||||
CoCreateInstance(CLSID, IID_v2 | fallback IID_v1)
|
||||
CoSetProxyBlanket(PKT_PRIVACY + IMPERSONATE)
|
||||
vtbl[slot]->DecryptData(bstrEnc)
|
||||
↓ COM RPC
|
||||
elevation_service (SYSTEM) → returns 32-byte plaintext key
|
||||
publish_key() → scratchBase[0x40..0x5F] (success)
|
||||
publish_error(code, hr, comErr) (failure)
|
||||
```
|
||||
|
||||
**Stage 5 — Back in our process**
|
||||
|
||||
1. `WaitForSingleObject(thread, 30s)` — covers cold-start of `GoogleChromeElevationService`.
|
||||
2. `ReadProcessMemory` for the 12-byte diagnostic header, then 32-byte key when `status == ready`.
|
||||
3. `TerminateProcess(browser)` — the target was a throwaway from the start.
|
||||
|
||||
The returned key flows back up to the cross-platform AES-256-GCM path (`crypto.AESGCMDecrypt`; see §5.3) and then to the usual cookie/password extraction pipeline.
|
||||
|
||||
## 4. C payload — `internal/abe/native/`
|
||||
|
||||
Three translation units, ~500 lines of pure C. No C++, no assembly, no direct syscalls, no vendored third-party code (Stephen Fewer's loader was evaluated and rejected — see §8.2). Built with `zig cc -target x86_64-windows-gnu`.
|
||||
|
||||
### 4.1 Reflective loader — `bootstrap.c`
|
||||
|
||||
`Bootstrap(LPVOID lpParameter)` exported as `__declspec(dllexport)`. The Go injector calls it at its **raw file offset** (not RVA) because we inject raw file bytes rather than a mapped image.
|
||||
|
||||
Structure after refactor: **one ~30-line orchestrator + seven single-purpose static helpers**:
|
||||
|
||||
| Helper | Responsibility |
|
||||
| ------------------------- | -------------------------------------------------------------------------------------------------- |
|
||||
| `locate_own_image_base` | Backward-scan from `__builtin_return_address(0)` for MZ/PE magic (must stay `noinline`) |
|
||||
| `read_bootstrap_params` | Read the standalone scratch pointer and 5 function pointers from the remote parameter block (§4.4) |
|
||||
| `allocate_and_copy_image` | `VirtualAlloc(SizeOfImage, RW)` + copy headers/sections |
|
||||
| `apply_base_relocations` | Walk `IMAGE_DIRECTORY_ENTRY_BASERELOC`, fix `IMAGE_REL_BASED_DIR64` |
|
||||
| `link_iat` | Resolve each imported DLL + fill IAT via parameter-supplied `LoadLibraryA` / `GetProcAddress` |
|
||||
| `set_section_protections` | `.text → RX`, `.rdata → R`, `.data → RW` per `Characteristics` |
|
||||
| `invoke_dllmain` | Call mapped `DllMain(DLL_PROCESS_ATTACH, scratchBase)` |
|
||||
|
||||
Progress markers: after each major step the orchestrator writes one byte to `scratchBase + BOOTSTRAP_MARKER_OFFSET` (0x28). The Go injector reads this back on failure to pinpoint the stage.
|
||||
|
||||
### 4.2 COM extractor — `abe_extractor.c`
|
||||
|
||||
Standard DLL whose `DllMain(DLL_PROCESS_ATTACH)` delegates to `DoExtractKey`, which is itself a thin orchestrator:
|
||||
|
||||
```
|
||||
DoExtractKey(imageBase)
|
||||
CoInitializeEx(APARTMENTTHREADED)
|
||||
GetOwnExeBasename → LookupBrowserByExe (com_iid.c)
|
||||
extract_key_inner(ids) → extract_result { hr, comErr, errCode, plain }
|
||||
if errCode == OK && plain correct length:
|
||||
publish_key(imageBase, plain) // atomic write with MemoryBarrier
|
||||
else:
|
||||
publish_error(imageBase, code, hr, comErr)
|
||||
SysFreeString + SecureZeroMemory + CoUninitialize
|
||||
```
|
||||
|
||||
`extract_key_inner` owns a single resource (`bstrEnc`) and uses early returns — no goto chain. Steps: read `HBD_ABE_ENC_B64` env var, base64-decode, `SysAllocStringByteLen`, `CoCreateInstance(IID_v2)` with fallback to `IID_v1`, `CoSetProxyBlanket(PKT_PRIVACY + IMPERSONATE)`, **slot-based vtable dispatch** of `DecryptData` (slot 5 for Chrome-family, 8 for Edge, 13 for Avast).
|
||||
|
||||
**Diagnostic channel** (`extract_err_code` / `hresult` / `com_err` fields in the scratch region, added alongside the success byte): lets the Go side report structured failures like `err=CoCreateInstance failed, hr=E_ACCESSDENIED (0x80070005), comErr=0x0` instead of the old `status=0x00, marker=0xff`. Failure categories enumerated in `bootstrap_layout.h`:
|
||||
|
||||
```
|
||||
ABE_ERR_BASENAME / BROWSER_UNKNOWN / ENV_MISSING / BASE64
|
||||
ABE_ERR_BSTR_ALLOC / COM_CREATE / DECRYPT_DATA / KEY_LEN
|
||||
```
|
||||
|
||||
### 4.3 Vendor table — `com_iid.c` / `com_iid.h`
|
||||
|
||||
Static table mapping `exe_basename → { CLSID, IID_v1, IID_v2, kind }`. `kind` selects the DecryptData vtable slot. Schema:
|
||||
|
||||
```c
|
||||
{ "chrome.exe", CHROME_BASE, { CLSID_bytes }, { IID_v1_bytes }, TRUE, { IID_v2_bytes } }
|
||||
```
|
||||
|
||||
Current coverage: Chrome Stable/Beta, Brave, Edge, Avast Secure Browser, CocCoc. Source file `internal/abe/native/com_iid.c` is the authoritative list — see §10 for how to add a new fork.
|
||||
|
||||
### 4.4 Bootstrap parameter block (non-obvious design)
|
||||
|
||||
The original plan had `Bootstrap` walk the PEB's `InMemoryOrderModuleList` to find kernel32 / ntdll and resolve `LoadLibraryA` etc. via export-table parsing. It worked in test processes but **crashed reproducibly in Chrome 147's broker process** — `resolve_export` returned NULL for every LDR entry. Root cause was never fully pinpointed (Chrome-specific process state + Windows 10 LDR layout interaction).
|
||||
|
||||
Workaround: **Go resolves the 5 required functions in its own process** (via `windows.LazyProc.Addr()` in `utils/winapi/process_windows.go`) and writes those raw u64 values into a dedicated `BootstrapParams` block in the target process. `Bootstrap` reads the remote-thread parameter; no PEB walk, no export parsing, and no mutation of the payload bytes.
|
||||
|
||||
Validity relies on Windows **KnownDlls + session-consistent ASLR** — `kernel32.dll` and `ntdll.dll` load at the same virtual address in all processes of a boot session.
|
||||
|
||||
## 5. Go integration
|
||||
|
||||
### 5.1 Injector package — `internal/abe/injector/`
|
||||
|
||||
Four files collaborate:
|
||||
|
||||
| File | Role |
|
||||
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `reflective_windows.go` | `Reflective.Inject(exePath, payload, env) ([]byte, error)` — the orchestrator. Win32 calls (`VirtualAllocEx`, `VirtualProtectEx`, `CreateRemoteThread`, import-address lookups) delegate to `utils/winapi/` via `CallBoolErr`. |
|
||||
| `errors_windows.go` | `formatABEError(scratchResult) string` — renders the C-side diag channel into human-readable strings via two lookup maps (`ABE_ERR_*` names + known HRESULT names like `E_ACCESSDENIED`). |
|
||||
| `pe_windows.go` | `FindExportFileOffset(dllBytes, "Bootstrap")` — raw-file offset via `debug/pe`. |
|
||||
| `arch_windows.go` | Architecture validation (amd64-only today). |
|
||||
|
||||
`scratchResult` is the Go mirror of the remote process's 12-byte diagnostic header: `Marker / Status / ErrCode / HResult / ComErr` + optional 32-byte `Key`. One `ReadProcessMemory` covers the header; a second reads the key only when `Status == KeyStatusReady`.
|
||||
|
||||
### 5.2 Scratch layout codegen
|
||||
|
||||
The C payload and Go injector communicate through a byte-level protocol in a standalone RW scratch allocation inside the target process. The layout is defined **once** as a `BootstrapScratch` struct + `offsetof`-based macros in `internal/abe/native/bootstrap_layout.h`. `_Static_assert`s in the same header guarantee compile-time detection of layout drift:
|
||||
|
||||
```c
|
||||
_Static_assert(offsetof(struct BootstrapScratch, marker) == 0x28, "marker offset");
|
||||
_Static_assert(offsetof(struct BootstrapScratch, hresult) == 0x2C, "hresult offset");
|
||||
_Static_assert(offsetof(struct BootstrapScratch, key) == 0x40, "key offset");
|
||||
```
|
||||
|
||||
Go consumes the same constants via **`go tool cgo -godefs`** (a development-time tool, not a runtime dependency). `make gen-layout` regenerates `internal/abe/native/bootstrap/layout.go` from `bootstrap_layout.h` using `CC="zig cc"` for bit-identical results across host OSes. `make gen-layout-verify` can be run locally to verify the committed `layout.go` matches the current header.
|
||||
|
||||
**Why `cgo -godefs` rather than runtime `import "C"`**: we only need constants shared, not FFI to C functions. Runtime CGO would force the whole project into `CGO_ENABLED=1`, losing the "non-Windows contributor needs no C toolchain" guarantee. `cgo -godefs` bakes the values into a pure-Go file that commits to git; the project stays `CGO_ENABLED=0`.
|
||||
|
||||
### 5.3 Retriever wiring & v20 routing
|
||||
|
||||
On Windows `RetrieveAll` runs a `dpapiRetriever` (v10) and an `abeRetriever` (v20), grouped by version and independent — not a first-success chain — because a single Chrome profile upgraded from pre-127 can carry mixed v10+v20 ciphertexts, and both keys must be available for `decryptValue` to route each ciphertext to its matching tier (see [RFC-015](015-key-retrieval-mechanisms.md) §4.4 and issue #578). `abeRetriever.Retrieve`:
|
||||
|
||||
1. Reads `Local State` → extracts `os_crypt.app_bound_encrypted_key` → strips `APPB` prefix. If the field is missing, `abeRetriever` returns `(nil, nil)`, v20 stays empty, and the independent v10 DPAPI tier still runs.
|
||||
2. Resolves browser executable via `internal/winapi/executable_windows.go` (install-location fallbacks → registry App Paths → running process; the install locations come first because an executable name such as `browser.exe` is shared by more than one vendor).
|
||||
3. Base64-encodes the encrypted blob and passes it as `HBD_ABE_ENC_B64` env var.
|
||||
4. `Reflective.Inject(exePath, payload, env)` runs the full flow in §3.
|
||||
5. Returns the 32-byte key on success, or a formatted diagnostic error.
|
||||
|
||||
On extraction success, logs at `Info` level (`abe: retrieved <browser> master key via reflective injection`).
|
||||
|
||||
**v20 decryption** is cross-platform by design: `internal/browser/chromium/cipher.go` routes a 32-byte (v20) key to `decryptGCM`, which calls `crypto.AESGCMDecrypt`. This lets Linux/macOS CI exercise the same decryption path as Windows — only the key-source side is platform-gated.
|
||||
|
||||
## 6. Build chain
|
||||
|
||||
- **Default build** (any host, no zig): `go build ./cmd/hack-browser-data/` succeeds; ABE is stubbed out. Legacy v10/v11 cookies still decrypt via DPAPI.
|
||||
- **Windows release with ABE**: `make build-windows` = `make payload` (zig cc → `internal/abe/payload/abe_extractor_amd64.bin`) + `GOOS=windows go build -tags abe_embed`. The `abe_embed` tag activates `//go:embed` on the compiled binary, so the payload is always built from the C sources in the same run and cannot go stale.
|
||||
- **Layout regen**: `make gen-layout` after any change to `bootstrap_layout.h`. This also covers the `BootstrapParams` field offsets the Go injector serializes by hand.
|
||||
- **`go.mod` unchanged** — no new dependencies. `zig` is the only external toolchain, and only when actually rebuilding the payload.
|
||||
|
||||
## 7. Impact on non-Windows contributors — zero
|
||||
|
||||
| Scenario | Requires zig? | Requires CGO? | Default `go build ./...` succeeds? |
|
||||
| ---------------------------- | ------------- | ------------- | ---------------------------------- |
|
||||
| macOS / Linux feature work | no | no | yes |
|
||||
| Windows non-ABE (v10/DPAPI) | no | no | yes (stub path) |
|
||||
| Windows release with ABE | **yes** | no | `make build-windows` |
|
||||
| CI on any host (non-release) | no | no | yes |
|
||||
|
||||
All ABE-specific Go code is behind `//go:build windows` (plus `&& abe_embed` for the payload embed).
|
||||
|
||||
## 8. Zero disk footprint (enforced)
|
||||
|
||||
**No payload bytes ever touch disk on the target machine.**
|
||||
|
||||
- Payload DLL exists only as:
|
||||
1. Build artifact on the developer machine (`internal/abe/payload/abe_extractor_amd64.bin`, git-ignored)
|
||||
2. `.rdata` section of `hack-browser-data.exe` (`//go:embed`)
|
||||
3. Go `[]byte` in our process memory
|
||||
4. `VirtualAllocEx`'d RX payload region in the target browser during injection; released on `TerminateProcess`
|
||||
|
||||
No `%TEMP%\*.dll` or `%TEMP%\*.txt`. The master key is handed back via `ReadProcessMemory` on the target's standalone scratch region at `scratchBase + 0x40` (32 bytes). Everything stays in RAM.
|
||||
|
||||
### 8.1 Scratch layout
|
||||
|
||||
```
|
||||
scratchBase + 0x28 marker (1 B) ← Bootstrap progress
|
||||
scratchBase + 0x29 key_status (1 B; 0x01 = ready)
|
||||
scratchBase + 0x2A extract_err_code (1 B) ← ABE_ERR_* category on failure
|
||||
scratchBase + 0x2C hresult (4 B LE) ← COM HRESULT on failure (0 on success)
|
||||
scratchBase + 0x30 com_err (4 B LE) ← IElevator out DWORD on failure
|
||||
scratchBase + 0x40..0x5F 32-byte master key
|
||||
```
|
||||
|
||||
Import pointers live in the separate `BootstrapParams` block passed as the remote thread parameter; the scratch block is only diagnostics plus key material.
|
||||
|
||||
## 9. Comparison with reference implementations
|
||||
|
||||
Three implementations of "extract Chrome v20 master key via reflective injection" exist in the ecosystem.
|
||||
|
||||
| Dimension | **This project** | **injector-old** (local C++ fork) | **xaitax/Chrome-App-Bound-Encryption-Decryption** |
|
||||
| --------------------------- | ------------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------- |
|
||||
| Top-level language | Go + C | Go + C++ | C++ end-to-end |
|
||||
| Injector runtime | Go, `CGO_ENABLED=0` | Go, `CGO_ENABLED=0` | C++ standalone exe |
|
||||
| Reflective loader | **Self-written C**, ~280 lines | Stephen Fewer 2012 `ReflectiveLoader` (vendored C, ~500) | Self-written C++, ~400 |
|
||||
| kernel32 resolution | **Pre-resolved by Go, passed in BootstrapParams** | PEB walk + `_rotr` hash | PEB walk + `_rotr` hash |
|
||||
| Syscall mechanism | Win32 APIs | Win32 APIs | Direct syscall via ASM trampoline |
|
||||
| COM DecryptData dispatch | Vtable slot by browser kind (5/8/13) | Full interface via `ComPtr` | Same as injector-old |
|
||||
| IPC payload → injector | **env var in, scratch-region read out** | Named pipe (full duplex) | Named pipe (full duplex) |
|
||||
| Build toolchain for payload | `zig cc` | MSVC / clang-cl | MSVC |
|
||||
| Runtime disk footprint | **0 bytes** | 1 temp file + pipe | Pipe |
|
||||
| EDR evasion posture | None (Win32 APIs visible) | Partial (optional Nt\*) | Strong (direct syscalls) |
|
||||
|
||||
### 9.1 Why we didn't vendor xaitax's Bootstrap
|
||||
|
||||
Tempting — it's known-good. But: C++ in an otherwise pure-C/Go repo; ASM trampolines + direct syscalls add a second toolchain leg; pipe-based IPC is 300+ lines of C we don't need; browser termination is a product-policy decision we skipped.
|
||||
|
||||
Comparisons in this section were made against [xaitax/Chrome-App-Bound-Encryption-Decryption @ `63b719f`](https://github.com/xaitax/Chrome-App-Bound-Encryption-Decryption/commit/63b719f2ab3dbf8573fd9228a9c028526e9eb1db). It is a reference for reading only — nothing from it is vendored, and it is deliberately not a submodule.
|
||||
|
||||
### 9.2 Why we abandoned Stephen Fewer's loader
|
||||
|
||||
`while(curr)` loop without `curr != head` termination → walked past end of the circular `InMemoryOrderModuleList` → dereferenced `PEB_LDR_DATA` itself as an `LDR_DATA_TABLE_ENTRY` → access-violated on `BaseDllName.pBuffer`. The 2012-era struct alignment hack (commented-out first `LIST_ENTRY`) also makes it brittle against Windows internals. Our replacement is strictly smaller, addresses these bugs explicitly, and is first-party.
|
||||
|
||||
## 10. Browser coverage
|
||||
|
||||
| Browser class | Behavior |
|
||||
| ----------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
||||
| Chrome Stable/Beta, Brave, CocCoc | ABE v20 via `CHROME_BASE` slot (5) |
|
||||
| Microsoft Edge | ABE v20 via `EDGE` slot (8); v2 `E_NOINTERFACE` → v1 fallback succeeds |
|
||||
| Avast Secure Browser | ABE v20 via `AVAST` slot (13) |
|
||||
| Opera / OperaGX / Vivaldi / Yandex / Arc / 360 / QQ / Sogou | Not in `com_iid.c`; legacy v10 cookies still decrypt via DPAPI, v20 cookies do not |
|
||||
|
||||
Authoritative CLSID/IID table: `internal/abe/native/com_iid.c`.
|
||||
|
||||
## 11. Adding support for a new Chromium fork
|
||||
|
||||
Three steps.
|
||||
|
||||
1. **Discover CLSID** — find the fork's elevation Windows service, look up its AppID in `HKLM\SOFTWARE\Classes\AppID`, then the CLSID that binds to it in `HKLM\SOFTWARE\Classes\CLSID`.
|
||||
2. **Mine IIDs from TypeLib** — the interface IIDs live in the TypeLib resource of `<InstallDir>\Application\<version>\elevation_service.exe`. PowerShell + `ITypeLib.GetTypeInfo` enumerates them. Map `IElevator<Vendor>` → v1 IID, `IElevator2<Vendor>` → v2 IID (absent for older vendors).
|
||||
3. **Determine vtable slot** — count `IElevator` methods in the TypeLib. Chrome-family has 3 methods (slot 5). Edge prepends 3 placeholders (slot 8). Avast extends the interface further (slot 13).
|
||||
|
||||
Edit `internal/abe/native/com_iid.c` (add the C-side entry: exe, kind, CLSID, IIDs) and `internal/browser/table.go` (on the browser's row, set the `Windows` platform's `Exe`, `ExeFallbacks`, and `ABE` to the matching `masterkey.ABEKind`), then `make payload-clean && make build-windows` and redeploy. `TestABERowsMatchPayloadTable` fails at `go test` time if a Go `ABE` row has no `com_iid.c` row with the same exe and kind.
|
||||
|
||||
## 12. Known issues & future work
|
||||
|
||||
**Known**:
|
||||
|
||||
- Non-`com_iid.c` browsers (Opera, Vivaldi, Yandex, Arc, 360, QQ, Sogou) fall back to DPAPI; v20 cookies remain encrypted. Fix = §11 procedure per vendor.
|
||||
- ARM64 Windows unsupported. Payload is `x86_64-windows-gnu` only. xaitax ships ARM64; we'd need parallel payload builds + runtime arch dispatch.
|
||||
- Chrome v20 domain-binding prefix: injector-old strips 32 bytes at the start of v20 plaintext. Left unimplemented pending evidence that current Chrome versions emit this prefix; re-add if encountered.
|
||||
- Running-browser handling: if the user has the target browser open we spawn a second instance. Some vendors (Opera GX) serialize the elevation service, which could surface conflicts; an opt-in `--kill-running` is future work.
|
||||
|
||||
**Future** (ordered by value):
|
||||
|
||||
1. Runtime CLSID/IID lookup from `elevation_service_idl.tlb` (no rebuild per fork rotation)
|
||||
2. More forks via §11 (Opera, Vivaldi, Yandex, Arc)
|
||||
3. x86 payload variant (for legacy 32-bit Chrome installs)
|
||||
4. Optional `--kill-running` flag
|
||||
5. EDR-hardened `injector.Strategy` variant (direct syscalls)
|
||||
6. Release signing (cosign / SBOM) + reproducible-build CI verification
|
||||
7. ARM64 Windows support
|
||||
|
||||
## 13. Related RFCs
|
||||
|
||||
| RFC | Relation |
|
||||
| ----------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
||||
| [RFC-014 Chromium Encryption](014-chromium-encryption.md) | v10/v11/v20 cipher format reference; v20 now implemented on Windows per this RFC |
|
||||
| [RFC-015 Key Retrieval](015-key-retrieval-mechanisms.md) | `masterkey` retriever taxonomy; Windows runs V10 (DPAPI) + V20 (ABE) as independent versions |
|
||||
| [RFC-021 Windows Locked Files](021-windows-locked-file-bypass.md) | Sibling Windows-specific workaround (handle duplication for locked DBs) |
|
||||
@@ -1,158 +0,0 @@
|
||||
# RFC-017: Yandex Browser Decryption
|
||||
|
||||
**Author**: moonD4rk\
|
||||
**Status**: Living Document\
|
||||
**Created**: 2026-04-22\
|
||||
**Last updated**: 2026-04-22
|
||||
|
||||
## 1. Overview
|
||||
|
||||
Yandex Browser is a Chromium fork, but its saved-credential encryption diverges from the Chromium reference in three ways that together make a plain Chromium extractor produce zero plaintext:
|
||||
|
||||
1. The Chromium master key (DPAPI on Windows, Keychain on macOS) does not decrypt `password_value` directly — it decrypts a per-DB _intermediate_ key stored in `meta.local_encryptor_data`. That intermediate key is what actually decrypts rows.
|
||||
2. Each row's AES-GCM ciphertext is sealed with row-specific Additional Authenticated Data (AAD). A password row's AAD is a SHA-1 digest over five form fields joined by `\x00`; a credit-card row's AAD is the row's `guid`. AAD mismatch → GCM tag failure → empty plaintext.
|
||||
3. Credit cards live in `records(guid, public_data, private_data)` — two JSON blobs — not Chromium's flat `credit_cards` table.
|
||||
|
||||
This RFC documents the on-disk layout, the decryption math, and how the integration plugs into the existing Chromium extract pipeline without perturbing the v10/v11/v20 paths that the rest of HackBrowserData depends on.
|
||||
|
||||
Resolved issues: #90 (feature request), #105 / #462 / #476 (downstream bug reports against the incomplete skeleton that was merged before this RFC).
|
||||
|
||||
Related RFCs:
|
||||
|
||||
- [RFC-014](014-chromium-encryption.md) — Chromium cipher versions (v10 / v11 / v20)
|
||||
- [RFC-015](015-key-retrieval-mechanisms.md) — master-key retrieval chain
|
||||
|
||||
Deferred to a follow-up RFC / PR:
|
||||
|
||||
- Master-password (RSA-OAEP + PBKDF2) unseal path.
|
||||
- Windows ABE v20 for Yandex — not in scope until Yandex adopts App-Bound Encryption.
|
||||
- Linux support; Yandex Browser has no official Linux build.
|
||||
|
||||
## 2. Protocol differences at a glance
|
||||
|
||||
| Layer | Standard Chromium | Yandex |
|
||||
| --------------------------- | ------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Master key | `os_crypt.encrypted_key` in `Local State`, unwrapped via DPAPI / Keychain | Same |
|
||||
| Decryption key used per row | Master key directly | Intermediate 32-byte key stored per-DB in `meta.local_encryptor_data` |
|
||||
| Key wrapper format | `"v10"\|nonce\|ct+tag` (or DPAPI blob) | `"v10"\|nonce\|ct+tag`, plaintext prefixed by 4B protobuf signature `08 01 12 20`, 32B key follows |
|
||||
| Password DB file | `Login Data` (table: `logins`) | `Ya Passman Data` (table: `logins`) |
|
||||
| Password ciphertext | `"v10"\|nonce\|ct+tag`, AAD = empty | No prefix; raw `nonce\|ct+tag`; AAD = SHA1(origin_url ‖ \x00 ‖ username_element ‖ \x00 ‖ username_value ‖ \x00 ‖ password_element ‖ \x00 ‖ signon_realm) |
|
||||
| Credit-card DB file | `Web Data` (table: `credit_cards`) | `Ya Credit Cards` (table: `records`) |
|
||||
| Credit-card layout | Columns: `name_on_card`, `expiration_month`, `card_number_encrypted`, … | JSON: `public_data` (plaintext) + `private_data` (AES-GCM sealed JSON, AAD = `guid`) |
|
||||
| Master password | n/a | Optional; when set, `active_keys.sealed_key` holds an RSA-OAEP envelope (deferred) |
|
||||
|
||||
## 3. On-disk layout
|
||||
|
||||
### 3.1 `meta.local_encryptor_data`
|
||||
|
||||
```
|
||||
[protobuf preamble bytes...] "v10" [12B nonce] [68B ciphertext + 16B GCM tag]
|
||||
```
|
||||
|
||||
The 68-byte plaintext (decrypted with the Chromium master key, empty AAD) has the shape:
|
||||
|
||||
```
|
||||
08 01 12 20 | KK KK ... KK (32 bytes) | padding / extra protobuf fields
|
||||
^ signature | ^ data-encryption key
|
||||
```
|
||||
|
||||
The data-encryption key is the first 32 bytes after the signature; trailing bytes are ignored. The fixed 96-byte region after `"v10"` is a Yandex invariant (the reference implementation slices `[:96]` unconditionally) and is checked as a minimum length.
|
||||
|
||||
### 3.2 Password row (`logins.password_value`)
|
||||
|
||||
```
|
||||
[12B nonce] [ciphertext] [16B GCM tag]
|
||||
```
|
||||
|
||||
No version prefix. AAD binds five form columns:
|
||||
|
||||
```
|
||||
SHA1(origin_url ‖ 0x00 ‖ username_element ‖ 0x00 ‖ username_value ‖ 0x00 ‖ password_element ‖ 0x00 ‖ signon_realm)
|
||||
```
|
||||
|
||||
When a master password is set, the sealed keyID is appended after the SHA-1 sum. v1 always passes `nil` and skips sealed profiles.
|
||||
|
||||
### 3.3 Credit card row (`records.private_data`)
|
||||
|
||||
Same byte shape as passwords but AAD = the row's `guid` bytes (plus optional keyID). Decrypted plaintext is a JSON object with `full_card_number`, `pin_code`, `secret_comment`. The sibling `public_data` column is plaintext JSON with `card_holder`, `card_title`, `expire_date_month`, `expire_date_year`.
|
||||
|
||||
## 4. Architecture
|
||||
|
||||
### 4.1 Two-level key hierarchy
|
||||
|
||||
Yandex adds a second key layer on top of the standard Chromium key. The Chromium master key — unwrapped from `Local State` via DPAPI (Windows) or Keychain (macOS) — never decrypts row ciphertext directly. Instead, each target SQLite database carries its own _data key_ in `meta.local_encryptor_data`, and only that data key decrypts row-level ciphertext. The master key's only job is to unwrap the data key.
|
||||
|
||||
### 4.2 Recovery steps
|
||||
|
||||
For every target DB (`Ya Passman Data` for passwords, `Ya Credit Cards` for cards), the extractor runs the same five steps:
|
||||
|
||||
1. **Master key**: read `Local State`, base64-decode `os_crypt.encrypted_key`, strip the `DPAPI` prefix, and unwrap it via DPAPI (Windows) or Keychain (macOS). Yields 32 bytes.
|
||||
2. **Open DB**: open the target SQLite file (a temp copy is used to avoid lock contention if the browser is running).
|
||||
3. **Master-password gate**: `SELECT sealed_key FROM active_keys`. Non-empty → log a warning and skip the profile (v1 limitation — RSA-OAEP unseal deferred). Table missing (credit-card DB) or empty value → continue.
|
||||
4. **Data key**: `SELECT value FROM meta WHERE key='local_encryptor_data'`. Find the `"v10"` byte sequence, take the 96 bytes that follow, split into 12B nonce + 84B (ciphertext+tag), AES-GCM-decrypt with the master key (no AAD), strip the 4-byte protobuf signature `08 01 12 20`, keep the first 32 bytes.
|
||||
5. **Per-row decryption**: for each row, compute AAD (see §4.4), split `[12B nonce][ct+tag]`, AES-GCM-decrypt with the data key under that AAD.
|
||||
|
||||
### 4.3 Key hierarchy
|
||||
|
||||
| Level | Key | Origin | Scope |
|
||||
| ----- | --------------------- | ----------------------------------------------- | -------------------------------------------------- |
|
||||
| 1 | Chromium master key | `Local State` → DPAPI / Keychain | Whole profile (shared with cookies, history, etc.) |
|
||||
| 2a | Passwords data key | `Ya Passman Data` → `meta.local_encryptor_data` | `logins` rows in this DB only |
|
||||
| 2b | Credit cards data key | `Ya Credit Cards` → `meta.local_encryptor_data` | `records` rows in this DB only |
|
||||
|
||||
### 4.4 Per-category decryption inputs
|
||||
|
||||
| Category | DB file | Table / column | Ciphertext layout | AAD |
|
||||
| ----------- | ----------------- | ----------------------- | --------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
||||
| Password | `Ya Passman Data` | `logins.password_value` | `[12B nonce][ct+tag]` | `SHA1(origin_url ‖ \x00 ‖ username_element ‖ \x00 ‖ username_value ‖ \x00 ‖ password_element ‖ \x00 ‖ signon_realm)` |
|
||||
| Credit card | `Ya Credit Cards` | `records.private_data` | `[12B nonce][ct+tag]` | raw `guid` bytes |
|
||||
|
||||
Credit-card plaintext is a JSON object (`full_card_number`, `pin_code`, `secret_comment`) that the extractor unmarshals into `CreditCardEntry`. The sibling `records.public_data` is plaintext JSON (`card_holder`, `card_title`, `expire_date_year`, `expire_date_month`) and needs no decryption.
|
||||
|
||||
### 4.5 Independence property
|
||||
|
||||
The two level-2 data keys are unwrapped from **different** `meta.local_encryptor_data` blobs — one per DB. This matters in two ways:
|
||||
|
||||
- A profile with a master password blocks passwords (step 3 trips) but credit cards can still decrypt, because the card DB has no `active_keys` table.
|
||||
- Corruption of one DB's meta blob does not cascade to the other.
|
||||
|
||||
Both data keys still ultimately derive from the same level-1 Chromium master key, so loss of DPAPI (e.g., Windows user-profile rebuild) breaks both simultaneously.
|
||||
|
||||
## 5. Layering rationale
|
||||
|
||||
### 5.1 Yandex-specific derivation stays in the extract path, not the key-retrieval layer
|
||||
|
||||
The key-retrieval layer dispatches on cipher-version prefix — `v10` / `v11` / `v20`. Yandex password rows carry no such prefix; they are raw `[nonce][ct+tag]`. Folding Yandex's intermediate-key step into the prefix dispatcher would overload an abstraction that is purely "pick the key for this byte prefix". The intermediate-key unwrap therefore lives alongside the Yandex extractor and consumes the standard Chromium master key as input; the prefix dispatcher is untouched.
|
||||
|
||||
### 5.2 AAD construction belongs with the consumer, not the crypto layer
|
||||
|
||||
The crypto layer exposes cryptographic primitives — transforms of bytes under a key (AES, GCM, 3DES, DPAPI, PBKDF2). Yandex's AAD rules (SHA-1 over five form fields for passwords, the row's GUID for cards) are not cryptography; they are Yandex's per-row identification scheme that happens to be bound to GCM's authentication tag. Placing them in the crypto layer would leak product-specific knowledge into a layer that otherwise sees only bytes and keys.
|
||||
|
||||
The final split:
|
||||
|
||||
- A single generic AES-GCM-with-AAD primitive in the crypto layer. Any current or future protocol that needs per-row AAD can reuse it without the crypto layer growing per-product surface.
|
||||
- Yandex-specific AAD helpers next to the consumer that builds the AAD inputs. Product knowledge stays with the product.
|
||||
|
||||
This keeps the crypto surface minimal — the only Yandex symbol it owns is the intermediate-key unwrap, because that one function genuinely _is_ cryptography (it strips a protobuf frame and decrypts AES-GCM).
|
||||
|
||||
## 6. Non-goals and deferred work
|
||||
|
||||
1. **Master-password unseal** (#90 edge case). Profiles with a non-empty `active_keys.sealed_key` are detected and skipped with a warning. A follow-up RFC will cover the RSA-OAEP path: PBKDF2-SHA256 derives a KEK; the KEK decrypts `encrypted_private_key` with AAD = `unlock_key_salt`; the resulting PKCS8 RSA private key + RSA-OAEP-SHA256 decrypts `encrypted_encryption_key`; the signature strip then yields the dataKey.
|
||||
2. **Windows ABE v20 for Yandex**. Yandex has not adopted App-Bound Encryption. If that changes, Yandex joins the RFC-016 vendor table and the ABE path begins returning a non-empty v20 key for Yandex ciphertexts.
|
||||
3. **Linux support**. Yandex Browser has no official Linux release, so there is no Linux code path to add.
|
||||
|
||||
## 7. Test strategy
|
||||
|
||||
Decryption math is covered by cross-platform unit tests that build synthetic DBs by running the encryption path in reverse — no real Yandex install or Windows host is required. Coverage spans:
|
||||
|
||||
- Intermediate-key unwrap: round-trip, missing `v10` marker, truncated blob, bad protobuf signature, trailing bytes ignored.
|
||||
- AES-GCM-with-AAD primitive: round-trip, mismatched AAD surfaces as authentication failure, under-sized blob surfaces as a distinct error.
|
||||
- Password extraction: round-trip on multi-row fixtures, master-password skip path, wrong master key surfaces as error.
|
||||
- Credit-card extraction: round-trip on multi-card fixtures verifying every JSON field maps to the output schema; count; wrong master key surfaces as error.
|
||||
- AAD formulas: SHA-1 field concatenation (passwords), GUID bytes (cards), both with and without a master-password keyID appended.
|
||||
|
||||
End-to-end validation on a Windows host with a real Yandex profile is expected before shipping changes that touch the decryption path; the existing Chromium full-sweep doubles as a regression gate against unintended impact on other Chromium forks.
|
||||
|
||||
## 8. Rollout
|
||||
|
||||
Single PR that wires all of the above; merge automatically closes #90 / #105 / #462 / #476. Follow-up PRs for master password and (if/when Yandex adopts ABE) v20 integration reference this RFC rather than reopening the decryption design question.
|
||||
@@ -1,130 +0,0 @@
|
||||
# RFC-018: Firefox Data Storage
|
||||
|
||||
**Author**: moonD4rk\
|
||||
**Status**: Living Document\
|
||||
**Created**: 2026-04-05
|
||||
|
||||
## 1. Profile Structure
|
||||
|
||||
Firefox stores per-user data in **profile directories** beneath a platform-specific root (e.g. `~/Library/Application Support/Firefox/Profiles/` on macOS). Each profile directory has a random-prefix name like `97nszz88.default-release`.
|
||||
|
||||
Profile discovery enumerates subdirectories of the root and accepts any directory that contains at least one known data file. Unlike Chromium (which looks for a `Preferences` sentinel), Firefox validation simply checks for the presence of any source file from the table below.
|
||||
|
||||
## 2. Data File Locations
|
||||
|
||||
All paths are relative to the profile directory.
|
||||
|
||||
| Category | File | Format |
|
||||
| ------------ | --------------------- | ------ |
|
||||
| Password | `logins.json` | JSON |
|
||||
| Cookie | `cookies.sqlite` | SQLite |
|
||||
| History | `places.sqlite` | SQLite |
|
||||
| Download | `places.sqlite` | SQLite |
|
||||
| Bookmark | `places.sqlite` | SQLite |
|
||||
| Extension | `extensions.json` | JSON |
|
||||
| LocalStorage | `webappsstore.sqlite` | SQLite |
|
||||
|
||||
History, Download, and Bookmark all share `places.sqlite` but query different tables within it. Firefox does not support CreditCard or SessionStorage extraction.
|
||||
|
||||
The master encryption key is stored separately in `key4.db` (see [RFC-019](019-firefox-encryption.md)).
|
||||
|
||||
## 3. Data Storage Formats
|
||||
|
||||
### 3.1 Passwords (logins.json)
|
||||
|
||||
Passwords are stored as a JSON file with a top-level `logins` array. Each entry contains:
|
||||
|
||||
- `formSubmitURL` / `hostname` — the login URL (formSubmitURL preferred, hostname as fallback)
|
||||
- `encryptedUsername` — base64-encoded, ASN1 PBE-encrypted username
|
||||
- `encryptedPassword` — base64-encoded, ASN1 PBE-encrypted password
|
||||
- `timeCreated` — creation timestamp in **milliseconds**
|
||||
|
||||
Decryption pipeline: base64 decode the field, parse as ASN1 PBE structure, decrypt with the master key.
|
||||
|
||||
### 3.2 Cookies (cookies.sqlite)
|
||||
|
||||
Cookies are **not encrypted** — values are stored in plaintext.
|
||||
|
||||
```sql
|
||||
SELECT name, value, host, path, creationTime, expiry, isSecure, isHttpOnly
|
||||
FROM moz_cookies
|
||||
```
|
||||
|
||||
The database must be opened with `journal_mode=off` to avoid locking conflicts with a running Firefox instance.
|
||||
|
||||
### 3.3 History (places.sqlite)
|
||||
|
||||
```sql
|
||||
SELECT url, COALESCE(last_visit_date, 0), COALESCE(title, ''), visit_count
|
||||
FROM moz_places
|
||||
```
|
||||
|
||||
The `last_visit_date` column uses **microseconds** since epoch.
|
||||
|
||||
### 3.4 Downloads (places.sqlite)
|
||||
|
||||
Downloads use the `moz_annos` annotation table joined with `moz_places`:
|
||||
|
||||
```sql
|
||||
SELECT place_id, GROUP_CONCAT(content), url, dateAdded
|
||||
FROM (SELECT * FROM moz_annos INNER JOIN moz_places ON moz_annos.place_id = moz_places.id)
|
||||
t GROUP BY place_id
|
||||
```
|
||||
|
||||
Download metadata is stored as a concatenated string: `target_path,{json}` where the JSON portion contains `fileSize` and `endTime`.
|
||||
|
||||
### 3.5 Bookmarks (places.sqlite)
|
||||
|
||||
```sql
|
||||
SELECT id, url, type, dateAdded, COALESCE(title, '')
|
||||
FROM (SELECT * FROM moz_bookmarks INNER JOIN moz_places ON moz_bookmarks.fk = moz_places.id)
|
||||
```
|
||||
|
||||
The `type` field distinguishes URL bookmarks (1) from folders.
|
||||
|
||||
### 3.6 Extensions (extensions.json)
|
||||
|
||||
Extensions are read from the `addons` array. Only entries with `location == "app-profile"` are included (user-installed extensions). Fields extracted: `defaultLocale.name`, `id`, `version`, `defaultLocale.description`, `defaultLocale.homepageURL`, `active`.
|
||||
|
||||
### 3.7 LocalStorage (webappsstore.sqlite)
|
||||
|
||||
```sql
|
||||
SELECT originKey, key, value FROM webappsstore2
|
||||
```
|
||||
|
||||
The `originKey` column uses a **reversed-host format**: `moc.buhtig.:https:443` represents `https://github.com:443`. The host portion is byte-reversed and dot-suffixed; the remaining fields are scheme and port.
|
||||
|
||||
## 4. Time Formats
|
||||
|
||||
Firefox uses inconsistent timestamp units across data types. All are Unix epoch-based.
|
||||
|
||||
| Data Type | Unit | Conversion |
|
||||
| --------------------------- | ------------ | ----------- |
|
||||
| Cookies (`creationTime`) | Microseconds | / 1,000,000 |
|
||||
| Cookies (`expiry`) | Seconds | direct |
|
||||
| History (`last_visit_date`) | Microseconds | / 1,000,000 |
|
||||
| Downloads (`dateAdded`) | Microseconds | / 1,000,000 |
|
||||
| Downloads (`endTime`) | Milliseconds | / 1,000 |
|
||||
| Bookmarks (`dateAdded`) | Microseconds | / 1,000,000 |
|
||||
| Passwords (`timeCreated`) | Milliseconds | / 1,000 |
|
||||
|
||||
## 5. Key Differences from Chromium
|
||||
|
||||
| Aspect | Chromium | Firefox |
|
||||
| ---------------------- | ------------------------------------------ | ------------------------------------------------------------- |
|
||||
| Profile naming | Named directories (`Default`, `Profile 1`) | Random-prefix (`97nszz88.default-release`) |
|
||||
| Profile detection | `Preferences` sentinel file | Any known source file present |
|
||||
| Password storage | SQLite (`Login Data`) | JSON (`logins.json`) |
|
||||
| Cookie encryption | Encrypted with master key | **Plaintext** |
|
||||
| Shared database | Separate files per category | `places.sqlite` shared by History/Download/Bookmark |
|
||||
| LocalStorage | LevelDB | SQLite (`webappsstore.sqlite`) |
|
||||
| CreditCard support | Yes | No |
|
||||
| SessionStorage support | Yes | No |
|
||||
| Encryption scope | Passwords, cookies, credit cards | **Passwords only** (see [RFC-019](019-firefox-encryption.md)) |
|
||||
|
||||
## Related RFCs
|
||||
|
||||
| RFC | Topic |
|
||||
| ------------------------------------------ | ------------------------------------------------ |
|
||||
| [RFC-019](019-firefox-encryption.md) | Firefox NSS encryption and master key derivation |
|
||||
| [RFC-007](007-snapshot-and-acquisition.md) | Snapshot-first file acquisition |
|
||||
@@ -1,144 +0,0 @@
|
||||
# RFC-019: Firefox Encryption
|
||||
|
||||
**Author**: moonD4rk\
|
||||
**Status**: Living Document\
|
||||
**Created**: 2026-04-05
|
||||
|
||||
## 1. Overview
|
||||
|
||||
Firefox uses Mozilla's NSS (Network Security Services) for credential encryption. Unlike Chromium, which delegates key storage to the OS (DPAPI, Keychain, D-Bus), Firefox manages its own encryption entirely within the profile directory via `key4.db`. This makes Firefox encryption **platform-agnostic** — the same derivation logic works on Windows, macOS, and Linux.
|
||||
|
||||
Only passwords are encrypted. Cookies, history, bookmarks, downloads, extensions, and localStorage are all stored in plaintext. See [RFC-018](018-firefox-data-storage.md) for storage details.
|
||||
|
||||
## 2. Master Key Derivation (key4.db)
|
||||
|
||||
### 2.1 Database Structure
|
||||
|
||||
`key4.db` is a SQLite database containing two relevant tables:
|
||||
|
||||
| Table | Purpose | Key Columns |
|
||||
| ------------ | -------------------------------------------------------- | ------------------------------------------------------------------ |
|
||||
| `metaData` | Stores the global salt and an encrypted integrity marker | `item1` (global salt), `item2` (encrypted "password-check" string) |
|
||||
| `nssPrivate` | Stores encrypted master key candidates | `a11` (PBE-encrypted key blob), `a102` (key type tag) |
|
||||
|
||||
The `nssPrivate` table may contain multiple rows (certificates, other NSS objects). Only rows where `a102` matches a specific 16-byte type tag (`{0xF8, 0x00, ...0x01}`) are actual master key entries.
|
||||
|
||||
### 2.2 Derivation Flow
|
||||
|
||||
1. **Read metaData** — extract the global salt and encrypted password-check marker from the row where `id = 'password'`.
|
||||
2. **Verify integrity** — decrypt the password-check marker using the global salt via ASN1 PBE. The plaintext must contain the string `"password-check"`. This confirms the database is valid and the empty-password assumption holds (Firefox uses an empty master password by default).
|
||||
3. **Decrypt key candidates** — for each `nssPrivate` row matching the type tag, decrypt the `a11` blob using the global salt via ASN1 PBE. The result must be at least 24 bytes.
|
||||
4. **Validate against logins** — if `logins.json` is available, each candidate key is tested by attempting to decrypt an actual login entry (both username and password). The first key that succeeds is selected. This prevents selecting the wrong candidate when multiple keys exist.
|
||||
|
||||
## 3. ASN1 PBE Types
|
||||
|
||||
Firefox wraps all encrypted data in ASN1 structures. Three PBE (Password-Based Encryption) types are used, each with a distinct ASN1 layout:
|
||||
|
||||
| PBE Type | Used For | Cipher | Key Derivation |
|
||||
| ------------------ | ---------------------------------- | ----------------------- | ---------------------------------------- |
|
||||
| `privateKeyPBE` | Master key entries in `nssPrivate` | 3DES-CBC | SHA1 + HMAC-SHA1 custom NSS derivation |
|
||||
| `passwordCheckPBE` | Integrity marker in `metaData` | AES-256-CBC | PBKDF2-SHA256 |
|
||||
| `credentialPBE` | Encrypted fields in `logins.json` | 3DES-CBC or AES-256-CBC | Master key used directly (no derivation) |
|
||||
|
||||
The `key` parameter has different semantics depending on the PBE type:
|
||||
|
||||
- **privateKeyPBE / passwordCheckPBE**: the key parameter is the **global salt**, used as input to key derivation.
|
||||
- **credentialPBE**: the key parameter is the **already-derived master key**, used directly for decryption.
|
||||
|
||||
`NewASN1PBE()` auto-detects the type by attempting to unmarshal the raw bytes against each ASN1 structure in order.
|
||||
|
||||
### 3.1 privateKeyPBE Key Derivation
|
||||
|
||||
The NSS PBE-SHA1-3DES derivation produces a 40-byte derived key from the global salt and an entry-specific salt:
|
||||
|
||||
```
|
||||
hp = SHA1(globalSalt)
|
||||
ck = SHA1(hp || entrySalt)
|
||||
k1 = HMAC-SHA1(ck, pad(entrySalt,20) || entrySalt)
|
||||
k2 = HMAC-SHA1(ck, HMAC-SHA1(ck, pad(entrySalt,20)) || entrySalt)
|
||||
dk = k1 || k2 // 40 bytes
|
||||
key = dk[:24], iv = dk[32:40] // 3DES key + IV
|
||||
```
|
||||
|
||||
### 3.2 passwordCheckPBE Key Derivation
|
||||
|
||||
Uses PBKDF2-SHA-256 with parameters embedded in the ASN1 structure (entry salt, iteration count, key size). The PBKDF2 password is `SHA1(globalSalt)` (a 20-byte digest), not `globalSalt` itself. The IV is reconstructed by prepending the ASN.1 OCTET STRING header (`0x04 0x0E`) to the 14-byte IV value from the parsed structure, yielding a 16-byte AES IV.
|
||||
|
||||
## 4. Password Decryption
|
||||
|
||||
### 4.1 3DES-CBC (Firefox < 144)
|
||||
|
||||
Legacy Firefox versions encrypt login credentials with 3DES-CBC. The `credentialPBE` ASN1 structure wraps the ciphertext with its own IV:
|
||||
|
||||
```
|
||||
| ASN1 OID + params | IV | 3DES-CBC ciphertext (PKCS5 padded) |
|
||||
|--------------------|-------|------------------------------------|
|
||||
| variable | 8B | remaining bytes |
|
||||
```
|
||||
|
||||
Decryption details:
|
||||
|
||||
- **Key**: the first 24 bytes of the master key (derived from `key4.db`, see Section 2)
|
||||
- **IV**: 8-byte IV embedded in the ASN1 structure
|
||||
- **Algorithm**: Triple DES in CBC mode with PKCS5 padding
|
||||
- **Padding removal**: after decryption, PKCS5 padding bytes are stripped. The last byte of plaintext indicates how many padding bytes to remove (1-8).
|
||||
|
||||
3DES uses three independent 8-byte DES keys (k1, k2, k3) packed into the 24-byte key:
|
||||
|
||||
```
|
||||
| k1 (DES key 1) | k2 (DES key 2) | k3 (DES key 3) |
|
||||
|-----------------|-----------------|-----------------|
|
||||
| 8B | 8B | 8B |
|
||||
```
|
||||
|
||||
Encryption: `E(k1) → D(k2) → E(k3)`. Decryption: `D(k3) → E(k2) → D(k1)`.
|
||||
|
||||
### 4.2 AES-256-CBC (Firefox 144+)
|
||||
|
||||
Starting from [Firefox 144](https://www.firefox.com/en-US/firefox/144.0/releasenotes/) (January 2025), Mozilla migrated password encryption from 3DES to AES-256-CBC for stronger security. The ASN1 structure has the same layout but with a larger IV:
|
||||
|
||||
```
|
||||
| ASN1 OID + params | IV | AES-256-CBC ciphertext (PKCS5 padded) |
|
||||
|--------------------|-------|---------------------------------------|
|
||||
| variable | 16B | remaining bytes |
|
||||
```
|
||||
|
||||
Decryption details:
|
||||
|
||||
- **Key**: the full master key (32 bytes for AES-256)
|
||||
- **IV**: 16-byte IV embedded in the ASN1 structure
|
||||
- **Algorithm**: AES-256 in CBC mode with PKCS5 padding
|
||||
- **Cipher selection**: the cipher is inferred from the **IV length** rather than checking OIDs — 8-byte IV means 3DES, 16-byte IV means AES-256-CBC. This allows the same code path to handle both old and new Firefox profiles.
|
||||
|
||||
### 4.3 Pipeline
|
||||
|
||||
Each encrypted login field (`encryptedUsername`, `encryptedPassword` in `logins.json`) follows the same decryption pipeline:
|
||||
|
||||
```
|
||||
logins.json
|
||||
→ encryptedUsername / encryptedPassword (base64 string)
|
||||
|
||||
| base64 encoded string |
|
||||
|----------------------------------------------------------|
|
||||
↓ base64 decode
|
||||
| raw ASN1 DER bytes |
|
||||
|----------------------------------------------------------|
|
||||
↓ ASN1 parse (auto-detect credentialPBE)
|
||||
| IV (8B or 16B) | ciphertext |
|
||||
|----------------------------------------------------------|
|
||||
↓ decrypt (3DES or AES-256 based on IV length)
|
||||
| plaintext + PKCS5 padding |
|
||||
|----------------------------------------------------------|
|
||||
↓ strip PKCS5 padding
|
||||
| plaintext (UTF-8 string) |
|
||||
|----------------------------------------------------------|
|
||||
```
|
||||
|
||||
The master key is passed through unchanged — `credentialPBE` uses the key directly without further derivation (unlike `privateKeyPBE` and `passwordCheckPBE` which derive from the global salt).
|
||||
|
||||
## Related RFCs
|
||||
|
||||
| RFC | Topic |
|
||||
| ------------------------------------------ | ---------------------------------------------------------------------------------- |
|
||||
| [RFC-018](018-firefox-data-storage.md) | Firefox data file locations and storage formats |
|
||||
| [RFC-015](015-key-retrieval-mechanisms.md) | Platform-specific master key retrieval (Chromium only — Firefox is self-contained) |
|
||||
@@ -1,279 +0,0 @@
|
||||
# RFC-020: Safari Data Storage
|
||||
|
||||
**Author**: moonD4rk\
|
||||
**Status**: Living Document\
|
||||
**Created**: 2026-04-21
|
||||
|
||||
## 1. Overview
|
||||
|
||||
Safari is **macOS-only** and sandboxed under App Sandbox. Most of Safari's user data lives inside `~/Library/Containers/com.apple.Safari/Data/Library/` (the container root) and requires **Full Disk Access (TCC)** for third-party processes to read. A few legacy files still reside at `~/Library/Safari/` for backwards compatibility.
|
||||
|
||||
Unlike Chromium and Firefox, Safari does **not** encrypt bookmarks, history, cookies, downloads, or localStorage — all are stored in plaintext on disk. Passwords are the only encrypted category and are delegated to the macOS login Keychain (see [RFC-015](015-key-retrieval-mechanisms.md) §7).
|
||||
|
||||
Safari 17 (September 2023) introduced **multi-profile support**. Profile discovery therefore has two layers: a synthetic "default" profile mapped to the pre-profile legacy paths, plus one or more named profiles enumerated from `SafariTabs.db`.
|
||||
|
||||
## 2. Profile Structure
|
||||
|
||||
A Safari profile is identified by five pieces of information (`internal/browser/safari/profiles.go`):
|
||||
|
||||
| Field | Meaning |
|
||||
| ------------ | ------------------------------------------------------------------------- |
|
||||
| `name` | Human-readable profile name, disambiguated for duplicates |
|
||||
| `uuidUpper` | UUID in uppercase (used by `Safari/Profiles/<UUID>/` directories) |
|
||||
| `uuidLower` | UUID in lowercase (used by `WebKit/WebsiteDataStore/<uuid>/` directories) |
|
||||
| `legacyHome` | `~/Library/Safari` |
|
||||
| `container` | `~/Library/Containers/com.apple.Safari/Data/Library` |
|
||||
|
||||
Empty `uuidUpper` marks the synthetic default profile.
|
||||
|
||||
### 2.1 Profile Discovery
|
||||
|
||||
The default profile is always emitted first. Named profiles come from `SafariTabs.db`:
|
||||
|
||||
```sql
|
||||
SELECT external_uuid, title FROM bookmarks
|
||||
WHERE subtype = 2 AND external_uuid != 'DefaultProfile'
|
||||
```
|
||||
|
||||
`DefaultProfile` is Safari's sentinel string for the pre-profile era; it is filtered out because it is already represented by the synthetic default.
|
||||
|
||||
If the DB cannot be opened (missing, permission-denied), Safari falls back to scanning `Safari/Profiles/` for any directory whose name is a canonical 8-4-4-4-12 UUID and synthesizing the name as `profile-<uuid[:8]>`. This makes profile discovery robust even when TCC blocks the SQL read.
|
||||
|
||||
Duplicate display names are disambiguated with `-2`, `-3`, … suffixes, deterministically by discovery order.
|
||||
|
||||
### 2.2 UUID Case Asymmetry
|
||||
|
||||
Safari uses two different casings for the same profile UUID across the container:
|
||||
|
||||
| Path prefix | Casing | Example |
|
||||
| --------------------------------- | :-------: | -------------------------------------- |
|
||||
| `Safari/Profiles/<UUID>/` | Uppercase | `5604E6F5-02ED-4E40-8249-63DE7BC986C8` |
|
||||
| `WebKit/WebsiteDataStore/<uuid>/` | Lowercase | `5604e6f5-02ed-4e40-8249-63de7bc986c8` |
|
||||
|
||||
Both casings are derived once at discovery, so no call site has to case-fold.
|
||||
|
||||
## 3. Data File Locations
|
||||
|
||||
### 3.1 Default Profile
|
||||
|
||||
| Category | Path | Format |
|
||||
| ------------ | ---------------------------------------------------------------------------------------------------- | ------------------ |
|
||||
| History | `~/Library/Safari/History.db` | SQLite |
|
||||
| Cookie | `Container/Cookies/Cookies.binarycookies`, then `~/Library/Cookies/Cookies.binarycookies` | BinaryCookies |
|
||||
| Bookmark | `~/Library/Safari/Bookmarks.plist` | plist |
|
||||
| Download | `~/Library/Safari/Downloads.plist` | plist |
|
||||
| Extension | `Container/Safari/AppExtensions/Extensions.plist`, `Container/Safari/WebExtensions/Extensions.plist` | plist |
|
||||
| LocalStorage | `Container/WebKit/WebsiteData/Default/` | WebKit Origins dir |
|
||||
| Password | macOS Keychain | — |
|
||||
|
||||
The Cookie path is resolved in priority order — the first candidate that exists wins. Modern (macOS 14+) installs keep cookies in the sandboxed container; the legacy path is kept as a fallback for upgraded systems.
|
||||
|
||||
### 3.2 Named Profiles
|
||||
|
||||
| Category | Path | Format |
|
||||
| ------------ | ------------------------------------------------------------------------ | ------------------ |
|
||||
| History | `Container/Safari/Profiles/<UUID>/History.db` | SQLite |
|
||||
| Cookie | `Container/WebKit/WebsiteDataStore/<uuid>/Cookies/Cookies.binarycookies` | BinaryCookies |
|
||||
| Download | `~/Library/Safari/Downloads.plist` (filtered by UUID) | plist |
|
||||
| LocalStorage | `Container/WebKit/WebsiteDataStore/<uuid>/Origins/` | WebKit Origins dir |
|
||||
|
||||
Bookmark is intentionally **omitted** from named profiles: `Bookmarks.plist` is a shared plist with no per-entry profile tag, so it is attributed to the default profile only. Duplicate bookmarks would otherwise be emitted per profile.
|
||||
|
||||
Downloads is shared across all profiles but each entry carries a `DownloadEntryProfileUUIDStringKey`; the extractor filters at read time so each profile sees only its own downloads.
|
||||
|
||||
Passwords live in the user-scope Keychain, not on a per-profile basis — only the default profile emits passwords to avoid duplicates across the output.
|
||||
|
||||
## 4. Data Storage Formats
|
||||
|
||||
### 4.1 History (History.db — SQLite)
|
||||
|
||||
```sql
|
||||
SELECT hi.url, COALESCE(hv.title, ''), hi.visit_count, COALESCE(hv.visit_time, 0)
|
||||
FROM history_items hi
|
||||
LEFT JOIN history_visits hv ON hv.id = (
|
||||
SELECT hv2.id FROM history_visits hv2
|
||||
WHERE hv2.history_item = hi.id
|
||||
ORDER BY hv2.visit_time DESC LIMIT 1
|
||||
)
|
||||
```
|
||||
|
||||
Schema notes:
|
||||
|
||||
- `visit_time` is a `REAL` column using the **Core Data epoch** (see Section 5)
|
||||
- One item → many visits; the extractor takes the most recent visit per item
|
||||
- Results are sorted by `visit_count` descending
|
||||
|
||||
### 4.2 Cookies (Cookies.binarycookies — binary)
|
||||
|
||||
Apple's proprietary BinaryCookies format — not SQLite, not a documented format. Parsed by the [binarycookies](https://github.com/moond4rk/binarycookies) library.
|
||||
|
||||
High-level layout:
|
||||
|
||||
```
|
||||
| "cook" magic | page_count | page_sizes[] | pages[] |
|
||||
|--------------|------------|------------------|--------------------------|
|
||||
| 4B | 4B (BE) | page_count × 4B | variable |
|
||||
```
|
||||
|
||||
Each page is an index-of-cookies table followed by per-cookie records. A cookie record carries flags (`isSecure`, `isHTTPOnly`), URL/name/path/value offsets into the record, and creation / expiry timestamps in Core Data epoch.
|
||||
|
||||
Cookie values are **plaintext** — no per-cookie encryption. This is a fundamental divergence from Chromium, which encrypts `encrypted_value` with the OS master key.
|
||||
|
||||
### 4.3 Bookmarks (Bookmarks.plist — property list)
|
||||
|
||||
A nested dictionary tree with a `WebBookmarkType` discriminator at each node:
|
||||
|
||||
| Type | Meaning | Additional keys |
|
||||
| --------------------- | --------- | ---------------------------------- |
|
||||
| `WebBookmarkTypeList` | Folder | `Children` (array) |
|
||||
| `WebBookmarkTypeLeaf` | URL entry | `URLString`, `URIDictionary.title` |
|
||||
|
||||
The extractor walks the tree recursively, collecting leaf nodes into a flat list. Folder names are preserved in the `Folder` field of each `BookmarkEntry`.
|
||||
|
||||
### 4.4 Downloads (Downloads.plist — property list)
|
||||
|
||||
A flat structure with a `DownloadHistory` array. Relevant keys per entry:
|
||||
|
||||
| Key | Meaning |
|
||||
| ----------------------------------- | ------------------------------------------------------ |
|
||||
| `DownloadEntryURL` | Source URL |
|
||||
| `DownloadEntryPath` | Local filesystem path |
|
||||
| `DownloadEntryProgressTotalToLoad` | Total bytes to download |
|
||||
| `DownloadEntryProfileUUIDStringKey` | Owning profile's uppercase UUID, or `"DefaultProfile"` |
|
||||
|
||||
The extractor filters by the caller-provided owner UUID so each profile reports its own downloads. MIME type and start/end times are not stored by Safari — `MimeType` is always empty in the output.
|
||||
|
||||
### 4.5 Passwords (macOS Keychain)
|
||||
|
||||
Safari does **not** persist passwords to a file in its container. All credentials live in `login.keychain-db`, accessible via `InternetPassword` records. The extractor reads them directly through [keychainbreaker](https://github.com/moond4rk/keychainbreaker) and reconstructs the URL from `(protocol, server, port, path)`.
|
||||
|
||||
Default port handling:
|
||||
|
||||
| Protocol | Default port | URL rendering |
|
||||
| -------- | -----------: | ---------------------------------- |
|
||||
| `https` | 443 | `https://host/path` (port omitted) |
|
||||
| `http` | 80 | `http://host/path` (port omitted) |
|
||||
| `ftp` | 21 | `ftp://host/path` (port omitted) |
|
||||
| Other | — | `scheme://host:port/path` |
|
||||
|
||||
The `htps` FourCC protocol code emitted by some Keychain entries is normalized to `https`.
|
||||
|
||||
Partial-extraction mode: if the Keychain cannot be unlocked (no `--keychain-pw` supplied, or the password is wrong), metadata-only records are still emitted — URL, username, timestamps — with `PlainPassword` left blank. See [RFC-015](015-key-retrieval-mechanisms.md) §7 for the full credential-extraction architecture.
|
||||
|
||||
### 4.6 LocalStorage (WebKit Origins — nested SQLite)
|
||||
|
||||
Safari 17+ stores localStorage under a **partition-aware nested tree**, rooted at:
|
||||
|
||||
| Profile | Root path |
|
||||
| ------- | --------------------------------------------------- |
|
||||
| Default | `Container/WebKit/WebsiteData/Default/` |
|
||||
| Named | `Container/WebKit/WebsiteDataStore/<uuid>/Origins/` |
|
||||
|
||||
Under the root, two levels of hashed directories lead to the actual data:
|
||||
|
||||
```
|
||||
<root>/<top-frame-hash>/<frame-hash>/
|
||||
├── origin ← binary-serialized origins (top + frame)
|
||||
└── LocalStorage/
|
||||
├── localstorage.sqlite3 ← ItemTable(key TEXT UNIQUE, value BLOB NOT NULL)
|
||||
├── localstorage.sqlite3-shm
|
||||
└── localstorage.sqlite3-wal
|
||||
```
|
||||
|
||||
`top-frame-hash == frame-hash` for **first-party** storage. They differ for **partitioned third-party** storage (an iframe with a different origin than the top document). The named profile root additionally carries a `salt` sibling file used by WebKit's origin-hashing — skipped at traversal time.
|
||||
|
||||
The flat `WebsiteDataStore/<uuid>/LocalStorage/<scheme>_<host>_<port>.localstorage` layout used by older WebKit is **empty on modern Safari** and is not supported.
|
||||
|
||||
#### Origin file format
|
||||
|
||||
Two `origin` blocks back-to-back — top-frame then frame. Each block:
|
||||
|
||||
```
|
||||
| scheme record | host record | port section |
|
||||
|--------------------------|--------------------------|-----------------|
|
||||
| uint32_le len | enc byte | uint32_le len | enc byte | 0x00 |
|
||||
| <len bytes> | <len bytes> | |
|
||||
or
|
||||
| 0x01 | uint16_le port |
|
||||
```
|
||||
|
||||
- `enc byte`: `0x01` = Latin-1/ASCII (common), `0x00` = UTF-16 LE
|
||||
- Port section: `0x00` marker means "use scheme default" (stored as port 0 in the parsed struct); `0x01` marker is followed by a 2-byte little-endian port
|
||||
|
||||
The extractor reads both blocks and reports the **frame origin URL** — that is what JavaScript's `window.localStorage` actually exposes in the partitioned case. If only the top-frame block is parseable, the extractor falls back to it.
|
||||
|
||||
#### ItemTable
|
||||
|
||||
```sql
|
||||
SELECT key, value FROM ItemTable
|
||||
```
|
||||
|
||||
Schema: `(key TEXT UNIQUE ON CONFLICT REPLACE, value BLOB NOT NULL ON CONFLICT FAIL)`.
|
||||
|
||||
Values are **UTF-16 LE** encoded JS strings. Oversized values (≥ 2048 bytes) are replaced with a size marker in the output — this matches the cap used by the Chromium extractor ([RFC-013](013-chromium-data-storage.md) §4.8) and keeps JSON/CSV exports bounded.
|
||||
|
||||
## 5. Time Formats
|
||||
|
||||
Safari uses the **Core Data epoch** — 2001-01-01 00:00:00 UTC, which is **978,307,200 seconds** after the Unix epoch. To convert a Core Data timestamp to Unix time, add `978307200` seconds.
|
||||
|
||||
| Data Type | Field | Storage |
|
||||
| ------------ | -------------------- | --------------------------------------- |
|
||||
| History | `visit_time` | REAL seconds, Core Data epoch |
|
||||
| Cookies | `creation`, `expiry` | REAL seconds, Core Data epoch |
|
||||
| Downloads | — | No timestamp stored |
|
||||
| Passwords | Keychain `Created` | Already Unix time (via keychainbreaker) |
|
||||
| LocalStorage | — | No timestamp stored |
|
||||
|
||||
Bookmarks carry no timestamp in Safari's plist representation.
|
||||
|
||||
## 6. Encryption
|
||||
|
||||
Safari's encryption story is deliberately thin:
|
||||
|
||||
| Category | Encryption |
|
||||
| ------------ | ------------------------------------------------------------------ |
|
||||
| History | None (plaintext SQLite) |
|
||||
| Cookies | None (plaintext binary format) |
|
||||
| Bookmarks | None (plaintext plist) |
|
||||
| Downloads | None (plaintext plist) |
|
||||
| LocalStorage | None (plaintext SQLite; UTF-16 LE is an encoding, not encryption) |
|
||||
| Passwords | macOS Keychain — see [RFC-015](015-key-retrieval-mechanisms.md) §7 |
|
||||
|
||||
The only encrypted category is passwords. Because they are not stored in Safari's own files at all, there is no Safari-specific cipher, key derivation, or master-key retrieval to document. See RFC-015 for the `InternetPassword` extraction path.
|
||||
|
||||
## 7. Platform Specifics
|
||||
|
||||
- **macOS-only**. There is no Safari on Windows or Linux.
|
||||
- **Full Disk Access (TCC)** is required to read the sandboxed container. Without it, cookies / history / downloads / localStorage reads fail silently with permission errors at stat or open time. Legacy paths under `~/Library/Safari/` sometimes remain readable without FDA, but are mostly empty on modern systems.
|
||||
- **Live-file safety** follows a live-vs-temp split:
|
||||
- **Discovery read**: `SafariTabs.db` is copied into a temporary snapshot and opened `?mode=ro&immutable=1` on the copy, which disables WAL replay and locking — a running Safari is never touched, at the cost of missing any pending WAL content.
|
||||
- **Snapshot reads** vary by file: `localstorage.sqlite3` uses `?mode=ro` so SQLite can replay the copied `-wal` sidecar; `History.db` opens with `PRAGMA journal_mode=off` (WAL replay not needed for read-only history queries). The snapshot copier copies the `-wal` / `-shm` sidecars alongside the main DB. Any `-shm` writes SQLite performs during replay land on the copy and are removed with the snapshot.
|
||||
- **Multi-profile availability**: requires Safari 17 (macOS 14 Sonoma) or newer. Older Safari versions have only the default profile; discovery degrades cleanly via the ReadDir fallback described in §2.1.
|
||||
- **File acquisition**: every file a profile reads, `SafariTabs.db` included, is copied into a temporary snapshot before it is read. See [RFC-007](007-snapshot-and-acquisition.md) for the general pattern.
|
||||
|
||||
## 8. Key Differences from Chromium and Firefox
|
||||
|
||||
| Aspect | Chromium | Firefox | Safari |
|
||||
| --------------------------- | -------------------------------- | ------------------------------------- | --------------------------------------- |
|
||||
| Platform | Cross-platform | Cross-platform | **macOS-only** |
|
||||
| Profile discovery | `Preferences` sentinel file | Any data file present | `SafariTabs.db` SQL + dir fallback |
|
||||
| Profile naming | `Default`, `Profile 1`, … | `<prefix>.default-release` | Human-readable title from SafariTabs.db |
|
||||
| Password storage | Encrypted SQLite (`Login Data`) | Encrypted JSON (`logins.json`) | **macOS Keychain** (no file) |
|
||||
| Cookie encryption | Encrypted with OS master key | Plaintext | **Plaintext** |
|
||||
| Cookie format | SQLite | SQLite | Proprietary BinaryCookies binary |
|
||||
| History | SQLite | SQLite (`places.sqlite`) | SQLite (Core Data epoch) |
|
||||
| Bookmark | JSON | SQLite (`places.sqlite`) | **plist** |
|
||||
| Download | SQLite (`History`, shared) | SQLite (`places.sqlite`, shared) | **plist** (filtered by UUID) |
|
||||
| LocalStorage | LevelDB | SQLite (`webappsstore.sqlite`) | Nested **WebKit Origins** SQLite |
|
||||
| LocalStorage partitioning | No | No | **Yes** (top-frame + frame hashes) |
|
||||
| CreditCard / SessionStorage | Supported | Not supported | Not supported |
|
||||
| Encryption scope | Passwords, cookies, credit cards | Passwords only | Passwords only |
|
||||
| Time format | WebKit microseconds since 1601 | Mixed (μs for most, ms for passwords) | Core Data seconds since 2001 |
|
||||
|
||||
## Related RFCs
|
||||
|
||||
| RFC | Topic |
|
||||
| ------------------------------------------- | ----------------------------------------------- |
|
||||
| [RFC-001](001-architecture-and-pipeline.md) | Architecture and pipeline |
|
||||
| [RFC-015](015-key-retrieval-mechanisms.md) | §7 covers Safari Keychain credential extraction |
|
||||
| [RFC-007](007-snapshot-and-acquisition.md) | Snapshot-first file acquisition |
|
||||
@@ -1,121 +0,0 @@
|
||||
# RFC-021: Windows Locked File Bypass
|
||||
|
||||
**Author**: moonD4rk\
|
||||
**Status**: Living Document\
|
||||
**Created**: 2026-04-05
|
||||
|
||||
## 1. Problem
|
||||
|
||||
Chromium on Windows sets `PRAGMA locking_mode=EXCLUSIVE` on certain SQLite databases, most notably the `Cookies` file (`Network/Cookies`). This means Chrome's process holds the file open with `dwShareMode=0` (no sharing), preventing any other process from opening it — even for reading.
|
||||
|
||||
```
|
||||
Chrome.exe
|
||||
→ CreateFileW("Network/Cookies", ..., dwShareMode=0) // exclusive lock
|
||||
→ PRAGMA locking_mode=EXCLUSIVE
|
||||
|
||||
hack-browser-data.exe
|
||||
→ os.ReadFile("Network/Cookies")
|
||||
→ ERROR: access denied
|
||||
```
|
||||
|
||||
This is a **Windows-specific problem**. On macOS and Linux, SQLite uses `fcntl`/`flock` advisory locks, which do not prevent other processes from reading the file. The standard copy path works fine on those platforms.
|
||||
|
||||
## 2. Solution Overview
|
||||
|
||||
Bypass the exclusive lock using Windows kernel APIs: enumerate system handles to find Chrome's file handle, duplicate it into our process, then read the file contents via memory-mapped I/O. **No admin privileges required.**
|
||||
|
||||
```
|
||||
NtQuerySystemInformation → find Chrome's handle to Cookies file
|
||||
→ DuplicateHandle into our process
|
||||
→ CreateFileMappingW + MapViewOfFile (read from kernel cache)
|
||||
→ write bytes to temp destination
|
||||
```
|
||||
|
||||
## 3. Step-by-Step
|
||||
|
||||
### 3.1 Enumerate System Handles
|
||||
|
||||
Call `NtQuerySystemInformation` with `SystemExtendedHandleInformation` (class 64) to get every open handle in the system. The "extended" variant uses `ULONG_PTR` for PIDs and handle values, avoiding truncation on 64-bit Windows.
|
||||
|
||||
The query starts with a 4 MB buffer and doubles it (up to 256 MB) if the API returns `STATUS_INFO_LENGTH_MISMATCH`.
|
||||
|
||||
Each entry in the result table:
|
||||
|
||||
| Field | Size | Description |
|
||||
| --------------- | --------- | ---------------------------------- |
|
||||
| Object | `uintptr` | Kernel object pointer |
|
||||
| UniqueProcessID | `uintptr` | Owning process PID |
|
||||
| HandleValue | `uintptr` | Handle value in the owning process |
|
||||
| GrantedAccess | `uint32` | Access mask |
|
||||
| ObjectTypeIndex | `uint16` | Kernel object type |
|
||||
|
||||
### 3.2 Find the Target Handle
|
||||
|
||||
For each handle entry:
|
||||
|
||||
1. `OpenProcess(PROCESS_DUP_HANDLE, pid)` — open the owning process
|
||||
2. `DuplicateHandle` — duplicate the handle into our process with `DUPLICATE_SAME_ACCESS`
|
||||
3. `GetFileType` — verify it is `FILE_TYPE_DISK` (skip pipes, sockets, etc.)
|
||||
4. `GetFinalPathNameByHandleW` — get the full file path
|
||||
|
||||
### 3.3 Path Matching with Short-Name Tolerance
|
||||
|
||||
Windows 8.3 short path names (e.g. `RUNNER~1` vs `runneradmin`) cause direct path comparison to fail. The solution extracts a **stable suffix** by stripping everything before `AppData\Local\` or `AppData\Roaming\` and comparing in lowercase:
|
||||
|
||||
```
|
||||
Input: C:\Users\RUNNER~1\AppData\Local\Google\Chrome\...\Network\Cookies
|
||||
Suffix: google\chrome\...\network\cookies
|
||||
|
||||
Input: C:\Users\runneradmin\AppData\Local\Google\Chrome\...\Network\Cookies
|
||||
Suffix: google\chrome\...\network\cookies
|
||||
|
||||
→ match!
|
||||
```
|
||||
|
||||
### 3.4 Read via Memory-Mapped I/O
|
||||
|
||||
Once we have a duplicated handle to the locked file:
|
||||
|
||||
```
|
||||
| DuplicateHandle(DUPLICATE_SAME_ACCESS) |
|
||||
|-------------------------------------------------|
|
||||
↓
|
||||
| CreateFileMappingW(handle, PAGE_READONLY) |
|
||||
|-------------------------------------------------|
|
||||
↓
|
||||
| MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0) |
|
||||
|-------------------------------------------------|
|
||||
↓
|
||||
| byte slice from kernel file cache |
|
||||
| (includes uncommitted WAL data from Chrome) |
|
||||
|-------------------------------------------------|
|
||||
↓
|
||||
| os.WriteFile(destination, bytes, 0600) |
|
||||
|-------------------------------------------------|
|
||||
```
|
||||
|
||||
Memory-mapped I/O reads from the OS kernel's **file cache**, which includes data Chrome has written but not yet checkpointed to disk. This produces a more complete snapshot than a raw `ReadFile`.
|
||||
|
||||
**Fallback**: if `CreateFileMappingW` fails for any reason, falls back to `Seek(0)` + `ReadFile` on the duplicated handle.
|
||||
|
||||
## 4. Why This Works
|
||||
|
||||
The key insight is that `dwShareMode=0` only prevents **new** `CreateFileW` calls from opening the file. It does **not** prevent:
|
||||
|
||||
- `DuplicateHandle` — which creates a copy of an existing handle (Chrome's own handle)
|
||||
- `CreateFileMappingW` — which operates on a handle we already own
|
||||
- `MapViewOfFile` — which reads from the kernel's page cache
|
||||
|
||||
This is a documented Windows behavior, not an exploit. The technique requires only standard user privileges because `PROCESS_DUP_HANDLE` access is available for processes owned by the same user.
|
||||
|
||||
## 5. Limitations
|
||||
|
||||
- **Performance**: enumerating all system handles is expensive (the system may have 100,000+ handles). The entire table must be scanned to find the target file.
|
||||
- **Race condition**: Chrome could close and reopen the file between enumeration and duplication, though this is unlikely for long-lived database files.
|
||||
- **Not needed on macOS/Linux**: advisory locking on these platforms does not prevent reading, so the standard `copyFile` path is always sufficient.
|
||||
|
||||
## Related RFCs
|
||||
|
||||
| RFC | Topic |
|
||||
| ------------------------------------------ | ------------------------------- |
|
||||
| [RFC-007](007-snapshot-and-acquisition.md) | Snapshot-first file acquisition |
|
||||
+17
-56
@@ -1,62 +1,23 @@
|
||||
# HackBrowserData RFCs
|
||||
|
||||
This directory is HackBrowserData's design record. The design RFCs (000–011) describe how the program is organized — a single explicit pipeline, a flat `internal/` package tree, outcome-per-extraction reporting, and names that read the way Go wants them to read — while the tool's external interface stays exactly as it is in v1.1.0. The format and technique RFCs (013–021) describe how each browser stores and protects its data, and how the tool reads it.
|
||||
These RFCs are HackBrowserData's design record: the decisions that shape the program, why they were made, and what was rejected. They are short on purpose. The code, its doc comments, and the git history carry everything else.
|
||||
|
||||
Every RFC states the current design. When a decision changes, the RFC is edited in place and git keeps the history; a superseded RFC is removed rather than kept beside its replacement.
|
||||
## How an RFC is written
|
||||
|
||||
The design RFCs describe _architecture_ — how the program is organized, how data moves through it, what the packages and types are called, and which dependencies are chosen and why. They deliberately do **not** restate decryption algorithms, key-extraction techniques, or platform specifics. Those live in the format and technique RFCs and are referenced by boundary, not reproduced.
|
||||
- It states a decision, the reason for it, and the alternatives rejected — in the words of the domain and the external contract.
|
||||
- It names no code: no types, functions, fields, files, or tests. It gives no step-by-step procedures, and it keeps no list that grows with the code, such as browsers, versions, or fixes.
|
||||
- The test for every sentence: would a refactor, a rename, a bug fix, or a new browser force an edit? If so, the sentence belongs in the code or its history, not here.
|
||||
- An RFC changes only when a decision changes, and the pull request that edits one says which decision changed. The code never cites an RFC.
|
||||
|
||||
## Why rewrite
|
||||
## Index
|
||||
|
||||
HackBrowserData is an MIT-licensed security-research tool with a large user base, presented at DEF CON. These RFCs serve three goals, in priority order:
|
||||
|
||||
1. **A clean architecture that reads as a reference implementation.** The code is read on stage and by every contributor; it should teach the design, not apologize for it.
|
||||
2. **A better operator experience without breaking anyone.** Fast failures, honest reporting, no surprises — and every existing command line, script, and output consumer keeps working unchanged.
|
||||
3. **Durable code quality.** One obvious way to add a browser, a data type, or an output format — verified by tests, not tribal knowledge.
|
||||
|
||||
## Hard constraints (non-negotiable)
|
||||
|
||||
- **Go 1.20.** Windows 7 support depends on it. No Go 1.21+ features (`log/slog`, `slices`, `maps`, `cmp`, generic stdlib helpers that landed later), and no dependency version whose `go` directive is above 1.20.
|
||||
- **Compatible external interface.** Commands, flags, defaults, output files and their field names, the `keys.json` and archive formats, and exit codes stay as they are in v1.1.0 — the compatibility contract in [RFC-000](000-goals-and-constraints.md). It stays on the existing module path; there is no v2.
|
||||
- **MIT license**, cross-platform (Windows, macOS, Linux), fully offline. The tool never phones home.
|
||||
- **No new offensive capability.** The redesign reorganizes and hardens existing, published functionality. It does not add targets, bypasses, or techniques.
|
||||
|
||||
## Design
|
||||
|
||||
| RFC | Title | What it settles |
|
||||
| --------------------------------------- | ----------------------- | -------------------------------------------------------------------------- |
|
||||
| [000](000-goals-and-constraints.md) | Goals & Constraints | Why we rewrite, the compatibility contract, guiding principles |
|
||||
| [001](001-architecture-and-pipeline.md) | Architecture & Pipeline | The seven stages, data flow, outcome model, exit status |
|
||||
| [002](002-package-layout.md) | Package Layout | The `internal/` tree, dependency direction, why `internal/` |
|
||||
| [003](003-core-types.md) | Core Types | Every central type and its shape |
|
||||
| [004](004-naming-decisions.md) | Naming Decisions | Settled names and the alternatives considered |
|
||||
| [005](005-browser-definitions.md) | Browser Definitions | The supported-browser table, per-fork overrides, how a fork is added |
|
||||
| [006](006-key-retrieval-and-crypto.md) | Key Retrieval & Crypto | `masterkey`, `crypto`, and `keychain` boundaries, key scopes, lazy secrets |
|
||||
| [007](007-snapshot-and-acquisition.md) | Snapshot & Acquisition | Snapshot-first capture, user-data-dir identity, archive layout |
|
||||
| [008](008-output-and-export.md) | Output & Export | Formats, frozen wire names, deterministic ordering |
|
||||
| [009](009-cli-surface.md) | CLI Surface | The unchanged command surface, validation order, keychain password input |
|
||||
| [010](010-dependencies.md) | Dependencies | Keep / drop / pin, with rationale |
|
||||
| [011](011-testing-and-quality.md) | Testing & Quality | Test strategy, compatibility tests, CI, lint |
|
||||
|
||||
## Formats and techniques
|
||||
|
||||
| RFC | Title | What it covers |
|
||||
| ---------------------------------------- | --------------------------------------- | ----------------------------------------------------------- |
|
||||
| [013](013-chromium-data-storage.md) | Chromium Data Storage | Where Chromium keeps each category, and the file formats |
|
||||
| [014](014-chromium-encryption.md) | Chromium Encryption | Cipher versions per platform |
|
||||
| [015](015-key-retrieval-mechanisms.md) | Key Retrieval Mechanisms | Where each OS keeps the master key, and the Safari keychain |
|
||||
| [016](016-chrome-abe-integration.md) | Chrome App-Bound Encryption Integration | The Windows `v20` key path and its payload |
|
||||
| [017](017-yandex-decryption.md) | Yandex Browser Decryption | Yandex's own layer on top of Chromium's |
|
||||
| [018](018-firefox-data-storage.md) | Firefox Data Storage | Where Firefox keeps each category, and the file formats |
|
||||
| [019](019-firefox-encryption.md) | Firefox Encryption | The NSS key and login encryption |
|
||||
| [020](020-safari-data-storage.md) | Safari Data Storage | Safari's files, profiles, and keychain passwords |
|
||||
| [021](021-windows-locked-file-bypass.md) | Windows Locked File Bypass | Reading files a running browser keeps locked |
|
||||
|
||||
## Status legend
|
||||
|
||||
Each design RFC marks decisions as one of:
|
||||
|
||||
- **DECIDED** — agreed; build to it.
|
||||
- **DEFERRED** — intentionally left out of this rewrite; listed so it is not mistaken for an omission.
|
||||
|
||||
Naming decisions and the alternatives behind them live in [004](004-naming-decisions.md).
|
||||
| RFC | Decides |
|
||||
| -------------------------- | --------------------------------------------------------------------- |
|
||||
| [000](000-goals.md) | The goals, the limits, and the external contract |
|
||||
| [001](001-architecture.md) | The one-way pipeline, outcomes, layering, and naming |
|
||||
| [002](002-browsers.md) | Browsers as data, bases, and forks as rows |
|
||||
| [003](003-secrets.md) | Key scopes, lazy retrieval, and where secret handling lives |
|
||||
| [004](004-snapshots.md) | Snapshot-first capture, and archive and restore as the same pipeline |
|
||||
| [005](005-output.md) | The frozen output, deterministic order, and safe writing |
|
||||
| [006](006-cli.md) | The frozen command surface, validation first, and password input |
|
||||
| [007](007-quality.md) | How tests, lint, Go 1.20, and dependency rules keep the design honest |
|
||||
Reference in new issue
Block a user