🛡️ Sentinel: Enhance email security with strict validation and sanitization #39

Merged
ragusa-it merged 2 commits from sentinel-email-security-enhancement-1361969690950207643 into main 2026-01-30 05:00:02 +00:00
ragusa-it commented 2026-01-30 01:48:49 +00:00 (Migrated from github.com)

🛡️ Sentinel: [Security Enhancement] Strict Email Validation & Sanitization

Vulnerability:
Email addresses containing double quotes (") or backticks (`) can potentially be used as vectors for XSS attacks (e.g., attribute breakout) if injected into HTML templates without proper escaping. While isValidEmail previously filtered < and >, it allowed quotes.

Enhancement:

  1. Strict Validation: Updated isValidEmail regex to explicitly reject " and `.
    • Note: Apostrophes (') are allowed to support names like "O'Connor".
  2. Defense in Depth: Updated Contact.tsx to sanitize the email field using sanitizeInput before sending it to EmailJS. This ensures that even valid characters like ' are escaped (to &#039;) preventing any potential HTML attribute manipulation.
  3. Testing: Added comprehensive test cases to src/utils/security.test.ts to verify valid (apostrophes) and invalid (quotes/backticks) inputs.

Verification:

  • src/utils/security.test.ts passes.
  • Verified manual test script confirming correct regex behavior.

Journal:

  • Added entry regarding Strict Email Regex vs RFC Compliance trade-offs.

PR created automatically by Jules for task 1361969690950207643 started by @ragusa-it

🛡️ Sentinel: [Security Enhancement] Strict Email Validation & Sanitization **Vulnerability:** Email addresses containing double quotes (`"`) or backticks (`` ` ``) can potentially be used as vectors for XSS attacks (e.g., attribute breakout) if injected into HTML templates without proper escaping. While `isValidEmail` previously filtered `<` and `>`, it allowed quotes. **Enhancement:** 1. **Strict Validation:** Updated `isValidEmail` regex to explicitly reject `"` and `` ` ``. - Note: Apostrophes (`'`) are *allowed* to support names like "O'Connor". 2. **Defense in Depth:** Updated `Contact.tsx` to sanitize the `email` field using `sanitizeInput` before sending it to EmailJS. This ensures that even valid characters like `'` are escaped (to `&#039;`) preventing any potential HTML attribute manipulation. 3. **Testing:** Added comprehensive test cases to `src/utils/security.test.ts` to verify valid (apostrophes) and invalid (quotes/backticks) inputs. **Verification:** - `src/utils/security.test.ts` passes. - Verified manual test script confirming correct regex behavior. **Journal:** - Added entry regarding Strict Email Regex vs RFC Compliance trade-offs. --- *PR created automatically by Jules for task [1361969690950207643](https://jules.google.com/task/1361969690950207643) started by @ragusa-it*
google-labs-jules[bot] commented 2026-01-30 01:48:50 +00:00 (Migrated from github.com)

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to **Reactive Mode**. When this mode is on, I will only act on comments where you specifically mention me with `@jules`. You can find this option in the **Pull Request** section of your [global Jules UI settings](https://jules.google.com/settings). You can always switch back! New to Jules? Learn more at [jules.google/docs](https://jules.google/docs). --- *_For security, I will only act on instructions from the user who triggered this task._*
Sign in to join this conversation.