Commit graph

251 commits

Author SHA1 Message Date
76839f6ec2
Merge fix/verify-packages-at-launch: verify package owner and signature before a session starts (#19) 2026-10-10 09:21:40 +02:00
9b1e7cb940
Merge fix/verify-package-trust: install only trusted packages and bind each app ID to its owner (#17) 2026-10-10 09:21:27 +02:00
af6f716823
fix(pack): let --claim-data install without HOME and test HOME refusals
Claiming data does not depend on finding earlier-layout data, so an
install that claims it no longer needs HOME. Tests cover a first launch
and a first install with an unusable HOME refusing and recording no
owner, and the security docs state the HOME requirement.
2026-10-09 14:56:42 +00:00
d3adced897
fix(appd): require a usable HOME for ownership decisions and keep records for earlier-layout data
Without an absolute HOME the earlier data layout could not be checked,
so a first-launch or install owner record was written anyway and that
data was migrated to the new owner later. Both now refuse instead.
Uninstall keeps an owner record while data exists in either layout, or
while it cannot tell. Launch tests use a private HOME, and the test
data-home cleanup never removes the running process's own.
2026-10-09 14:46:21 +00:00
95db80a86d
fix(appd): count app data in the earlier layout as existing before recording an owner
App data in the earlier layout, <home>/.local/share/weft/apps/<id>/data,
is migrated to the app data directory after the owner check, so a
trusted package from another store could be recorded as owner on its
first launch and then receive that data. Both layouts now count as
existing data, in weft-appd and in weft-pack install, so unowned data
is only given away with --claim-data. The refusal says how to claim
it. Stale test data homes are removed only when their process has
exited, and the app-data check records the owner of the data it seeds.
2026-10-09 14:41:23 +00:00
39aacac822
fix(appd): bind the launched manifest to the signature and record first owners
The manifest is now read once, and its bytes must match the verified
inventory, so a manifest swapped in around the check cannot grant
capabilities or entries the owner did not sign. A trusted package with
no owner record is recorded as its signer's on its first launch, and
app data without a recorded owner is refused rather than handed to the
first publisher, matching weft-pack's --claim-data rule. A damaged
trust store or owner record is a host error (500), and the trust store
is not consulted for development content.

Supervisor tests use a private data home and an empty trust store; the
counter check runs with a private home, and the notes check records
the owner of the data it seeds.
2026-10-09 14:36:06 +00:00
11cea5e7e3
fix(appd): verify package owner and signature before a session starts
weft-appd trusted an installed directory as installed, so content
changed after installation, or signed by a key since removed from the
trust store, still ran with the owner's app data. Before anything
starts, a package recorded as a publisher's must carry that
publisher's valid signature over its current content, with the key
still trusted; a package with no record must be signed by a trusted
key; development content, recorded by weft-pack install --dev, runs
unverified. Failures are refused with code 403.

The desktop checks trust the demo key, and the confinement check,
whose package deliberately holds a link, records it as development
content.
2026-10-09 14:29:14 +00:00
fb13a99e17
fix(pack): remove a new store directory whose mode cannot be set
A directory left private after a failed mode change would stay
unreadable to other users on every later install, since existing
directories are not touched. It is now removed again. The test's
relative store is cleaned up even when an assertion fails.
2026-10-09 14:26:43 +00:00
025388f84e
fix(pack): create relative stores and set new store modes through a no-follow descriptor
A relative store none of whose components existed failed, because the
empty ancestor was treated as a directory to create. New store
directories are now created private and set to 0755 through a
descriptor opened without following links, so a swapped path cannot
redirect the mode change. The security docs state the hard-link
protection as the kernel enforces it.
2026-10-09 14:25:09 +00:00
d67ea24004
fix(pack): create a missing store at 0755 regardless of umask
A first root install under a restrictive umask created the store and its
parents unreadable to other users even though the package inside was
0755/0644. Missing store directories are now created and set to 0755.
The copy comment and the hard-link note in the security docs describe
exactly what is checked and what the kernel enforces.
2026-10-09 14:22:37 +00:00
8221e6fc3d
fix(pack): set installed modes regardless of umask and hold one descriptor per level
Modes requested at creation were masked by the umask, so a root install
under umask 077 produced system packages other users could not read.
They are now set explicitly after creation. The copy reads each
directory's names and closes the listing before recursing, so deep
trees hold one descriptor per level. The owner-lock test now uses an
ID that would otherwise open, and the docs describe the copy check and
its device-node residual precisely.
2026-10-09 14:20:35 +00:00
181aa0fefa
fix(pack): copy packages by directory descriptor so swapped links cannot redirect the copy
Checking each file's device and inode against a path-based listing still
followed a directory replaced by a link after it was listed. The copy now
holds each source directory open and opens its entries relative to it
with O_NOFOLLOW, checking type, device and inode against the listing.
Only real packages in other stores keep an owner record, the store list
is deduplicated, archive names must be valid app IDs, and the help text
is wrapped.
2026-10-09 14:17:09 +00:00
c64ee531ee
fix(pack): take the app ID from the staged copy and check copied file identity
The app ID now comes from the staged copy, so a source changed after
validation cannot steer paths outside the store or the owners directory,
and lock_owner refuses invalid IDs. Copied files must keep the device and
inode they were listed with, and are opened without following links or
blocking on FIFOs, which no longer depends on /proc. Uninstall keeps an
owner record while another known store holds the package, and a failure
to inspect app data refuses rather than counting as no data.
2026-10-09 14:13:18 +00:00
39f7ca2a3f
fix(pack): close inventory forgery, serialize ownership changes and refuse to follow links
Names with control characters have no content digest, so a crafted name
can no longer reproduce other inventory lines and drop signed files.
Installs and uninstalls of an ID hold a per-ID lock, so a failed
concurrent install cannot remove the record of the one that won. App
data without a recorded owner goes to a new owner only with
--claim-data. Uninstall releases a record left by an interrupted
install once no data remains. Files are opened without following links
and, on Linux, must be the file that was listed.
2026-10-09 14:04:53 +00:00
d175bf012e
fix(pack): normalize installed modes and never leave a partial or orphaned owner record
Installed files take fixed modes (0644, or 0755 when executable) and
directories 0755, so a world-writable source cannot install as such.
An owner record created by an installation whose package then fails to
be placed is removed, and records are written under a temporary name
and linked into place, so they are never partial. Archives unpack into
a random private directory that is always removed. Uninstall frees an
ID only when the app data is truly absent, signatures are checked with
verify_strict, and list marks development installs.
2026-10-09 13:59:54 +00:00
88c2e9f6a5
fix(pack): install only trusted packages and bind each app ID to its owner
weft-pack install copied any package into the store: signatures were
never checked, no key was trusted for anything, any publisher could
install over another's app ID and reach its retained data, and the
signing inventory followed symbolic links, so a package could sign and
install files from outside itself.

Installation now requires a signature by a key in the trust store
($XDG_CONFIG_HOME/weft/trusted-keys and /etc/weft/trusted-keys, or
$WEFT_TRUSTED_KEYS alone). Unsigned or untrusted content installs only
with --dev, recorded as development content. The package is copied
into the store, checked and verified on that copy, and renamed into
place, so the verified bytes are the installed bytes.

The first installation of an app ID records its owner beside the app
data; later installations must have the same owner, so neither another
publisher nor a development build can take the ID over. The record
outlives uninstall while app data remains.

The content digest moves to weft_ipc_types::trust and refuses links,
special files and non-UTF-8 paths; it keeps the existing inventory
format, and both committed demo signatures still verify. Catalogs list
only directories named after their package ID. The security guide
described a signature over wapp.toml and app.wasm only; it now
describes the full inventory and the trust and ownership rules.
2026-10-09 13:49:49 +00:00
5c82b540e6
Merge fix/resolve-verified-package: resolve each launch to one package and fail closed on images (#16)
weft-appd resolves each launch once: a verified image in any store wins over a directory install and must mount or the launch is refused, with no fallback to a mutable directory. The manifest must declare the requested ID and its entries must be contained regular files without links. weft-runtime receives --module and weft-app-shell --ui; neither searches the stores. Grants come from the same manifest and the mount belongs to the session. The manifest parser and image file names are shared through weft-ipc-types with weft-pack.
2026-10-09 14:53:49 +02:00
cad8c016d6
Merge remote-tracking branch 'origin/main' into fix/resolve-verified-package 2026-10-09 12:50:31 +00:00
c0fdca18b6
Merge fix/confine-app-renderer: confine application pages to their UI files and bridge (#15)
weft-app-shell checks every resource load: files inside the UI directory, also after resolving links, inline data: and blob: resources, about:blank and the session bridge are allowed; other files and network destinations, redirects and loads not tied to the webview fail before a request leaves the renderer. The Servo pin moves to e5d9a51, which keeps pending classic scripts traced until they run and withholds navigator.servo from about:blank and about:srcdoc documents.
2026-10-09 14:50:24 +02:00
ba82535ae2
Merge remote-tracking branch 'origin/main' into fix/confine-app-renderer 2026-10-09 12:33:46 +00:00
8214c12d7e
Merge fix/session-owned-ipc-relay: make the IPC relay part of the session it serves (#14)
The session supervisor opens and owns each session's IPC relay; every exit path stops the relay task, removes its socket and unregisters its sender. A session ends when its IPC connection closes. IPC_FORWARD never waits on a component and reports an error for a missing relay or a full queue. appd's runtime directory is created mode 0700 and the relay socket 0600.
2026-10-09 14:33:28 +02:00
969f719d2d
Merge remote-tracking branch 'origin/main' into fix/session-owned-ipc-relay 2026-10-09 12:18:43 +00:00
84930b13d8
Merge fix/separate-app-data: keep app data apart from installed packages (#13)
App data lives in $XDG_DATA_HOME/weft/app-data/<id>, private to the user, and is moved from the earlier layout in one no-replace rename; conflicting or cross-filesystem data is never moved or deleted. weft-pack never removes a data directory with a package. Notes stores text exactly, refuses saves edited from a stale revision and writes through a locked, synced staging file.
2026-10-09 14:18:28 +02:00
1f58a7be11
Merge remote-tracking branch 'origin/main' into fix/separate-app-data 2026-10-09 11:57:17 +00:00
744acc8164
Merge fix/enforce-session-grants: enforce effective capability grants per session (#12)
weft-appd derives each session's grants once, before the session exists, from one shared capability vocabulary and refuses packages it cannot satisfy. weft-runtime receives them as --grant and --preopen arguments, preopens read-only directories read-only and checks every notifications, clipboard and fetch call. Fetch is limited to http and https to granted hosts, standard methods, no Host or hop-by-hop headers, unfollowed redirects and bounded time and size.
2026-10-09 13:56:57 +02:00
6f2f566fe4
Merge remote-tracking branch 'origin/fix/confine-app-renderer' into fix/resolve-verified-package
# Conflicts:
#	crates/weft-runtime/src/main.rs
2026-10-09 11:43:01 +00:00
b45fe27e9b
Merge remote-tracking branch 'origin/fix/session-owned-ipc-relay' into fix/confine-app-renderer 2026-10-09 11:37:44 +00:00
cda9c14426
Merge remote-tracking branch 'origin/fix/separate-app-data' into fix/session-owned-ipc-relay 2026-10-09 11:37:17 +00:00
b17b74f310
Merge remote-tracking branch 'origin/fix/enforce-session-grants' into fix/separate-app-data 2026-10-09 11:36:27 +00:00
12e4c1d91a
Merge remote-tracking branch 'origin/main' into fix/enforce-session-grants
# Conflicts:
#	.gitignore
#	README.md
#	docs/building.md
2026-10-09 11:30:01 +00:00
0ab429b2ea
Merge fix/authorize-session-messages: authorize WebSocket clients by role and session (#11)
weft-appd's WebSocket requires HELLO within 5 seconds. A system role authenticated with appd.systoken manages sessions; an app role authenticated with a per-session bridge token exchanges APP_MESSAGE envelopes with its own session only. The Servo hosts hand credentials only to their own top-level documents and deny navigation outside them.
2026-10-09 13:28:43 +02:00
8eed654be7
fix(appd): let no directory shadow an image, and refuse linked roots
- A verified image in any store now takes precedence over a directory
  install in any store, so a user's directory cannot shadow a system
  image of the same app.
- The package root must be a directory and wapp.toml a regular file,
  not links to content outside the root the entries are checked in.
- Incomplete or malformed image metadata is refused with 403; a
  missing helper, a failed mount or an unreadable manifest with 500.
- A supervisor test records the arguments of both children and
  requires the resolved component and UI document.

The documentation states that the root hash is read from the store
and not yet authenticated.
2026-10-09 11:08:41 +00:00
04cde8901c
Merge remote-tracking branch 'origin/fix/confine-app-renderer' into fix/resolve-verified-package 2026-10-09 10:29:32 +00:00
fecf4c5b55
fix(app-shell): report a UI path that is not absolute 2026-10-09 10:29:32 +00:00
1641bf31a8
build(servo): trace pending classic scripts instead of rooting them
Servo e5d9a51 replaces the root that kept a pending classic script
alive with tracing through the document that holds it. A root also
kept the script's global alive, so a document dropped while a script
was pending would leak. The crash the root fixed stays fixed.
2026-10-09 10:29:24 +00:00
e2f9746fb5
Merge remote-tracking branch 'origin/fix/confine-app-renderer' into fix/resolve-verified-package
# Conflicts:
#	docs/architecture.md
2026-10-09 10:18:47 +00:00
d056045ad8
test(appd): launch complete packages in the supervisor tests
Launch tests wrote manifests without names, versions or entries, which
the shared parser rejects. They now write complete packages.
2026-10-09 10:18:36 +00:00
687439a2a3
test(frame): make the worker and srcdoc confinement probes observable
Servo refuses worker scripts for file: pages, blob: ones included, so
the worker probe now requires only that no worker fetch succeeds, and
the worker is built from the page itself. The srcdoc frame reports to a
listener installed before the frame exists. Band failures and requests
that reached the servers are reported together, so a run without the
policy shows every leak.
2026-10-09 10:16:22 +00:00
2148ffc8ae
fix(appd): resolve each launch to one package and fail closed on images
The runtime, the app shell and grant derivation each searched the
package stores and parsed wapp.toml on their own, so they could use
different roots; the runtime ignored [runtime].module, the image loader
looked for companion files the builder never wrote, and a failed image
mount fell back to the mutable directory install.

weft-appd now resolves a launch once: a verified image wins over a
directory in the same store, and when any image file exists the image
must mount or the launch is refused. The manifest must declare the
requested ID, and both entries must be plain relative paths to regular
files without links. The runtime receives --module and the app shell
--ui; neither looks for the package. Grants come from the same
manifest, and the mount belongs to the session.

The manifest parser and the image file names move to weft-ipc-types,
shared with weft-pack, whose check now applies the same entry rules.
Mapper devices are named after their per-launch mountpoint, so
concurrent sessions no longer collide.
2026-10-09 10:03:40 +00:00
16a184ad9e
fix(app-shell): close the remaining paths out of the application page
Review of the renderer policy found loads it did not see or judged
wrongly:

- Loads Servo does not attribute to the webview, such as
  navigator.sendBeacon(), reached the network. They are all refused.
- On a redirect Servo reports the first URL again, so every redirect
  is refused.
- A symbolic link inside the UI directory led anywhere on disk; file
  loads are checked again after resolving links.
- Only about:blank is allowed among about: URLs.

The Servo pin moves to 5d90f51, which keeps compiled classic scripts
rooted until they run (a parser-blocking script waiting for a failed
stylesheet import crashed the content process) and withholds
navigator.servo from about:blank and about:srcdoc documents.

The confinement check gains probes for links, workers, beacons,
imports, fonts and srcdoc frames, and its WebSocket server completes
the handshake. The slow stylesheet's delay now starts when the host
first tries to open it.
2026-10-09 10:03:30 +00:00
d60152f443
fix(app-shell): confine application pages to their UI files and bridge
An application page could load any local file through file: URLs and
reach any network destination with images, fetch, XHR or WebSockets,
bypassing the component's fetch grants. The shell now checks every
resource load: files inside the UI directory, inline data:, blob: and
about: resources and the session bridge are allowed; anything else
fails with a network error before a request leaves the renderer.

tests/frame/check_confinement.py probes each path on the nested desktop
and requires that no HTTP request or TCP connection reaches the host.
The frame check's slow stylesheet becomes a file next to the page held
back with a file lease, so it stays inside the confined scope.
2026-10-09 09:39:37 +00:00
010573eb16
fix(appd): create the runtime directory private wherever it is made
appd created $XDG_RUNTIME_DIR/weft with the umask mode when it opened
its own socket, wrote its port or system token, or opened a portal
socket, so the 0700 mode requested for session sockets never applied.
All of them now use one helper that creates the directory 0700 and
tightens an existing one.
2026-10-09 09:27:28 +00:00
ec00531c75
test(appd): give each test process its own runtime directory
Session sockets are named by session ID and every test registry starts
at 1, so test processes running at the same time shared one socket path
in the common test runtime directory and broke each other's sessions.
Each test process now uses its own directory under the system temporary
directory, and directories of ended test processes are removed. The
test of a closed IPC connection connects to the socket itself instead
of relying on python3 in a child script.

A session whose component closes its IPC connection during startup now
stops before it is reported ready. The weft runtime directory is
created with mode 0700, and the socket is removed if its permissions
cannot be restricted.
2026-10-09 09:24:49 +00:00
67bce2fb22
Merge branch 'main' into fix/authorize-session-messages 2026-10-09 09:19:26 +00:00
5174a58d47
Merge pull request #9: report sessions running only after the UI host is ready
Sessions become Running only after token-authenticated READY from the runtime and the app shell, and every exit path shares one teardown.
2026-10-09 11:19:16 +02:00
818a831895
Merge pull request #6: stop reporting readiness without an engine
A runtime built without wasmtime-runtime now exits with an error instead of printing READY; its env-dependent tests are serialised.
2026-10-09 11:19:13 +02:00
26bd5b5079
fix(appd): end sessions whose IPC connection closes and never block on it
IPC_FORWARD held the registry lock while awaiting a send to the
component; with a full queue it stalled appd, and once the relay was
closed it locked the registry again and deadlocked. It now sends without
waiting and reports an error when the session has no relay or its queue
is full.

A relay whose component disconnected left the session running with no
way to exchange messages. The session now stops when its IPC connection
closes. The relay releases its task and socket when dropped, so a
cancelled supervisor leaks neither, and the socket is created with mode
0600.

New tests fail against the previous code: IPC_FORWARD against a missing
relay and a full queue must answer at once, and a runtime that closes
its IPC connection while still running must end its session. The test
runtime directory lives under target/ instead of one directory per run.
2026-10-09 09:18:39 +00:00
ac6559a814
Merge pull request #10: add the stability blueprint, engineering contract and contributor toolkit
BLUEPRINT.md defines the 0.1.0 target; AGENTS.md and .agents/ give the contribution procedures and checks.
2026-10-09 11:14:20 +02:00
d9d9d24205
fix(appd): make the IPC relay part of the session it serves
dispatch opened each session's IPC socket and registered its sender
before the supervisor existed, and nothing released them: a relay whose
runtime never connected waited forever with its socket file in place,
and every stopped session left its sender registered, so app messages
for it were still accepted and queued.

The supervisor now opens the relay after its early checks, and the
session owns it: every exit path stops the relay task, removes the
socket and unregisters the sender. A session whose socket cannot be
opened does not start. The relay accepts a single connection.

A dispatch-level test launches a package whose runtime reports ready
and exits without connecting; it requires the stopped session to leave
no sender and no socket, and fails against the previous code. The
Counter and Notes checks pass end to end.
2026-10-09 09:11:35 +00:00
481495d929
fix(notes): show loading status and check the editor after a failed load
The first load showed an empty status while the editor was read-only;
it now says loading. check_notes.py also types and saves after a failed
load and requires the stored file to stay unchanged.
2026-10-09 09:07:27 +00:00