Skip to content

Security: CSP, rate-limit phishing, CDN denylist, audit rotation#540

Open
sandrawillow001-afk wants to merge 1 commit into
MettaChain:mainfrom
sandrawillow001-afk:security/csp-rate-limit-cdn-audit-rotation
Open

Security: CSP, rate-limit phishing, CDN denylist, audit rotation#540
sandrawillow001-afk wants to merge 1 commit into
MettaChain:mainfrom
sandrawillow001-afk:security/csp-rate-limit-cdn-audit-rotation

Conversation

@sandrawillow001-afk

@sandrawillow001-afk sandrawillow001-afk commented Jun 27, 2026

Copy link
Copy Markdown

Summary

Resolves issues #445, #446, #449, #450 assigned to sandrawillow001-afk.

Changes

#445 - Enforce strict CSP in production middleware

  • Created \src/middleware.ts\ with strict CSP (default-src 'self', script-src with nonce)
  • Created \src/app/api/csp-report/route.ts\ for CSP violation reports
  • Added Playwright E2E test verifying CSP headers
  • Documented CSP policy in \docs/csp.md\

#446 - Rate-limit phishing detection lookups

  • Added memoization per \window.location.origin\ in \PhishingProtection.detectPhishing\
  • Added rate-limited
    eportPhishing\ with configurable max reports
  • Added tests for memoization and rate-limiting

#449 - CDN-sourced phishing denylist with signed manifest

  • Added \loadManifestFromCDN\ with manifest verification
  • Reduced fallback list to 3 domains, 1 contract
  • Documented manifest schema and update procedure in \docs/phishing-denylist.md\

#450 - Audit log rotation & quota enforcement

  • Implemented LRU-by-time eviction with size cap (10K entries)
  • Warning at 90% capacity; remote export before eviction
  • Alert rotation with recency-based sorting
  • Documented retention policy in \docs/audit-retention.md\

Verification

…d denylist, audit log rotation

- Create src/middleware.ts with strict CSP headers (default-src 'self', img-src, script-src with nonce)
- Create src/app/api/csp-report/route.ts for CSP violation reports
- Add Playwright E2E test verifying CSP headers block inline scripts
- Add docs/csp.md documenting the policy

- Add memoization per window.location.origin in PhishingProtection.detectPhishing
- Add rate-limited reportPhishing with configurable max reports per minute
- Add clearMemoizedResults for testing
- Add tests for memoization and rate-limiting behavior

- Add loadManifestFromCDN with signed manifest verification
- Keep minimal fallback list (3 domains, 1 contract) for offline scenarios
- Add docs/phishing-denylist.md documenting manifest schema and update procedure
- Add tests for CDN fallback behavior

- Implement LRU-by-time eviction when MAX_LOG_SIZE exceeded
- Add warning at 90% capacity threshold
- Export evicted entries to remote sink before removal
- Add alert rotation with recency-based sorting
- Add docs/audit-retention.md documenting retention policy
- Add tests for eviction, warning, and alert rotation
@sandrawillow001-afk sandrawillow001-afk force-pushed the security/csp-rate-limit-cdn-audit-rotation branch from c6531db to 44dd445 Compare June 27, 2026 11:31
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@sandrawillow001-afk Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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

Labels

None yet

Projects

None yet

1 participant