Skip to content

feat(artifacts): decode Android Verified Boot vbmeta images offline - #13239

Merged
morluto merged 22 commits into
morluto:mainfrom
mvanhorn:fix/android-vbmeta-descriptors
Nov 26, 2026
Merged

morluto merged 22 commits into
morluto:mainfrom
mvanhorn:fix/android-vbmeta-descriptors

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

REA can inspect boot images that carry an AVB footer, but a standalone vbmeta.img (the image fastboot flashes to the vbmeta partition) is not recognized as a format. An analyst who pulls one from a factory image gets an unknown blob and has to run avbtool info_image outside REA, losing Evidence provenance.

This adds an offline android-vbmeta artifact format. inspect-artifact and extract-artifact (and the MCP inspect_artifact / extract_artifact tools) now decode the vbmeta header and its descriptors and expose the authentication block, public key, public key metadata, and each successfully decoded descriptor as stored children. No issue exists for this; it is a format-inspection addition within the supported contribution scope.

Problem and expected behavior

Use case: given vbmeta.img, answer "which partitions does this chain to, which hash and hashtree descriptors does it carry, what rollback index and flags are set, and which key signed it" without leaving REA.

Observable outcome:

  • A file that starts with AVB0 and has a well-formed header is recognized as android-vbmeta regardless of filename.
  • The full inventory lists every descriptor (PROPERTY, HASHTREE, HASH, KERNEL_CMDLINE, CHAIN_PARTITION) with its file offset; descriptors with unknown tags are kept with their tag, size, and offset.
  • The summary view reports header fields and per-type descriptor counts.
  • Extraction returns the authentication block, public key, public key metadata, and successful descriptors (including unknown tags) as byte-exact children. Valid descriptors remain available when a later descriptor is malformed.
  • Signatures, hashes, and hashtree digests are recorded and never verified; signatures_verified is always false.

Change and scope

  • Descriptor-byte extraction consolidates the useful child behavior from feat(artifacts): inspect standalone AVB0 vbmeta headers and descriptors #14465; thanks @iamcipherdev. It reuses this parser and retains partial facts, adjustable limits, and existing key children.

  • Refusal fixtures, CLI/MCP assertions, and the guide now match the owning contracts: malformed/truncated targets use unsupported_target with details.failure_kind; adjustable-limit refusals use partial.

  • src/domain/firmware/androidVbmeta.ts owns parsing. It validates the header (magic, block sizes and alignment, offset/size ranges inside the authentication and auxiliary blocks, the release string's final NUL at header byte 175, supported major version) and walks the descriptor table with per-type layouts. Malformed descriptors stop the walk with a tagged failure that records both descriptor_offset and the offending field's offset, while descriptors decoded before it are kept.

  • src/artifacts/AndroidVbmetaArtifactReader.ts consumes the parser's facts. Coverage is complete only when every descriptor decoded and the major version is supported; otherwise it is unknown, with the tentative facts still reported. Returned metadata is an independent snapshot of the reader's cached facts.

  • src/domain/analysisView/androidVbmetaSummary.ts adds the summary projection; format registration lives in artifactFormats.ts, artifactFormatRecognition.ts, and targetFormats.ts.

  • Docs: new docs/guides/firmware/android-vbmeta.md, plus CLI, firmware-analysis, and skill reference updates.

Not included: signature or digest verification, AVB footers on partition images other than boot images, and any device or runtime interaction.

Contract and boundary impact

  • Semantic owner and earliest changed stage: androidVbmeta.ts produces parsed facts; the reader, summary view, and inventory graph consume them without reparsing raw bytes.
  • Contribution scope fit and linked maintainer decision: format inspection and ordinary extraction of a local file; not applicable (no target execution, injection, mutation, or protection recovery).
  • CLI and MCP/tool-catalog contract: no new tools. Existing inspect_artifact / extract_artifact recognize one more format value, android-vbmeta, and accept one new optional artifact_limits.android_vbmeta group (authentication_block_bytes, auxiliary_block_bytes, descriptor_bytes, descriptor_count). Defaults match the previous fixed budgets; a refusal reports required_value and the parameter to raise.
  • Provider, bridge, target-format, or platform compatibility: new target format android-vbmeta; existing formats unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: new android-vbmeta and android-vbmeta-summary metadata shapes; children carry stored ranges and SHA-256.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none committed; authored skill references updated under .agents/skills/reverse-engineer-anything/.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/domain/firmware/androidVbmeta.test.ts (header and descriptor decoding, every refusal with its field offset, malformed-descriptor prefix retention, chain rollback index location 0, release string final byte, unsupported major version), src/artifacts/AndroidVbmetaArtifactReader.test.ts (coverage, children, independent metadata snapshots), androidVbmetaSummary.test.ts, tests/acceptance/androidVbmetaCli.test.ts, tests/boundary/mcp/androidVbmetaMcp.test.ts, plus format recognition and inventory graph tests. Fixtures are generated in androidVbmeta.fixture.ts.
  • Base reproduction or other evidence: executed. On the base revision the same file is not recognized as android-vbmeta; the boundary tests fail there.
  • User-visible CLI/MCP output (executed, rea inspect-artifact vbmeta.img --detail summary --evidence_output vbmeta.evidence.json --json, excerpt of root_format_metadata):
{
  "kind": "android-vbmeta-summary",
  "magic": "AVB0",
  "required_libavb_version_major": 1,
  "algorithm_name": "SHA256_RSA2048",
  "rollback_index": "42",
  "flag_names": ["HASHTREE_DISABLED", "VERIFICATION_DISABLED"],
  "release_string": "avbtool 1.2.0",
  "signatures_verified": false,
  "descriptor_failure": null,
  "descriptor_count": 6,
  "property_count": 1,
  "hashtree_count": 1,
  "hash_count": 1,
  "kernel_cmdline_count": 1,
  "chain_partition_count": 1,
  "unknown_count": 1
}

with limitations including "Signatures, hashes, and hashtree digests are recorded and not verified." and "1 descriptor with an unknown AVB tag (7) is retained with its tag, size, and file offset."

  • Remaining proof gaps: tested against generated fixtures that follow the libavb layout, not a corpus of vendor images.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Demo

Rendered walkthrough of the CLI inspect and extract output above (simulated terminal, values taken from a real run on the generated fixture).

demo

Maintainer validation

  • Full consolidated candidate independently reviewed through P2: no remaining findings.
  • Pinned formatter, Node syntax, and diff checks passed.
  • New coverage exercises exact descriptor bytes, valid prefixes before malformed descriptors, unknown tags, existing key children, limits, and mutation/cancellation.
  • Merge conflicts resolved against pinned main 1f262f5d1356c3ce94fb0e9c99302fdb60d3349c; the two advertised input summaries now match the CI generator.
  • Dependency-backed local tests were not run because no qualified task dependency installation was available; schema summaries were refreshed from the CI generator output. Required CI passed on a27e01086a5efd7d4ee74025f7478d8dd59ea557: all 12 test shards and all required checks, with 31 successful jobs and 19 intentional skips.

Author-reported validation before consolidation

  • npx --no-install vitest run over the eight changed test files (vocabularies, reader, inventory graph, summary view, format recognition, domain parser, CLI acceptance, MCP boundary): passed
  • Focused vitest (androidVbmeta.test.ts, AndroidVbmetaArtifactReader.test.ts): 21 passed
  • androidVbmetaCli.test.ts: 8 passed
  • androidVbmetaMcp.test.ts and tests/acceptance/tools/localToolContracts.test.ts: 2 and 11 passed
  • npm run verify:test-discovery: all 3841 test and spec files discovered exactly once
  • npm run format:check: all matched files use the correct format

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable; offline parsing only, run on macOS.
  • Package or release metadata impact: none beyond the new format value.
  • Security, privacy, process, or containment review: reads a local file only. Release strings, property values, kernel command lines, and partition names are labeled target-derived and untrusted. Descriptor count and sizes are bounded before allocation by per-call limits.

AI was used for assistance.

Author readiness

Human owner: @mvanhorn

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-26T18:58:31.979113Z
We couldn’t complete this review. Comment @codex review to try again.
689994a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The reviewed changes appear safe to merge; no actionable issue remains.RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The reviewed changes appear safe to merge; no actionable issue remains.

Summary

Adds offline recognition, inspection, and extraction for standalone Android Verified Boot images.

  • Standalone Android vbmeta images now reveal their Verified Boot facts and stored bytes.
  • The vbmeta summary shows header facts and descriptor counts by type.
  • Callers can adjust four per-call limits for vbmeta images.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Local AVB0 image] --> B[Check header and limits]
  B --> C[Decode descriptors]
  C --> D[Header facts and decoded prefix]
  D --> E[Inventory and stored children]
  D --> F[Summary counts]
  E --> G[Byte-exact extraction]
Loading

Reviews (17) · Last reviewed commit: "chore: merge main into fix/android-vbmet..." · Reviewed by Greptile

Comment thread src/domain/firmware/androidVbmeta.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a79afb600

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/domain/firmware/androidVbmeta.ts Resolved
Comment thread src/domain/artifactReaderLimits.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 888cef32b5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/domain/firmware/androidVbmeta.ts Resolved
With raised descriptor_bytes and auxiliary_block_bytes limits, a valid
KERNEL_CMDLINE longer than half the host string bound passed the byte
limits, and toString("hex") then threw ERR_STRING_TOO_LONG, which
surfaced as an I/O error. Check the field against the host bound before
hex encoding and report a typed capacity failure with its own limit.
A header whose declared blocks do not fit the file, or whose descriptor
range does not fit its auxiliary block, now reports truncation or a
malformed range instead of a limit a larger budget cannot repair. The
over-budget fixtures are now fully present so they still prove the limit.
@morluto morluto added area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request labels Nov 22, 2026
@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@mvanhorn thanks for the PR — there is 1 open review thread here:

Could you address or reply to this? Once it's resolved and CI is green we can take another look.
cc @gensokyo-dev @dandgabr

@mvanhorn

Copy link
Copy Markdown
Contributor Author

This is handled on the current head (a5cb624), which is why the thread shows as outdated: the vbmeta auxiliary, descriptor-table and descriptor-count budgets are now per-call reader limits instead of fixed limits, so an image like the 4,097-descriptor example can be admitted by raising them. The branch conflicts with main now, so that is the next thing to clear.

@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@mvanhorn also, this branch has merge conflicts with main — please resolve those along with the open threads.

# Conflicts:
#	src/artifacts/artifactFormats.ts
#	src/artifacts/inventory/ArtifactGraphConstruction.test.ts
#	src/domain/artifactFormatMetadata.ts
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@mvanhorn

Copy link
Copy Markdown
Contributor Author

Conflicts with main are resolved in 1f487a8, a merge commit that moves the vbmeta metadata schema into main's new formatMetadata/androidAndSystemMetadata.ts owner and keeps the per-call vbmeta budgets alongside main's reader limits.

…aders

The summary counts every descriptor tag in a single loop instead of six
filtered arrays, and androidVbmeta reuses one BinaryReader per buffer.
The malformed-header refusal fixtures follow main's unsupported_target
classification for malformed target bytes.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Resolve the inspect_artifact advertised schema summary conflict.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread docs/guides/firmware/android-vbmeta.md Resolved
Malformed vbmeta headers classify as unsupported_target, not
invalid_request, matching analysisErrorClassification and the refusal
fixtures.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@wmccormick979

wmccormick979 commented Nov 25, 2026 via email

Copy link
Copy Markdown

@mvanhorn

Copy link
Copy Markdown
Contributor Author

This is a pull request that adds Android vbmeta parsing to rea, and the email was a notification from its review thread. You can stop these from the Unsubscribe link in the email or the Notifications button on the PR page.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@mvanhorn

Copy link
Copy Markdown
Contributor Author

Merged current main into this branch. Three follow-up commits: - 3716ef8 regenerates the advertised schema hashes for extract_artifact and inspect_artifact after the merge. - 4fc3ade is the merge itself. CI on 295006a is still running. npm ci && npm run verify:advertised-schemas passed. npm run check:fast passed. node scripts/run-vitest.mjs src/domain/firmware/androidVbmeta.test.ts src/artifacts/AndroidVbmetaArtifactReader.test.ts src/domain/analysisView/androidVbmetaSummary.test.ts src/domain/artifactReaderLimits.test.ts src/domain/artifactFormatRecognition.test.ts src/application/binary/TargetFormatVocabularies.test.ts passed.

@vincentkoc

Copy link
Copy Markdown
Collaborator

this overlaps #14465; the shared parser should preserve your partial facts and its raw descriptor-byte children. keeping both open while those pieces are consolidated; the limit-result test and Author readiness still need attention.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Comment thread docs/guides/firmware/android-vbmeta.md Resolved
@vincentkoc

Copy link
Copy Markdown
Collaborator

I’m working through the remaining refusal-contract fixes and adding the descriptor-byte children from #14465 to this parser. I’ll leave Author readiness for you to complete after reviewing the final change.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@vincentkoc

Copy link
Copy Markdown
Collaborator

Thanks! The maintainer pass is complete: descriptor children are consolidated, review is clean, and CI passed on a27e010. @mvanhorn, please complete Author readiness when you’ve reviewed the final change; that is the remaining step before landing.

@morluto
morluto enabled auto-merge (squash) November 26, 2026 18:09
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@morluto
morluto merged commit 3e8f6a4 into morluto:main Nov 26, 2026
54 checks passed
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Appreciate you landing all four of these today, @morluto: standalone vbmeta images here, plus Nintendo DS ROMs in #14664, Switch NSO and NRO executables in #14655, and OCI image layouts in #12470. Nice to have those formats inventoried offline inside REA now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants