Cyber
Rust remediation SDK
The preview RemediationModule trait supplies customer logic after Eden selects an endpoint and request structure. It returns a decision proposal over authenticated, bounded Unix RPC. The Cybersecurity architecture describes policy selection, activation and the upstream effect boundary.
Status: draft Linux-only SDK, not a generally available package or qualified production protection. The crate is publish = false; obtain the matching reviewed source through your Eden evaluation workflow. EDNP 1.1 remediation capability assignments still require protocol-owner approval before release. Do not use a version number from this guide as a crates.io dependency.
Trait and lifecycle
The public trait is RemediationModule: Send + Sync + 'static, implemented with async_trait. Its methods are:
async fn initialize(&self) -> Result<(), HandlerErrorCode>;
async fn evaluate(
&self,
invocation: RemediationInvocation,
) -> Result<RemediationDecision, HandlerErrorCode>;
async fn shutdown(&self) -> Result<(), HandlerErrorCode>;initialize and shutdown have default successful implementations. Initialization finishes before registration/readiness. Evaluations may run concurrently, so shared state must be synchronized and bounded. Evaluation tasks settle before bounded cooperative shutdown. Process kill does not guarantee that shutdown runs; neither lifecycle hook can undo upstream effects.
RemediationInvocation contains the validated request envelope, the remaining original deadline in milliseconds and a cancellation signal. The request carries host-selected context, captures and permissions. The context binds request, deployment/worker, endpoint, operation, stage, analyzer, pattern, structural, module and binding identities, plus inspection completeness. Correlation IDs and digests are not credentials.
How one request reaches the module
- The protocol gateway parses the original request and resolves its trusted
organization, endpoint and operation. A client cannot select these identities by adding an internal-looking header.
- The prepared policy matches the canonical method/path and declared structural
observations. Its selected module leaf names a digest and entrypoint; it does not contain executable code or authorize a process.
- The host admits the binding's original application revision, immutable image,
manifest and live worker. It retains that worker's invocation lease through evaluation and the upstream effect boundary.
- The adapter extracts only the declared captures. For the example below,
has_data is a Boolean derived from decoded root-member presence, including an explicit null. The worker does not receive the original body implicitly.
- The SDK sends the versioned envelope to the installed entrypoint within the
original deadline. The module evaluates it and returns one proposal.
- The host validates the echoed context, decision permissions, sizes and current
peer authority. For Mutate, the protocol adapter applies the permitted changes and updates request framing. It refuses an invalid proposal before forwarding.
- Eden rechecks the binding and base authorization immediately before admitting
the original upstream continuation. Reject ends the selected request before that dispatch. A successful evaluation is not permission to execute a second independent upstream call.
The module cannot redirect a request to a different tenant, open an Eden-managed backend connection, mint credentials or grant itself a new field permission. It has no backend capability handles. Runtime isolation is still required to prevent an untrusted process from attempting access outside the SDK; the trait alone cannot enforce network or filesystem restrictions.
Input available to evaluate | How to use it |
|---|---|
request.context | Correlate the selected operation and immutable revisions. Treat these as host facts, not grants that can be reassigned. |
request.captures | Inspect the named values explicitly disclosed by the adapter. Distinguish missing values, null and the capture's declared type. |
request.permissions | Stay within exact mutable root-member names and permitted rejection codes. The host independently enforces the same ceiling. |
remaining_deadline_ms | Bound local computation and waits within the original request lifetime. It cannot renew the host deadline. |
cancellation | Stop cooperative work promptly. Returning a late proposal cannot recover expired authority. |
Implement a module
This is the implemented example's evaluation logic. A trusted has_data capture indicates whether a root data member exists. When the binding permits it, the module proposes removing that member; other input continues unchanged.
use async_trait::async_trait;
use eden_local_handler::{
HandlerErrorCode, JsonFieldMutation, RemediationDecision,
RemediationInvocation, RemediationModule,
};
struct StoredDefinitionOnly;
#[async_trait]
impl RemediationModule for StoredDefinitionOnly {
async fn evaluate(
&self,
invocation: RemediationInvocation,
) -> Result<RemediationDecision, HandlerErrorCode> {
if invocation.cancellation.is_cancelled() {
return Err(HandlerErrorCode::Cancelled);
}
if invocation.request.captures.get("has_data")
.and_then(serde_json::Value::as_bool) == Some(true)
{
Ok(RemediationDecision::Mutate {
changes: vec![JsonFieldMutation::Remove {
field: "data".into(),
}],
})
} else {
Ok(RemediationDecision::Continue)
}
}
}This is an evaluation excerpt, not a complete binary or a vulnerability proof. The full checked-in remediation_worker example registers stored.definition with HandlerRegistry::register_remediation, connects using WorkerClient and runs the session. The host must configure the matching capture schema; a client header or caller-supplied has_data field does not become trusted context.
From the matching source workspace:
cargo build --locked -p eden-local-handler \
--features remediation-v1 --example remediation_worker
./target/debug/examples/remediation_worker /private/runtime/worker.sockThe socket must be provisioned by the host. Running the binary does not create a binding or start protecting an application. For Runtime's explicit shared socket mount, the example accepts a numeric socket group as its second argument; use the actual provisioned group, not an arbitrary GID.
Register and run the worker
The module's logical entrypoint must match its manifest and binding exactly. These are the remaining registration and session steps from the checked-in example, used with the StoredDefinitionOnly implementation above:
use eden_local_handler::{
HandlerRegistry, LocalHandlerLimits, WorkerClient, WorkerConfig,
};
/// Connect the dedicated worker to its Runtime-provisioned local socket.
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut arguments = std::env::args_os().skip(1);
let socket = arguments.next().ok_or("expected Runtime worker socket path")?;
let mut configuration = WorkerConfig::new(socket);
if let Some(group) = arguments.next() {
configuration.socket_group = Some(
group.into_string().map_err(|_| "expected numeric socket group")?.parse()?
);
}
if arguments.next().is_some() {
return Err("expected socket path and optional shared socket group".into());
}
let limits = LocalHandlerLimits::default();
let mut registry = HandlerRegistry::new();
registry.register_remediation("stored.definition", StoredDefinitionOnly, limits)?;
WorkerClient::connect(configuration, registry).await?.run().await?;
Ok(())
}register_remediation installs this implementation in a dedicated remediation registry. WorkerClient::connect negotiates the SDK session with the host; run services its bounded invocation lifecycle. Neither step publishes the management binding. Package the separately compiled worker with the matching manifest, retain its immutable image identity, then activate it through the authorized control path described in the architecture guide.
Decisions and capture permissions
| Decision | Serialized proposal | Host obligation |
|---|---|---|
| Continue | {"decision":"continue"} | Require complete inspection and recheck current binding/base authority. |
| Reject | {"decision":"reject","status_code":403,"reason":"shape.rejected"} | Require an explicitly granted 4xx status and bounded safe reason identifier. |
| Mutate | {"decision":"mutate","changes":[{"action":"remove","field":"data"}]} | Validate every root-member change, serialize correctly and recheck authorization before continuation. |
JsonFieldMutation supports Remove { field } and Set { field, value }. Permissions name exact mutable root JSON members and permitted rejection statuses. Duplicate changes, unknown fields and ungranted members are refused. Names identify literal root members, with no nested-path or wildcard interpretation. Headers, methods, routes and destinations cannot be changed by this profile. The host updates framing atomically when applying a supported body mutation and preserves other raw member values.
There are at most 32 permitted fields/changes and 16 rejection statuses. Partial or unsupported inspection can reject, but cannot Continue or Mutate. Errors never convert to Continue. A module-generated response body is not part of the Reject decision contract.
HTTP captures can expose method, path without query values, named header presence, root-member presence, and explicitly granted root JSON values. Presence distinguishes an absent member from a member set to null. Header values and an implicit raw request body are not supplied. JSON-value capture needs an explicit host disclosure grant in addition to the manifest declaration.
For example, this typed manifest declares the example's capture and removal ceiling. Its parser digest identifies the preview JSON-root semantics, not an application binary. It must match the host adapter; do not substitute an arbitrary digest to bypass a compatibility refusal.
{
"schema_version": 1,
"module_id": "stored-definition",
"module_version": "1",
"entrypoint": "stored.definition",
"sdk": "ednp-1.1-remediation-v1",
"stage": "before_upstream",
"inputs": [{
"profile": "http1-json-root-v1",
"parser_sha256": "sha256:6a9b3f1d4a49c73031222e861430f9e34c299aeec3e7eb9a88b926f6aa1c54c7",
"captures": [{
"name": "has_data",
"input": { "source": "json_root_present", "field": "data" }
}]
}],
"permissions": { "mutable_json_fields": ["data"], "reject_statuses": [] },
"limits": {
"request_bytes": 65536,
"result_bytes": 65536,
"in_flight": 1,
"deadline_ms": 1000
}
}A valid manifest is metadata. It still needs an admitted immutable image, application revision and separately authorized binding before evaluation.
Negotiation, identity and deadlines
remediation-v1 enables local-handler-v1; both are off by default. The host must separately enable its listener. A dedicated remediation worker cannot mix final-response handlers or receive backend capability grants. Required draft semantic capability 8 is negotiated on the EDNP 1.1 carrier; unsupported peers refuse it rather than discard the contract. The SDK's internal RPC path and media type are transport details, not public HTTP endpoints.
The host obtains Linux kernel peer credentials and SO_PEERPIDFD, then asks the Runtime-owned resolver for the original process's current deployment, revision, incarnation and grants. Unsupported kernels fail closed. WorkerHello cannot assert tenant identity or issue grants. Socket permissions alone do not authenticate a workload.
The default socket is mode 0600 inside a mode-0700 directory. An explicitly provisioned shared socket uses exact mode 0660 and a verified primary group. The host repeats authority checks before readiness/invocation and after a remediation result. The gateway must still validate the current binding and base permissions immediately before upstream effects.
One original deadline covers queue waits, authority reads, RPC and evaluation. An authority read completing after expiry cannot admit a binding or validate a late result. Cancellation is cooperative inside module code and separately enforced by the host's original invocation lifetime. Do not spawn detached work as a way to extend the deadline.
Resource limits
The manifest may request lower limits; negotiated host/worker limits also apply. The manifest's maximum concurrency does not enlarge the SDK session's eight active-invocation ceiling.
| Resource | Preview ceiling |
|---|---|
| Encoded EDNP frame payload | 2 MiB. |
| HTTP request and response body bounds in the carrier | 1 MiB each; remediation captures/envelopes have lower limits. |
| Module manifest request/result envelope | 1–65,536 bytes each. |
| Manifest requested in-flight evaluations | 1–64, further limited by the session and host. |
| SDK active and queued invocations | At most 8 each per session. |
| Queue residence | At most 100 ms within the original deadline. |
| Invocation deadline | 1–30,000 ms. |
| Session retained-byte reservation ceiling | 32 MiB. |
| JSON nesting / elements per container | 16 / 1,024. |
| Session request identities before drain | 65,536. |
The 32 MiB figure bounds transport reservations, decoder bytes and handoff accounting. It is not total process RSS or an application heap limit. Decoded objects, module state, task/allocator overhead and kernel buffers require separate accounting and Runtime enforcement. Persistent and cross-worker state are not supplied by this SDK profile; process-local state is lost on restart.
Test malformed frames, duplicate/stale results, unknown capabilities, revoked authority, overload, timeout, panic, disconnect and cancellation alongside normal decisions. Real separate-process conformance does not by itself qualify a native container boundary, API rollout or CVE protection.