Skip to content

Reject truncated or non-relocatable ELF outputs in object contract checks #562

Open

Description

@LunaStev

Current master follow-up (2026-11-12)

This update records the remaining behavior on the audited master. The historical report and earlier delivered work are retained below; current code paths are Rust rather than the retired Python helpers.

Problem

The current Rust artifact check accepts a real executable as an object because it checks architecture/width but not ELF kind.

Reproduction and evidence

Audited canonical master 69a67c6e0fb700f37ee6114f5a66d37ee13771a5 (0.0.1-alpha-dev). Matching checkout-built compiler/std were used for compiler probes on Linux amd64 with Rust 1.89.0 and LLVM 21.1.8. Artifact inspection, mocked/projection checks and foreign-target object emission are identified below and are not native execution on those operating systems.

// wave-test: mode=build, runner=compile, target=x86_64-unknown-linux-gnu, emit=obj, object-arch=x86_64, object-bits=64
fun main(){}

Use an executable fake compiler containing:

#!/usr/bin/python3
import shutil,sys
shutil.copyfile("/bin/true",sys.argv[sys.argv.index("-o")+1])
target/debug/wave-tools test --wavec ./fake-compiler --target-id linux-amd64 --source repro.wave --report-json report.json

Executed result: pass, despite /bin/true being ET_DYN rather than ET_REL. An additional synthetic big-endian x86_64 ELF is accepted for a little-endian target; keep that byte-order assertion in the same contract-validation work rather than filing an issue per field.

Scope

Require the selected object role/kind in runner validation, preserving general package executable inspection and architecture/float ABI checks.

Starting points: tools/src/runner.rs:448, tools/src/binary.rs:287.

Completion criteria

  • ET_EXEC/ET_DYN/ET_CORE cannot pass an ELF obj contract.
  • Real supported relocatable objects pass; check header completeness and byte order consistently.
  • Do not impose ET_REL on package executable checks.

This is a bounded newcomer task with the starting point and focused negative/positive checks above.

Original report (historical)

read_elf_contract checks at least 52 bytes, the ELF magic/class/encoding, and enough bytes for e_flags. For ELF64, that still allows a 52-byte file even though the ELF64 header is 64 bytes. It does not inspect e_type, so an executable/shared-object header with matching machine/flags can satisfy an emit=obj contract. These are false-positive artifact checks, separate from the already tracked missing-file path.

Code evidence:

Acceptance:

  • Require the full header for the selected class and validate the expected relocatable object kind (ET_REL) for object contracts.
  • Reject invalid header version/size fields rather than accepting a matching few bytes.
  • Add synthetic-byte fixtures for truncated ELF32/64, ET_EXEC/ET_DYN and valid relocatable headers in supported byte orders.
  • Preserve architecture and RISC-V/LoongArch float ABI checks without requiring a native compiler for the Python tests.

#514 concerns an absent artifact; #463 concerns WebAssembly objects. This issue tightens validation of an existing ELF file.

Audit status: static source inspection against canonical master ea74c2dafc31da876e5561f2d176ba719f5a0458 on 2026-09-10. No compiler build, test execution, implementation change or local reproduction was performed for this report. The examples describe the source-derived behavior to verify when implementing the fix.

Activity

  1. added
    bug
    good first issue
    on Sep 10, 2026
  2. self-assigned this
    on Sep 30, 2026
  3. added
    build
    on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugbuildgood first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions