6. Verification
A client accepts a file from Logos Storage only if its bytes hash to the SHA-256 pinned above it. The record pins the root list, and each list pins what it contains. Nothing from Storage is fetched or shown without a pin. On-chain pages and name icons are the exception: they come with the record (section 6.8).
Describes Names Browser 0.4.6 / core 0.3.6 (source commit 4a3c32a: Main.qml, logic.mjs, storage.rs, lib.rs, links.rs, cache.rs) and the round-3 gateway (serve.mjs, storage.mjs). Verification here means SHA-256 checks only. The record itself is not verified (section 6.11).
6.1 The hash chain
A pinned hash is a SHA-256 written above the bytes it names: in the record for the root list, or in a list entry for a file or subfolder. A client fetches bytes by CID from Logos Storage, hashes them, and compares the result with the pinned hash. Only bytes that match are parsed, drawn, cached or saved.
record (from your LEZ RPC)
cid cid.sha256 cid.type=links
│ fetch cid, hash, compare with cid.sha256
▼
root list ─ entry docs/ CID sha256
│ fetch CID, hash, compare, then parse
▼
folder list ─ entry intro.html CID sha256
│ fetch CID, hash, compare
▼
file bytes → drawn, cached or saved
A client checks each step before it takes the next. It never parses a list it has not checked, so a bad list cannot point the walk anywhere.
A client MUST compute the SHA-256 of every root list, folder list and file it fetches from Logos Storage, and MUST refuse the bytes if the hash differs from the pinned hash.
Browser:finishBasecampDownloadBytes in Main.qml (Storage module path) and StorageClient::download in storage.rs (HTTP path). Gateway: downloadVerified in serve.mjs and StorageClient.download in storage.mjs.
6.2 Checking a file
Checking a file has three parts: knowing what a CID and a hash each prove, reading the record, and walking the lists down to the file.
6.2.1 CIDs and hashes
The two values in an entry do different jobs. The CID says where to fetch. The SHA-256 says what to accept.
- A CID is checked only for its form: 8 to 128 ASCII letters and digits. Clients do not decode it.
- The multihash inside the CID is not compared with the bytes. A Storage node could answer a CID with other bytes, and the SHA-256 check would still catch it.
- A hash is 64 hex digits. Either case is accepted, and it is compared in lower case.
A client MUST treat the SHA-256, not the CID, as the identity of the bytes.
CID form:CID_RE in logic.mjs, is_valid_cid in storage.rs. No multihash decoding exists in either codebase.
6.2.2 Reading the record
A client asks its LEZ RPC for the record of the LNS name in the address. Three text entries describe the site (section 5.8):
| Entry | What the client does with it |
|---|---|
cid | The root's CID. A leading cid=, cid: or cid:// is removed. A value that is not a valid CID counts as no site. |
cid.sha256 | The pinned hash of the root. Required whenever cid is set. |
cid.type | links, manifest or single. A hint for how to read the root. Without it the client decides from the bytes, after they pass the hash check. |
A client MUST refuse a site whose record has a cid but no valid cid.sha256. It MUST NOT fetch the root in that case.
Main.qml "Unverified file skipped — LNS record for … has no pinned cid.sha256 hash". Gateway: loadSiteRoot in serve.mjs answers 502 "Unverified site root".
The Names Browser binds the record to the name the user typed, not to any name the RPC returns, so an answer for one name cannot fill another name's older-version cache, avatar or display name.
A client MUST NOT open a bare cid:// address as a site, because nothing pins its hash.
Main.qml loadNativeStaticNavigation ("Unverified file skipped — direct cid:// URLs have no pinned SHA-256 hash"); core lib.rs fetch_static_site and fetch_site also refuse any root without a valid 64-hex expected_sha256. Section 7 notes where STATIC-PROFILE.md says otherwise.
Although parse_url (links.rs) and parseUrl (logic.mjs) parse cid://<cid>[/path], Names Browser 0.4.6 refuses to fetch or draw one. Because the CID's multihash is never checked against the bytes (section 6.2.1), a bare CID has no integrity check at all. Opening bare cid:// addresses safely in a future build would require verifying the CID multihash (or passing an explicit hash pin), distinguishing an lns-links/1 list from a single file by its # lns-links/1 header (section 5.9), and marking the view as unpinned by any LNS name.
If the record has no cid, the client reads the name's on-chain page instead (section 6.8).
6.2.3 Walking the tree
- Fetch the root by
cid, hash it, compare withcid.sha256. - If it is a list (
cid.type=linksor a first line of# lns-links/1), parse it under the rules of section 5. - Resolve the path (section 5.7). For each folder on the way, fetch its list by CID, hash it, compare with the entry's SHA-256, and only then parse it.
- Fetch the final file by CID, hash it, compare with its entry's SHA-256.
- Render it (section 7), or offer it as a download (section 6.6).
Section 6.9 lists the size caps that apply while fetching.
A client MUST NOT fetch a file or folder whose entry has no SHA-256, and MUST NOT parse a folder list before its hash matches.
Browser:resolveLinksSync in logic.mjs, resolve_links_tree callers in lib.rs, "Unverified file skipped — entry has no pinned SHA-256 hash" in Main.qml. Gateway: requireSha256: true in serve.mjs.
6.3 Caches
Verified bytes are cached under their SHA-256, never under a CID. Two sites that pin the same bytes share one entry. A site cannot place bytes under another site's hash, because an entry is written only when the bytes hash to its key.
- Disk cache (browser). Files are named
<sha256>.<ext>inside the plugin's cache folder. At most 200 MiB in all and 16 MiB per file. Oldest files are evicted first. - Every read re-hashes. On a mismatch the file is deleted and fetched again from Storage. Symlinks, dotfiles and paths outside the folder are refused.
- Memory caches (browser). Folder lists, images and stylesheets are also kept in memory, keyed by SHA-256: 64 folder lists in the core, 128 entries per cache in the interface, and 16 MiB in the core's byte cache.
- Gateway. Verified blobs are kept in a byte-bounded cache keyed by SHA-256. Section 8 describes its other caches.
A client that caches verified bytes MUST key the cache by SHA-256 and MUST NOT write bytes that do not hash to the key.
put_verified and get_verified in cache.rs; getCachedLinksEntry and getCachedImageEntry in logic.mjs; blobCache.set(expSha, …) in serve.mjs.
6.4 Subresources
A page's subresources are verified the same way as the page. A site-relative reference is resolved through the same tree, so its pin comes from a checked list.
- A reference that does not resolve to a pinned entry is skipped. The browser counts it and shows how many were skipped.
- A
cid://reference inside a page (in<img>,<link>or@font-face) is never fetched by the Names Browser, because nothing pins it. The gateway resolves acid://reference only when the same CID appears with a pinned SHA-256 in the site's root folder list, current folder list or manifest (serve.mjsmakeSubresourceResolvers), and drops any unlistedcid://reference. - After the hash check, an image's first bytes must be PNG, JPEG, GIF or WebP, and its header size must be within the limits in section 7.
- After the hash check, a font in the Names Browser must be a raw TrueType (TTF) or OpenType (OTF) SFNT file (
cache.rssanitize_and_isolate_font); WOFF and WOFF2 are refused. The browser rejects any font declaring a reserved system or interface family name and rewrites itsnametable to a private family name derived from its hash (lns-<first 12 hex>), so a site font cannot replace the interface's fonts. - Inline
data:images and fonts in the page are part of the page's verified bytes, so they need no pin of their own.
A client MUST NOT fetch a subresource that has no pinned SHA-256.
Browser:resolve_asset_target in lib.rs returns nothing for a cid:// source or an unpinned path, and the asset is counted in skipped_unverified. Gateway: unlisted cid:// references are dropped (serve.mjs).
6.5 New versions
When an LNS name now points to a new root, the new files may take time to arrive. The Names Browser can show the last version it verified for that name while it fetches the new one.
- After each verified load, the browser stores the name, the root's CID and SHA-256, and the time. It keeps this for up to 256 names. On-chain pages are not stored.
- On the next visit, if the record pins a different root, the browser draws the stored version from its local cache while it fetches the new root. With Basecamp's Storage module it skips this step when the new root is already cached.
- The older version uses only files already cached and verified on this machine. It makes no network request.
- The badge reads "older version", not "verified". A banner gives the time of the stored version and whether the new one is loading, waiting for Storage, failed, or failed verification.
- When the new version passes verification, it replaces the older one. If it fails, the older one stays, marked as older.
- Clear history deletes the stored versions.
A client that shows a cached older version while it fetches a newer one MUST mark it as older and MUST NOT show it as verified.
formatBadgeState, staleVersionTabState and formatStaleVersionBanner in logic.mjs; tryRenderCachedStaleVersion in Main.qml.
Showing an older version at all is a choice of this implementation, not a requirement. The true wording for 0.4.6 is: "When an LNS name points to a new version and the last version this browser verified is still in its local cache, the browser shows that cached version, marked as older, while it fetches the new one."
Gateway. The gateway has no older-version banner. If the chain lookup fails, it keeps serving the last record it resolved for a name for up to 24 hours, and its responses allow CDN caches to serve stale copies on error for the same time. Neither is marked as older. Section 8 has the details.
6.6 Downloads
A file the browser does not render, such as .lgx, .zip, .dmg or .pdf, or a link with a download attribute, is offered as a download. Nothing is saved without a click.
- The user clicks Save. The browser resolves the file's CID and pinned SHA-256 through the verified tree.
- A confirmation shows the checked filename, the CID and the pinned hash. Filenames with control or BiDi characters, a leading dot, or any of
/ \ : * ? " < > |are refused. - After the user confirms, the file is fetched into a private staging file in the cache folder.
- The core hashes the staging file. Only if it matches the pin is it moved into Downloads. Otherwise it is deleted and nothing reaches Downloads.
A client MUST ask the user before saving a file, MUST refuse a download that has no pinned SHA-256, and MUST NOT place a file in the user's Downloads folder before its hash matches.
prepareDownloadConfirmation in logic.mjs; finalize_staged_download_in_dir and the direct save path in lib.rs.
At most 16 download buttons are shown for a page. The gateway sends downloads with the same hash check as any other file.
6.7 What is refused
| Case | Names Browser | Gateway |
|---|---|---|
Record has cid but no valid cid.sha256 | Error page, nothing fetched | 502 |
Bare cid:// address | Error page, nothing fetched | Not applicable: gateway addresses are LNS names |
| Root, list or page hash mismatch | Error page "SHA-256 mismatch" | 502, no byte sent |
| Entry without a SHA-256 | "Unverified file skipped" | 502 |
| Subresource unpinned or mismatched | Not drawn, counted as skipped | 502 when requested |
| Image or font with the wrong magic bytes | Not drawn, not cached | Hash-checked like any file; its Content-Type comes from an extension allowlist (section 8) |
| Fetch over its size cap | Error or skipped | 413 |
| Bad list (section 5) | Error page | 502 |
6.8 On-chain pages and avatars
Two kinds of content come straight from the record through the RPC, not from Storage. There is no pin above them, so there is nothing to check them against.
- On-chain page. Used when the record has no
cid. It is either one HTML page, shown only at/or/index.html, or a root list smaller than 10,240 bytes (section 5.8.2). The Names Browser's badge reads "✓ ON CHAIN". Files below an on-chain root list come from Storage and are checked as in section 6.2.3. - Avatar (name icon). The record's
avatarentry, adata:image/png,jpeg,giforwebpbase64 URL. The browser accepts at most 12 KiB, checks the base64, checks that the magic bytes match the declared type, and refuses images over 256 × 256. Anything else falls back to a letter tile.
The browser hashes both locally. That hash is only a cache key. It is not a check, because it is computed from the same bytes the RPC sent.
A client MUST refuse an on-chain root list of 10,240 bytes or more.
Main.qml (MAX_ONCHAIN_LINKS_BYTES); loadSiteRoot in serve.mjs. The gateway also refuses any on-chain page over 80 KiB (MAX_ONCHAIN_PAGE_BYTES).
6.9 Size caps while fetching
The Names Browser has two fetch paths with different caps. Both stop reading once a cap is passed.
| What is fetched | Basecamp Storage module path (hashed in QML) | External Storage node path (hashed in Rust) |
|---|---|---|
| Folder list | 2 MiB | 10 MiB per fetch, then the list limit of 2 MiB applies |
| Page (HTML root or file) | 512 KiB | 10 MiB per fetch |
| Stylesheet | 256 KiB | 10 MiB per fetch |
| SVG image | 64 KiB, also when sniffed in the first chunk | 10 MiB per fetch; SVG over 64 KiB is not drawn |
| Other assets | 4 MiB | 10 MiB per fetch; images over 4 MiB are not drawn |
On the Basecamp Storage module path, a root whose record sets cid.type=links gets the 2 MiB folder-list cap; without cid.type=links, the root starts under the 512 KiB page cap (Main.qml). Section 7 lists the rendering caps that apply after a file is verified.
6.10 The gateway
The gateway applies the same pins before it sends a byte:
- Every fetch needs a 64-hex pinned SHA-256, or it answers 502 "Unverified content".
- It downloads the whole file, hashes it, and answers 502 if the hash differs. Only then does it start the response.
- When a JSON manifest also gives a size, the size must match too.
- It checks the pinned hash against its blocklist before fetching, and answers 451 for a blocked hash.
Section 8 covers what the gateway does after verification: sanitizing, headers and caching.
6.11 What is not verified
- The RPC's answer. Neither the browser nor the gateway checks that the record the LEZ RPC returned is the real one. A hostile RPC can point any LNS name at any content, and the client will show it as verified. Closing this needs light-client proofs or signed records.
- The CID. Its multihash is not compared with the bytes (section 6.2.1).
- On-chain pages and avatars. They come straight from the record through the RPC (section 6.8).
- Availability. Logos Storage, including the browser's built-in seed peer, can withhold or slow files. It cannot change them.
- The gateway itself, for its visitors. A gateway visitor trusts the gateway operator and the TLS endpoint in front of it. The visitor's browser does not repeat the hash checks.
True claim wording. "Every file from Logos Storage is checked against the SHA-256 pinned in the LNS record (or its folder list) returned by your LEZ RPC before it is shown or saved, and a mismatch is refused. Small on-chain pages and name icons come directly from the LNS record through the RPC."
Use "returned by your LEZ RPC". Do not say a file is checked against "the on-chain record" without it.
Section 10 covers the trust model in full.