Fix high audit findings and port the hidden-media rule

Fixed findings from the audit reports (SECURITY, QUALITY, PERFORMANCE):
- P-001 · Unbounded per-session timing maps and no connection cap in the sync hub
- S-001 · Anonymous `PUT /access` switches off login for every guarded route
- S-002 · Malformed cookies crash the Node middleware and fail requests in Java
- S-004 · Anonymous `PUT /sync` writes unvalidated JSON into shared session state

Also includes the pre-existing uncommitted changes in web-ui, README, shared-styles and the .changeset files, as the owner asked.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
Gabriel20xxandClaude Haiku 5.5 committed 2026-10-19 07:47:10 +00:00
1 parent 7fd2f14f91
commit 199a5efaef
12 files changed
+445 -42

No files matched your search

@@ -125,6 +125,29 @@ test('tokenFromRequest falls back to the auth_session cookie', () => {
assert.equal(client.tokenFromRequest(req), 'cookie-token');
});
test('tokenFromRequest treats a malformed cookie escape as no token', () => {
const client = new AuthClient('https://auth.example.com');
const req = { headers: { cookie: 'auth_session=bad%zz; other=1' } };
assert.equal(client.tokenFromRequest(req), '');
});
test('middleware answers 401 instead of rejecting on a malformed cookie', async () => {
const client = new AuthClient('https://auth.example.com', {
fetchImpl: fakeFetch([{ status: 401, body: { valid: false } }]),
});
let statusCode = null;
const res = {
status(code) {
statusCode = code;
return { json: () => {} };
},
};
await client.middleware()({ headers: { cookie: 'auth_session=100%' } }, res, () => {
throw new Error('next should not be called');
});
assert.equal(statusCode, 401);
});
test('middleware attaches authUser on success and 401s on failure', async () => {
const okClient = new AuthClient('https://auth.example.com', {
fetchImpl: fakeFetch([{ status: 200, body: { valid: true, user_id: 1, username: 'a', role: 'user' } }]),