# Codebase Audit — Summary **Date:** 2026-04-23 **Branch:** `codex/chore/codebase-audit` **Scope:** `src/` (~50k LOC, 364 files) **Method:** 7 parallel read-only agents, each focused on a distinct angle. No source files were modified. ## Reports | # | Angle | File | Headline | |---|---|---|---| | 01 | React anti-patterns | [01-react-anti-patterns.md](01-react-anti-patterns.md) | Moderate-to-good; effect cascades and copy-paste clusters are the main cost | | 02 | State management | [02-state-management.md](02-state-management.md) | `use-catalog-filters-store` is seriously broken; no `useShallow` anywhere | | 03 | Security | [03-security.md](03-security.md) | RNG polyfill is a critical latent bug; no CSP; embed iframes are under-sandboxed | | 04 | Dead code & duplication | [04-dead-code-duplication.md](04-dead-code-duplication.md) | Codebase is remarkably clean; duplication is the real issue | | 05 | Accessibility | [05-accessibility.md](05-accessibility.md) | Posting/reply surfaces are unlabeled; modals aren't real dialogs | | 06 | Performance | [06-performance.md](06-performance.md) | Three critical re-render hotspots; zero lazy-loaded images in feeds | | 07 | Type safety | [07-type-safety.md](07-type-safety.md) | Good overall; 4 realistic runtime-crash `!` assertions and a `PostProps.post?: any` leak | ## Criticals Across All Reports The 11 findings worth fixing first, consolidated: 1. **RNG polyfill backed by `Math.random()`** — `src/polyfills.js:20-29`. Catastrophic for keypair/signature derivation if ever hit. _Security._ 2. **`use-catalog-filters-store` stores a closure in state, mutates during render via `setTimeout`, primes before persist rehydration** — `src/stores/use-catalog-filters-store.ts`. _State mgmt._ 3. **No Content-Security-Policy** anywhere in `vercel.json` / `index.html`. _Security._ 4. **Third-party embed scripts inherit 5chan origin** — Twitter/Reddit/TikTok/Instagram widgets in `src/components/embed/embed.tsx` load into `about:srcdoc` iframes without `sandbox` or SRI. _Security._ 5. **Peer-supplied media URLs pass without a protocol/host allow-list** — only `new URL(url)` validation. _Security._ 6. **Mod-queue derived-state-via-effect cascade** — `src/views/mod-queue/mod-queue.tsx:672-772`, `ModQueueCountItem` renders null just to lift state upward through effects per feed item. _React patterns._ 7. **`reply-modal` has 8 `useEffect`s with explicit infinite-loop guard refs** — `src/components/reply-modal/reply-modal.tsx:104-288`. Author's own comments acknowledge the problem. _React patterns._ 8. **Reply-modal & post-form inputs have no programmatic labels** — placeholders only; not inside `