Skip to content

Conversation

ludfjig
Copy link
Contributor

@ludfjig ludfjig commented Oct 2, 2025

This PR adds a poison state to sandbox in order to prevent further operations when the sandbox is left in an inconsistent state that could compromise memory safety, data integrity, or security. The sandbox becomes poisoned when guest functions abort/panic or when host-initiated execution cancellation occurs, leaving behind leaked heap allocations, corrupted data structures, or unreleased resources.

Poisoned sandboxes will reject all further operations (guest calls, snapshots, memory mapping) until the inconsistent state is resolved through either restoring to a snapshot or manually clearing the poison state.

Closes #848

Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
@ludfjig ludfjig added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Oct 2, 2025
@ludfjig ludfjig marked this pull request as ready for review October 2, 2025 19:15
@ludfjig ludfjig requested a review from Copilot October 2, 2025 20:07
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces sandbox poisoning functionality to prevent further operations when a sandbox is in an inconsistent state that could compromise memory safety. The sandbox becomes poisoned when guest functions abort/panic or when host-initiated execution cancellation occurs.

Key changes:

  • Added poisoned state tracking with safety checks across all sandbox operations
  • Implemented automatic poison detection for specific error types (GuestAborted, ExecutionCanceledByHost)
  • Added recovery mechanisms through snapshot restoration or manual poison clearing

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/hyperlight_host/src/sandbox/initialized_multi_use.rs Core implementation of poison state tracking, safety checks, and recovery mechanisms
src/hyperlight_host/src/error.rs Added PoisonedSandbox error variant with detailed documentation
src/hyperlight_host/tests/integration_test.rs Updated interrupt tests to clear poison state for continued execution
src/hyperlight_host/src/sandbox/snapshot.rs Added Debug trait to Snapshot struct
src/hyperlight_host/src/mem/shared_mem_snapshot.rs Added Debug trait to SharedMemorySnapshot struct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding some kind of "poisoned sandbox" state to prevent sandbox misuse
1 participant