WASI Security PEP
WASI Security Policy Enforcement Point
As described in WASI Security Policies, a Propeller task can carry its own WASI security policy that decides what the WASM workload's capabilities are, i.e. what it is authorized to do on the host system. In WASI Security Policies, this is a static policy that is predetermined when the task is created and then started.
Here we introduced a new type of Proplet plugin - WASI Security PEP (Policy Enforcement Point) - that enables plugin developers to build the WASI Security Policy in their own custom way, possibly more dynamically, based on custom input parameters provided via the metadata/elastic/wasi_pep property of a Propeller Task creation request (more info in the API reference ); and also detect policy changes during runtime in which case they may trigger a restart of the task to apply the new policy on the guest workload.
One example, in line with the ABAC and NIST Zero Trust reference architecture, is a PEP that calls a PDP (Policy Decision Point) to get decisions on which capability is permitted or not, and based on that, determines the final WASI Security Policy. An example of such plugin is THS Lightweight ABAC component's WASI PEP plugin developed in ELASTIC project, which obtains authorization decisions from a remote PDP using XACML / ACAL standard at OASIS for each capability, and is able to check periodically for changes in such decisions - and therefore in the WASI policy - over time; and if a change occurs while the workload is still running, it sends an alert to the container orchestrator to trigger a re-deployment of the workload with the new WASI policy.
For brevity, we will refer to this type of plugin simply as WASI PEP.
WASI PEP implementation
A WASI PEP shall be implemented as a Linux shared library (.so) that implements the WasiSecurityProvider interface defined in ELASTIC wasi_security Rust crate which has a single method:
fn(config: &str, workload_meta: WasmWorkloadMetadata) -> Result<WasiSecurity>When a Propeller task is started, the Propeller passes the following arguments to the method:
workload_meta(workload metadata): task/workloadid,name,inputsandenvand optionalproplet_id(asworker_node_idproperty in the structure) passed in a previous step that is the Propeller Task creation request (more info in the API reference ) as well. See also the section WASI policy creation and enforcement workflow down below.config: the JSON value of themetadata.elastic.wasi_pepproperty that was passed in a previous step that is the Propeller Task creation request (more info in the API reference and the section WASI policy creation and enforcement workflow down below); typically, this would contain, in a plugin-specific format (e.g. JSON object), the requested permissions/capabilities for that task's workload, and some other useful subject/resource/action/environment attributes - not in the aboveworkload_meta- that the PDP may need to evaluate its ABAC policy decisions for example;
As a result, the plugin shall return a WasiSecurity structure that represents the final WASI security policy as defined in WASI Security Policies and that structure is also defined in wasi_security Rust crate; it may also return an error if it fails to build the WASI policy.
Also for convenience, the plugin's log level should be configurable with PROPLET_LOG_LEVEL environment variable if this variable is defined.
WASI PEP installation
The WASI PEP is deployed on a Proplet's host. Assuming the PROPLET_PLUGIN_DIR environment variable has been set for the Proplet to the plugin directory, the WASI PEP library (.so) shall be located at $PROPLET_PLUGIN_DIR/libWasiSecurityPlugin.so. In order to preserve the name (and version) of the plugin, it is recommended to create a symbolic link from that filename to the actual WASI PEP plugin's filename:
cd $PROPLET_PLUGIN_DIR; ln -s libelastic_custom_wasi_sec_plugin-1.0.0.so libWasiSecurityPlugin.soMake sure the library file is readable by the Proplet process.
Then refer to the plugin's documentation for finishing up the installation and configuration, and finally restart the Proplet.
You may refer to ELASTIC Lightweight ABAC component's WASI PEP plugin as an example.
WASI policy creation and enforcement workflow
Task creation request with WASI PEP input (JSON object)
│
▼
Manager
│ stored at metadata.elastic.wasi_pep
▼
start payload "metadata"
│
▼
Proplet ── call plugin - get_wasi_security_instance($metadata.elastic.wasi_pep, task.id/name/inputs/env(/proplet_id)) ──▶ WasiSecurity (policy) ──▶ WasiCtxBuilder ──▶ Wasm guest- The task-specific WASI PEP input is stored on the task under the reserved metadata sub-map
metadata.elastic, as keywasi_pep. The value is any JSON value the plugin understands (passed as a string). - Only
metadata.elasticis forwarded to the Proplet — the rest ofmetadatastays manager-side. - When the task starts, the Manager lifts that sub-map onto the start payload as
metadata, so the Proplet receives it asmetadata.wasi_pep. - The Proplet passes the raw value of that property to the plugin as a string (
configparameter) before it fetches the binary or spawns anything. An error result from the plugin fails the task immediately, and the error is reported back as the task's error.
Supplying Task-specific WASI PEP input over the REST API
Technically, a plugin could take any form of input that can be serialized as JSON value in the metadata.elastic.wasi_pep. However, for this example, we assume that the input is created in a developer-friendly (even devops-friendly) form that is a YAML file.
Prerequisites
You need the following tools:
For example, on Ubuntu:
sudo snap install yq
sudo apt install jqCalling the Manager API to create and start the task
Let's assume you create the WASI PEP input in the YAML file wasi-pep-input.yaml.
export WASI_PEP_CONFIG_JSON=$(yq -o=json -I=0 ./wasi-pep-input.yaml)
# Set the MANAGER variable to your Propeller Manager URL
export MANAGER=http://localhost:7070
TASK_ID=$( curl -sS -X POST "$MANAGER/tasks" -H "Content-Type: application/json" -d "$(jq -n --arg config $WASI_PEP_CONFIG_JSON '{name: "fsprobe", metadata: {elastic: {wasi_pep: $config}}}')" | jq -r '.id')
# Upload your WASM binary (see examples at https://www.absmach.eu/docs/propeller/examples/wasi-security/) for this task
curl -sS -X PUT "$MANAGER/tasks/$TASK_ID/upload" \
-F "file=@/path/to/your/example.wasm"
curl -sS -X POST "$MANAGER/tasks/$TASK_ID/start"
# Update an existing task the same way with `PUT /tasks/{TASK_ID}` — remember that `metadata` is replaced as a whole, so send every key you want to keep:
curl -sS -X PUT "$MANAGER/tasks/${TASK_ID}" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg config $WASI_PEP_CONFIG_JSON '{name: "fsprobe", metadata: {elastic: {wasi_pep: $config}}}')"
# Read the input back:
curl -sS "$MANAGER/tasks/${TASK_ID}" | jq -r '.metadata.elastic.wasi_pep'