Skip to content

Latest commit

 

History

History
102 lines (71 loc) · 8.76 KB

DEPENDENCY_FIXES.md

File metadata and controls

102 lines (71 loc) · 8.76 KB

Dependency and AI Server Action remediation

Remediation date: 2026-08-19

Audit result

The original lockfile produced 12 production findings from npm audit --omit=dev: 8 high, 3 moderate, and 1 low.

After the upgrades and lockfile refresh:

info: 0
low: 0
moderate: 0
high: 0
critical: 0
total: 0

Both npm audit and npm audit --omit=dev now report zero vulnerabilities.

Dependency changes

Package Before Resolved Reason
next 16.1.6 16.3.1 Current patched stable release for the affected Next.js 16 ranges
eslint-config-next 16.1.6 16.3.1 Keeps framework lint rules aligned with Next.js
react / react-dom 19.0.0 19.2.8 Aligns the React runtime with the current Next.js release
@types/react 18.3.27 19.2.18 Removes the React 18/19 runtime-type mismatch
@types/react-dom 18.3.7 19.2.4 Removes the React DOM 18/19 runtime-type mismatch
@anthropic-ai/sdk 0.71.2 0.118.0 Current SDK with supported model/API typings
direct ws 8.19.0 8.21.3 Fixes memory disclosure and memory-exhaustion advisories
socket.io / socket.io-client 4.8.3 removed The unauthenticated relay was replaced by the authenticated Yjs WebSocket service
engine.io stack vulnerable transitives removed No Engine.IO transport remains in the application graph
postcss / nanoid vulnerable transitives 8.5.23 / 3.3.18 Removes source-map disclosure and generator-loop findings
sharp vulnerable <0.35.0 0.35.3 Removes inherited libvips findings
body-parser / qs vulnerable transitives 2.3.0 / 6.15.3 Removes request parsing denial-of-service findings
dompurify 3.4.8 through Monaco override to 3.4.14 Removes the remaining sanitizer findings while Monaco pins an older patch
eslint 9.19.0 9.39.5 Removes the development-only plugin-kit ReDoS chain

.npmrc was deleted, removing legacy-peer-deps=true. The final dependency installation succeeds with normal npm peer resolution and the React 19 type packages dedupe across the tree.

Advisories resolved

Next.js 16.1.6 to 16.3.1

The upgrade moves beyond all vulnerable Next.js ranges reported by the original audit, including:

The refreshed Next.js dependency graph also resolves the audited PostCSS advisories GHSA-qx2v-qp2m-jg93, GHSA-6g55-p6wh-862q, GHSA-fxqj-rqcc-2cmp, and GHSA-r28c-9q8g-f849, plus Sharp/libvips GHSA-f88m-g3jw-g9cj.

WebSocket and former Socket.IO stack

Other audited transitives

AI Server Action hardening

Both exported actions now authenticate with supabase.auth.getUser() before inspecting or processing caller input. Unauthenticated requests receive Authentication required and never reach Anthropic.

Runtime input limits are enforced even when TypeScript and the UI are bypassed:

Input Maximum
Completion prompt 8,000 characters
Completion context 32,000 characters
Inline prefix 24,000 characters
Inline suffix 12,000 characters
Language identifier 64 restricted characters

Migration 20260819000500_ai_usage_budget.sql adds an RLS-protected ai_usage_events table and reserve_ai_usage() function. The function derives the user from auth.uid(), serializes concurrent reservations per user with a transaction advisory lock, and atomically enforces:

  • 5 requests per rolling minute;
  • 50 requests per rolling day;
  • 250,000 submitted input characters per rolling day.

Clients have no direct INSERT permission. A quota-database error fails closed, so an unavailable budget store cannot turn into unlimited Anthropic usage. Reservations happen before the external API call, preventing failed-request floods from bypassing the budget.

Prompt, context, prefix, suffix, code, email, API responses, and exception messages are never logged. Logs contain only action name, status/reason, model, character/token counts, duration, and an error class/code. Anthropic calls also have a 30-second timeout.

Anthropic model changes

  • claude-3-5-sonnet-20241022 was replaced with Anthropic's documented successor claude-sonnet-4-6.
  • claude-3-5-haiku-20241022 was replaced with claude-haiku-4-5-20251001.

Anthropic lists both 3.5 IDs as retired and states that requests to retired models fail. See Anthropic model deprecations and model IDs and versioning.

Required deployment order

Apply supabase/migrations/20260819000500_ai_usage_budget.sql before deploying the updated Server Actions. Until the RPC exists, AI requests intentionally fail closed with a temporary-unavailable response.