sumaid.github.io

Security Policy & Guidelines

Fixed Security Issues

1. 🔴 CRITICAL: Exposed API Key ✅ FIXED

2. 🟡 HIGH: HTML/Email Injection ✅ FIXED

3. 🟡 HIGH: Missing Input Validation ✅ FIXED

4. 🟡 MEDIUM: Missing CORS Headers ✅ FIXED

5. 🟢 LOW: target=”_blank” Security ✅ SECURE


Security Best Practices Applied

Input Validation

// Length validation
if (trimmedName.length > 100 || trimmedMessage.length > 5000) {
  return res.status(400).json({ message: 'Input too long' });
}

// Email format validation
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(trimmedEmail)) {
  return res.status(400).json({ message: 'Invalid email format' });
}

HTML Sanitization

function sanitizeHTML(str) {
  const map = {
    '&': '&',
    '<': '&lt;',
    '>': '&gt;',
    '"': '&quot;',
    "'": '&#039;',
  };
  return str.replace(/[&<>"']/g, (m) => map[m]);
}

Error Handling


Remaining Recommendations

1. Rate Limiting (Not Implemented - Optional)

Consider adding rate limiting to prevent spam:

npm install express-rate-limit

2. CAPTCHA (Not Implemented - Optional)

Consider adding reCAPTCHA or similar:

3. Email Verification (Optional)

Add email verification before processing:

4. API Authentication (Optional)

For future enhancement:

5. Content Security Policy (Optional)

Add CSP headers in next.config.js:

headers: async () => {
  return [
    {
      source: '/(.*)',
      headers: [
        {
          key: 'Content-Security-Policy',
          value: "default-src 'self'"
        }
      ]
    }
  ]
}

Environment Variables

Required

RESEND_API_KEY=your_api_key_here

Optional

NEXT_PUBLIC_DOMAIN=yourdomain.com

Security Checklist


Deployment Security

Before Deployment:

  1. Set RESEND_API_KEY in production environment variables
  2. Enable HTTPS only
  3. Set secure headers (done in Next.js by default)
  4. Review all environment variables
  5. Update .env.local with production values (never commit)

In Production:

  1. Monitor API logs for suspicious activity
  2. Keep dependencies updated: npm audit fix
  3. Regularly review security updates
  4. Monitor your email for form submissions

Reporting Security Issues

If you find a security vulnerability, please report it responsibly without disclosing publicly.


Last Updated: March 24, 2026