What are WASM Policies?
WASM (WebAssembly) policies are custom validation rules that run in a secure sandbox environment using Chainloop’s experimental WASM policy engine. This is an alternative to Chainloop’s default Rego-based policy engine. Unlike Rego policies (the default), WASM policies let you write validation logic in familiar programming languages like Go or JavaScript, with full access to standard libraries and ecosystem tools. Key benefits of WASM policies:- Write policies in Go or JavaScript using high-level SDKs
- Access to language ecosystems (JSON parsing, HTTP clients, etc.)
- Type safety and IDE support
- Secure execution in WebAssembly sandbox
- Portable across platforms
When to Use WASM vs Rego
| Feature | WASM Policies (Experimental) | Rego Policies (Default) |
|---|---|---|
| Status | Experimental preview | Production-ready default |
| Languages | Go, JavaScript, Rust, etc. | Rego only |
| Learning Curve | Use familiar languages | Learn Rego syntax |
| Libraries | Full language ecosystem | Limited built-ins |
| Type Safety | Full type checking | Dynamic typing |
| Performance | Fast (native code) | Fast (optimized) |
| Sandbox | WASM isolation | OPA runtime |
- You need complex logic with external libraries
- Your team prefers Go/JavaScript over Rego
- You need HTTP API integration
- You want strong type safety and IDE support
- You’re willing to use experimental features
- You want production-ready, stable policy engine
- You need declarative policy syntax
- Your policies are simple queries and filters
- You’re already familiar with OPA/Rego
- You prefer the standard, widely-adopted approach
How WASM Policies Work
Execution Architecture
WASM policies run in a host/guest architecture where:- Host (Chainloop): The policy engine that loads and executes WASM modules
- Guest (Policy): Your WASM policy code running in an isolated sandbox

- In-process execution: Policies run embedded in the control plane process (not as sidecars)
- Sandboxed environment: WebAssembly isolation prevents filesystem access and unsafe operations
- Single-threaded: Each policy execution is single-threaded and deterministic
- Bytes-in/bytes-out: Material data flows through a simple byte interface
- Host functions: Controlled capabilities (HTTP, discovery) exposed by Chainloop
Technology Stack
Chainloop WASM policies are powered by Extism, a universal plugin system that allows policies written in different languages to run securely in WebAssembly sandboxes. Why Extism?- Multi-language support: Extensible architecture for multiple languages
- Security: WASM sandbox isolates policies from the host system
- Performance: Fast in-process execution with minimal overhead
- Portability: Same policy runs anywhere WASM is supported
- Flexible serialization: Supports JSON, Protocol Buffers, and other formats
- Go: Built on extism/go-pdk - Provides idiomatic Go APIs
- JavaScript: Built on extism/js-pdk - Runs JS in QuickJS WASM runtime
While Extism supports additional languages (Rust, Python, C#, etc.), Chainloop currently provides official SDKs for Go and JavaScript only. Additional language support is planned for future releases.
Quick Start
1. Choose Your Language
2. Create Your First Policy
Here’s a minimal policy that validates a string message:3. Build the Policy
4. Create Policy Configuration
Create apolicy.yaml file:
5. Test Locally
Create test data (test.json):
Policy Result States
Every policy execution returns one of three states:Success
Material passes all validation rules.Fail
Material violates one or more rules. Include specific violation messages.Skip
Policy doesn’t apply to this material (wrong format, missing fields, etc.).Testing Workflow
- Write the policy in Go or JavaScript
- Build to WASM using TinyGo or extism-js
- Test locally with
chainloop policy devel eval - Iterate based on test results
- Deploy to Chainloop once validated
