Reviewer: SR (independent). Date: 2026-11-28. Code reviewed: main at 7e799f3. Line numbers refer to that commit; other agents were editing the working tree during the review.
Status on 2026-11-30: both Highs and all six Mediums are fixed on main, and every fix has a test that passes. The Lows are fixed or partly fixed; the Info items are fixed or accepted as product calls. Each finding’s status, fix and test are in Status, and the second pass covers what this review did not: the S3 client, the prod compose file and the code changed after 7e799f3. The findings below describe the code as it was at 7e799f3. The CodeQL triage of 2026-12-01 is an addendum: the first public code-scanning run, alert by alert.
Threat model: ../architecture/security.md (malicious client, stolen token, resource exhaustion, cross-tenant access). ADRs read: 0011, 0023, 0101, 0302, 0303, 0304, 0702.
| Severity | Count |
|---|---|
| Critical | 0 |
| High | 2 |
| Medium | 6 |
| Low | 10 |
| Info | 6 |
I found no cross-tenant read or write path and no authentication bypass. Both High findings are cheap, cross-tenant denial of service on shared tiers. They need only a self-registered account, because signup is open and makes the caller owner (and so editor) of their own project.
| Id | Sev | Title | Owner | Status (2026-11-30) |
|---|---|---|---|---|
| SR-01 | High | nameRegex search can block a shared doc worker for minutes |
S1 (apps/docworker), DC2 (packages/doc find) |
Fixed |
| SR-02 | High | MCP id-run expansion runs before the 10,000-id cap: a 14 KB call OOMs the hosted adapter | main (apps/mcp) |
Fixed |
| SR-03 | Medium | DELETE id lists: 18x gateway-to-owner amplification; rate limits count ops, not ids | DC2 (scan.ts), R1 (gateway) |
Fixed |
| SR-04 | Medium | Revocation fails open: a LISTEN gap loses events, and open sockets are never re-checked | R1 | Fixed |
| SR-05 | Medium | Per-IP connection cap trusts a client-sent PROXY v2 header | R1, O1 | Fixed |
| SR-06 | Medium | Hosted MCP: unauthenticated body buffering, a shared API IP bucket, no per-token session cap | main (apps/mcp), S1 |
Fixed |
| SR-07 | Medium | One HMAC keyring and one DB role for every tier: a doc worker can mint any user’s realtime token | S1 (server-common), O1 |
Fixed |
| SR-08 | Medium | render builds the full SVG (text included) before its size cap, on the event loop |
DC2 (toSvg), S1 (render.ts) |
Fixed |
| SR-09 | Low | Denylist compares API-clock iat with realtime-clock receipt time |
R1, S1 | Fixed |
| SR-10 | Low | Rate-limit and cap keys use the full IPv6 address; bucket eviction resets depleted buckets | S1, R1 | Fixed |
| SR-11 | Low | The web app’s CSP and framing headers are documented but not served | O1, ED1 | Fixed |
| SR-12 | Low | The “unsafe() banned outside migrations” lint does not exist |
O1 | Fixed |
| SR-13 | Low | Per-email login lockout lets anyone lock a victim out | S1 | Fixed |
| SR-14 | Low | Rejected binary batches are decoded to JS arrays outside the body budget | S1 | Fixed |
| SR-15 | Low | Text with XML-illegal characters breaks every render of its region | DC2 | Fixed |
| SR-16 | Low | Realtime inflates structure sections with no output cap | R1 | Fixed |
| SR-17 | Low | NODE_ENV defaults to development, which turns off Secure cookies and HSTS |
S1, O1 | Fixed |
| SR-18 | Low | Metrics listeners bind to the service host (0.0.0.0 in production) | S1, R1, O1 | Fixed |
| SR-19 | Info | Account enumeration via signup 409 and addMember 404/409 | S1 (product call) | Partly fixed (product call) |
| SR-20 | Info | MCP prompt-injection exposure from names and text | main (apps/mcp) |
Mostly fixed |
| SR-21 | Info | Open signup makes the editor role free (amplifies SR-01/03/05/06/08) | product | Partly fixed (product call) |
| SR-22 | Info | uWS comes from a GitHub tarball with prebuilt binaries (integrity-pinned) | O1 | Fixed / accepted |
| SR-23 | Info | Web reads linora_csrf, but production sets __Host-linora_csrf |
ED1 | Fixed |
| SR-24 | Info | Realtime subscribe skips files:read; writer mode is open to any editor client |
R1 | Fixed; hidden write mode accepted |
probes/), not in the repo:
redos.mjs: regex cost with the doc worker’s V8 flags.delete-amp.ts: scan, summary size and StructIndex cost of one max-size DELETE frame.proxyv2.mjs: uWS PROXY v2 handling.mcp-runs.ts: MCP id-run expansion.svgctl.mjs: resvg with control characters.npm test -w @linorahq/api: 50/50 pass.revocation, session and units: 26/26 pass.nameRegex search can block a shared doc worker for minutesWhere
apps/docworker/src/queries/regex.ts:19-31 (checkRegex)apps/docworker/src/queries/handlers.ts:182packages/doc/src/query/index.ts:227 (find compiles the pattern and tests every distinct name)Evidence
checkRegex only checks that the pattern compiles with the linear engine (l flag). It puts no limit on total work.redos.mjs (Node 26, with the worker’s --enable-experimental-regexp-engine-on-excessive-backtracks): (a*)*b, (a|a)*b, (?:a+)+b and ((a+)+)+(b|c|d) all pass checkRegex. Each costs 0.22-0.26 ms per 1,000-char name.LINORA_DOCWORKER_MAX_BYTES): about 22 s per request;Impact
POST .../nodes/search.Fix
find a work budget (names tested, or performance.now() checked every 1,024 nodes). When it runs out, return a partial page with truncated: true and a cursor, or a 503 with Retry-After.l-mode program is large (for example, more than 20 quantifiers).searchNodes per user in the API proxy.Where
apps/mcp/src/format.ts:79-88 (expandIdRun: up to 100,001 ids per run)apps/mcp/src/session.ts:250-264 (nodeIds: the cap runs at :263, after every run is expanded)tools/edit.ts:400,438,568,646,737, tools/read.ts:77,163.Evidence
mcp-runs.ts: 40 runs "1:0-100000" … "40:0-100000" (552 bytes of JSON) cost 438 MiB of RSS and 1.6 s of CPU before the 10,000-id error.http.ts:72), about 500K runs. About 1,000 runs (~14 KB) need ~11 GB.Impact
Fix
out.length + (b - a + 1) > 10_000 before expanding each run, and stop at the cap.maxBodyBytes for /mcp to about 1 MiB.Where
packages/doc/src/scan.ts:211-235: DELETE allows m <= remaining bytes ids (about 4M in a 4 MiB frame).apps/realtime/src/validation.ts:50-52: summary = 16 B per extra id.apps/realtime/src/gateway/gateway.ts:713,724: the backlog is checked before the frame is added; takeUser(s, n) counts ops.Evidence
delete-amp.ts: one 4 MiB OPS frame holding one DELETE of 4,194,274 ids:
StructIndex.check even when every id is missing.USER_OPS_PER_SEC (2,000).shared/src/api.ts:124); the binary and WS paths have no cap.OWNER_BACKLOG_BUSY_BYTES, 32 MiB) admits a frame whenever the backlog is under 32 MiB, so each gateway/owner pair can hold about 104 MiB.BatchScan arrays grow to about 68 MiB each and never shrink.Impact
Fix
scanBatch (50,000, as the JSON schema does) and total extras per batch (for example, MAX_OPS_PER_BATCH), and fail framing beyond that.takeUser with scan.count + scan.extraCount.backlog + payload.Where
apps/realtime/src/supervisor.ts:163-169: listen() is called without an onlisten callback.apps/realtime/src/gateway/gateway.ts:235-275: onOpen keeps no exp, and nothing ever re-checks it.packages/server-common/src/auth-events.ts:5-6 says the realtime tier has “nothing to do, tokens expire in 5 min”.Evidence
auth.ts:71). After that, a socket lives until it closes or a linora_auth event closes it.apps/api/src/events.ts:50-53); realtime does nothing.member_removed, project_deleted, cred_revoked or role_changed event sent during a gap therefore never reaches open sockets. A Postgres failover, network blip or LISTEN connection restart is enough.Impact
Fix
onlisten to listenSql.listen. On every reconnect after the first:
exp + 10 min, after which the gateway sends error{unauthorized} and closes with 4001. Clients already refresh on 4001.Where: apps/realtime/src/gateway/gateway.ts:221-226.
Evidence
proxyv2.mjs sent a PROXY v2 header for 203.0.113.7, then a WebSocket upgrade, straight from an ordinary TCP client to the bundled uWebSockets.js 20.69.0.upgrade, getProxiedRemoteAddressAsText() returned 203.0.113.7 while the socket address was 127.0.0.1. The gateway uses the proxied value as the LINORA_REALTIME_MAX_CONN_PER_IP key.Impact
429 ip_connections. This needs valid tokens, which free accounts provide (50 sockets each).Fix
LINORA_REALTIME_PROXY_PROTOCOL=off|required (and an allowed source CIDR list):
off: ignore the proxied address.required: refuse connections without a PROXY header from an allowed LB address.Where: apps/mcp/src/http.ts:49-59,92-117,71; the API client sends no client address (apps/mcp/src/api.ts:73).
Evidence
Authorization: Bearer x reads and JSON.parses up to 8 MiB before the token is checked. No process-wide body budget exists (the API has one).initialize with a junk token costs one GET /v1/me from the MCP host’s IP. The API’s IP bucket (100/s, burst 200, apps/api/src/server.ts:176) then covers every hosted agent at once.maxSessions (1,000) is global. One PAT may open all of them; realtime then caps the user at 50 sockets, but the sessions themselves still count.Impact
Fix
/^linora_pat_[A-Za-z0-9_-]{43}$/) before reading the body.ByteBudget.me results per token hash for about 30 s.initialize per client IP at the MCP.X-Forwarded-For and have the API trust the MCP as a proxy hop, or have the API exempt the MCP host from the IP bucket (S1).Where
packages/server-common/src/token.ts:29-61 (one keyring signs rt, cg and svc).apps/docworker/src/config.ts loads LINORA_TOKEN_KEYS.db/migrations/0001_init.sql grants no per-tier roles.Evidence
svc:'docworker' and verify svc:'api'. They hold the same key the API uses to mint rt tokens for users. The doc worker is also the tier that parses attacker-shaped documents and runs resvg.DATABASE_URL role.Impact
rt token with any uid/fid/role, or write the database directly.Fix
HKDF(key, "rt"), "cg", "svc:api" and "svc:docworker", and give each tier only the subkeys it needs. Doc workers then cannot sign rt.page_ops, pages.head, files.next_client_id;render builds the whole SVG before its size cap, on the event loopWhere: packages/doc/src/query/index.ts:436 onward (toSvg) and apps/docworker/src/queries/render.ts:88-90.
Evidence
toSvg caps elements (200K) but not bytes. Each text element carries the node’s full text (up to 64 KiB, MAX_TEXT_BYTES). esc can grow it up to 6x (' becomes ').MAX_SVG_CHARS) runs only after the whole string has been joined, synchronously.format=svg skips the render slot and queue.' characters (128 MB of document) build about 768 MB of SVG text. That passes V8’s maximum string length (about 512M characters), so the join throws (500) after GBs of allocation. Near the RSS limit (1.5 x max bytes + 256 MiB), the worker exits.Impact
GET .../render. This is cheaper than SR-01 to trigger, but only near the memory limits.Fix
toSvg and stop at MAX_SVG_CHARS (return a “too complex” marker).format=svg through the same slot and queue as PNG.iat with realtime-clock receipt timeWhere: apps/realtime/src/supervisor.ts:163 (atS = realtime Date.now() at receipt) and apps/realtime/src/auth.ts:176-186 (a.iat <= at).
Evidence
iat > at. Both are floored to seconds, so even a sub-second lead can do this.Fix
extract(epoch from clock_timestamp()) inside the transaction).iat <= at + 2). A re-added user then waits 2 s.Where: apps/api/src/http.ts:153-162, apps/api/src/ratelimit.ts:52-62, apps/realtime/src/gateway/gateway.ts:222-226.
Evidence
ip, authIp and the realtime IP cap key on the exact address, so one IPv6 /64 gives 2^64 buckets. That removes the signup/login limit of 10, then 1 per 6 s per IP.sweep drops “the oldest half” regardless of state. That resets depleted buckets, including the attacker’s own.Fix
Where
apps/web/index.html and apps/web/vite.config.ts set nothing.apps/api/src/server.ts:43-49).Impact
dangerouslySetInnerHTML is used only with constant icon strings (apps/web/src/panels/Layers.tsx:38-43, Toolbar.tsx:39).Fix: O1 should serve the app with:
Content-Security-Policy: default-src 'self'; script-src 'self'; connect-src 'self' wss://<realtime>; img-src 'self' data: blob:; style-src 'self'; frame-ancestors 'none'; base-uri 'none'; object-src 'none';X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer and HSTS.Add a test that fetches the built app and checks these headers.
unsafe() banned outside migrations” lint does not existWhere: security.md “SQL injection” row; tools/check-deps.mjs has no such rule.
Evidence
grep -F 'unsafe(' finds only packages/server-common/src/migrate.ts:66, testing.ts:39,56 and tools/loadtest/seed.ts:30,49.Fix: Add a check-deps rule that rejects .unsafe( in apps/*/src and packages/*/src, except in migrate.ts and testing.ts.
Where: apps/api/src/routes/auth.ts:75-79.
Evidence: The lockout bucket is keyed by email only. Ten failed logins from anywhere leave the real owner one attempt per minute.
Fix
Where: apps/api/src/content/ops.ts:52,62 (readOps on the raw body when any op was rejected).
Evidence
Fix: Decode only the rejected ops, by offset (the ACK gives their indices; scanBatch gives offsets), or skip hints when raw.length is over 256 KiB.
Where: packages/doc/src/query/index.ts:416 (esc handles &<>"' only), and string checks in packages/doc/src/codec/block.ts:159-162 (only a leading BOM is rejected).
Evidence: Probe svgctl.mjs: resvg refuses SVG text containing U+0001 or U+FFFE (“a non-XML character found”). The worker then answers 500 internal.
Impact
format=svg output is not well-formed XML.Fix: In esc, replace characters outside the XML 1.0 Char production (\x00-\x08\x0B\x0C\x0E-\x1F, , ) with U+FFFD.
Where: apps/realtime/src/owner/store.ts:120 (gunzipAsync(gz)).
Evidence: The data is written by the compactor, so it is not user input. Still, a corrupted or malicious blob inflates without limit on an owner thread. Doc workers do cap inflation (apps/docworker/src/store.ts:136).
Fix: gunzip(gz, { maxOutputLength: MAX_NODES_PER_PAGE * 14 + 1 MiB }), or the stored struct_bytes with some slack.
NODE_ENV defaults to developmentWhere: packages/server-common/src/config.ts:97.
Evidence: If NODE_ENV is unset in production:
LINORA_COOKIE_SECURE defaults to false: no __Host- prefix, no Secure;LINORA_ALLOWED_ORIGINS defaults to http://localhost:5173;Fix
NODE_ENV is unset and the process is not attached to a TTY, or set NODE_ENV=production in the Dockerfiles.Where: apps/api/src/main.ts:39 (cfg.host, 0.0.0.0 in production); the realtime metrics server in apps/realtime/src/supervisor.ts (around line 181) does the same.
Impact: /metrics exposes operational data (rates, connection counts, route latencies) on every interface. api.md says it is “kept off the public port”, but only the port differs.
Fix: Add LINORA_*_METRICS_HOST, default 127.0.0.1, and set the private interface in deploy.
Where: apps/api/src/routes/auth.ts:64 (signup returns 409 email_taken); apps/api/src/routes/projects.ts:109,115 (addMember 404 “no account” vs 409 “already a member”).
Impact: Anyone can test whether an email has an account (signup is rate-limited per IP; see SR-10). Project owners can probe without that limit.
Fix: This is a product call. The usual fix is to make signup always answer “check your email”, once email verification exists (tracked as out of scope for v1).
Where
apps/docworker/src/queries/format.ts:148-151, apps/mcp/src/tools/navigation.ts:73,84,97), so a newline cannot forge a new line.navigation.ts:113 (page names in an error hint) and navigation.ts:138 (peer names).Recommendation
Signup creates an account with no verification. createProject makes the caller owner. Every “editor-only” DoS above (SR-01, SR-03, SR-05, SR-06, SR-08) is therefore open to anonymous internet users. Email verification is tracked as out of scope for v1. Until it ships, treat editor as unauthenticated for capacity limits. Per-account quotas would help: projects, files, nodes and bytes per account per day.
Where: apps/realtime/package.json, and package-lock.json:2756-2760 (sha512 integrity present).
Evidence
fsevents is the only package with an install script.Recommendation
npm ci only, so a changed GitHub archive or a moved tag fails closed.npm audit --omit=dev (or an offline SCA) to CI.linora_csrf, but production sets __Host-linora_csrfWhere: apps/web/src/shell/api.ts:45 and apps/api/src/server.ts:93.
Impact: In production the cookie fallback never matches. The header from signup, login or me still works, so this is a robustness issue, not a hole.
Fix: Read both names.
files:read; writer mode is open to any editor clientWhere: apps/realtime/src/gateway/gateway.ts:600-640.
Evidence
SCOPE_READ. The API never mints an rt token without files:read, so this is defense in depth only.mode:'write' (hidden, no presence) is available to any editor socket, not only the API’s. Edits stay attributed in the journal, but peers do not see the editor.Fix
scopes & SCOPE_READ for any subscribe.kind:'agent' API tokens, for example with a claim the API sets.Tokens
verifyToken (packages/server-common/src/token.ts):
v, typ and exp.Sessions and CSRF
__Host- + HttpOnly + Secure + SameSite=Lax.Origin allow-list and JSON-only bodies. Login CSRF is blocked by the Origin and content-type checks.PATs
authorize, and an allow-list may name only the user’s own projects.Passwords
Authorization and tenancy
room.fileId !== req.fileId on subscribe;cache.get(pageId, fileId).SUB_CAN_EDIT).tenancy.test.ts walks the whole route table.SQL: postgres.js tagged templates everywhere; validate() plus format checks run before values reach the database.
Binary input
scanBatch, validateBlock and ByteReader bound every count by the remaining bytes.Paths and compression
inflate with a limit).Output encoding
default-src 'none'.Logging, config and the MCP
.env is gitignored and .env.example holds no secrets. Each tier refuses to start without DATABASE_URL or LINORA_TOKEN_KEYS.Dependencies: every version is pinned exactly, and the lockfile has integrity for every package, uWS included.
docker-compose.prod.yml / docs/ops/deploy.md and packages/editor/src/tools/ were being written during the review. They are covered by the second pass.scanBatch/readOps differential fuzz would be a good next step. (2026-11-30: one already existed and runs in every npm test: packages/doc/test/codec.test.ts › “scanBatch framing fails exactly when shared readOps throws (fuzz)”, 20,000 truncated or corrupted batches.)Verified in the code at main on 2026-11-30, not only in the docs. Every test named here passes; the High and Medium ones were run one by one, and all of them run in npm test and CI. “Fixed differently” means the fix closes the finding by another route than the one suggested above.
| Id | Status | Fix (commits, ADR) | Verified by (test file › test) |
|---|---|---|---|
| SR-01 | Fixed | f040af9, 7ba818c; ADR 0704 (amends 0702), 0105. find has a 100 ms work budget with a resumable cursor and truncated; a regex sees the first 256 characters of a name and runs only on the linear engine; one search in flight per user (4 per IP, 5/s); every query runs under a 2 s guard (a vm timeout, not a worker thread) |
packages/doc/test/query-safety.test.ts (4 tests); apps/docworker/test/guard.test.ts › “nameRegex ReDoS…”, “guarded() preempts…”, “a query over the wall-clock guard answers 503…”; apps/api/test/queries.test.ts › “nodes/search (SR-01)…” |
| SR-02 | Fixed | cc84e68; ADR 0603. The id budget is checked before each run; 1 MiB body cap (64 KiB before a session). 1b0925d also charges repeated runs (second pass S2-S1) |
apps/mcp/test/unit.test.ts › “SR-02: the 40-run probe…”, “id lists…”, “id lists (S2-S1)…”; apps/mcp/test/e2e.test.ts › “SR-02 over HTTP…” |
| SR-03 | Fixed differently | b6eb91f, b0fe7ce, 81dce2d; ADR 0204, realtime.md. A batch carries at most 1,048,576 ids (else protocol_error); above 65,536 ids the summary is a 16-byte header and the owner re-scans, so the 18x copy is gone; a per-user id bucket (2M/s); the backlog check includes the payload; scan arrays shrink after big batches. A binary DELETE may still hold about 1M ids (JSON: 50k) |
apps/realtime/test/security-r1.test.ts › “SR-03: a DELETE of 100k ids…”, “SR-03 + SR-10…” (made deterministic in a718c16); r1-units.test.ts › “scan summary…”; packages/doc/test/transform.test.ts › “ScanBatch: more than MAX_BATCH_EXTRAS…”; overload.test.ts › “bug 1…” |
| SR-04 | Fixed differently | 81dce2d, 0501742; ADR 0205. Each LISTEN reconnect, and every LINORA_REALTIME_RECHECK_S (300 s) instead of a maximum socket age, re-checks open sockets’ sessions, PATs, users, memberships, projects and files in batched queries. Closing every socket on reconnect was rejected (reconnect storm) |
security-r1.test.ts › “a LISTEN reconnect (events may have been lost) triggers a re-check”, “a logged-out session, a removed member and a lowered role…”, and since a718c16 “a revoked, expired or re-scoped PAT, a disabled user and a deleted file or project…”, “the periodic re-check (LINORA_REALTIME_RECHECK_S)…” |
| SR-05 | Fixed differently | 0ca58f0, 81dce2d; deploy.md. PROXY v2 and X-Forwarded-For count only from LINORA_TRUSTED_PROXIES peers (empty: ignored). No required mode (second pass S2-S4) |
security-r1.test.ts › both “SR-05: …”; r1-units.test.ts › “client address: forwarded headers count only from trusted proxies…” |
| SR-06 | Fixed | cc84e68, 0ca58f0; ADR 0603. PAT shape checked before the body; 1 MiB cap plus a byte budget; me cached 30 s; sessions capped per token (10) and per user (20); initialize 2/s per IP; the MCP forwards the agent’s address, trusted only from the edge subnet |
apps/mcp/test/e2e.test.ts › the three “SR-06: …” tests; unit.test.ts › “limits: gate…”, “hosted transport helpers…”; apps/api/test/global-limits.test.ts › “X-Forwarded-For is honoured only from trusted proxies…” |
| SR-07 | Fixed | d48694c, 81dce2d (migration 0003), 8553307, 1e6e7f8, 877462e; ADR 0310. 7be3f9e removed realtime’s TEMPORARY master keyring from the prod compose (ADR 0906) |
packages/server-common/test/token.test.ts (3 tests); apps/docworker/test/roles.test.ts (2); apps/api/test/auth.test.ts › “config refuses to start without secrets…”; deploy/prod-compose.test.mjs › “SR-07: …” (keyrings and DB login per tier) |
| SR-08 | Fixed | b0fe7ce, 7ea6c77; ADR 0105, 0704. toSvg counts its output and has a time budget; text is cut at 4,096 characters; SVG shares the PNG render slot; the rasterizer runs in a child process with a deadline and an RSS cap |
query-safety.test.ts › “SR-08: toSvg stops at maxChars…”; guard.test.ts › “render (SR-08)…”, and since 1b0925d “render (SR-08): SVG goes through the same slot and queue as PNG…”; raster.test.ts (2) |
| SR-09 | Fixed (skew margin) | 81dce2d: a 2 s margin. Receipt time, not commit time, is compared, which fails safe |
r1-units.test.ts › “denylist: tokens minted up to DENY_SKEW_S s after an event (API clock ahead) are still denied” |
| SR-10 | Fixed | 0ca58f0, 81dce2d; 1b0925d (local-store eviction, second pass S2-S2) |
packages/server-common/test/net.test.ts › “bucket keys: IPv6 by /64…”; global-limits.test.ts › “…/64”, “buckets: depleted ones survive eviction…”, “local store (S2-S2)…” |
| SR-11 | Fixed | 8553307, b8a4453 (deploy/nginx/web.conf.template). HSTS stays off on the plain-HTTP local stack by design |
deploy/smoke.mjs step “web headers” (CI job “Images + prod-like smoke”) |
| SR-12 | Fixed | d8d965a (check-sql in npm run check) |
packages/server-common/test/check-sql.test.ts (2) |
| SR-13 | Fixed | 0ca58f0; 1b0925d fails closed when the lockout map cannot track a pair. No known-device bypass (optional) |
global-limits.test.ts › “login lockout: per (account, client)…”, “login lockout fails closed (S2-S2)…” |
| SR-14 | Fixed | 81dce2d |
apps/api/test/units.test.ts › “SR-14: large rejected binary batches are not decoded…” |
| SR-15 | Fixed | b0fe7ce |
query-safety.test.ts › “SR-15: XML-illegal characters…” |
| SR-16 | Fixed | 81dce2d |
security-r1.test.ts › “SR-16: a structure section that inflates past the cap…” |
| SR-17 | Fixed | d48694c, 0ca58f0, 8553307 (images set NODE_ENV=production). Since 7be3f9e production also refuses the published dev secrets (ADR 0906) |
packages/server-common/test/common.test.ts › “loadServerConfig reads required settings…”, “production refuses the published development secrets…” |
| SR-18 | Fixed | 0ca58f0, 81dce2d; 7be3f9e keeps api and realtime metrics on loopback in the prod compose (second pass S2-I5) |
deploy/prod-compose.test.mjs › “SR-18: …” |
| SR-19 | Partly fixed (product call) | 81dce2d: member lookups by email are rate-limited per user. Signup still answers 409 in open mode until email verification exists |
auth.test.ts › “SR-19: adding members by email is rate-limited per user” |
| SR-20 | Mostly fixed | cc84e68; ADR 0603: content is quoted and marked untrusted. Open: the note in every tool description; not acting on ids found only in text |
unit.test.ts › “SR-20: document content is marked as untrusted data” |
| SR-21 | Partly fixed (product call) | 81dce2d: invite-only sign-up is the production default. No per-account quotas yet. The prod-like stack defaults to open, configurable since 7be3f9e |
auth.test.ts › “SR-21: LINORA_SIGNUP=invite…” |
| SR-22 | Fixed / accepted | a849d32 (CI npm ci and npm audit), check-deps rule 7; bee4275 licence gate (ADR 0907). No internal mirror (local-only project) |
tools/check-deps.test.mjs › “lockfile entries must come from the registry with sha512 integrity (SR-22)” |
| SR-23 | Fixed | cd5e24f |
apps/web/test/shell.test.ts › “CSRF cookie: production __Host- name first…” |
| SR-24 | Fixed; hidden write mode accepted | 81dce2d: subscribe needs files:read. Hidden write mode stays open to any editor, by decision |
security-r1.test.ts › “SR-24: subscribe needs files:read” |
Scope: what the first pass did not cover. That is the S3 blob client (packages/server-common/src/blob/), docker-compose.prod.yml, deploy/ and docs/ops/deploy.md, and the server code changed between 7e799f3 and 129274a: api, realtime, mcp, docworker, server-common, shared, migrations 0003-0005, the binary-input parts of packages/doc, and a look at the editor tools. Two independent reviewers read the code and ran probes (SigV4 vectors, socket-pool starvation, uWS header handling, MCP id lists, rate-limit maps, SVG cost); the test-to-fix map above was a third, separate pass.
Result: no cross-tenant read or write path and no authentication bypass. Four Mediums: three are fixed with tests, and one (S2-I2) can only happen once the blob store is switched to S3, which has not happened. Every Low that is a few lines and touches nothing live is fixed; the rest are follow-ups, listed below.
| Id | Sev | Finding | Status |
|---|---|---|---|
| S2-I1 | Medium | The doc worker and realtime mounted the snapshot volume read-write, and the S3 root key went to all four blob tiers. Code execution in the doc worker could rewrite every tenant’s snapshots, since content_hash is not checked on read |
Fixed 7be3f9e (ADR 0906): readers mount read-only and no tier holds an S3 secret while the store is local; deploy/prod-compose.test.mjs. Follow-up: check content_hash on read |
| S2-I2 | Medium (not live) | With LINORA_BLOB_STORE=s3, slow snapshot downloads can hold the API’s 32 S3 sockets: the timeout covers socket inactivity only, a stalled read reopens up to 4 times, and the client side has no write deadline |
Follow-up, before any switch to S3: an in-flight cap per user and IP on GET snapshot, an idle deadline on response writes, and an abort signal that also covers time in the agent queue |
| S2-I3 | Low | A ranged resume accepts any status and Content-Range (and resumes without If-Match when the first response had no ETag) |
Follow-up with the S3 switch: require 206 and a matching start; refuse to resume without an ETag |
| S2-I4 | Low | Plain-HTTP S3 endpoints are accepted in production, and GET bodies are not integrity-checked | Follow-up with the S3 switch: refuse http: in production unless explicitly allowed; content_hash check |
| S2-I5 | Low | SR-18 was only partly fixed: api and realtime bound metrics to 0.0.0.0 on containers that are also on the edge network |
Fixed 7be3f9e; deploy/prod-compose.test.mjs; checked on the running stack (refused from the edge container) |
| S2-I6 | Low | prod:env --force overwrote .env.prod while the stack’s volumes held data, then pointed at down -v |
Fixed 7be3f9e: refuses while the project has volumes, backs up, always 0600; test in deploy/prod-compose.test.mjs |
| S2-I7 | Low | Hardening gaps: web and edge lack read_only and log caps; db, s3 and the one-shot jobs lack cap_drop and no-new-privileges; nginx keeps its default worker connections and header timeout |
Follow-up (needs a custom nginx.conf and tmpfs paths; changes the running edge) |
| S2-I8 | Info | Realtime already read only its per-purpose keyrings, so the TEMPORARY master key line was stale | Fixed 7be3f9e |
| S2-I9 | Info | Base images are pinned by tag, not digest | Accepted for the local stack (ADR 0903); pin digests when images are published |
| S2-I10 | Info | LINORA_TRUSTED_PROXIES trusts the whole edge /24, not just the edge and mcp |
Follow-up: static addresses for edge and mcp, trust only those |
| S2-I11 | Info | S3 client nits: LINORA_S3_PREFIX is not validated; log redaction is exact-match; the query is sent with encodeURIComponent but signed with RFC 3986 encoding (differs only for !'()*, unused today); RequestTimeTooSkewed is retried; the db-roles and s3-init jobs pass passwords on their command lines |
Follow-up |
| S2-S1 | Medium | MCP id lists: a run repeated 10,000 times was walked every time (about 3 s of CPU per call on the event loop) | Fixed 1b0925d: runs are charged their full width; unit.test.ts › “id lists (S2-S1)…” |
| S2-S2 | Medium (local rate store only) | With LINORA_API_RATE_STORE=local (the default is pg), used keys were never evicted, so new clients were refused for good after 100K keys, and a full lockout map silently turned the login lockout off |
Fixed 1b0925d: consumption is tracked only with a sync attached; the lockout fails closed; two tests in global-limits.test.ts |
| S2-S3 | Low | POST /v1/sessions/revoke-others sends one NOTIFY per session inside one transaction, and each gateway scanned every socket slot per event |
Partly fixed a718c16: applyAuth returns early when no socket holds the credential (r1-units.test.ts › “applyAuth: a cred_revoked for a credential no socket here holds…”). Follow-up: cap sessions per user, batch the NOTIFYs |
| S2-S4 | Low | Realtime reads only the first X-Forwarded-For header line, and believes a PROXY v2 header from any trusted peer | Follow-up: join every XFF line; LINORA_REALTIME_PROXY_PROTOCOL=off\|required. Safe in the prod-like stack, whose edge replaces XFF |
| S2-S5 | Low | Render has no per-user admission: one global slot per worker (1 running, 4 queued), so one editor can make render answer 503 for everyone on that worker | Follow-up: an in-flight gate per user and IP, as for search |
| S2-S6 | Low | The per-user op and id buckets are per gateway thread, so 5 gateways allow 5x the documented per-user rate | Follow-up: shared buckets, or rates divided by the gateway count |
| S2-S7 | Info | Small client-address inconsistencies: an over-long XFF is ignored (shared bucket, not a bypass); LINORA_MCP_TRUST_PROXY is a hop count; the MCP’s initialize bucket keys full IPv6 addresses |
Follow-up |
Checked and solid in the second pass (one line each):
.env.prod is 0600 and gitignored, .env* is excluded from the build context, builds come from git archive, and the proxy CA is only a BuildKit secret.7e799f3 (session list and revoke, large-page pool, snapshot revalidation, compact-after-deletes) check scope, tenancy and ids, and use parameterised SQL; no unsafe() outside the migration runner.textarea.value: no HTML sinks.The first public scan of v0.1.0 by CodeQL (.github/workflows/codeql.yml, the security-extended suite) raised 37 alerts. Each one was triaged for reachability: can untrusted input (a client of the API, realtime, the MCP server or a doc worker) reach it in production, or is it operator configuration, tooling or a test? Nothing was reachable by a client in a way that does harm. 27 alerts are fixed in code, each with a test where the code ships; 10 are dismissed with a written reason in code scanning.
| Rule | Alerts | Where | Reachable by a client? | Resolution |
|---|---|---|---|---|
js/polynomial-redos |
11 | /\/+$/ and /^\/+\|\/+$/g in the api, docworker and mcp config, the MCP API client and the S3 client; /[?#].*$/ in the MCP session |
No: env configuration, server-issued URLs. Quadratic all the same (40K / took 470 ms) |
Fixed: a linear character scan, trimTrailingSlashes/trimSlashes (packages/server-common/src/url.ts, one copy in apps/mcp/src/config.ts) and indexOf for shownUrl. Tests: 200K-character inputs finish in under 100 ms (common.test.ts, mcp unit.test.ts) |
js/remote-property-injection |
5 | coerceQuery in apps/api/src/http.ts and apps/docworker/src/worker/server.ts |
Yes, but harmless: ?__proto__=x hit the setter (a string is ignored), so the key was silently dropped |
Fixed: the query object is built with Object.fromEntries, so every client key is an own data property and validation rejects unknown ones. Test: apps/api/test/units.test.ts › “query keys from the client are own data properties…” |
js/remote-property-injection |
1 | the fake S3 server in packages/server-common/test/blob.test.ts |
Test only | Fixed the same way |
js/path-injection |
4 | the static server in tools/demo/check.ts |
Tooling (127.0.0.1 only); it already checked containment, but on a normalize(join()) path |
Fixed: resolve(root, rel) (absolute and normalized) must start with root + sep before any file-system call, and again after a directory’s index.html is added; a malformed % escape answers 400 instead of throwing |
js/server-side-unvalidated-url-redirection |
1 | tools/bench/serve.ts |
Tooling; the location was built from the request path, and mounts[name] also matched constructor |
Fixed: mounts are a Map built at start with their redirect targets; a request only selects one. Same containment check as above |
js/shell-command-injection-from-environment |
1 | git archive … \| tar -x through sh -c in tools/bench/trees.ts |
Tooling (the path was passed as $0, not interpolated) |
Fixed: git archive -o and tar -x -f with argument arrays, no shell |
js/insecure-temporary-file |
2 | tools/bench/trees.ts (a fixed linora-bench name in the shared temp dir), apps/api/test/resources.test.ts |
Tooling and a test | Fixed: the bench cache lives in ${XDG_CACHE_HOME:-~/.cache}/linora-bench (--cache-dir still overrides it); the test uses mkdtempSync |
js/file-system-race |
1 | existsSync then writeFileSync of .env.prod in deploy/prod-env.mjs |
Local operator script | Fixed: one read (ENOENT means absent); a new file is created with flag wx (never over a file that appeared meanwhile), --force writes a fresh 0600 temp file and renames it over the old one, and the backup is created the same way. Test: deploy/prod-compose.test.mjs › “prod:env writes secrets without a check-then-write race…” |
js/incomplete-sanitization |
1 | a hand-escaped RegExp in apps/mcp/test/unit.test.ts |
Test only | Fixed: a plain substring check, no regex |
js/redos |
7 | apps/docworker/test/guard.test.ts, packages/doc/test/query-safety.test.ts |
Test only | Dismissed (used in tests): deliberately catastrophic patterns such as ^(a+)+$ and (a\|a)*b, the probes that prove SR-01’s defence. They run only through compileNameRegex or new RegExp(p, 'l'), the linear-time engine, under time budgets the tests assert |
js/regex-injection |
3 | checkNameRegex and compileNameRegex in packages/doc/src/query/index.ts |
Yes, by design: nameRegex is a user-supplied regex search |
Dismissed (won’t fix): the feature is the user’s pattern. SR-01 (ADR 0704) bounds it: 200-character patterns, the linear-time engine only (flag l; backreferences and lookaround are refused, never run on the backtracking engine), the first 256 characters of each name, a 100 ms find budget with a resumable cursor, a 2 s wall-clock guard, and per-user and per-IP search limits |
Found while triaging, not flagged by CodeQL: the schema validators looked up properties[key] without an own-key check. A request body (from JSON.parse, which makes __proto__ an own key) or a query string with a key named after an Object.prototype member (__proto__, constructor, toString, hasOwnProperty, …) found the prototype’s member, treated it as an empty schema and passed additionalProperties: false. No handler copies unknown keys, so nothing reached the database or another object, but such keys were accepted silently. validate (shared/src/schema.ts) and the MCP’s validateArgs now use own keys only, so these keys are unknown fields (API: 400 bad_request; MCP: “unknown property”), and record schemas check them against their value schema. Tests: shared/test/schema.test.ts › “keys named after Object.prototype members are unknown fields…”, mcp unit.test.ts › “validation names the path and how to fix it”.