[GH-ISSUE #1431] [Feature] HarmonyOS/OpenHarmony package and Ark bytecode analysis (ArkDecompiler evaluation) #487

Open
opened 2026-10-15 18:25:30 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @N0zoM1z0 on GitHub (Oct 10, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/1431

Area

Managed runtime, bytecode and packaged-application analysis

Current limitation and goal

Investigate a reusable static reverse-engineering workflow for HarmonyOS NEXT / OpenHarmony application artifacts, prompted by JD ArkDecompiler. Analysts should be able to identify a package, inspect its modules and entry points, examine selected Ark bytecode/functions, and follow evidenced native-library boundaries through equivalent CLI/MCP workflows.

This is a deferred research roadmap, requested by the maintainer to retain the opportunity. Current implementation priorities remain bug fixes, stability and output usability. This issue does not start feature implementation or a release. Parent: #42. Future runtime work can coordinate with #1267 and #968.

Research date: 2026-10-10; REA baseline f4a0c1ce95375c1661ca95b414829113a10298b8. Open/closed issue and PR searches for Harmony, ArkTS, ArkDecompiler, HAP and Panda found no focused proposal. REA's existing Android/JADX adapter is relevant reuse experience; its APK/DEX support does not establish Ark bytecode support.

Ecosystem and artifact scope

The official package overview and Stage build/release structure establish several distinct targets:

Artifact Analyst questions / scope
.hap Installable application module: bundle/module identity, abilities and entry points, declared permissions, embedded bytecode, resources and native libraries.
.hsp Runtime shared package: module dependencies and exported/imported relationships; distinguish in-app products from integrated build inputs.
.app Distribution App Pack containing HAP/HSP modules and pack.info; preserve each child package's identity and provenance.
.har / OHPM metadata Build-time reusable library with code, native libraries and resources; distinguish source/build products actually present. HAR is not an independently installed runtime module; do not invent original HAR ownership from a flattened final HAP.
.abc / textual .pa Ark/Panda bytecode and disassembly: records/classes, functions, strings/literals, imports/exports, instructions and available debug/source locations.
Resources and native products resources.index, resource/profile files and .so libraries: connect observed resource references and native imports/exports to their owning module. AOT/profile artifacts require separate identification and coverage.

Do not treat all Harmony products or SDK generations as equivalent. Start with a recorded Stage-model/compiler/bytecode combination. Older FA packages use a different layout and config.json; Stage build inputs use JSON5 while installed products use module.json. Identify contents rather than assuming .hap always means .abc or treating a package extension as an Android target.

The official bytecode format documentation is explicitly based on 12.0.6.0 and describes PANDA magic, an internal four-part bytecode version, offsets/indexes and MUTF-8 strings. That version is distinct from application version, SDK/API level and tool version. Runtime Core also has separate dynamic and static-core specifications. Verify dialect compatibility; filename/magic alone cannot establish decompiler coverage.

Upstream candidates and limits

Candidate Source-backed role and integration consideration
JD ArkDecompiler Apache-2.0 C++ decompiler rebuilding ArkTS via IR/AST. README and v0.1.0 release explicitly say decompilation is Linux-only, while disassembly is cross-platform. Cross-platform GUI downloads do not establish cross-platform decompilation.
Official ark_disasm SDK CLI converting .abc to assembly; reports format/minimum-supported versions and can include byte positions. Strong first disassembly baseline. Options that skip literals must not silently remove evidence.
Official AbcKit Inspection/modification library with enumeration and static/dynamic graph APIs. Evaluate read-only structured metadata/graph access before writing another bytecode parser; build and ABI/version prerequisites still need a real compatibility experiment.
ABCDE Apache-2.0 Kotlin/JVM package, bytecode and resource-index parser, with library/examples. Its experimental decompiler documents unsupported try/catch and some async bytecode. Useful alternative for inventory/resources rather than assumed full decompilation.
abc-decompiler Apache-2.0 project based on modified JADX and ABCDE, still under development; some instructions become pseudo-functions. Evaluate separately from ordinary JADX and verify component licenses and headless interfaces.
dayu Python parser/CLI with selected-method IR/pseudocode and CFG output; decompilation requires matching .abc and ark_disasm output. Upstream calls it rudimentary and does not guarantee correctness. Declares AGPL-3.0; distribution/use choice needs explicit license review.
Official packaging/signing tools Packing/unpacking tooling documents HAP/HSP/HAR/App Pack and other product modes. HAP signer supplies signature/profile verification. Expose inspected signing facts and verification results separately from trust/distribution-policy conclusions.

JD's CLI entry point accepts an input and output filename (xabc input.abc output.ts) and selects dynamic bytecode. Its current main ignores the decompilation return value and returns zero: exit status alone is not success proof. Its preparation script selects OpenHarmony 6.0.0.1 sources; upstream also requires local compiler/dependency patches, while its Docker recipe selects 5.1.0. Pin one working combination; do not run these scripts as REA setup or assume current master components build together.

ArkAnalyzer is adjacent static-analysis prior art and points to its maintained OpenHarmony-SIG repository. It is not proof of binary-decompiler compatibility. Cangjie–ArkTS interoperability introduces another language/native boundary; record such artifacts explicitly and defer language-specific recovery until independently justified.

Suggested increments and acceptance

  1. Package identification and inventory: HAP/HSP/App Pack/HAR, source versus installed manifests, bytecode versions, resources, libraries and module dependencies. Reuse existing archive/native/Evidence infrastructure, keep format/provider code outside domain/application layers, and report unsupported facets explicitly.
  2. Selected bytecode inspection: real ark_disasm and/or a proven structured reader; inspect one selected record/function and references, retaining raw identifiers, bytes/offsets, literal values and unresolved targets. Map native loading/registration only where supported by evidence; static references are not observed runtime calls.
  3. Optional JD decompilation adapter: bring-your-own Linux xabc plus its compatible libraries. Retain original artifact identity and raw disassembly, record exact provider/compiler versions, validate actual produced output, preserve partial failures, and classify generated ArkTS as derived evidence. Missing source names/types/locations remain unknown.
  4. Independent follow-ups: deeper resource resolution, package/function comparison, native/N-API or other interop tracing, additional dialects/hosts, signature verification, FA/AOT/patch products and Cangjie. Device debugging/instrumentation belongs to a separate runtime increment.

Acceptance must use source-generated public fixtures compiled/packaged by the actual pinned toolchain, then exercise the compiled CLI, actual SDK-connected stdio MCP and an installed REA package with real providers. Include multi-module/shared-library packages, imports/exports, literals, closures/async/exception flow, stripped/obfuscated information, resource references and a known native bridge. Compare observations against producer outputs; never require reconstructed source to equal original source.

Also test malformed/checksum/version/offset failures, Unicode/MUTF-8 strings and names, duplicate archive entries/path escape/decompression pressure, incomplete modules, missing/mismatched tooling, provider crashes/zero-status failures, cancellation and large producer output. Bound process/output retention by documented resource constraints, preserve collected evidence, and declare examined scope/completeness. Selected results should avoid copying entire bytecode, AST and source into every label or response; coordinate retained Evidence/views with #1065 instead of duplicating its shared transport work. Serialized size is not a model-token or billing measurement.

REA remains local-only and the first increment is static/read-only. Do not execute target applications, re-sign/repack them, drive a GUI, install device services, upgrade Java/Node/SDKs, or modify global toolchain settings as part of discovery. Reuse upstream code where appropriate, pin provenance and review actual redistributed component licenses.

Research status: documentation, repository metadata, CLI source and alternative tool boundaries reviewed using gh. No SDK/compiler/decompiler was installed or executed for this issue. API availability and upstream claims do not establish REA support; record verified host/dialect/version combinations separately when implementation begins.

Originally created by @N0zoM1z0 on GitHub (Oct 10, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/1431 ### Area Managed runtime, bytecode and packaged-application analysis ### Current limitation and goal Investigate a reusable static reverse-engineering workflow for **HarmonyOS NEXT / OpenHarmony application artifacts**, prompted by [JD ArkDecompiler](https://github.com/jd-opensource/arkdecompiler). Analysts should be able to identify a package, inspect its modules and entry points, examine selected Ark bytecode/functions, and follow evidenced native-library boundaries through equivalent CLI/MCP workflows. This is a **deferred research roadmap**, requested by the maintainer to retain the opportunity. Current implementation priorities remain bug fixes, stability and output usability. This issue does not start feature implementation or a release. Parent: #42. Future runtime work can coordinate with #1267 and #968. Research date: 2026-10-10; REA baseline `f4a0c1ce95375c1661ca95b414829113a10298b8`. Open/closed issue and PR searches for Harmony, ArkTS, ArkDecompiler, HAP and Panda found no focused proposal. REA's existing [Android/JADX adapter](https://github.com/morluto/rea/blob/f4a0c1ce95375c1661ca95b414829113a10298b8/docs/android-analysis.md) is relevant reuse experience; its APK/DEX support does not establish Ark bytecode support. ### Ecosystem and artifact scope The official [package overview](https://github.com/openharmony/docs/blob/f41b9345badd47c7ab0c263344cd7f4b5a549afb/en/application-dev/quick-start/application-package-overview.md) and [Stage build/release structure](https://github.com/openharmony/docs/blob/f41b9345badd47c7ab0c263344cd7f4b5a549afb/en/application-dev/quick-start/application-package-structure-stage.md) establish several distinct targets: | Artifact | Analyst questions / scope | | --- | --- | | `.hap` | Installable application module: bundle/module identity, abilities and entry points, declared permissions, embedded bytecode, resources and native libraries. | | `.hsp` | Runtime shared package: module dependencies and exported/imported relationships; distinguish in-app products from integrated build inputs. | | `.app` | Distribution App Pack containing HAP/HSP modules and `pack.info`; preserve each child package's identity and provenance. | | `.har` / OHPM metadata | Build-time reusable library with code, native libraries and resources; distinguish source/build products actually present. HAR is not an independently installed runtime module; do not invent original HAR ownership from a flattened final HAP. | | `.abc` / textual `.pa` | Ark/Panda bytecode and disassembly: records/classes, functions, strings/literals, imports/exports, instructions and available debug/source locations. | | Resources and native products | `resources.index`, resource/profile files and `.so` libraries: connect observed resource references and native imports/exports to their owning module. AOT/profile artifacts require separate identification and coverage. | Do not treat all Harmony products or SDK generations as equivalent. Start with a recorded Stage-model/compiler/bytecode combination. [Older FA packages](https://github.com/openharmony/docs/blob/f41b9345badd47c7ab0c263344cd7f4b5a549afb/en/application-dev/quick-start/application-package-structure-fa.md) use a different layout and `config.json`; Stage build inputs use JSON5 while installed products use `module.json`. Identify contents rather than assuming `.hap` always means `.abc` or treating a package extension as an Android target. The official [bytecode format documentation](https://github.com/openharmony/docs/blob/f41b9345badd47c7ab0c263344cd7f4b5a549afb/en/application-dev/arkts-utils/arkts-bytecode-file-format.md) is explicitly based on **12.0.6.0** and describes PANDA magic, an internal four-part bytecode version, offsets/indexes and MUTF-8 strings. That version is distinct from application version, SDK/API level and tool version. Runtime Core also has separate [dynamic](https://github.com/openharmony/arkcompiler_runtime_core/blob/6b3a0de5e971b667a1e46e17283595df67a99f0b/docs/file_format.md) and [static-core](https://github.com/openharmony/arkcompiler_runtime_core/blob/6b3a0de5e971b667a1e46e17283595df67a99f0b/static_core/docs/file_format.md) specifications. Verify dialect compatibility; filename/magic alone cannot establish decompiler coverage. ### Upstream candidates and limits | Candidate | Source-backed role and integration consideration | | --- | --- | | [JD ArkDecompiler](https://github.com/jd-opensource/arkdecompiler/blob/8afb36903127b56edee362ce67aacd823610d3e4/README.md) | Apache-2.0 C++ decompiler rebuilding ArkTS via IR/AST. README and [v0.1.0 release](https://github.com/jd-opensource/arkdecompiler/releases/tag/v0.1.0) explicitly say **decompilation is Linux-only**, while disassembly is cross-platform. Cross-platform GUI downloads do not establish cross-platform decompilation. | | [Official `ark_disasm`](https://github.com/openharmony/docs/blob/f41b9345badd47c7ab0c263344cd7f4b5a549afb/en/application-dev/arkts-utils/tool-disassembler.md) | SDK CLI converting `.abc` to assembly; reports format/minimum-supported versions and can include byte positions. Strong first disassembly baseline. Options that skip literals must not silently remove evidence. | | [Official AbcKit](https://github.com/openharmony/arkcompiler_runtime_core/blob/6b3a0de5e971b667a1e46e17283595df67a99f0b/libabckit/README.md) | Inspection/modification library with [enumeration and static/dynamic graph APIs](https://github.com/openharmony/arkcompiler_runtime_core/blob/6b3a0de5e971b667a1e46e17283595df67a99f0b/libabckit/doc/mini_cookbook.md). Evaluate read-only structured metadata/graph access before writing another bytecode parser; build and ABI/version prerequisites still need a real compatibility experiment. | | [ABCDE](https://github.com/Yricky/abcde/blob/62f7fc6a0d455d478db1bf3bcb61f2b79d5a473a/README.md) | Apache-2.0 Kotlin/JVM package, bytecode and resource-index parser, with library/examples. Its experimental decompiler documents unsupported try/catch and some async bytecode. Useful alternative for inventory/resources rather than assumed full decompilation. | | [abc-decompiler](https://github.com/ohos-decompiler/abc-decompiler/blob/427c4cd9f80496236a4a3548d29a6b8aaf74b8e0/README.md) | Apache-2.0 project based on modified JADX and ABCDE, still under development; some instructions become pseudo-functions. Evaluate separately from ordinary JADX and verify component licenses and headless interfaces. | | [dayu](https://github.com/hx1997/dayu/blob/da592965e03ff05d7dd3c7d39699471aedd89436/README.md) | Python parser/CLI with selected-method IR/pseudocode and CFG output; decompilation requires matching `.abc` and `ark_disasm` output. Upstream calls it rudimentary and does not guarantee correctness. Declares AGPL-3.0; distribution/use choice needs explicit license review. | | Official packaging/signing tools | [Packing/unpacking tooling](https://github.com/openharmony/developtools_packing_tool/blob/b2aa3f6abcdb0f2d3a63f5220019465e412fe22a/README_zh.md) documents HAP/HSP/HAR/App Pack and other product modes. [HAP signer](https://github.com/openharmony/developtools_hapsigner/blob/24ef0c843d94f68d16975cac42e377f31def48c6/README.md) supplies signature/profile verification. Expose inspected signing facts and verification results separately from trust/distribution-policy conclusions. | JD's [CLI entry point](https://github.com/jd-opensource/arkdecompiler/blob/8afb36903127b56edee362ce67aacd823610d3e4/xabc.cpp) accepts an input and output filename (`xabc input.abc output.ts`) and selects dynamic bytecode. Its current `main` ignores the decompilation return value and returns zero: exit status alone is not success proof. Its [preparation script](https://github.com/jd-opensource/arkdecompiler/blob/8afb36903127b56edee362ce67aacd823610d3e4/scripts/prepare.sh) selects OpenHarmony 6.0.0.1 sources; upstream also requires local compiler/dependency patches, while its [Docker recipe](https://github.com/jd-opensource/arkdecompiler/blob/8afb36903127b56edee362ce67aacd823610d3e4/docker/Dockerfile) selects 5.1.0. Pin one working combination; do not run these scripts as REA setup or assume current master components build together. [ArkAnalyzer](https://github.com/SMAT-Lab/ArkAnalyzer/blob/e9167bab5f950dafbe3f5956d8d5835e3364b4a5/README.md) is adjacent static-analysis prior art and points to its maintained OpenHarmony-SIG repository. It is not proof of binary-decompiler compatibility. [Cangjie–ArkTS interoperability](https://github.com/openharmony/arkcompiler_cangjie_ark_interop/blob/9ff68bddb407897ab482b5456abb7ba9d3618c51/README.md) introduces another language/native boundary; record such artifacts explicitly and defer language-specific recovery until independently justified. ### Suggested increments and acceptance 1. **Package identification and inventory:** HAP/HSP/App Pack/HAR, source versus installed manifests, bytecode versions, resources, libraries and module dependencies. Reuse existing archive/native/Evidence infrastructure, keep format/provider code outside domain/application layers, and report unsupported facets explicitly. 2. **Selected bytecode inspection:** real `ark_disasm` and/or a proven structured reader; inspect one selected record/function and references, retaining raw identifiers, bytes/offsets, literal values and unresolved targets. Map native loading/registration only where supported by evidence; static references are not observed runtime calls. 3. **Optional JD decompilation adapter:** bring-your-own Linux `xabc` plus its compatible libraries. Retain original artifact identity and raw disassembly, record exact provider/compiler versions, validate actual produced output, preserve partial failures, and classify generated ArkTS as derived evidence. Missing source names/types/locations remain unknown. 4. **Independent follow-ups:** deeper resource resolution, package/function comparison, native/N-API or other interop tracing, additional dialects/hosts, signature verification, FA/AOT/patch products and Cangjie. Device debugging/instrumentation belongs to a separate runtime increment. Acceptance must use source-generated public fixtures compiled/packaged by the **actual pinned toolchain**, then exercise the compiled CLI, actual SDK-connected stdio MCP and an installed REA package with real providers. Include multi-module/shared-library packages, imports/exports, literals, closures/async/exception flow, stripped/obfuscated information, resource references and a known native bridge. Compare observations against producer outputs; never require reconstructed source to equal original source. Also test malformed/checksum/version/offset failures, Unicode/MUTF-8 strings and names, duplicate archive entries/path escape/decompression pressure, incomplete modules, missing/mismatched tooling, provider crashes/zero-status failures, cancellation and large producer output. Bound process/output retention by documented resource constraints, preserve collected evidence, and declare examined scope/completeness. Selected results should avoid copying entire bytecode, AST and source into every label or response; coordinate retained Evidence/views with #1065 instead of duplicating its shared transport work. Serialized size is not a model-token or billing measurement. REA remains local-only and the first increment is static/read-only. Do not execute target applications, re-sign/repack them, drive a GUI, install device services, upgrade Java/Node/SDKs, or modify global toolchain settings as part of discovery. Reuse upstream code where appropriate, pin provenance and review actual redistributed component licenses. **Research status:** documentation, repository metadata, CLI source and alternative tool boundaries reviewed using `gh`. No SDK/compiler/decompiler was installed or executed for this issue. API availability and upstream claims do not establish REA support; record verified host/dialect/version combinations separately when implementation begins.
Author
Owner

@asmjmp0 commented on GitHub (Oct 22, 2026):

how about xpanda.I've submitted a PR. https://github.com/morluto/rea/pull/6288

<!-- gh-comment-id:6336762897 --> @asmjmp0 commented on GitHub (Oct 22, 2026): how about xpanda.I've submitted a PR. https://github.com/morluto/rea/pull/6288
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#487
No description provided.