Skip to content

M-1: Vendored portfolio layout lacks runtime validation; false claims about LiteSVM test #160

Description

@v1ktorrr0x

Bug

The NFT program mirrors the converged v17 portfolio layout (PortfolioAccountV16Account, 9227 bytes) via bytemuck cast in decode_portfolio (slab_types_v16.rs:484). This is the only place portfolio bytes are interpreted, and every security decision downstream depends on correct field offsets.

False Claims

  • cpi_v16.rs:14: "end-to-end path is verified by the A.5 LiteSVM suite"
  • README.md:95: "Struct offsets are validated at compile-time with size and offset assertions"
  • slab_types_v16.rs:43: "The LiteSVM integration test (cross-cut phase) is the runtime ground truth"

Reality: There is no tests/ directory, and CI runs only cargo test --lib --tests (self-referential unit tests).

The const_assert! macros measure the mirror struct against itself, proving internal consistency but proving nothing about correspondence to the live engine layout.

Risk

If the engine layout ever inserts/reorders/resizes a field before the read fields (legs, owner, locks), the provenance header checks still pass while owner/market_id/gate-flags are silently read from wrong bytes:

  • wrong owner offset → mint against positions you don't own
  • wrong market_id/slot-reuse anchor → transfer gate decisions on garbage
  • wrong lock/stale flags → bypass transfer restrictions

This is the failure mode warned about in SCHEMA_DRIFT_v12.19.md: "mirror schema drift can mask itself as compile-pass."

Fix

Either:

  1. Remove false claims from comments/docs to match reality, OR
  2. Add the promised LiteSVM integration test (spin up real wrapper portfolio, assert NFT reads match)

Labels: security, documentation

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions