From 69f343baf60ec6e21837cf7f8f3ab7d0644ceb05 Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Thu, 15 Oct 2026 11:53:48 +0000 Subject: [PATCH] feat(nfs): import files added over the NFS share While nfs.add_files is on, rclone serves NFS without --read-only and with a VFS write cache under data_dir/cache/nfs: a file written to the share is put to Lens's own S3 server once it's closed, with the share's service key, and imported as nfs.account adds it. The S3 server tells the NFS key apart (file_key.service) so NFS writes follow nfs.add_files and are audited as coming over NFS. Off, the share is read-only as before; changing the setting restarts rclone. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_013sC1p4dJXjteytbxDXnk5g --- CHANGELOG.md | 5 +++ README.md | 4 +- docs/file-shares.md | 39 ++++++++++++++----- docs/file-tree.md | 15 ++++--- docs/requirements.md | 2 +- fastapi_backend/app/domain/nfs_share.py | 31 +++++++++------ fastapi_backend/app/domain/s3.py | 8 ++-- fastapi_backend/app/domain/settings.py | 6 +-- fastapi_backend/app/domain/store.py | 1 + fastapi_backend/app/schemas/admin.py | 1 + fastapi_backend/tests/api/test_s3_writes.py | 17 ++++++++ .../tests/domain/test_nfs_share.py | 13 +++++-- .../app/openapi-client/types.gen.ts | 6 +++ nextjs-frontend/components/settings/model.ts | 13 +++++-- nextjs-frontend/openapi.json | 6 +++ threat-model.json | 6 +-- threat-model.md | 8 ++-- threat-model.yaml | 10 ++--- 18 files changed, 137 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 435ba5864..35c81d4b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,11 @@ The backend (`fastapi_backend`) and the frontend (`nextjs-frontend`) are version sign-in link from email or an admin. Now Profile and sign-in › Passkeys lists Lens's other addresses with **Open signed in**, which opens one with a 15-minute sign-in link of your own, where one fingerprint adds a passkey for it ([Authentication](docs/authentication.md#signing-in-passkeys)). +- **Files added over NFS are imported.** A file copied into a collection's folder on the NFS share is imported a moment + after it's closed, as the account the share shows the tree as (`nfs.account`), with the same checks as an upload. + rclone keeps files being written in a cache on Lens's disk and puts them to Lens once they're closed; a file Lens + can't take shows in the share's log. **Import files people add** in Settings, NFS share (`nfs.add_files`, on) turns it + off and serves the share read-only again ([Adding files](docs/file-shares.md#adding-files)). - **Export a conversation.** `GET /api/v1/chats//export.md`, `.pdf` or `.json` gives the version showing, one message (`?message=`) or, as JSON, every version (`?all=true`). The Markdown has each question and answer, its citations as footnotes linking back to the moment in Lens and the tools it used; the PDF is that Markdown printed by diff --git a/README.md b/README.md index 3fbf3d4a2..c28537588 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,8 @@ listed under [In progress](#in-progress), and what comes next under [Planned](#p answer OpenAI's chat completions API for any app, cited from that namespace alone, each off until its owner turns it on, with API keys that open that one namespace and nothing else. The same folders and files can be mounted over S3, WebDAV, NFS or SMB (S3 and WebDAV also at the web app's address, through remote access), so file managers and scripts - read Lens too, and a file copied in over S3, WebDAV or SMB is imported where it was put. The web app runs on the same - REST API, so an agent can do what a person can. ([MCP](docs/mcp.md), [one namespace's MCP + read Lens too, and a file copied into any of them is imported where it was put. The web app runs on the same REST + API, so an agent can do what a person can. ([MCP](docs/mcp.md), [one namespace's MCP server](docs/mcp.md#one-namespaces-mcp-server), [chat completions](docs/api.md#chat-completions-for-any-app), [API](docs/api.md), [the graph as files](docs/file-tree.md), [authentication](docs/authentication.md); [checks](docs/requirements.md#connect-your-agents)) diff --git a/docs/file-shares.md b/docs/file-shares.md index 2cca12062..fe3887cf2 100644 --- a/docs/file-shares.md +++ b/docs/file-shares.md @@ -7,20 +7,22 @@ and assets are files inside them. ## NFS Settings → NFS share → **Share the file tree over NFS**. It's off until you turn it on, and then a worker starts -serving within seconds. The share is **read-only**. +serving within seconds. A file copied into a collection's folder is imported there, as the share's account +([Adding files](#adding-files)); turn **Import files people add** off and the share is read-only. -Mount it on Linux (Settings shows the command with your port filled in): +Mount it on Linux (Settings shows the command with your port filled in; add `ro` to only read): ```sh -sudo mount -t nfs -o port=12049,mountport=12049,tcp,vers=3,ro :/ /mnt/lens +sudo mount -t nfs -o port=12049,mountport=12049,tcp,vers=3 :/ /mnt/lens ``` -On macOS: `sudo mount -t nfs -o port=12049,mountport=12049,tcp,vers=3,ro,resvport :/ /Volumes/lens`. +On macOS: `sudo mount -t nfs -o port=12049,mountport=12049,tcp,vers=3,resvport :/ /Volumes/lens`. | Setting | Default | What it does | | --- | --- | --- | | `nfs.enabled` | off | Serve the share | -| `nfs.account` | the first admin | Whose view of the tree the share shows: it holds exactly what that person sees in the web app | +| `nfs.account` | the first admin | Whose view of the tree the share shows: it holds exactly what that person sees in the web app, and files written to it are added as that person | +| `nfs.add_files` | on | Import the files written to the share (**Import files people add**); off, rclone serves it read-only | | `nfs.allowed_networks` | private networks (`10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `127.0.0.0/8`, `fc00::/7`, `::1/128`) | Machines anywhere else are turned away before they read anything; changes apply without a restart | | `nfs.port` | 2049 | The port inside Lens (with Docker, inside the worker container) | @@ -34,18 +36,34 @@ on its own while the web app stays local. NFS (version 3) trusts the network: there is no password, passkey or token. So Lens: - serves nothing until an admin turns it on; -- serves it read-only, so nothing reaching the share can change the archive; +- adds files only as one account may (`nfs.account`), checked as uploads are, and never writes over, renames or + deletes what Lens made; with `nfs.add_files` off it serves the tree read-only, so nothing reaching the share can + change the archive; - shows one account's view (`nfs.account`), never more than that person may see; pick an account that sees only what the share should show (a member of just the namespaces or collections to share), not an admin, when the network has - people who shouldn't see everything; + people who shouldn't see everything, or add to everything; - turns away every client outside `nfs.allowed_networks`, and counts them in Settings. -Anyone on an allowed network can read the share, and an address on the local network can be spoofed, so list only your -own networks, and keep the port off the internet. +Anyone on an allowed network can read the share and add files to it as its account, and an address on the local +network can be spoofed, so list only your own networks, and keep the port off the internet. + +### Adding files + +Copy files into a collection's folder (`cp` onto the mount, or a file manager) and each is imported as an upload is, +as the share's account: the same checks of its type and size, the namespace's pipeline, and the same file twice is +added once. A file anywhere else in a namespace goes to its default collection, and one written inside a new folder +under `Collections` makes that collection ([Adding files](file-tree.md#adding-files) has the rest). + +rclone keeps a file being written in a cache on Lens's disk (`data_dir/cache/nfs`) and puts it to Lens a couple of +seconds after it's closed, so it shows up in Lens a moment later. NFS has no way to tell the client that Lens turned a +file down after it was written, so a file Lens can't take (its type, its size) shows in Settings → NFS share's log, +and rclone tries it again later. An empty new folder lasts as long as rclone remembers it; it becomes a +collection when a file is written into it. ### How it works -A worker runs `rclone serve nfs --read-only` (rclone is in Lens's image already; MIT licensed) over Lens's own S3 +A worker runs `rclone serve nfs` (rclone is in Lens's image already; MIT licensed; `--read-only` while +`nfs.add_files` is off) over Lens's own S3 server (a copy on 127.0.0.1 inside the worker, so the S3 share itself needn't be on), signed in with an S3 key made for `nfs.account`, which is revoked when the share stops. rclone listens on 127.0.0.1 inside the container; a small relay in Lens (`domain/share_relay.py`) holds the published port and hands rclone only the connections from allowed @@ -58,3 +76,4 @@ state at `GET /api/v1/settings/nfs/status` and change it with `PUT /api/v1/setti - NFS version 4 and Kerberos (sec=krb5) for a share with a real login. - A share per namespace or collection, each with its own account and networks. - Packaging for the Synology and QNAP compose files, which don't publish the port yet. +- Tell the client when Lens turns a written file down, and make empty new folders collections at once. diff --git a/docs/file-tree.md b/docs/file-tree.md index d30928a6e..ccb7ce69c 100644 --- a/docs/file-tree.md +++ b/docs/file-tree.md @@ -3,14 +3,14 @@ Lens shows its graph as an ordinary tree of folders and files: graph nodes (collections, topics, entities) are folders, nested along the graph's links, and every asset (a recording, document or image) is a few files inside the folders it belongs to, its metadata in a sidecar beside it. Agents and tools that already understand files can read -Lens without learning its API, and add to it the same way: a file copied into a collection's folder over S3, WebDAV or -SMB is imported there ([Adding files](#adding-files)). +Lens without learning its API, and add to it the same way: a file copied into a collection's folder over S3, WebDAV, +SMB or NFS is imported there ([Adding files](#adding-files)). | Where | Status | | --- | --- | | The API (`GET /api/v1/tree`, `GET /api/v1/tree/file`) and the MCP tools `list_files` and `read_file` | built | | An [S3 server](#s3) and a [WebDAV server](#webdav) (off until turned on); files added through them are imported | built | -| An [NFS share](file-shares.md) (read-only, off until turned on, allowed networks only) | built | +| An [NFS share](file-shares.md) (off until turned on, allowed networks only); files added through it are imported | built | | An [SMB share](smb.md) (off until turned on); files added through it are imported | built | Every way in serves the same tree, built by `app/domain/filetree.py`. @@ -47,7 +47,8 @@ Names are made safe for every file system: `/ \ : * ? " < > |` and control chara Exactly what the web app shows them ([Access](access.md)): an admin sees every namespace; others see the namespaces they have a role in, and in a namespace where they only have roles on some collections, those collections and the topics and entities of the assets in them (with the topics broader than those). Anything else answers "not found". The API only -reads; files are added through the [S3](#s3) and [WebDAV](#webdav) servers and the [SMB share](smb.md). +reads; files are added through the [S3](#s3) and [WebDAV](#webdav) servers and the [SMB](smb.md) and +[NFS](file-shares.md) shares. ## The API @@ -118,7 +119,8 @@ behind TLS on a network you don't trust. ## Adding files -A file copied into the tree over S3, WebDAV or [SMB](smb.md) is imported, as an upload in the web app is: the same checks of its type +A file copied into the tree over S3, WebDAV, [SMB](smb.md) or [NFS](file-shares.md) is imported, as an upload in the +web app is: the same checks of its type and size (Settings, Uploads), the namespace's pipeline, and the same file twice is added once. Where it's put decides where it goes: @@ -144,7 +146,8 @@ kept on the uploads disk, in memory per worker, so a restart forgets them. Adding files is on whenever the shares are; turn it off in Settings, File shares (**Import files people add**, `shares.add_files`) and they're read-only again. `GET /api/v1/shares/s3` says whether it's on (`add_files`). The SMB -share has its own switch (`smb.add_files`, on). The [NFS](file-shares.md) share stays read-only for now. +and NFS shares have their own switches (`smb.add_files` and `nfs.add_files`, on); NFS adds files as the account it +shows the tree as, since NFS has no login. ## At the web app's address diff --git a/docs/requirements.md b/docs/requirements.md index 8e083416c..73326093f 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -66,7 +66,7 @@ request, to another check that proves the same thing; loosening a requirement or | API keys that open one namespace and nothing else | [test_namespace_keys.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_namespace_keys.py) `test_a_key_for_one_namespace_opens_its_servers_alone`, `test_it_has_the_persons_role_there_and_no_more` | | The graph's folders and files mounted read-only over S3, WebDAV, NFS and SMB | [test_s3.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_s3.py) `test_people_read_their_namespaces_over_s3`, `test_what_s3_refuses`; [test_webdav.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_webdav.py) `test_mount_and_read`, `test_what_webdav_refuses`; [test_nfs_share.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/domain/test_nfs_share.py) `test_the_runner_follows_the_setting`; [test_smb_share.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/domain/test_smb_share.py) `test_reads_the_tree_as_its_key_sees_it`, `test_nothing_can_be_written` | | S3 and WebDAV at the web app's address, through remote access, once an admin allows it | [test_s3.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_s3.py) `test_at_the_web_apps_address_once_an_admin_allows_it`; [test_webdav.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_webdav.py) `test_at_the_web_apps_address_once_an_admin_allows_it`, `test_through_the_web_app_each_visitor_has_its_own_throttle` | -| A file copied in over S3, WebDAV or SMB is imported where it was put, with an upload's checks and permissions | [test_s3_writes.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_s3_writes.py) `test_a_file_put_into_a_collection_is_imported_there`, `test_folders_become_collections`, `test_multipart_uploads`, `test_what_may_not_be_added_is_refused`, `test_files_added_at_the_web_apps_address`; [test_webdav_writes.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_webdav_writes.py) `test_finder_copies_a_file`, `test_windows_copies_a_file`, `test_a_folder_dragged_in_becomes_collections`, `test_what_may_not_be_added_is_refused`; [test_smb_writes.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/domain/test_smb_writes.py) `test_a_file_copied_into_a_collection_is_imported_there`, `test_new_folders_under_collections_are_new_collections`, `test_what_may_not_be_added_is_refused`, `test_the_share_is_read_only_while_add_files_is_off` | +| A file copied in over S3, WebDAV, SMB or NFS is imported where it was put, with an upload's checks and permissions | [test_s3_writes.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_s3_writes.py) `test_a_file_put_into_a_collection_is_imported_there`, `test_folders_become_collections`, `test_multipart_uploads`, `test_what_may_not_be_added_is_refused`, `test_files_added_at_the_web_apps_address`; [test_webdav_writes.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_webdav_writes.py) `test_finder_copies_a_file`, `test_windows_copies_a_file`, `test_a_folder_dragged_in_becomes_collections`, `test_what_may_not_be_added_is_refused`; [test_smb_writes.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/domain/test_smb_writes.py) `test_a_file_copied_into_a_collection_is_imported_there`, `test_new_folders_under_collections_are_new_collections`, `test_what_may_not_be_added_is_refused`, `test_the_share_is_read_only_while_add_files_is_off`; [test_s3_writes.py](https://github.com/adeelahmad/lense/blob/main/fastapi_backend/tests/api/test_s3_writes.py) `test_the_nfs_shares_key_follows_nfs_add_files` (NFS adds through rclone's S3 client) | | The web app runs on the same REST API, through a client generated from its OpenAPI schema | [ci.yml](https://github.com/adeelahmad/lense/blob/main/.github/workflows/ci.yml) `OpenAPI schema is up to date` | ## Ask, and get cited answers diff --git a/fastapi_backend/app/domain/nfs_share.py b/fastapi_backend/app/domain/nfs_share.py index 8f3d6139a..e4fbd6393 100644 --- a/fastapi_backend/app/domain/nfs_share.py +++ b/fastapi_backend/app/domain/nfs_share.py @@ -1,9 +1,11 @@ -"""The file tree over NFS (docs/file-tree.md, NFS): graph nodes as folders and assets as files, read-only, for the -machines on the networks you allow (Settings → NFS share). - -Off by default. Turned on, one worker runs `rclone serve nfs --read-only` (rclone is in Lens's image already) over -Lens's own S3 server, signed in with an S3 key made for the account the share shows the tree as (`nfs.account`; -nobody picked: the first admin), so the share shows exactly what that person sees in the web app and nothing else. +"""The file tree over NFS (docs/file-tree.md, NFS): graph nodes as folders and assets as files, for the machines on +the networks you allow (Settings → NFS share). + +Off by default. Turned on, one worker runs `rclone serve nfs` (rclone is in Lens's image already) over Lens's own S3 +server, signed in with an S3 key made for the account the share shows the tree as (`nfs.account`; nobody picked: the +first admin), so the share shows exactly what that person sees in the web app and nothing else. While `nfs.add_files` +is on, rclone keeps files being written in a cache on disk and puts each one to the S3 server once it's closed, where +it's imported as that account adds it (share_import.py); off, rclone serves it --read-only. NFS has no sign-in of its own, so rclone listens on 127.0.0.1 only and a relay (share_relay.py) on the published port lets in only `nfs.allowed_networks`. @@ -16,6 +18,7 @@ import datetime as dt import json import os +import pathlib import shutil import socket import subprocess @@ -68,8 +71,9 @@ def status(db, cfg): "refused": s.get("refused") or 0, "log": s.get("log") or [], "process": s.get("owner") if live else None, - "mount": f"sudo mount -t nfs -o port={published},mountport={published},tcp,vers=3,ro :/ /mnt/lens", + "mount": f"sudo mount -t nfs -o port={published},mountport={published},tcp,vers=3{'' if c['add_files'] else ',ro'} :/ /mnt/lens", "rclone": bool(rclone_binary()), + "add_files": bool(c["add_files"]), } @@ -198,8 +202,13 @@ def _start(self, cfg, c): account = _account(self.db, c) remote, env_extra = self.remote(self.db, self.cfg_fn, account) inner = _free_port() - cmd = [exe, "serve", "nfs", remote, "--addr", f"127.0.0.1:{inner}", "--read-only", "--vfs-cache-mode", "off", - "--dir-cache-time", "30s", "--no-checksum"] # fmt: skip + cmd = [exe, "serve", "nfs", remote, "--addr", f"127.0.0.1:{inner}", "--dir-cache-time", "30s", "--no-checksum"] + if c["add_files"]: # files are written to a cache on disk, then put to the S3 server (imported) once closed + cache = pathlib.Path(cfg["data_dir"]) / "cache" / "nfs" + cache.mkdir(parents=True, exist_ok=True, mode=0o700) + cmd += ["--vfs-cache-mode", "writes", "--cache-dir", str(cache), "--vfs-write-back", "2s", "--vfs-cache-max-age", "10m"] + else: + cmd += ["--read-only", "--vfs-cache-mode", "off"] env = {**os.environ, **env_extra} # the key in the environment, not on the command line where `ps` shows it self.proc = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1) threading.Thread(target=self._read, args=(self.proc,), daemon=True, name="nfs-rclone-log").start() @@ -218,7 +227,7 @@ def _start(self, cfg, c): raise ShareError(f"port {c['port']}: {e.strerror or e}") from None self.account, self.account_id = account.get("email"), account["id"] self.phase, self.error, self.fails = "running", None, 0 - self.log(f"nfs: serving the file tree as {self.account} on port {self.relay.port}") + self.log(f"nfs: serving the file tree as {self.account} on port {self.relay.port}" + ("" if c["add_files"] else " (read-only)")) def _drop_key(self): aid, self.account_id = self.account_id, None @@ -243,7 +252,7 @@ def tick(self): if self.proc or self.relay: self.stop_serving() return - sig = json.dumps([c["port"], c["account"], c["bind"]]) + sig = json.dumps([c["port"], c["account"], c["bind"], c["add_files"]]) if sig != self.sig: self.stop_serving() self._drop_key() diff --git a/fastapi_backend/app/domain/s3.py b/fastapi_backend/app/domain/s3.py index dc5a45e1c..cf1095c97 100644 --- a/fastapi_backend/app/domain/s3.py +++ b/fastapi_backend/app/domain/s3.py @@ -226,7 +226,7 @@ def _amz_time(s): def verify(db, cfg, method, raw_path, pairs, headers, now=None, chunks=None): """Check a request's signature; the account it acts as. `pairs`: the query string's (name, value) pairs, `headers` lowercased names to values. `chunks`, a dict, gets what a streaming body's chunks are signed with - (http_body.Signed) under "signed".""" + (http_body.Signed) under "signed", and the service the key was made for (NFS: "nfs"), if any, under "service".""" now = now or dt.datetime.now(dt.timezone.utc) q = dict(pairs) presigned = "X-Amz-Signature" in q @@ -277,6 +277,7 @@ def verify(db, cfg, method, raw_path, pairs, headers, now=None, chunks=None): if chunks is not None: stamp = amz or when.strftime("%Y%m%dT%H%M%SZ") chunks["signed"] = http_body.Signed(signing_key(secret, date, region, service), stamp, "/".join(scope[1:]), sig) + chunks["service"] = db.one("SELECT VALUE service FROM $r", r=R("file_key", kid.upper())) return acct @@ -464,9 +465,10 @@ def _write(self): chunks: dict[str, Any] = {} acct = verify(db, cfg, self.command, raw, pairs, headers, chunks=chunks) raw = shares.share_path(raw, prefix) - if not share_import.accepting(cfg, "s3"): + via = chunks.get("service") if chunks.get("service") in share_import.PROTOCOLS else "s3" # the NFS share's key + if not share_import.accepting(cfg, via): raise S3Error(403, "AccessDenied", "the file tree is read-only") - adder = share_import.Adder(db, cfg, acct, "s3") + adder = share_import.Adder(db, cfg, acct, via) bucket, _, key = urllib.parse.unquote(raw).lstrip("/").partition("/") q = dict(pairs) if not bucket or (not key and self.command != "POST"): diff --git a/fastapi_backend/app/domain/settings.py b/fastapi_backend/app/domain/settings.py index 46550c592..afc0f636d 100644 --- a/fastapi_backend/app/domain/settings.py +++ b/fastapi_backend/app/domain/settings.py @@ -65,7 +65,7 @@ "tunnel": None, "https": None, # bind is a startup setting only - "nfs": ("enabled", "port", "allowed_networks", "account"), + "nfs": ("enabled", "port", "allowed_networks", "account", "add_files"), # bind is a startup setting only # the SMB share of the file tree (smb_share.py): bind and port are startup settings only (Docker publishes the port) "smb": ("enabled", "allowed_networks", "add_files"), @@ -1281,9 +1281,9 @@ def _logs_setting(key, value): def _nfs_setting(key, value): - if key == "enabled": + if key in ("enabled", "add_files"): if not isinstance(value, bool): - raise ValueError("nfs.enabled is true or false") + raise ValueError(f"nfs.{key} is true or false") return value if key == "port": if not (isinstance(value, int) and not isinstance(value, bool) and 1 <= value <= 65535): diff --git a/fastapi_backend/app/domain/store.py b/fastapi_backend/app/domain/store.py index 586dfa744..3395366fc 100644 --- a/fastapi_backend/app/domain/store.py +++ b/fastapi_backend/app/domain/store.py @@ -600,6 +600,7 @@ def labels(): "port": 2049, "allowed_networks": ["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "127.0.0.0/8", "fc00::/7", "::1/128"], "account": None, + "add_files": True, # files written to the share are imported, as `account` (share_import.py); off: read-only }, # the graph as files over S3 and WebDAV (shares.py, docs/file-tree.md): off until an admin turns it on. Then the process # that runs routines (`lens worker`) serves it on these ports; add_files imports the files people add to it diff --git a/fastapi_backend/app/schemas/admin.py b/fastapi_backend/app/schemas/admin.py index 9664ffb23..e8d1c1b1f 100644 --- a/fastapi_backend/app/schemas/admin.py +++ b/fastapi_backend/app/schemas/admin.py @@ -176,6 +176,7 @@ class NfsStatus(ResponseModel): process: str | None = Field(None, description="the worker running it") mount: str = Field(description="the command that mounts it on Linux") rclone: bool = Field(description="whether rclone is installed here") + add_files: bool = Field(False, description="whether files written to the share are imported (nfs.add_files); off: read-only") class Removed(ResponseModel): diff --git a/fastapi_backend/tests/api/test_s3_writes.py b/fastapi_backend/tests/api/test_s3_writes.py index ea88cb20b..3ed5dce01 100644 --- a/fastapi_backend/tests/api/test_s3_writes.py +++ b/fastapi_backend/tests/api/test_s3_writes.py @@ -286,3 +286,20 @@ def test_people_with_a_role_on_a_collection_add_there_only(client, db, env): assert day["parent"] == env["talks"] and _recording(db, "minutes")["collection"] == day["id"] assert _code(lambda: c.put_object(Bucket="pods", Key="Collections/Other/x.pdf", Body=PDF))[0] == "AccessDenied" assert _code(lambda: c.put_object(Bucket="pods", Key="x.pdf", Body=PDF))[0] == "AccessDenied" # the default collection isn't theirs + + +def test_the_nfs_shares_key_follows_nfs_add_files(db, env): + """rclone serving NFS writes through the S3 server with the share's own key: that follows nfs.add_files, and the + import says it came over NFS.""" + cfg = env["conf"]["cfg"] + ed = db.one("SELECT VALUE record::id(id) FROM account WHERE email = 'ed@x.io'") + _, kid, secret = s3.service_key(db, cfg, ed, "nfs") + env["keys"]["nfs"] = (kid, secret) + env["conf"]["cfg"] = {**cfg, "shares": {**cfg["shares"], "add_files": False}, "nfs": {**cfg["nfs"], "add_files": True}} + _s3(env, "nfs").put_object(Bucket="pods", Key="Collections/Talks/minutes.pdf", Body=PDF) + rec = _recording(db, "minutes") + assert rec["collection"] == env["talks"] + assert db.one("SELECT VALUE detail.via FROM audit_log WHERE action = 'share.import'") == "nfs" + assert _code(lambda: _s3(env).put_object(Bucket="pods", Key="Collections/Talks/b.pdf", Body=PDF))[0] == "AccessDenied" + env["conf"]["cfg"] = {**env["conf"]["cfg"], "nfs": {**cfg["nfs"], "add_files": False}} + assert _code(lambda: _s3(env, "nfs").put_object(Bucket="pods", Key="Collections/Talks/c.pdf", Body=PDF))[0] == "AccessDenied" diff --git a/fastapi_backend/tests/domain/test_nfs_share.py b/fastapi_backend/tests/domain/test_nfs_share.py index fb14b5407..6875ac1b5 100644 --- a/fastapi_backend/tests/domain/test_nfs_share.py +++ b/fastapi_backend/tests/domain/test_nfs_share.py @@ -17,7 +17,7 @@ FAKE_RCLONE = """#!{python} import socketserver, sys args = sys.argv[1:] -assert args[:2] == ["serve", "nfs"] and "--read-only" in args, args +assert args[:2] == ["serve", "nfs"], args host, port = args[args.index("--addr") + 1].rsplit(":", 1) class Echo(socketserver.BaseRequestHandler): @@ -86,7 +86,7 @@ def test_settings_are_checked(db, cfg): settings.save(db, cfg, "nfs", {"enabled": True, "allowed_networks": ["192.168.1.7", "192.168.1.0/24", "192.168.1.7/32"]}, "t") assert settings.Settings(db, cfg).current()["nfs"]["allowed_networks"] == ["192.168.1.7/32", "192.168.1.0/24"] for bad in ({"allowed_networks": []}, {"allowed_networks": ["0.0.0.0/0"]}, {"allowed_networks": ["nope"]}, - {"port": 0}, {"enabled": "yes"}, {"account": "me"}, {"bind": "0.0.0.0"}): # fmt: skip + {"port": 0}, {"enabled": "yes"}, {"account": "me"}, {"bind": "0.0.0.0"}, {"add_files": "yes"}): # fmt: skip with pytest.raises(ValueError): settings.save(db, cfg, "nfs", bad, "t") @@ -116,10 +116,17 @@ def remote(db_, cfg_, account): assert run.phase == "running", (run.error, run.lines) assert seen["account"] == "ad@x.io" # nobody picked: the first admin assert "s3cret" not in " ".join(run.proc.args) # the key isn't on the command line + assert "--read-only" not in run.proc.args and "writes" in run.proc.args # files written to it are imported + assert ",ro " not in nfs_share.status(db, s.current())["mount"] assert echo(port) == b"ping" st = nfs_share.status(db, s.current()) assert st["phase"] == "running" and st["account"] == "ad@x.io" and st["process"] == "test" + settings.save(db, cfg, "nfs", {"add_files": False}, "t") # read-only: rclone starts again without writes + run.tick() + assert run.phase == "running" and "--read-only" in run.proc.args and nfs_share.status(db, s.current())["add_files"] is False + assert echo(port) == b"ping" + settings.save(db, cfg, "nfs", {"allowed_networks": ["10.0.0.0/8"]}, "t") run.tick() assert echo(port) == b"" # this machine isn't allowed any more, without a restart @@ -129,7 +136,7 @@ def remote(db_, cfg_, account): settings.save(db, cfg, "nfs", {"enabled": False}, "t") run.tick() assert run.proc is None and run.relay is None - assert len(revoked) == 1 # its S3 key goes once the share stops + assert len(revoked) == 2 # its S3 key goes when it starts again read-only, and once the share stops assert nfs_share.status(db, s.current())["phase"] == "off" with pytest.raises(OSError): socket.create_connection(("127.0.0.1", port), timeout=1).close() diff --git a/nextjs-frontend/app/openapi-client/types.gen.ts b/nextjs-frontend/app/openapi-client/types.gen.ts index 017e33798..370f808a9 100644 --- a/nextjs-frontend/app/openapi-client/types.gen.ts +++ b/nextjs-frontend/app/openapi-client/types.gen.ts @@ -12689,6 +12689,12 @@ export type NfsStatus = { * whether rclone is installed here */ rclone: boolean; + /** + * Add Files + * + * whether files written to the share are imported (nfs.add_files); off: read-only + */ + add_files?: boolean; [key: string]: unknown; }; diff --git a/nextjs-frontend/components/settings/model.ts b/nextjs-frontend/components/settings/model.ts index 445c43566..09b9f84f2 100644 --- a/nextjs-frontend/components/settings/model.ts +++ b/nextjs-frontend/components/settings/model.ts @@ -341,7 +341,7 @@ export const SECTIONS: SectionSpec[] = [ label: "NFS share", backend: ["nfs"], description: - "Off unless you turn it on. The archive as folders and files over NFS, read-only: namespaces, collections, topics and entities as folders, assets as files, for machines on the networks you allow.", + "Off unless you turn it on. The archive as folders and files over NFS: namespaces, collections, topics and entities as folders, assets as files, for machines on the networks you allow; files copied into a collection’s folder are imported there.", }, { id: "smb", @@ -2594,7 +2594,14 @@ export const FIELDS: FieldSpec[] = [ key: "enabled", label: "Share the file tree over NFS", kind: "switch", - hint: "Read-only. Off: nothing listens", + hint: "Off: nothing listens", + }, + { + section: "nfs", + key: "add_files", + label: "Import files people add", + kind: "switch", + hint: "A file copied into a collection’s folder is imported there, as the account below adds it (NFS has no login). Off: read-only", }, { section: "nfs", @@ -2603,7 +2610,7 @@ export const FIELDS: FieldSpec[] = [ kind: "select", nullable: true, options: [], - hint: "The share shows what this person sees in the web app, and nothing else", + hint: "The share shows what this person sees in the web app, and nothing else; files added to it are added as them", }, { section: "nfs", diff --git a/nextjs-frontend/openapi.json b/nextjs-frontend/openapi.json index e33a161c2..6f1fb1878 100644 --- a/nextjs-frontend/openapi.json +++ b/nextjs-frontend/openapi.json @@ -53296,6 +53296,12 @@ "type": "boolean", "title": "Rclone", "description": "whether rclone is installed here" + }, + "add_files": { + "type": "boolean", + "title": "Add Files", + "description": "whether files written to the share are imported (nfs.add_files); off: read-only", + "default": false } }, "additionalProperties": true, diff --git a/threat-model.json b/threat-model.json index a2fd3838b..31fba4f95 100644 --- a/threat-model.json +++ b/threat-model.json @@ -1271,9 +1271,9 @@ }, { "property": "P-NFS", - "violation_symptom": "info-leak", + "violation_symptom": "info-leak, integrity-bypass", "severity_tier": "security", - "conditions": "the NFS share is off until an admin turns it on, is read-only, shows only what one chosen account sees, and lets in only allowed_networks", + "conditions": "the NFS share is off until an admin turns it on, shows only what one chosen account sees, imports files written to it only where that account may import (never over what Lens made; nfs.add_files off: read-only), and lets in only allowed_networks", "provenance": "documented", "source": "docs/file-shares.md \"NFS has no login\"" }, @@ -1725,7 +1725,7 @@ "Keep the IIIF cookie SameSite=None; Secure by serving IIIF over HTTPS", "Verify webhook-signature on receipt; treat Slack and Discord target URLs as secrets", "Keep logs that record request paths private when sensor push tokens are in use", - "When the NFS share is on, list only your own networks and pick an account that sees only what the share should show" + "When the NFS share is on, list only your own networks and pick an account that sees only what the share should show (and may add only where the share should take files), or turn nfs.add_files off" ], "known_misuse": [ { diff --git a/threat-model.md b/threat-model.md index 12d47ce27..a34f8b18d 100644 --- a/threat-model.md +++ b/threat-model.md @@ -305,7 +305,7 @@ classified by gate only *(inferred, Q8)*; unread modules are listed in Q34. | MQTT 1883, syslog 5514, `POST /sensors/push/{token}/{stream}` | payloads, hub logins, token in the path | yes, once enabled | data, size/rate, x-credential, x-prompt-injection | admin enables; operator firewalls; readings, alert patterns and new devices reach automations as outside text (`lens.untrusted`) | *(documented, docs/sensors.md "Sensors are off until an admin turns them on")* | | `POST /automations/hooks/{token}` (an automation's webhook) | body (JSON, a form's text fields or text), query, Standard Webhooks headers, token in the path | yes, anyone given the address | data, size/rate, x-credential, x-prompt-injection | no hook exists until an automation with a webhook trigger is saved; the token is 256 random bits kept only as a hash, and revoked with its trigger; 64 KB and 60 calls a minute per hook; a signature, when sent (or required by a `signed` hook), must match the hook's sealed secret within five minutes; a retried message id is logged once; what was sent is outside text (`lens.untrusted`), wrapped as data in prompts | *(documented, docs/automations.md "No webhook exists until an automation with such a trigger is saved")* | | automations' params and prompts, `POST /automations/preview` and `/automations/variables` | template text, a draft automation, an activity id | yes, anyone signed in (preview, the picker); the namespace editors who manage an automation (its params) | callback/code (declarative), data, x-prompt-injection | rendered in the Jinja sandbox (2 MB of output, `*` and `**` guarded; Q23); previews read only activities, namespaces and automations the person may see; prompts mark outside text as data | *(documented, docs/automations.md "The variable picker and preview")* | -| NFS share (port 12049 on the host, 2049 in the worker) | NFS and MOUNT RPCs, client address | yes, once enabled, from `nfs.allowed_networks` | data, x-network-source | admin enables and picks the account; operator firewalls | *(documented, docs/file-shares.md "NFS has no login")* | +| NFS share (port 12049 on the host, 2049 in the worker) | NFS and MOUNT RPCs, client address | yes, once enabled, from `nfs.allowed_networks` | data, x-network-source | admin enables and picks the account; operator firewalls; files written are imported as that account would upload them, checked as uploads, never over what Lens made (`nfs.add_files` off: read-only) | *(documented, docs/file-shares.md "NFS has no login")* | | SMB share (port 1445 on the host, 4445 in the worker) | SMB2 requests, NTLM sign-in with a file access key, client address | yes, once enabled, from `smb.allowed_networks` | data, x-credential, x-network-source | admin enables; operator firewalls; files added are imported only where that key's owner may import (`smb.add_files` off: read-only), written to the uploads folder and cut off at the upload size limit | *(documented, docs/smb.md "What keeps it safe")* | | S3 9555 and WebDAV 9556 (file shares) | signed S3 requests (SigV4 header or presigned link); WebDAV with an access key as Basic sign-in | yes, once enabled | x-credential, resource-name | admin enables; each request carries a person's own access key; files added are imported only where that person may import (`shares.add_files` off: read-only), checked as uploads, size-capped while streamed, never over Lens's own files; failed WebDAV sign-ins throttled per address | *(documented, docs/file-tree.md "Off until an admin turns it on")* | | web app `/mqtt` and port 9883 (MQTT over WebSockets, relayed by `lens-relay.js` ahead of Next) | the WebSocket handshake, MQTT packets in binary messages, hub logins | yes, once `sensors.enabled`, `sensors.mqtt` and `sensors.mqtt_web`; from the internet through the tunnel or HTTPS | data, size/rate, x-credential, x-network-source | admin enables; a hub login on every connection (anonymous refused whatever `mqtt_anonymous` says); eight failed logins from one visitor in 15 minutes turn it away, the visitor read from `X-Forwarded-For` as trusted proxies report it; the login rides inside MQTT, not in a cookie, so another site's page can't borrow it | *(documented, docs/sensors.md "At the web app's address")* | @@ -420,7 +420,7 @@ Every row is claimed, disclaimed, N/A with a reason, or unresolved. Family short | Optional | Atomicity, recursion, serialization | N/A — flat, append-only readings stored as data | no multi-step state, nesting or object reconstruction | none | *(inferred, Q34)* | | Optional | Callback / collaborator execution | claimed | tunnel token and llama-server key stay off command lines | P-CHILD-SECRETS | *(documented, docs/remote-access.md "in its environment, not on its command line")* | | Optional | Reference lifecycle | claimed | each service off until an admin turns it on | P-SENSORS | *(documented, docs/sensors.md "Sensors are off until an admin turns them on")* | -| Optional | Confidentiality | claimed | NFS share off until an admin turns it on; read-only; one account's view; allowed networks only | P-NFS | *(documented, docs/file-shares.md "NFS has no login")* | +| Optional | Confidentiality | claimed | NFS share off until an admin turns it on; adds files only as its account may import, never changes what Lens made (`nfs.add_files` off: read-only); one account's view; allowed networks only | P-NFS | *(documented, docs/file-shares.md "NFS has no login")* | | Optional | Confidentiality | claimed | SMB share off until an admin turns it on; adds files only as its owner may import, never changes what Lens made (`smb.add_files` off: read-only); each key sees its owner's view; allowed networks only | P-SMB | *(documented, docs/smb.md "What keeps it safe")* | | Optional | Concurrency; resource cost | disclaimed | MQTT and syslog connection counts, one thread per connection | N-VOLUME | *(documented, SECURITY.md "denial of service by sheer volume")* | @@ -553,7 +553,7 @@ Paths in the Voided by column are relative to `fastapi_backend/app/`. Searches c | P-TELEMETRY | Telemetry is off unless turned on, has no built-in destination, and never sends content, names, addresses or error messages. | info-leak | security-critical | *(documented, docs/telemetry.md "Never sent")* | Voided by: none identified (not required for this symptom; no exhaustive search) | | P-MODEL-CHECKSUM | Catalog GGUF models are pinned to a revision and checked against their SHA-256. | integrity-bypass | security-critical | *(documented, docs/local-models.md "checked against their SHA-256")* | Voided by: `hf:` references have no pin or hash — `domain/local_llm.py:138-139`. | | P-SENSORS | Sensors are off until an admin enables them. MQTT needs a hub login unless `mqtt_anonymous` is on, and always over WebSockets (`/mqtt`, `sensors.mqtt_web`). Syslog hears only listed networks. | integrity-bypass | security-critical | *(documented, docs/sensors.md "Sensors are off until an admin turns them on")* | Voided by: `sensors.mqtt_anonymous` — `domain/sensors.py:984`; `sensors.syslog_networks`, `sensors.bind`; `sensors.mqtt_web` with the web app on plain HTTP sends hub passwords in clear. | -| P-NFS | The NFS share is off until an admin turns it on. It is read-only, shows only what one chosen account sees in the web app, and turns away every client outside `nfs.allowed_networks` before rclone reads a byte. | info-leak | security-critical | *(documented, docs/file-shares.md "NFS has no login")* | Voided by: `nfs.allowed_networks` set wide, or a client address spoofed on the local network (NFS has no login) — `domain/share_relay.py`; Docker publishing that rewrites client addresses. | +| P-NFS | The NFS share is off until an admin turns it on. It shows only what one chosen account sees in the web app, imports files written to it only where that account may import (checked as uploads, never over, renaming or deleting what Lens made; with `nfs.add_files` off it is read-only), and turns away every client outside `nfs.allowed_networks` before rclone reads a byte. | info-leak, integrity-bypass | security-critical | *(documented, docs/file-shares.md "NFS has no login")* | Voided by: `nfs.allowed_networks` set wide, or a client address spoofed on the local network (NFS has no login, so anyone let in reads and adds files as the share's account) — `domain/share_relay.py`, `domain/share_import.py`; Docker publishing that rewrites client addresses. | | P-SMB | The SMB share is off until an admin turns it on. It adds files only where the key's owner may import, checked as uploads (type, size cut off while written), never writes over, renames or deletes what Lens made, and with `smb.add_files` off is read-only. It signs people in with their own file access keys and shows each only what they see in the web app, refuses guests and SMB1 sessions, gives every connection its own NTLM challenge, and closes connections from outside `smb.allowed_networks` before reading a byte. | info-leak, integrity-bypass | security-critical | *(documented, docs/smb.md "What keeps it safe")* | Voided by: `smb.allowed_networks` set wide; SMB 2.0 has no encryption on the wire, so a key's NTLM exchange and the files read or added can be watched (or files added altered) on the network — `domain/smb_share.py`, `domain/share_import.py`. | | P-SHARES | The file shares (S3 and WebDAV) are off until an admin enables them. Every request is signed (S3: AWS Signature Version 4) or signed in (WebDAV: Basic) with an access key someone made while signed in to the web app; it reads as them and sees only what the web app shows them. A file it writes is imported as an upload by that person would be (the import permission or an editor's role on the collection; making a collection as the web app allows; the upload type and size checks, with the body streamed to disk and cut off at the size limit), never replaces or deletes an asset or a file Lens made, and with `shares.add_files` off nothing is written. Keys expire as API keys do, stop with a disabled account, and are revoked at once. | info-leak, integrity-bypass | security-critical | *(documented, docs/file-tree.md "Off until an admin turns it on")* | Through the web app (`/s3`, `/dav`) only with `shares.remote` on as well. Voided by: `shares.enabled` with `LENS_BIND=0.0.0.0` sends files, S3 signatures and WebDAV's Basic secret in clear over plain HTTP on the network, as does `shares.remote` when the web app itself is reached over plain HTTP; key secrets are sealed with the server key (`secret.key`), not hashed, since SigV4 signs with the secret itself; a leaked key can add files as its owner can — `domain/s3.py`, `domain/webdav.py`, `domain/share_import.py`. | | P-CHILD-SECRETS | The tunnel token reaches cloudflared in its environment, not its command line; llama-server gets its own random API key. | info-leak | correctness-only | *(documented, docs/remote-access.md "in its environment, not on its command line")* | Voided by: none identified (not required for this symptom; no exhaustive search) | @@ -661,7 +661,7 @@ The operator (and, for the last rows, integrators that consume Lens output) must | After a password change or suspected theft, revoke API tokens and app grants, or disable the account | N-REVOKE-TOKENS | *(inferred, Q3)* | | List private networks in `documents.web_networks` or `notifications.networks` only on purpose | P-SSRF-GUARD, P-ADMIN-GUARD | *(documented, docs/configuration.md "The web app can't list this machine (loopback) or link-local addresses")* | | When sensors are on, firewall ports 1883 and 5514 or bind them to a private address | P-SENSORS, N-MQTT-SUBSCRIBE | *(documented, docs/sensors.md "Ways in")* | -| When the NFS share is on, list only your own networks and pick an account that sees only what the share should show | P-NFS | *(documented, docs/file-shares.md "NFS has no login")* | +| When the NFS share is on, list only your own networks and pick an account that sees only what the share should show (and may add only where the share should take files), or turn `nfs.add_files` off | P-NFS | *(documented, docs/file-shares.md "NFS has no login")* | | When the SMB share is on, list only your own networks, keep its port off the internet, and revoke file access keys you no longer use | P-SMB | *(documented, docs/smb.md "What keeps it safe")* | | Give the chat-room bridge its own low-role account | N-BRIDGE | *(documented, docs/chat-rooms.md "it reads only what that account can read")* | | Run workers only on trusted hosts; they hold the DB credential | N-APP-LAYER | *(inferred, Q9)* | diff --git a/threat-model.yaml b/threat-model.yaml index 334f0cb35..25ce50722 100644 --- a/threat-model.yaml +++ b/threat-model.yaml @@ -752,7 +752,7 @@ contract_dimensions: - {component: optional, dimension: serialization-reconstruction, status: not-applicable, conditions: "readings stored as data; no object reconstruction", provenance: {kind: inferred, question_id: Q34}} - {component: optional, dimension: callback-execution, status: claimed, property_id: P-CHILD-SECRETS, conditions: "tunnel token and llama-server key stay off command lines", provenance: {kind: documented, source: 'docs/remote-access.md "in its environment, not on its command line"'}} - {component: optional, dimension: reference-lifecycle, status: claimed, property_id: P-SENSORS, conditions: "each service off until an admin turns it on", provenance: {kind: documented, source: 'docs/sensors.md "Sensors are off until an admin turns them on"'}} - - {component: optional, dimension: confidentiality, status: claimed, property_id: P-NFS, conditions: "NFS share off until an admin turns it on; read-only; one account's view; allowed networks only", provenance: {kind: documented, source: 'docs/file-shares.md "NFS has no login"'}} + - {component: optional, dimension: confidentiality, status: claimed, property_id: P-NFS, conditions: "NFS share off until an admin turns it on; adds files only as its account may import, never changes what Lens made (nfs.add_files off: read-only); one account's view; allowed networks only", provenance: {kind: documented, source: 'docs/file-shares.md "NFS has no login"'}} - {component: optional, dimension: confidentiality, status: claimed, property_id: P-SMB, conditions: "SMB share off until an admin turns it on; adds files only as its owner may import, never changes what Lens made (smb.add_files off: read-only); each key sees its owner's view; allowed networks only", provenance: {kind: documented, source: 'docs/smb.md "What keeps it safe"'}} - {component: optional, dimension: concurrency-reentrancy, status: disclaimed, property_id: N-VOLUME, conditions: "MQTT and syslog connection counts, one thread per connection", provenance: {kind: documented, source: 'SECURITY.md "denial of service by sheer volume"'}} - {component: optional, dimension: resource-complexity, status: disclaimed, property_id: N-VOLUME, conditions: "MQTT and syslog connection counts, one thread per connection", provenance: {kind: documented, source: 'SECURITY.md "denial of service by sheer volume"'}} @@ -1723,9 +1723,9 @@ properties_claimed: kind: confidentiality components: [optional] tier: security-critical - conditions: "the NFS share is off until an admin turns it on, is read-only, shows only what one chosen account sees, and lets in only allowed_networks" - violation_symptoms: [info-leak] - x-voided-by: "nfs.allowed_networks set wide, or a spoofed client address on the local network (domain/share_relay.py); Docker publishing that rewrites client addresses" + conditions: "the NFS share is off until an admin turns it on, shows only what one chosen account sees, imports files written to it only where that account may import (never over what Lens made; nfs.add_files off: read-only), and lets in only allowed_networks" + violation_symptoms: [info-leak, integrity-bypass] + x-voided-by: "nfs.allowed_networks set wide, or a spoofed client address on the local network, who then reads and adds files as the share's account (domain/share_relay.py, domain/share_import.py); Docker publishing that rewrites client addresses" provenance: {kind: documented, source: 'docs/file-shares.md "NFS has no login"'} - id: P-SMB kind: confidentiality @@ -1918,7 +1918,7 @@ downstream_responsibilities: - {id: dr-untrusted-prompt-input, component: assistant, statement: "Treat asset text and MCP results as untrusted prompt input in your agents", enforces: [N-PROMPT, dmna-mcp-text-as-instructions], provenance: {kind: inferred, question_id: Q26}} - {id: dr-iiif-over-https, component: authz, statement: "Keep the IIIF cookie SameSite=None; Secure by serving IIIF over HTTPS", enforces: [], x-protects: "IIIF cookie", provenance: {kind: documented, source: 'docs/iiif.md "its cookie is `SameSite=None; Secure`"'}} - {id: dr-verify-webhook-signature, component: outbound, statement: "Verify webhook-signature on receipt; treat Slack and Discord target URLs as secrets", enforces: [dmna-chat-webhooks-signed], x-protects: "§1.8 webhook bodies", provenance: {kind: documented, source: 'domain/notify.py docstring "signed the Standard Webhooks way"'}} - - {id: dr-limit-nfs-share, component: optional, statement: "When the NFS share is on, list only your own networks and pick an account that sees only what the share should show", enforces: [P-NFS, enable-and-limit-nfs], provenance: {kind: documented, source: 'docs/file-shares.md "NFS has no login"'}} + - {id: dr-limit-nfs-share, component: optional, statement: "When the NFS share is on, list only your own networks and pick an account that sees only what the share should show (and may add only where the share should take files), or turn nfs.add_files off", enforces: [P-NFS, enable-and-limit-nfs], provenance: {kind: documented, source: 'docs/file-shares.md "NFS has no login"'}} - {id: dr-private-logs-push-tokens, component: optional, statement: "Keep logs that record request paths private when sensor push tokens are in use", enforces: [P-SENSORS], provenance: {kind: documented, source: 'docs/sensors.md "Ways in"'}} # ---------------------------------------------------------------- §1.14