Skip to content

fix(security): Critical production hardening#7

Open
ibrsiaika wants to merge 3 commits intovydyas:mainfrom
ibrsiaika:main
Open

fix(security): Critical production hardening#7
ibrsiaika wants to merge 3 commits intovydyas:mainfrom
ibrsiaika:main

Conversation

@ibrsiaika
Copy link

CRITICAL FIXES:

  • CB-1: Downgrade React from 19 RC to stable 18.3.1
  • CB-2: Implement admin auth checks on all admin routes (requireAdminAuth helper)
  • CB-3: Add comprehensive localStorage-Supabase sync hook (use-resume-sync)
    • Debounced auto-save every 1 second
    • Periodic cloud sync every 3 seconds
    • Conflict resolution with localStorage backup
    • Prevents data loss on logout
  • CB-4: Add DOMPurify sanitization & enhanced Zod validation
    • Sanitize all HTML text fields
    • Validate input sizes (max 5000 chars for descriptions)
    • Strict schema validation with field limits
    • Add isomorphic-dompurify package
  • CB-5: Fix memory leak in Resume component
    • Remove JSON.stringify key (causes full re-mounts)
    • Add React.memo with deep prop comparison
    • Prevent DOM node leaks from drag-drop listeners

SECURITY Updates:

  • HD-4: Implement in-memory rate limiting middleware
    • Per-IP rate limiting (100 req/min)
    • Per-user auth limiting (7 req/15min)
    • 429 status codes with Retry-After headers
    • Ready for Upstash Redis integration
  • SC-1: Add comprehensive security headers in next.config.ts
    • Content-Security-Policy with strict directives
    • X-Frame-Options: DENY
    • X-Content-Type-Options: nosniff
    • X-XSS-Protection headers
    • Referrer-Policy: strict-origin-when-cross-origin
    • Permissions-Policy: disable camera/mic/geolocation

DEPENDENCIES ADDED:

  • dompurify@3.0.6 (HTML sanitization)
  • isomorphic-dompurify@2.3.0 (SSR-safe sanitization)

TESTING:

  • Project builds successfully (webpack/TypeScript compilation)
  • No breaking changes to existing functionality
  • ESLint warnings noted (unused imports can be cleaned in next commit)

See CRITICAL BUGS section of audit for detailed vulnerability descriptions.

CRITICAL FIXES:
- CB-1: Downgrade React from 19 RC to stable 18.3.1
- CB-2: Implement admin auth checks on all admin routes (requireAdminAuth helper)
- CB-3: Add comprehensive localStorage-Supabase sync hook (use-resume-sync)
  * Debounced auto-save every 1 second
  * Periodic cloud sync every 3 seconds
  * Conflict resolution with localStorage backup
  * Prevents data loss on logout
- CB-4: Add DOMPurify sanitization & enhanced Zod validation
  * Sanitize all HTML text fields
  * Validate input sizes (max 5000 chars for descriptions)
  * Strict schema validation with field limits
  * Add isomorphic-dompurify package
- CB-5: Fix memory leak in Resume component
  * Remove JSON.stringify key (causes full re-mounts)
  * Add React.memo with deep prop comparison
  * Prevent DOM node leaks from drag-drop listeners

SECURITY Updates:
- HD-4: Implement in-memory rate limiting middleware
  * Per-IP rate limiting (100 req/min)
  * Per-user auth limiting (7 req/15min)
  * 429 status codes with Retry-After headers
  * Ready for Upstash Redis integration
- SC-1: Add comprehensive security headers in next.config.ts
  * Content-Security-Policy with strict directives
  * X-Frame-Options: DENY
  * X-Content-Type-Options: nosniff
  * X-XSS-Protection headers
  * Referrer-Policy: strict-origin-when-cross-origin
  * Permissions-Policy: disable camera/mic/geolocation

DEPENDENCIES ADDED:
- dompurify@3.0.6 (HTML sanitization)
- isomorphic-dompurify@2.3.0 (SSR-safe sanitization)

TESTING:
- Project builds successfully (webpack/TypeScript compilation)
- No breaking changes to existing functionality
- ESLint warnings noted (unused imports can be cleaned in next commit)

See CRITICAL BUGS section of audit for detailed vulnerability descriptions.
@vercel
Copy link

vercel bot commented Dec 18, 2025

Someone is attempting to deploy a commit to the vydyas' projects Team on Vercel.

A member of the Team first needs to authorize it.

@vydyas
Copy link
Owner

vydyas commented Dec 18, 2025

thansks for the PR. I'll review it

@ibrsiaika
Copy link
Author

ibrsiaika commented Dec 18, 2025

@vydyas theres any problem?

@ibrsiaika
Copy link
Author

@vydyas I need the required test keys for the .env file to run the project locally.
Could you please share

@vydyas
Copy link
Owner

vydyas commented Dec 18, 2025

@ibrsiaika You can create your own in Clerk, Supabase

here is the env file

NEXT_PUBLIC_LINKEDIN_CLIENT_ID=
NEXT_PUBLIC_APP_URL=

# Root Environment Variables
# Copy this to .env.local and fill in your values

# Clerk Authentication (Get from https://dashboard.clerk.com)
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=

# Supabase (Get from https://supabase.com/dashboard)
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_SERVICE_ROLE_KEY=

# Required: Your Resend API key
RESEND_API_KEY=

# Optional: Custom "from" email address
# Format: "Display Name <email@domain.com>"
# If not set, defaults to: SimpleResu.me <welcome@simpleresu.me>
FROM_EMAIL=SimpleResu.me <welcome@simpleresu.me>

@ibrsiaika
Copy link
Author

@vydyas this not good?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants