@@ -83,6 +83,8 @@ pub enum HyperlightError {
83
83
ExecutionAccessViolation ( u64 ) ,
84
84
85
85
/// Guest execution was cancelled by the host
86
+ ///
87
+ /// **This error poisons the sandbox.** See [`crate::MultiUseSandbox::clear_poison()`] for recovery options.
86
88
#[ error( "Execution was cancelled by the host." ) ]
87
89
ExecutionCanceledByHost ( ) ,
88
90
@@ -95,6 +97,8 @@ pub enum HyperlightError {
95
97
FieldIsMissingInGuestLogData ( String ) ,
96
98
97
99
/// Guest aborted during outb
100
+ ///
101
+ /// **This error poisons the sandbox.** See [`crate::MultiUseSandbox::clear_poison()`] for recovery options.
98
102
#[ error( "Guest aborted: {0} {1}" ) ]
99
103
GuestAborted ( u8 , String ) ,
100
104
@@ -196,6 +200,36 @@ pub enum HyperlightError {
196
200
#[ error( "Failure processing PE File {0:?}" ) ]
197
201
PEFileProcessingFailure ( #[ from] goblin:: error:: Error ) ,
198
202
203
+ /// The sandbox is poisoned due to an inconsistent internal state that could lead to
204
+ /// undefined behavior, memory corruption, or security vulnerabilities.
205
+ ///
206
+ /// ## What causes poisoning?
207
+ ///
208
+ /// Sandbox poisoning occurs when operations leave the sandbox in an inconsistent state:
209
+ ///
210
+ /// ### Guest Function Panics/Aborts
211
+ /// - **Heap Memory Leaks**: When a guest function panics or aborts, the call stack is not
212
+ /// properly unwound, leaving heap allocations permanently leaked
213
+ /// - **Resource Leaks**: File handles, network connections, or other resources may remain
214
+ /// open and unreachable
215
+ /// - **Partial State Updates**: Data structures may be left in an inconsistent state
216
+ /// (e.g., half-updated linked lists, corrupted hash tables)
217
+ ///
218
+ /// ### Interrupted Function Calls
219
+ /// When you interrupt an in-progress guest function with [`InterruptHandle::kill()`]:
220
+ /// - **Memory Allocations**: Heap memory allocated during the call remains leaked
221
+ /// - **Mutex/Lock State**: Guest-side mutexes may remain locked, causing deadlocks
222
+ /// - **I/O Buffers**: Partially written buffers may contain corrupted data
223
+ /// - **Global State**: Static variables may be left in an inconsistent state
224
+ ///
225
+ /// ## Recovery
226
+ ///
227
+ /// - **Safe**: Restore from a non-poisoned snapshot using [`MultiUseSandbox::restore()`]
228
+ /// - **Unsafe**: Clear poison manually with [`MultiUseSandbox::clear_poison()`] (only if you
229
+ /// understand the inconsistent state and have manually resolved it)
230
+ #[ error( "The sandbox was poisoned" ) ]
231
+ PoisonedSandbox ,
232
+
199
233
/// Raw pointer is less than base address
200
234
#[ error( "Raw pointer ({0:?}) was less than the base address ({1})" ) ]
201
235
RawPointerLessThanBaseAddress ( RawPtr , u64 ) ,
0 commit comments