Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/patches/7a493c0e51e536dc # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers ## [Codex Security] Unchecked Physics0 reset arity reads beyond the request stack buffer open `7a493c0e51e536dc` #11 · opened 2026-11-15 19:19 UTC Imported from GitHub drakestapleton/omega-mv#11, by drakestapleton Base `91f88c287d7831784a808c5b054818fd9055afb5` · Head `f510ee37f2cb53f905279146cb4c19159ea51e3f` drakestapleton wrote on 2026-11-15 19:19 UTC Reset requests are now bounded before transport, closing the stack disclosure path. - The encoder accepts only one to four observations, valid pointers, and sufficient output capacity. - The channel refuses zero or oversized encoded lengths before either transport can read the request buffer. - This prevents hostile arities from turning a 34-byte request into a longer stack read. - Valid one-to-four observation resets keep their existing canonical bytes and channel behavior. ### Static Verification Checks - Encoder rejects unsafe requests (Passed) — src/physics0/pd0_wire.c pd0_req_reset rejects invalid arities, null pointers, and undersized buffers before writes. - Channel bounds transport length (Passed) — src/physics0/pd0_chan.c pd0_chan_reset refuses zero or oversized encoded lengths before invoking either transport path. - Hostile arities stay local (Passed) — tests/physics0/test_pd0_world.c asserts counts zero, five, 116, 117, and 255 never reach transport. - Valid resets remain canonical (Passed) — tests/physics0/test_pd0_world.c preserves canonical four-value framing and ordinary descriptor-sized reset flow through the channel. - Callers use bounded contract (Passed) — pd0_req_reset declarations and all repository call sites include capacity, preserving the bounded request contract. - Finding: `acf_7bb6d26e14b0398705f041fec300b963` - Patch: `arp_0485416cd0758906924b1bcf049617ff` - Base commit: `91f88c287d7831784a808c5b054818fd9055afb5` - Patch SHA-256: `1cdc730bf0696a541614e79df982a427eceefa25052db64fe03a7b013d0e84f4` ### Apply it ``` git checkout -b patch-7a493c0e51e536dc 91f88c287d7831784a808c5b054818fd9055afb5 curl -fsSL https://interplane.io/drakestapleton/omega-mv/patches/7a493c0e51e536dc.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 drakestapleton/omega-mv 11 f510ee37f2cb53f905279146cb4c19159ea51e3f ``` ``` {"kind":"github-import","owner":"drakestapleton","repo":"omega-mv","number":11,"url":"https://github.com/drakestapleton/omega-mv/pull/11","export_sha256":"7a4dc05cfaafc4ff4b6c7811f8b55128091a7d4d233c7761f900f26220660f83","imported_utc":"2026-11-18T16:39:50Z"} ``` ### Changes ``` diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index aa4a7bd38..32229f839 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -7,6 +7,7 @@ The current development method is [Human-Directed Agentic Engineering (HDAE)](RE | Model | What it did | |---|---| +| Codex | Bounded Physics0 reset request encoding by arity and output capacity, refused null inputs before transport, and added hostile-count and valid-framing regression controls. | | Grok 4.7 (via Cursor Agent) | Merged main `fd3751b31` (#1020, carrying #1045 and #1050) into #1052. The only conflict was the generated root `.crumb` (child `last_commit` stamps, the `tests` digest, and the root digest). Recompiled with the crumb.lock tool (`d0f0b95d`); `crumb verify .` current. The #525/#962 pins were left as committed: `src/checker2/c2_check.c`, `src/compiler/osc_ir.c` and `src/compiler/osc_ir.h` still hash to the SHA-256s in `ACCEPTED`. | | Claude Opus 5.5 (via omp) | #1020 (actions/cache-4.3.0 ->6.1.0): merged main `d3d1b1bc` and recompiled the root crumb with the crumb.lock tool (`d0f0b95d`). The root crumb's source tree covers `.github/workflows/`, so the bump alone left it stale and `AIEN Checks` failed at `crumb verify .` (`1 of 188 crumbs stale`). | | Claude Opus 5.5 (via omp) | #1018 (actions/upload-artifact-4 ->7): merged main `d3d1b1bc` and recompiled the root crumb with the crumb.lock tool (`d0f0b95d`). The root crumb's source tree covers `.github/workflows/`, so the bump alone left it stale and `AIEN Checks` failed at `crumb verify .` (`1 of 188 crumbs stale`). | diff --git a/src/physics0/pd0_chan.c b/src/physics0/pd0_chan.c index 9ff66bac6..a1d7b2030 100644 --- a/src/physics0/pd0_chan.c +++ b/src/physics0/pd0_chan.c @@ -59,7 +59,10 @@ int pd0_chan_describe(pd0_chan *c, pd0_desc *d) { } int pd0_chan_reset(pd0_chan *c, uint8_t n_obs, const int64_t *vals, pd0_rec *r) { uint8_t req[PD0_REQ_MAX], resp[PD0_REC_MAX]; - size_t n = chan_call(c, req, pd0_req_reset(n_obs, vals, req), resp, sizeof resp); + if (!c || !vals || !r) return -1; + size_t req_len = pd0_req_reset(n_obs, vals, req, sizeof req); + if (req_len == 0 || req_len > sizeof req) return -1; + size_t n = chan_call(c, req, req_len, resp, sizeof resp); return n ? pd0_rec_decode(resp, n, r) : -1; } int pd0_chan_step(pd0_chan *c, uint8_t channel, int64_t value, pd0_rec *r) { diff --git a/src/physics0/pd0_wire.c b/src/physics0/pd0_wire.c index 27af02457..909190074 100644 --- a/src/physics0/pd0_wire.c +++ b/src/physics0/pd0_wire.c @@ -137,10 +137,13 @@ int pd0_rec_chained(const pd0_rec *r, const pd0_rec *prev) { } size_t pd0_req_describe(uint8_t *out) { out[0] = PD0_OP_DESCRIBE; return 1; } -size_t pd0_req_reset(uint8_t n_obs, const int64_t *vals, uint8_t *out) { +size_t pd0_req_reset(uint8_t n_obs, const int64_t *vals, uint8_t *out, size_t cap) { + if (n_obs < 1 || n_obs > PD0_MAX_OBS || !vals || !out) return 0; + size_t need = 2 + 8u * n_obs; + if (cap < need) return 0; out[0] = PD0_OP_RESET; out[1] = n_obs; - for (unsigned i = 0; i < n_obs && i < PD0_MAX_OBS; i++) pd0_put_u64(out + 2 + 8 * i, (uint64_t)vals[i]); - return 2 + 8u * n_obs; + for (unsigned i = 0; i < n_obs; i++) pd0_put_u64(out + 2 + 8 * i, (uint64_t)vals[i]); + return need; } size_t pd0_req_step(uint8_t channel, int64_t value, uint8_t *out) { out[0] = PD0_OP_STEP; out[1] = channel; diff --git a/src/physics0/pd0_wire.h b/src/physics0/pd0_wire.h index 4e7fa5d98..50b8df5d8 100644 --- a/src/physics0/pd0_wire.h +++ b/src/physics0/pd0_wire.h @@ -83,7 +83,8 @@ int pd0_rec_decode(const uint8_t *in, size_t len, pd0_rec *r); int pd0_rec_chained(const pd0_rec *r, const pd0_rec *prev); size_t pd0_req_describe(uint8_t *out); -size_t pd0_req_reset(uint8_t n_obs, const int64_t *vals, uint8_t *out); +/* Returns 0 unless n_obs, pointers and output capacity describe a complete reset request. */ +size_t pd0_req_reset(uint8_t n_obs, const int64_t *vals, uint8_t *out, size_t cap); size_t pd0_req_step(uint8_t channel, int64_t value, uint8_t *out); /* little-endian helpers shared by the law record encoder */ diff --git a/tests/physics0/test_pd0_world.c b/tests/physics0/test_pd0_world.c index 91ec1a217..d52331347 100644 --- a/tests/physics0/test_pd0_world.c +++ b/tests/physics0/test_pd0_world.c @@ -50,6 +50,16 @@ uint64_t turing_ev_cost(const turing_evidence *e, int pack) { (void)e; (void)pac static unsigned long failures, checks; #define CHECK(c, ...) do { checks++; if (!(c)) { failures++; printf("FAIL %s:%d: ", __FILE__, __LINE__); printf(__VA_ARGS__); printf("\n"); } } while (0) +typedef struct { unsigned calls; size_t req_len; } reset_probe; + +static size_t probe_reset_call(void *ctx, const uint8_t *req, size_t req_len, uint8_t *resp, size_t cap) { + reset_probe *p = ctx; + (void)req; (void)resp; (void)cap; + p->calls++; + p->req_len = req_len; + return 0; +} + static void t_wire(void) { pd0_desc d, d2; pd0_gen_desc(PD0_L3, &d); @@ -110,6 +120,42 @@ static void t_wire(void) { CHECK(!strstr(claim, "always") && !strstr(claim, "true") && !strstr(claim, "universally"), "forbidden words"); } +static void t_reset_request_bounds(void) { + static const uint8_t bad_counts[] = {0, PD0_MAX_OBS + 1, 116, 117, 255}; + int64_t vals[PD0_MAX_OBS] = {1, -2, 3, -4}; + uint8_t req[PD0_REQ_MAX], untouched[PD0_REQ_MAX]; + memset(untouched, 0xA5, sizeof untouched); + + for (size_t i = 0; i < sizeof bad_counts; i++) { + memcpy(req, untouched, sizeof req); + CHECK(pd0_req_reset(bad_counts[i], vals, req, sizeof req) == 0 && memcmp(req, untouched, sizeof req) == 0, + "reset arity %u refused without touching output", (unsigned)bad_counts[i]); + } + memcpy(req, untouched, sizeof req); + CHECK(pd0_req_reset(PD0_MAX_OBS, vals, req, sizeof req - 1) == 0 && memcmp(req, untouched, sizeof req) == 0, + "reset request refuses short output capacity"); + CHECK(pd0_req_reset(1, NULL, req, sizeof req) == 0, "reset request refuses null values"); + CHECK(pd0_req_reset(1, vals, NULL, sizeof req) == 0, "reset request refuses null output"); + + size_t n = pd0_req_reset(PD0_MAX_OBS, vals, req, sizeof req); + CHECK(n == sizeof req && req[0] == PD0_OP_RESET && req[1] == PD0_MAX_OBS && + (int64_t)pd0_get_u64(req + 2) == vals[0] && (int64_t)pd0_get_u64(req + 26) == vals[3], + "valid maximum-arity reset keeps its canonical framing"); + + reset_probe probe = {0, 0}; + pd0_chan c = {probe_reset_call, &probe, -1, -1}; + pd0_rec rec; + for (size_t i = 0; i < sizeof bad_counts; i++) { + CHECK(pd0_chan_reset(&c, bad_counts[i], vals, &rec) == -1 && probe.calls == 0, + "reset arity %u refused before transport", (unsigned)bad_counts[i]); + } + CHECK(pd0_chan_reset(&c, 1, NULL, &rec) == -1 && probe.calls == 0, "null reset values refused before transport"); + CHECK(pd0_chan_reset(NULL, 1, vals, &rec) == -1 && probe.calls == 0, "null reset channel refused before transport"); + CHECK(pd0_chan_reset(&c, 1, vals, NULL) == -1 && probe.calls == 0, "null reset record refused before transport"); + CHECK(pd0_chan_reset(&c, PD0_MAX_OBS, vals, &rec) == -1 && probe.calls == 1 && probe.req_len == sizeof req, + "valid maximum-arity reset reaches transport with bounded length"); +} + /* drive a channel with a fixed script; append record bytes into out */ static size_t script(pd0_chan *c, int level, uint8_t *out, size_t cap, pd0_rec *last) { pd0_desc d; @@ -423,6 +469,7 @@ static void t_desc2(void) { int main(void) { t_wire(); + t_reset_request_bounds(); t_rules(); t_splitmix(); t_null_world(); ```