Skip to content

function-wasm-v1.0.1

Choose a tag to compare

@jonasz-lasut jonasz-lasut released this 13 Nov 12:35
· 9 commits to release-function-wasm-1.0 since this release

Caution

This is a security release, and every installation of 1.0.0 should upgrade. A module could keep a run going past limits.timeout and the request's deadline, a module with an egress grant could make the runtime buffer a request body of any size, and a signature verified for a module in one repository was accepted for the same digest in another. After the upgrade a module that sleeps or blocks in a WASI call spends its limits.timeout while it waits, a wasi:http request body is at most 4 MiB, and a policy that names a repository in a non-canonical spelling stops the runtime at startup. Read "Before you upgrade".

function-wasm 1.0.1 is a security release. It fixes two ways a module could use more of the runtime than its limits allow, and several ways a module reference, a policy or a download could get past a check an operator wrote. The Input, the flags, the manifest and the world are unchanged, and a module built for 1.0.0 runs without a rebuild.

Before you upgrade

Check the repository names in your policies. The runtime now reads the registry part of every OCI reference into one canonical form, and refuses a policy, the operator's or a compositionPolicy, that names a Repository in another spelling. The operator policy is checked at startup, so run function validate with the new version against your policy file first. The refusal gives the name to write:

Repository::"GHCR.IO/acme/prod" is not the canonical name of that repository; write Repository::"ghcr.io/acme/prod"

The canonical form is a lowercase host with no trailing dot and no default port, and Docker Hub is index.docker.io, as before.

Check module references that depended on a spelling. A reference with user information in its registry part (user:password@registry/…) is refused. So are a shorthand IP address such as 127.1 and a non-ASCII host name. A registry is reached over plain HTTP only when its host is exactly localhost or a loopback IP address. A host that merely starts with one, such as localhost-registry:5000, is now reached over HTTPS.

Check modules that wait on purpose. On 1.0.0 the time a module spent asleep or blocked in a WASI call didn't count against limits.timeout. On 1.0.1 it does, and the run ends with run failed: module exceeded its execution deadline (…) when the budget is spent. A module with a retry loop that sleeps between attempts may need a higher limits.timeout, up to the runtime's --module-timeout. The time a module waits for the host's HTTP answer is still credited back.

Check modules that upload. A wasi:http request with a body over 4 MiB now fails in the guest with sandbox.egress: the request body exceeds 4194304 bytes (maxRequestBytes).

Check policies with a forbid that leaves its action unconstrained, forbid (principal, action, resource) when { … };. On 1.0.0 such a rule did nothing for composeResource, requireResource and the sandbox actions of a compositionPolicy. On 1.0.1 it applies to them, so a module whose output, reads or requirements the rule matches is refused.

Check HTTP module sources behind a redirect. A redirect to another host is followed only when that host resolves to an address outside the default block list, and the runtime connects to it directly, without a proxy. For a module behind a redirect to an address inside the cluster, specify the final URL in module.http.url.

Security

A run could outlast its deadline

The runtime enforced a run's deadline by interrupting the module's code. A module suspended in a host call executes no code, so a module that slept on a WASI clock, or blocked on a pollable, ran until that call returned, whatever limits.timeout, --module-timeout and the request's deadline said. Each such run held a thread, its memory and its run slot for as long as it waited. Any module could do it, in the default sandbox with no grant, so an installation that runs modules it doesn't fully trust was exposed: enough waiting runs stall every request the runtime serves.

1.0.1 also holds a run to the wall clock. The limit is the run's budget plus the time credited for wasi:http, never past the request's deadline, and the run ends with the deadline message whether the module is executing or not (Limits, #354).

A request body was buffered without a bound

The host read a wasi:http request body whole before it asked the egress policy about the request, outside the run's memory limit. A module with an egress grant could stream a body of any size and exhaust the pod's memory, and the destination didn't have to be one its grant admits. A module without a grant couldn't, because the runtime refuses its sends first.

1.0.1 bounds the body at 4 MiB as the host reads it, the size of the response budget. It also credits back to the deadline only the time a module waits for the host's HTTP answer, once for requests that overlap. On 1.0.0 the time a module took to send its body was credited too, which let it stretch its own deadline (HTTP egress, #354).

A verified signature was remembered by digest alone

The runtime verifies a module's signature once per process and remembers the verdict. It remembered it under the manifest digest, without the repository. The trustSigner rules decide per repository, so once a digest had been verified in a repository whose signer the policy trusts, the same digest referenced from another repository loaded without a check against that repository's rules.

1.0.1 remembers a verdict per repository and digest (Signatures, #357).

A registry had more than one spelling

The policies compared a module's location as it was written. GHCR.IO/acme/x, ghcr.io:443/acme/x and ghcr.io./acme/x reach the same repository as ghcr.io/acme/x, and none of them matched a rule written for it. Where a composite resource chooses the module, its author could use such a spelling to step around a requireSignature or forbid rule. A host that only started with localhost or 127. was also contacted over plain HTTP.

1.0.1 reads the registry part into one canonical form before any policy, signature check or message uses it, refuses a reference whose registry part isn't a host, and refuses a policy that names a repository in another spelling, as "Before you upgrade" describes (The canonical registry, #357).

A forbid of any action didn't apply to the fences

A policy layer judges composeResource, requireResource and, in a compositionPolicy, the sandbox actions only where one of its rules specifies the action. A forbid with an unconstrained action specifies none, so the layer wasn't consulted and the rule never applied: forbid (principal, action, resource) when { resource == Kind::"core/Secret" }; let a module compose a Secret.

In 1.0.1 such a rule applies to those actions without scoping them. Where no other rule specifies the action, the layer refuses what the forbid matches and permits the rest (The composition layer, #360).

Downloads and registry responses

An HTTP module or manifest download followed any redirect, so a host a policy permits could point the runtime at an address inside the cluster. The runtime now follows a redirect within the URL's origin unchanged, and to another host only at an address outside the default block list (HTTP redirects, #359).

The registry client read a manifest and a token endpoint's answer whole. A manifest is now read up to 4 MiB and a token response up to 1 MiB, and a longer one is refused (#360).

Egress block list and listeners

The default egress block list gains the prefixes that embed an IPv4 address in an IPv6 one and were missing: the local-use NAT64 prefix 64:ff9b:1::/48, 6to4 2002::/16 and Teredo 2001::/32. It also gains 192.0.0.0/24 and the benchmarking range 198.18.0.0/15. An operator dialAddress rule still permits one of them where a module needs it (HTTP egress, #359).

The metrics and health listeners waited without limit for a client's request. A connection now has five seconds to send it (#359).

World, Wasmtime and WASI versions

Serves guestfn:function@1.0.0 on Wasmtime 50.0.1: WASI 0.2.12 (cli, clocks, http, io) for the sync scaffolds and WASI 0.3.0 (cli, clocks, http) for the rust scaffold. Nothing here moved since 1.0.0.

Merged pull requests

Full changelog: function-wasm-v1.0.0...function-wasm-v1.0.1