feat: WebAssembly plugin support with end-to-end host invocation#65
Draft
monshri wants to merge 7 commits into
Draft
feat: WebAssembly plugin support with end-to-end host invocation#65monshri wants to merge 7 commits into
monshri wants to merge 7 commits into
Conversation
51aeb57 to
7fde6ca
Compare
Contributor
Author
|
@araujof @terylt Few things to discuss on current implementation: 1. Raw Credentials - Completely Blocked
2. SecurityExtension - TruncatedOnly 4 of 8 fields are available in WASM: Available:
Missing:
Impact: WASM plugins cannot make workload-aware or client-aware authorization decisions 3. Extension Slots - Only 4 of 13 AvailableAvailable in WASM:
Missing from WASM:
To discussFor 1, we can discuss if we want to keep it as-is or not |
888ec5d to
51b3347
Compare
Introduces the WASM plugin sandbox system: cpex-wasm-plugin (guest-side cdylib targeting wasm32-wasip2) and cpex-wasm-host (host-side runtime using wasmtime with sandbox policy enforcement, resource limits, and network filtering). Signed-off-by: Shriti Priya <shritip@ibm.com>
… functionality in wasm compilation Signed-off-by: Shriti Priya <shritip@ibm.com>
Signed-off-by: Shriti Priya <shritip@ibm.com>
Signed-off-by: Shriti Priya <shritip@ibm.com>
Signed-off-by: Shriti Priya <shritip@ibm.com>
Signed-off-by: Shriti Priya <shritip@ibm.com>
Signed-off-by: Shriti Priya <shritip@ibm.com>
51b3347 to
18988db
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WASM Plugin End-to-End Support
Resolves #21
Addresses parts of #24
Summary
Adds full WebAssembly plugin support using the WASI Component Model, enabling sandboxed plugin execution with fine-grained capability control over filesystem, HTTP, and environment access.
New crates:
cpex-wasm-plugin: Guest-side plugin crate compiled as acdylibtargetingwasm32-wasip2.Implements the WIT-defined plugin interface (evaluate-hook) with type conversions between WIT representations and Rust domain types.cpex-wasm-host: Host-side runtime using Wasmtime. Includes:sandbox_manager.rs— Resource-limited WASM execution (memory caps, CPU time limits, network allowlists)policy_loader.rs— Loads sandbox policies from YAML configfactory.rs— Instantiates WASM plugin modulesconversions.rs— Marshals types across the host/guest boundarycpex-payload— a stripped-down subset of cpex-core types specifically designed to compile to WASM.cpex-coredepends on heavy crates (async runtimes like tokio, crypto libraries, FFI layers) that don't compile to wasm32-wasip2. This crate extracts the pure data types and trait definitions needed by the plugin guest.cpex-coreexecutor/manager/registry logic, no FFI dependencies.identity_checkerplugin under src/plugins/ as a reference implementation.Cargo.tomlupdated to include the new crate.Architecture
cpex-wasm-plugincompiles plugins into a portableplugin.wasmbinary. The host (cpex-wasm-host) loads and executes the WASM plugin inside a sandboxed wasmtime environment. Enforces resource limits (fuel, memory, execution time) and network/filesystem policies. Provides a bridge to cpex-core'sPluginManagerfor integration into the hook pipeline.cpex-wasm-host— Host RuntimeLoads and executes
.wasmplugins inside a sandboxed wasmtime environment with resource limits (fuel, memory, execution time) and network/filesystem policies.sandbox_policykey). Deny-by-default when absent.cpex-coretypes and WIT types (JSON serialization for complex types at the boundary).cpex-core'sPluginFactorytrait:WasmPluginFactory→WasmBridgePlugin→WasmBridgeHandler.Usage Modes
WasmPluginFactorywith awasm://scheme, load config, invoke hooks through the standard pipeline.Details: Readme
cpex-wasm-plugin— Plugin TemplateCompiles CPEX plugins into a portable
plugin.wasmbinary, loaded and executed in the host sandbox.wit/world.wit) — Defines the host-plugin contract: a single exportedhandle-hookfunction receiving message payload, extensions, and plugin context; returns allow/deny.src/lib.rs— Plugin entry point implementing theGuesttrait; delegates to plugin logic incpex-payload.src/conversions.rs— Bidirectional type mapping between WIT flat types and rich Rust types.Details: Readme
cpex-payload— Plugin TemplateThis crate includes only the files required for plugin compilation. Compiling the entire cpex-core into a WebAssembly component caused issues, so this separation was necessary.
crates/cpex-payload/src/plugins/identity_checker.rsprovides the implementation of the plugin but withfnvsasync fn, since the WebAssembly Component Model does not yet support asynchronous calls.