feat(poc-a): gate-a dynamic elf proof of concept (#13)
## Summary PoC-A proved that dynamically loaded ELF plugins are workable on ESP32-S3: plugins ship as signed MPB packages, are parsed by a strict single-type parser shared between host and target, and execute from PSRAM+IRAM within a measured admission budget. A 1000-cycle load/unload soak passed 18/18 trend gates with stable heaps, the capacity ladder settled at 8 coexisting plugin instances with a 3356B per-instance budget, and the fail-closed corpus executed zero attacker-controlled bytes across 14 rejection classes. Scheduler semantics (strand FIFO ordering, completion-cancel CAS, quiesce-as-noop ABI) were validated on both host (TSan suite) and target. **Gate-A verdict: PASS** — ADR-0002 moves to **Accepted** with the capacity value 8 and global-sum admission rule as PoC-derived proposals. ## Changes by area Grouped from `git log main..HEAD --oneline` (18 commits): - **Vendored loader + patches**: `4bb53f2` vendor elf_loader 1.3.3 + harness scaffold; `2f67b4f` plugin_iram loader patch with budget consistency (p1-p5 patch series in `PATCHES.md`). - **MPB toolchain**: `4793cc2` deterministic MPB manifest builder with test signing; `408df44` strict single-type MPB parser shared host/target; `796f9d2` host MPB corpus + policy CI lane. - **Plugin pipeline + probes**: `21d2842` plugin pipeline and first PSRAM execution on target; `cab9664` relocation/import allowlist matrix with probes; `c5d6c6c` C++ feature rejection matrix. - **Harness commands**: `e0e7159` generation coexistence with measured admission budget; `2a37556` thousand-cycle lifecycle soak with heap trend gate; `093a72b` on-target scheduler semantics validation (+ `eea3876` clang-format-18 sweep); `a302151` capacity ladder with signed budget; `f34dc72` fail-closed corpus with execution sentinel. - **Host prototypes**: `6198bca` strand FIFO prototype with TSan suite; `1c3ad59` completion-cancel CAS and cleanup semantics. - **Evidence + ADR/docs**: `887d0f7` Gate-A manifest and report; `1c29e8a` ADR-0002 outcome + frozen PoC values. ## QA evidence - `poc/evidence/poc-a-20260901/manifest.json` — 67-artifact hash index, every sha256 recomputed at assembly. - `poc/evidence/poc-a-20260901/GATE-A-REPORT.md` — full nine-item development-plan §4 mapping; TEST-003 10/10 clauses. - 14 verbatim per-task transcripts (`task-1` … `task-15-*.log`) + fresh build artifacts (`build/frame_poc_a.map`, size components). - Frozen in-repo references: `ALLOWLIST.md`, `REJECT-MATRIX.md`, `ADMISSION-BUDGET.md`, `soak_samples_1000.csv`, fc corpus (33 committed `.mpb` containers). - F1-F4 final-wave verdicts: **APPROVE**. - Key numbers: soak **18/18** trend gates over 1000 cycles; capacity **8/8** instances, **3356B** per-instance; fc corpus **14 rejection classes, zero attacker bytes executed**; **4 upstream loader defects found and patched** (p1-p5). ## Requirement IDs (GOV-006) ADR-0002; TEST-002, TEST-003; PLUG-001, PLUG-004, PLUG-008, PLUG-009; MEM-001, MEM-003, MEM-007, MEM-008; LIFE-001, LIFE-002, LIFE-005, LIFE-007; SEC-002, SEC-003, SEC-004, SEC-005; GH-003; GOV-004, GOV-005. ## Risks / known limitations From `GATE-A-REPORT.md` §(f) plus the trade-off table: 1. **Capacity descent path 7-5 unexercised** — rung 8 passed first attempt; rungs 7/6/5 and retry-once logic never ran on hardware (untested against real OOM). 2. **No Wi-Fi in the harness (MEM-001 caveat)** — all PSRAM/IRAM budget numbers are radio-off harness-class; product admission budgets must be re-measured with the network stack active. 3. **On-target scheduler vectors are a subset of the host suite** (256-node pool / 2e4 storm posts vs host 31000 / 1e5); consistency declaration covers only the vectors actually run. 4. **Quiesce is a no-op by ABI semantics** — plugin ABI 1.2 has no quiesce slot; NULL entry is defined as trivial success; real quiesce coordination is later-gate work. 5. **MEMPROT=n trade-off** — `CONFIG_ESP_SYSTEM_MEMPROT=n` is required for the IDF exec heap (`MALLOC_CAP_EXEC`) that `.plugin_iram` needs; software-only PMP config, no eFuse burned (documented in `PATCHES.md` p5); production must re-decide security vs plugin IRAM. 6. **Owner sign-off PENDING** — Gate-A PASS is the PoC team's verdict; formal acceptance of ADR-0002 awaits the owner. ## Not in scope - Product components (GOV-004) — this PR is PoC evidence only; no product code paths change. - **Merge is the owner's call** — do not merge without owner sign-off on ADR-0002. --------- Co-authored-by: ania-lain <[email protected]>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
# MPB host test corpus (T3)
|
||||
|
||||
Deterministic fixtures consumed by `mpb_parser_test` in `poc/host`. Binary
|
||||
corpus in git is intentional: the builder is fully deterministic (RFC 6979
|
||||
signing), so regeneration reproduces byte-identical files.
|
||||
|
||||
## Regeneration
|
||||
|
||||
```
|
||||
uv run python poc/host/tests/gen_mpb_corpus.py
|
||||
```
|
||||
|
||||
The generator calls the worktree's python oracle
|
||||
`tools/frame_tools/manifest_builder.py` (pinned at commit `4793cc2`) and
|
||||
re-verifies every fixture expectation against `verify_mpb` before writing.
|
||||
Run it from the worktree after any builder change; commit the `.mpb` files
|
||||
together with `corpus_manifest.inc`.
|
||||
|
||||
## Contents
|
||||
|
||||
2 positives (`pos_code`, `pos_resource_only` — the resource package carries
|
||||
two payloads with alignments 4 and 16 so alignment padding inside the payload
|
||||
window is exercised) and 16 negatives covering the 13 required tamper
|
||||
classes plus two extras (`neg_double_fault` proves signature is reported
|
||||
before payload hash, `neg_features` proves required-features policy), plus
|
||||
the wrong-key variant inside the signature class (`neg_key_id`, signed by a
|
||||
deterministically derived second key; the KAT context only trusts key
|
||||
`e5677a1c`).
|
||||
|
||||
Expected error codes are `frame_err_t` values; see `corpus_manifest.inc`.
|
||||
|
||||
## Host signature known-answer strategy
|
||||
|
||||
The host `ecdsa_verify_fn` test double accepts exactly the
|
||||
`(key_id, digest, signature)` triple the builder produced, recorded in
|
||||
`corpus_manifest.h`. Equality stands in for the P-256 math: tampering the
|
||||
signed prefix changes the recomputed digest, tampering the record changes
|
||||
the signature bytes, and the wrong-key fixture fails the key comparison.
|
||||
The target build performs real ECDSA P-256 verification through PSA crypto
|
||||
(`mpb_mbedtls_glue.c`).
|
||||
|
||||
Each fixture records its whole-file SHA-256; the test re-hashes every file
|
||||
with the reference SHA-256 before parsing, so a stale or partially
|
||||
regenerated corpus fails loudly instead of silently drifting.
|
||||
|
||||
All key material here is TEST-ONLY (SEC-003/SEC-005 dev default).
|
||||
@@ -0,0 +1,51 @@
|
||||
/* GENERATED by poc/host/tests/gen_mpb_corpus.py - do not edit.
|
||||
* Builder pin: tools/frame_tools/manifest_builder.py @4793cc2.
|
||||
* expected codes are frame_err_t values from frame_poc/frame_abi.h.
|
||||
*/
|
||||
#ifndef MPB_TEST_CORPUS_MANIFEST_H
|
||||
#define MPB_TEST_CORPUS_MANIFEST_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define MPB_CORPUS_KEY_ID_A UINT32_C(0xe5677a1c)
|
||||
#define MPB_CORPUS_EPOCH_FLOOR UINT32_C(1)
|
||||
|
||||
typedef struct {
|
||||
const char* file;
|
||||
const char* corpus_class;
|
||||
const char* file_sha256_hex;
|
||||
int32_t expected_error;
|
||||
int16_t package_kind; /* 0 n/a, 1 code, 2 resource-only */
|
||||
const char* name;
|
||||
const char* version;
|
||||
uint32_t epoch;
|
||||
uint32_t iram_required_bytes;
|
||||
uint32_t max_memory_bytes;
|
||||
int16_t payload_count;
|
||||
const char* payload_sha256_hex[16];
|
||||
const char* kat_digest_hex;
|
||||
const char* kat_signature_hex;
|
||||
} mpb_corpus_entry_t;
|
||||
|
||||
static const mpb_corpus_entry_t k_mpb_corpus[] = {
|
||||
{"pos_code.mpb", "positive-code", "d86937e9540d3b188d31fbd6ba67b5319694923d0210db2b4383a4724f0101ef", 0, 1, "poc-a-baseline", "1.2.3", UINT32_C(1), UINT32_C(4660), UINT32_C(262144), 1, {"1cc38307f9f8a8e8cd10b32fd066b0192c1b7c151f90e8f1d44de883b2992949", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "f713b27b437fac4cd727f9e3c2a584c0432d06ea3ecdaf6de721efdb16406a48", "05506860beee543b0271814c339f1c1710cf800438e0a3fae89e487bbc54081c4407c72a38c3283ac56ccb9a6c60cef720db3f5d8dae4bde29147ddc9d4a30b4"},
|
||||
{"pos_resource_only.mpb", "positive-resource-only", "318872c5ac2b50747d066e572c3d815688ec5c8fe74ab2147a5bfe1d8855b399", 0, 2, "poc-a-assets", "2.0.0", UINT32_C(1), UINT32_C(0), UINT32_C(65536), 2, {"f8add4c487fcf37675adecf84c265368e189649270036ece4a0fa331da472bc9", "4876cd4d6aade0bdb9a7460d5655b6d68e0aa58b390e7285eb6d573fa8aeb9b9", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "d6cbcd1f73181c668928cca3c7f0276d26e3b65653470eb03ee0d4f0746cd1ee", "31e5432fc49443a3e9f64911c5ae4fb08c8b1d1f8fa0b08d319df941fcc7faf6b0678fcb4e36c8ed8a031d067ebd01e23b7c7a5e0e6b519497ee67352195919d"},
|
||||
{"neg_magic.mpb", "negative-magic", "edca005c4f67db79386c136f91caf7cc2c41964eab064cea2049a4acf5eafde2", -18, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "17d85c9114adc6327d9de1373b2529f50c98f9a2fca1e96a26860f74aa63b55c", "05506860beee543b0271814c339f1c1710cf800438e0a3fae89e487bbc54081c4407c72a38c3283ac56ccb9a6c60cef720db3f5d8dae4bde29147ddc9d4a30b4"},
|
||||
{"neg_total_size.mpb", "negative-total-size", "e5fc8d7b2bb8d13dc7839692f70eda8e62bbeb9ef664c855533fbd4dc3d3edfe", -18, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "f713b27b437fac4cd727f9e3c2a584c0432d06ea3ecdaf6de721efdb16406a48", "05506860beee543b0271814c339f1c1710cf800438e0a3fae89e487bbc54081c4407c72a38c3283ac56ccb9a6c60cef720db3f5d8dae4bde29147ddc9d4a30b4"},
|
||||
{"neg_offset_oob.mpb", "negative-offset-oob", "525065064fabe251b3ba1f96b8d6843e03c5c893e7901b99c07381e20f05ab49", -18, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "a79965cdbf2f11a44edb30c2c3ca13a18bc938c42d0c7b7a92c2bacaadc011bd", "9e23f1737edd216066fa7497446ba6cbff16cd13cbc9d3c84e32ea14a2408eaddc25a69d1cb746f0b6e402772ee3527df5b939f0b68db67692091ca961710ee8"},
|
||||
{"neg_overlap.mpb", "negative-overlap", "6c61b658fcdccc1ebbecaae90a81994aedad44039a9a7a90df15d205d23feec8", -18, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "542e1c107fa181e346f4fb7a2ffee4faf0a7117fea2a8e13e879921cf36b348e", "b05e8353d37247fb6075b211497f1448bf961ff8ab3e97ea45bf1775807f64991eee71e2533e0f491547b0a7d0d1a612e3f4266e8a721cb0e69539c03fab7b64"},
|
||||
{"neg_dup_required.mpb", "negative-dup-required", "1441b28ea2034e122919467efa7d76b6911ed093fbf5f0931d6f0ad267893494", -18, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "53cd687b7afb38e2124140811f7921d062dd45244ffe7eee475fe9ab29cd5c04", "f36a3f3ad0758a7925ad0efa97e8dffd2d9991d4907c51c1ef0f0ddbd63bdccd3a2521bc7b8572291ac29158bdd926928f96f09a62d60c4a3a964df1a3ad479b"},
|
||||
{"neg_unknown_required_tlv.mpb", "negative-unknown-required-tlv", "0a6ba33bf7a6f3bc60687f4fabb1506b34fc46cd4d6d628438474dff1728cea6", -18, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "ff91e4871d41f90739837b692719730ac7037da536fe688a034691814ba9e595", "8594502f348fd09417d64d9393956c2eb347273e48a80da34963aab42401fb2e0feabbdd798df72329b557dadf7914d094d2f53cb70692f3d60d4b5d7295e55e"},
|
||||
{"neg_mixed_elf_in_res.mpb", "negative-mixed-elf-in-res", "80cca8ba5dc83103436791913990747bfd677f0e60263de5fae1f339fc08d05e", -18, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "2ce94249905d33b0d84830d6ad93458dcd4c816c72eeba069d1fa817491b97bd", "065935ded27bdc81ecb8bca064c5014c99c8304ac2988ba8e988024074e6e14e7d0dd99b857d4ba1f46e5d4b0e2af302fcb3b5048047230494f9457dcde66cb3"},
|
||||
{"neg_mixed_res_in_elf.mpb", "negative-mixed-res-in-elf", "872ee8e818f0708bcc4be4c043ce3cb68878a2825078dfed7835ea51ea800c7e", -18, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "36369ca5aaeb12d033d96c8a70c3acf543729c28fbe44ebe2381f51e97f72d35", "abe079192ee0b4e3102e50fa4218a5c1eb4c66c735ebfc98c0f821fba38c8c072185066a348666f2e1d30036248e04aaef5867e3aa9a58b21b43e72a17fa4ae4"},
|
||||
{"neg_payload_hash.mpb", "negative-payload-hash", "191059b17c44e0a5c1ea52a7a17a3d7594fb37662b45e030e618a3f4d36e4fd1", -19, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "f713b27b437fac4cd727f9e3c2a584c0432d06ea3ecdaf6de721efdb16406a48", "05506860beee543b0271814c339f1c1710cf800438e0a3fae89e487bbc54081c4407c72a38c3283ac56ccb9a6c60cef720db3f5d8dae4bde29147ddc9d4a30b4"},
|
||||
{"neg_signature.mpb", "negative-signature", "b7673bf613240bb6d596c53b83752ef4f2d0fc465bfd273ff0c4840c5c62a532", -17, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "f713b27b437fac4cd727f9e3c2a584c0432d06ea3ecdaf6de721efdb16406a48", "05506860beee543b0271814c339f1c1710cf800438e0a3fae89e487bbc54081c4407c72a38c3283ac56ccb9a6c60cef720db3f5d8dae4bde29147ddc9d4a30b4"},
|
||||
{"neg_double_fault.mpb", "negative-double-fault", "b29fed6c397ed193fbc55b44cc957311d5e1e79946206f4cf51e498e3b9cde65", -17, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "f713b27b437fac4cd727f9e3c2a584c0432d06ea3ecdaf6de721efdb16406a48", "05506860beee543b0271814c339f1c1710cf800438e0a3fae89e487bbc54081c4407c72a38c3283ac56ccb9a6c60cef720db3f5d8dae4bde29147ddc9d4a30b4"},
|
||||
{"neg_key_id.mpb", "negative-key-id", "aa23322034e7502a9537eaa5af800fe5cfa435503d37f32a01a8af3f859e6e70", -17, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "35f037f8c6bf1450a89b65e249d2d44d9f3744170bb24b350da17a775588e8fc", "9d6c021378ebf66ce80e95307373bcd02dce15533ab35866dbfe232224a0d36e16373243c941f14effa3903326752b6545cc7034e49e259a483450fd07db40cb"},
|
||||
{"neg_target.mpb", "negative-target", "8703e1b8cd9bd1e3d7afc857b618b3c50b14051bf3b5a37129153fae37252000", -35, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "8ffeea4acea13b9b9911c4498410fa0544ea25b784045ce0504755675febe777", "c31a66754f06438ffcb7bab13d6856a3229bf81b81ac02df3a9eeb10ac7d7f30049cf7dca5034ee2e50d9052c6bd8fa068e6fa9db24363744e9cd65a82bfe85c"},
|
||||
{"neg_abi.mpb", "negative-abi", "f6b9002aee6885719404b6feeb566a412a94e09d9d792bfb1b866998cac6f6dc", -7, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "8d0ad121e71b9659793c2627c48dd72e63a3ff12403bb8ce103444705a217c47", "a1eba6491128221124f5f7f73cad6ae7cbc402d471cd2db087bd98da5ca9f3d8afecd6f38639928f7e555a05114139b0f9f0cf3c214a02fc194702f34a3495d8"},
|
||||
{"neg_features.mpb", "negative-features", "87fe364bf95aeb74a3dc05d59da79e14a63a4c34a941f480755e5c1b15f152ba", -7, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "d5957ba810c8395557156badeccdb52174b86e3a1319db6f92ea8becd3a2998f", "1c95c633538f233881740b54c033b5268da8cf6cb2e565866118407ad1e9c17f35d6f64265adac778b73942447fb1a67ade1fe4d36833250e365f26e470a66b1"},
|
||||
{"neg_epoch.mpb", "negative-epoch", "ec9297e6cb6507073287216e1f311e14f161fc4e711c564943005debc0c5c76b", -34, 0, "", "", UINT32_C(0), UINT32_C(0), UINT32_C(0), 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "d1eab515460355f871bcdb6e51e4fa1b329b1223bf2bf8beb486dee5dcc42a66", "9f5530c715cff919190815d896973cd42561a21304de25e44d93e53070bc92ef83004524e429dc346b725cc01b2336ba6fb2347af83e58f340345c6ab26dfbf5"},
|
||||
};
|
||||
|
||||
#endif
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user