Repository navigation
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The PR appears safe to merge; no new blocking issue was established. SummaryAdds read-only firmware vector inspection through CLI and MCP.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[CLI or MCP request] --> B[Check caller inputs]
B --> C[Parse optional SVD within budgets]
C --> D[Stream file digest and retain bounded table bytes]
D --> E{Architecture}
E --> F[Decode ARM vectors]
E --> G[Decode RISC-V jump slots]
F --> H[Build counts, coverage and diagnostics]
G --> H
H --> I[Check file stability and close handle]
I --> J[Create digest-bound Evidence]
J --> K[Complete result]
J --> L[Retained summary]
L --> M[Paged analysis views]
Reviews (13) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile |
3ac2264 to
ebd570b
Compare
ebd570b to
ae48a8b
Compare
…t unbound SVD interrupts The architecture field now takes the ARM M-profile variant names REA uses for raw images (armv6-m through armv8.1-m.main) plus riscv. ARMv8-M Baseline gets ARMv6-M's exceptions; only Mainline names MemManage, BusFault, UsageFault, SecureFault and DebugMonitor. The old armv8-m value named Mainline faults on Cortex-M23 tables. vtor_aligned checks the 128-byte ARMv7-M/ARMv8-M minimum and is null on ARMv6-M, whose VTOR is optional and implementation-defined. Slots past the end of the 32-bit address space are no longer decoded with wrapped addresses, and an initial stack pointer that is not word-aligned is flagged. CMSIS-SVD interrupts without a name or with a non-integer value are reported as anomalies instead of skipped silently, and the expanded-name budget is charged once while parsing instead of twice with two formulas. likely_default_stub is removed: every shared-handler group set it to true. RISC-V limitations now cover vectored exceptions on slot 0, CLIC address tables and the mcause numbering assumed for SVD bindings.
|
Maintainer review of the vector-table decoder, checked against CMSIS-Core, the CMSIS-SVD schema and the RISC-V Privileged spec. Fixes are in commit 27728d8 on this branch. Please pull before rebasing so the commit isn't dropped. Defects fixed
Brittleness fixed
Left as is
TestsThere are six new regressions: Baseline versus Mainline naming, ARMv6-M VTOR unknown, the address-space end, a misaligned SP, unbound SVD interrupts, and the RISC-V limitations. These pass:
Sources
|
… RISC-V tables Duplicate interrupt declarations were found by rebuilding a key that repeats the full peripheral name for every <interrupt>, so a long name repeated across many declarations cost name length times declaration count. Bound names are now indexed per peripheral name, looked up once per <peripheral>. The 8-byte minimum held for every architecture, but only an ARM table must start with InitialSP and Reset; a RISC-V Direct-mode table can be one instruction. max_entries and max_file_bytes now admit one slot.
Head branch was pushed to by a user without write access
…ir owners Recovery assertions compare the delivered action with the shared refusal formatter applied to the reported limit, instead of pinning sentences. The summary-delivery test set REA_AGENT_RESULT_MAX_BYTES, which nothing reads, and used a result large enough to exceed the default budget too; it now sets REA_AGENT_RESULT_BUDGET_BYTES, asserts the reported budget, and uses a result between the minimum and default budgets, checking that the default delivers it complete. The view counts active ARM entries and recognized RISC-V slots with a loop instead of filtered copies.
The analysis view recounted active ARM entries and recognized RISC-V slots on every summary and page request. The producer already collects exactly those slots as handler targets, so the report now stores active_arm_entry_count and recognized_riscv_slot_count from them, and the view reads the stored fields. The service checks the stored counts against the slots once when it validates the provider's report.
Head branch was pushed to by a user without write access
# Conflicts: # src/domain/analysisView/analysisView.ts # src/domain/analysisView/analysisViewRequest.ts # src/domain/analysisView/analysisViewResult.ts # src/server/toolResult.ts
Summary
Advances #7955 and #3615 by adding
inspect_firmware_vector_table(rea inspect-firmware-vector-table), a read-only, session-free static interrupt and trap vector-table disassembly operation for ARM M-profile (armv6-m,armv7-m,armv8-m) and RISC-Vmtvecfirmware images, with optional CMSIS-SVD<interrupt>peripheral binding.Problem and expected behavior
Embedded and MCU firmware reverse engineering typically begins from hardware reset, exception, and external peripheral IRQ handlers rather than
main(). Previously, REA validated only the Reset vector when opening raw ARM M-profile images and had no standalone static decoder to inventory system exceptions, external IRQ handler addresses, Thumb bit-0 violations, shared dummy/default handler loops, or RISC-VmtvecDirect/Vectored jump stubs.With
inspect_firmware_vector_table:armv6-m,armv7-m,armv8-m): decodes 32-bit little-endian vector entries at caller-selectedbase_address+ 128-byte VTOR-alignedvector_table_offset, reporting Initial MSP (word 0), profile-specific architectural system exceptions1..15(Reset,NMI,HardFault,SVCall,PendSV,SysTick;MemManage,BusFault,UsageFault, andDebugMonitoronarmv7-m/armv8-m;SecureFaultonarmv8-m; slots 4, 5, 6, and 12 architecturally reserved onarmv6-m) withname_basis: "architecture_manual", Thumb bit-0 validation, non-zero reserved-slot diagnostics, externalIRQ 0..Nentries, andshared_handler_groupsfor default infinite-loop stubs.mtvec(riscv): decodes 4-byte aligned trap-vector slots (JAL,AUIPC+JALRwith bit-0 clearing, and compressedC.J), reporting slot 0's synchronous trap target intrap_entry_addresswhile keepingreset_code_address: null, distinguishingvectored_jumpsvssingle_entry_or_inlinetable shape, labeling architectural standard slots (1,3,5,7,9,11) withname_basis: "architecture_manual", and preserving unmapped local interrupt slots (>= 16) withname: null(name_basis: "observed_slot").<interrupt>binding (svd_xml): parses<peripheral><interrupt><name>/<value>declarations within caller-adjustablemax_svd_xml_nodesandmax_svd_expanded_charsbudgets (parseXmlDocumentWithinNodeLimit+Set-backed linear deduplication and pre-allocation expansion accounting) to label matching external IRQ numbers withname_basis: "explicit_profile", reporting duplicate IRQ declarations as explicit ambiguities rather than silently picking one.Change and scope
Follow the contribution scope.
Read-only static byte and optional caller-supplied SVD XML inspection (
not applicablefor target execution, injection, mutation, or protection recovery). Does not guessbase_addressor fabricate vendor IRQ names whensvd_xmlis omitted.Contract and boundary impact
src/domain/firmware/firmwareVectorTable.ts,src/domain/firmware/firmwareSvdInterrupts.ts,src/domain/firmware/firmwareRiscvTrapVector.ts, andsrc/domain/firmware/firmwareVectorTableParser.tsown vector-slot decoding, profile-specific architectural exception tables, RISC-V branch-stub decoding (readUint16At/readUint32Atfromsrc/domain/binaryContainer.ts), and bounded SVD<interrupt>extraction (parseXmlDocumentWithinNodeLimitfromsrc/domain/xmlDocument.ts).inspect_firmware_vector_table(rea inspect-firmware-vector-table <path> --architecture <arch> --base-address <hex> [--vector-table-offset N] [--max-entries N] [--svd-xml <xml>] [--max-svd-xml-nodes N] [--max-svd-expanded-chars N] [--max-file-bytes N]).FIRMWARE_VECTOR_TABLE_PROVIDERinsrc/firmware/vectorTable/FirmwareVectorTableProvider.ts).file-offset-rangetable span, omitting defaulted controls viacallerAnalysisParameters(rawInput)and preservingname_basis("architecture_manual" | "explicit_profile" | "observed_slot") andthumb_bit_setper entry.ArtifactResourceScope,withStableArtifactHandle, andreadAdmittedRangeso whole-file SHA-256 is streamed while retaining only the bounded vector-table slice;max_file_bytes,max_svd_xml_nodes, andmax_svd_expanded_charslimits report typeddetails.limit(control_kind: "parameter").docs/public/product-catalog.json), package, or installation impact: Authored guide added atdocs/guides/firmware/firmware-vector-tables.md, advertised schema summary updated atscripts/verify/advertised-schemas/tools/inspect_firmware_vector_table.json, and skill guidance updated in.agents/skills/reverse-engineer-anything/references/native-and-artifacts.md(synced to.cursor-plugin/). Ignored generated outputs remain uncommitted.Expected effects:
Evidence and regression coverage
src/domain/firmware/firmwareVectorTable.test.ts(executed): ARMv6-M reserved-slot enforcement (slots 4, 5, 6, 12), ARMv7-M and ARMv8-M (SecureFault) exception decoding, even-address Thumb bit-0 violation detection, shared default-handler grouping, CMSIS-SVD<interrupt>linearSetdeduplication and expansion bounds, and RISC-VmtvecJAL/C.J/ odd-immediateAUIPC+JALRtrap decoding withtrap_entry_addressandreset_code_address: null.src/application/binaryDiagnostics/FirmwareVectorTableService.test.ts(executed): digest-bound Evidence locations, omitted-default parameter preservation, late-cancellation Evidence retention, and typedcontrol_kind: "parameter"limit recovery.src/firmware/vectorTable/FirmwareVectorTableProvider.test.ts(executed):withStableArtifactHandlestreaming SHA-256 + bounded positional slice read,max_file_bytes/max_svd_xml_nodes/max_svd_expanded_charsbudget refusals,AbortSignalcancellation cause preservation, andread-coverageintegrity handling.tests/boundary/mcp/firmwareVectorTableMcpCli.test.ts(executed): end-to-end advertised MCP and public CLI parity, registered inproviderCapabilityCases.tsandproviderLifecycleCoverage.ts.mtvecmode bit (DIRECTvsVECTORED) is configured by runtimecsrw mtveccode rather than the table bytes themselves, so table-only inspection reports structural jump-slot evidence and notes that runtimemtvec.MODEremains unverified until code inspection.For evidence-bearing changes:
Validation performed
node scripts/run-typescript.mjs --noEmit && node scripts/run-typescript.mjs --noEmit -p tsconfig.scripts.json— passednpx oxlint -c .oxlintrc.json --quiet ... && npx oxfmt --check ... && node scripts/verify/architecture-guards.mjs && node scripts/verify-module-boundaries.mjs && node scripts/verify/fixed-ceilings.mjs && node scripts/verify/rea-numeric-limits.mjs— passednode scripts/run-typescript.mjs && node scripts/verify-advertised-schemas.mjs --package-root=. --update-summary— passednpx vitest run src/domain/firmware/firmwareVectorTable.test.ts src/application/binaryDiagnostics/FirmwareVectorTableService.test.ts src/firmware/vectorTable/FirmwareVectorTableProvider.test.ts tests/boundary/mcp/firmwareVectorTableMcpCli.test.ts tests/conformance/providerCapabilityConformance.test.ts tests/evaluation/providerLifecycleCoverage.test.ts tests/evaluation/fixedCeilingGuard.test.ts tests/evaluation/moduleReExportGuard.test.ts tests/boundary/cli/cliContractCommandParity.test.ts tests/boundary/mcp/enhancedTools.01-lists-the-complete-target-open.test.ts— passedCompatibility, safety, and release
.cursor-pluginskill mirror.withStableArtifactHandle), Saxes node-counted XML parsing disallowing DOCTYPE (parseXmlDocumentWithinNodeLimit), pre-allocation SVD expansion bounds, andArtifactResourceScopehandle cleanup.Author readiness
Human owner: @liziye627-design