Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Here's what the whitelist system actually blocks, based on reading the source directly: ((ACCORDING TO A CLAUDE CODE W SOURCE ACCESS)
- ---
- Two-Phase Enforcement
- Phase 1 — Compile-time Blacklist (BlacklistCodeWalker.cs, error SB500)
- Walks Roslyn syntax trees and blocks these by name, regardless of whether you call them directly:
- - System.Runtime.CompilerServices.Unsafe.* — all unsafe ops
- - MemoryMarshal.CreateReadOnlySpan*
- - Attributes: InlineArrayAttribute, SkipLocalsInitAttribute (uninitialized stack read), UnsafeAccessorAttribute,
- UnsafeAccessorTypeAttribute, AsyncMethodBuilderAttribute (the last three are flagged as RCE vectors in comments)
- Phase 2 — IL Whitelist (AssemblyAccess.cs, error SB1000)
- After Roslyn emits IL, Mono.Cecil walks every instruction and type reference. If it's not explicitly whitelisted, the
- assembly is rejected. This also catches compiler-generated code the user didn't write directly.
- ---
- What's Blocked (Notable Items)
- What: FileStream, File, Directory, DirectoryInfo
- Why: Not in whitelist — no direct filesystem access
- ────────────────────────────────────────
- What: StreamReader(string path)
- Why: Only the Stream-based constructor is whitelisted
- ────────────────────────────────────────
- What: Path.GetFullPath, Path.GetTempPath, Path.Exists
- Why: Explicitly !-excluded from an otherwise-allowed Path.* rule
- ────────────────────────────────────────
- What: Process, Environment.Exit, most of Environment
- Why: Not in whitelist (only StackTrace and CurrentManagedThreadId are)
- ────────────────────────────────────────
- What: Thread, ThreadPool, Mutex
- Why: Not in whitelist (only Interlocked, Monitor.Enter/Exit, SemaphoreSlim, CancellationToken, Channels)
- ────────────────────────────────────────
- What: MethodInfo.Invoke, PropertyInfo.GetValue, Type.GetMethods()
- Why: Reflection is whitelisted only for metadata reading, not invocation
- ────────────────────────────────────────
- What: Activator.CreateInstance<T>() with type parameters
- Why: Only the generic parameterless form is allowed
- ────────────────────────────────────────
- What: P/Invoke / DllImport
- Why: DllImportAttribute not in whitelist; any native method triggers it
- ────────────────────────────────────────
- What: fixed (pinned vars)
- Why: Triggers UnverifiableCodeAttribute → blocked
- ────────────────────────────────────────
- What: Explicit struct layout
- Why: StructLayoutAttribute not in whitelist
- ────────────────────────────────────────
- What: Marshal / MarshalAs / FieldOffset
- Why: Not in whitelist
- ────────────────────────────────────────
- What: MemberwiseClone, Array.Clone
- Why: Explicitly !-excluded from otherwise-allowed Object.* / Array.*
- ────────────────────────────────────────
- What: ArrayPool.Shared
- Why: Explicitly !-excluded — user must create their own pool
- ────────────────────────────────────────
- What: Getting a delegate to a finalizer
- Why: IL-level check: ldftn/ldvirtftn of Finalize is blocked
- ────────────────────────────────────────
- What: Delegate constructors / CreateDelegate
- Why: Not whitelisted (only Combine/Remove/GetInvocationList/DynamicInvoke are)
- ────────────────────────────────────────
- What: GC.* except SuppressFinalize
- Why: Not in whitelist
- ────────────────────────────────────────
- What: DataAnnotations.CompareAttribute
- Why: Specifically excluded with a comment: "magic sauce that allows a property access"
- ────────────────────────────────────────
- What: Any assembly not in the allowed list
- Why: Entire assemblies like System.Diagnostics.Process, System.Net.Sockets, etc. can't be referenced at all
- ---
- What's Allowed (Key Highlights)
- - All Sandbox engine APIs (Sandbox.Engine/*, etc.) — no restrictions
- - Standard collections, LINQ, immutable/concurrent collections
- - MemoryStream, Stream, BinaryReader/Writer — in-memory IO only
- - HttpClient-related types (via Sandbox.Engine), HttpResponseMessage, content types
- - MD5, SHA1, SHA256, SHA512 hashing
- - System.Text.Json fully
- - Regex
- - async/await machinery, Task/ValueTask, CancellationToken, Channels
- - Span<T>, ReadOnlySpan<T>, Memory<T>
- - Limited System.Type (15 specific methods — enough for is, typeof, GetInterfaces, IsAssignableFrom, etc.)
- - Limited reflection for metadata reading only (property names, attribute data, parameter info)
Advertisement