Skip to content

fix: Limit Wasm name section size - #12120

Merged
michael-weigelt merged 4 commits into
masterfrom
mwe/imports
Nov 23, 2026
Merged

michael-weigelt merged 4 commits into
masterfrom
mwe/imports

Conversation

@michael-weigelt

@michael-weigelt michael-weigelt commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Limits the number of entries in the name section. It should not exceed the number of local functions.

Also limits the number of imports. The only allowed imports are the system API (~80) and a memory and a table.

Interface spec.

@github-actions github-actions Bot added the fix label Nov 16, 2026
@michael-weigelt
michael-weigelt marked this pull request as ready for review November 16, 2026 14:07
@michael-weigelt
michael-weigelt requested a review from a team as a code owner November 16, 2026 14:07
Copilot AI balanced review requested due to automatic review settings November 16, 2026 14:07
@zeropath-ai

zeropath-ai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed everything up to ae65197.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/config/src/embedders.rs
    Change MAX_FUNCTIONS from pub(crate) to pub
► rs/embedders/src/wasm_utils/validation.rs
    Import MAX_FUNCTIONS from ic_config::embedders
    Add MAX_NUMBER_IMPORTS constant
    Add validation for name section entries against MAX_FUNCTIONS
    Add validation for total imports against MAX_NUMBER_IMPORTS
Enhancement ► rs/embedders/tests/validation.rs
    Import MAX_NUMBER_IMPORTS and MAX_FUNCTIONS
    Add tests for TooManyImports and TooManyNameSectionEntries
Enhancement ► rs/types/wasm_types/src/errors.rs
    Add TooManyImports variant and TooManyNameSectionEntries variant
    Update Display and UserError handling for new variants

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The function-name entry limit incorrectly rejects valid modules with 50,000 named local functions and a named import; it must account for imports and include regression coverage.

1 open issue
What changed in this PR

This PR adds limits to the embedder’s early Wasm validation pass to bound function-name entries and imports before further parsing.

Changes:

  • Limit function-name entries to 50,000 and imports to 200.
  • Add validation errors, user guidance, and rejection tests for both limits.
  • Make MAX_FUNCTIONS public for reuse in validation and tests.
File Description
rs/​types/​wasm_types/​src/​errors.rs Add errors and user guidance for exceeded limits.
rs/​embedders/​tests/​validation.rs Add rejection tests for excessive imports and function names.
rs/​embedders/​src/​wasm_utils/​validation.rs Enforce import and function-name limits during early validation.
rs/​config/​src/​embedders.rs Expose the existing function-limit constant.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 17, 2026 14:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the changes adding Wasm import and function-name metadata limits.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 20, 2026 13:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change adding Wasm import and function-name entry limits.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 20, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new import-limit assertion is missing #[test], so the Rust test harness never runs it and regressions in TooManyImports detection remain uncovered.

1 open issue

Review effort: Balanced

Comment thread rs/embedders/tests/validation.rs Resolved
…ssertion'

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 09:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the Wasm function-name and import validation limits.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@michael-weigelt
michael-weigelt added this pull request to the merge queue Nov 23, 2026
Merged via the queue into master with commit d3d9572 Nov 23, 2026
44 checks passed
@michael-weigelt
michael-weigelt deleted the mwe/imports branch November 23, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants