Skip to content

feat: require explicit consent and integrity check for WASM sandbox download (fixes #24)#34

Merged
Tanishq1030 merged 1 commit into
mainfrom
feature/issue-24-sandbox-consent-and-hashes
Jul 10, 2026
Merged

feat: require explicit consent and integrity check for WASM sandbox download (fixes #24)#34
Tanishq1030 merged 1 commit into
mainfrom
feature/issue-24-sandbox-consent-and-hashes

Conversation

@Tanishq1030

Copy link
Copy Markdown
Member

Description

This PR ensures that downloading the Diamond Cage WASM runtime requires explicit developer consent, while verifying the integrity of downloaded binaries using SHA-256 checksums.

Acceptance Criteria

  • Detect missing runtime before execution.
  • Prompt before downloading runtime components.
  • Verify downloaded runtime before installation.
  • Continue static analysis if installation is declined.
  • Clearly communicate unavailable sandbox features.
  • Documentation updated with runtime installation workflow.

Changes

  • CLI (anchor/cli.py):
    • Replaced automatic WASMEdge initialization with an interactive prompt:
      Sandbox runtime not found.
      Anchor uses WASMEdge to execute policies inside an isolated sandbox.
      The runtime must be downloaded once before sandbox execution.
      Download and install now? [Y/n]
      
    • If declined or non-interactive (CI/CD environments), falls back to static-only analysis, explains which runtime features are unavailable, and disables the sandbox (no_sandbox = True).
  • Sandbox Module (anchor/core/sandbox.py):
    • Added hardcoded SHA-256 checksum constants for all supported platforms' WasmEdge releases and the python-3.11.3.wasm binary.
    • Computes the SHA-256 hash of the downloaded archives and raises a validation error (cleaning up temporary file footprints) if the integrity verification fails.
  • Unit Tests (tests/unit/test_sandbox_consent.py):
    • Added test cases validating declining behavior (disabling sandbox, displaying warning details), accepting behavior (triggering download), and integrity mismatch detection (aborts setup).

Related Issues

Fixes #24

Copilot AI review requested due to automatic review settings July 10, 2026 16:44

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Tanishq1030
Tanishq1030 merged commit 7c2701b into main Jul 10, 2026
1 check 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.

Require Explicit Consent Before Downloading and Executing WASM Runtime

2 participants