Skip to content

Feat/audit vague1 nil realm#6

Merged
louis14448 merged 3 commits into
mainfrom
feat/audit-vague1-nil-realm
Jun 2, 2026
Merged

Feat/audit vague1 nil realm#6
louis14448 merged 3 commits into
mainfrom
feat/audit-vague1-nil-realm

Conversation

@louis14448

Copy link
Copy Markdown
Contributor

Add wave 1 audit tests — nil-realm cross-realm write hole (PR #5758)

Adds three on-chain audit scripts targeting the nil-realm cross-realm write hole
fixed in gnolang/gno#5758 (commit 2c7f1abe3, merged 2026-06-01).

Background

Before 2c7f1abe3, methods defined in /p/ packages ran with m.Realm == nil,
which disabled the cross-realm write check. An attacker could dispatch through a
/p/-init-stamped object to write into the state of a foreign realm. The fix gives
/p/ packages a frozen realm so the write check fires correctly.

New scripts

Script Vector
audit_nil_realm_hole.sh /p/-init-stamped Dispatcher + interface with no PkgID anchor (EvilInt); writes to /r/-stamped Slot
audit_launder_pointer_write.sh raw pointer to /r/-stamped string obtained via GetPtr(), written from outside the realm
audit_launder_panic_recover.sh /p/-init-stamped SafeRunner wraps defer/recover around a victim call that writes state then panics; verifies state rollback still occurs

All three scripts deploy unique per-run package paths (timestamp suffix), use
maketx run for the attack step (required since gnolang/gno#5669 — functions
without cur realm are non-crossing and cannot be called via MsgCall), and exit
0 on patched / exit 1 on vulnerable.

Test results

All three pass as PATCHED on test-13 (PASS: 16 FAIL: 0).

…R #5758)

Three new audit scripts targeting commit 2c7f1abe3 (PR #5758):

- audit_nil_realm_hole.sh: deploys a /p/-init-stamped Dispatcher + EvilInt
  (int-based Mutator, no PkgID anchor) and verifies the VM blocks the write
  to a /r/-stamped Slot routed through the nil-realm path.

- audit_launder_pointer_write.sh: victim realm exposes &gValue via GetPtr();
  verifies the VM blocks a direct *ptr = "pwnd" from outside the realm
  (PkgID mismatch: caller context vs victim-stamped string).

- audit_launder_panic_recover.sh: /p/-init-stamped SafeRunner wraps a
  victim.SetAndPanic(100) call with defer/recover; verifies that state is
  fully rolled back to 0 despite the panic being caught in /p/ context
  (extends audit_cross_realm_recover for the nil-realm recover path).
@louis14448 louis14448 merged commit e95371f into main Jun 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant