Skip to content

Protect imported source files from AST-only output aliases #901

Closed

Description

@LunaStev

Problem

An AST-only build can overwrite an imported Wave source through an output symlink. Output validation protects the primary source, then returns before collecting imported inputs.

Reproduction

Audited on Linux amd64 at 53bb5809cf32d29f5a5a9d313ffa332ea3cd4beb, whose tracked tree matches canonical master c5ab63f9eec388c75b00f5cd59eae28a45a9b39f. Compiler built with Rust 1.89.0, LLVM 21, and the checkout std; Whale is locked to 020d2a4. Executed in a temporary directory:

printf 'import("./helper.wave")::{value}; fun main() -> i32 { return value(); }\n' > main.wave
printf 'pub fun value() -> i32 { return 7; }\n' > helper.wave
ln -s helper.wave main.ast.json
wavec build main.wave --emit=ast --ast-format=json

Exit status is 0. helper.wave is replaced with AST JSON. The fixture was restored after the audit; no checkout source was used as the output.

Scope

src/cli.rs validate_output_paths returns early for a single AST emit after checking only classified inputs. The later imported-input collection never runs. Reuse the alias protections in src/output_guard.rs while preserving AST-only behavior and avoiding unnecessary backend compilation.

Related #745; this is the remaining AST-only imported-input gap. #851 separately concerns linker-script inputs.

Completion criteria

  • AST outputs cannot replace direct or transitively imported sources through direct, normalized, symlink, or hardlink aliases.
  • Rejection happens before any output write and leaves all inputs byte-identical.
  • Safe AST-only output still works for supported dump formats without requiring backend lowering.

Activity

  1. added
    bug
    help wanted
    needs testing
    on Oct 9, 2026
  2. self-assigned this
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughelp wantedneeds testing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions