Skip to content

Add input sanitization to prevent injection and XSS attacks (Issue #700)#705

Open
anshul23102 wants to merge 1 commit into
GitMetricsLab:mainfrom
anshul23102:fix/700-input-sanitization
Open

Add input sanitization to prevent injection and XSS attacks (Issue #700)#705
anshul23102 wants to merge 1 commit into
GitMetricsLab:mainfrom
anshul23102:fix/700-input-sanitization

Conversation

@anshul23102
Copy link
Copy Markdown
Contributor

Summary

Sanitize username and email inputs in auth validator to remove potentially dangerous characters and injection patterns. This prevents malicious payloads from being stored in the database and protects against XSS and injection attacks.

Changes

  • Add sanitizeString function that removes HTML tags and script patterns
  • Apply sanitization transform to username and email fields in schemas
  • Remove dangerous characters like <>, quotes, semicolons
  • Strip javascript: protocol and event handler patterns

Testing

  1. Attempt to sign up with username containing HTML tags (e.g., '<script>alert("xss")</script>')
  2. Verify username is stored without tags
  3. Attempt email with injection patterns (e.g., '')
  4. Verify email is sanitized
  5. Verify legitimate usernames/emails with special chars still work as intended

Type of Change

  • Security fix

Contributor Declaration

This contribution is original work and I have the right to contribute this code to the project. I understand that the project is licensed under its respective license and my contributions will be available under the same license terms.

Closes #700

…tMetricsLab#700)

Sanitize username and email inputs in auth validator to remove potentially dangerous characters and injection patterns. This prevents malicious payloads from being stored in the database and protects against XSS and injection attacks.

Changes:
- Add sanitizeString function that removes HTML tags and script patterns
- Apply sanitization transform to username and email fields in schemas
- Remove dangerous characters like <>, quotes, semicolons
- Strip javascript: protocol and event handler patterns

Fixes GitMetricsLab#700
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Warning

Review limit reached

@anshul23102, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 59 minutes and 25 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: df46f4ff-5b33-42cb-ab04-dfd4d9bc162b

📥 Commits

Reviewing files that changed from the base of the PR and between 53f820b and bd0618f.

📒 Files selected for processing (1)
  • backend/validators/authValidator.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 3, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit bd0618f
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a209d1b57543000080f3406
😎 Deploy Preview https://deploy-preview-705--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@anshul23102
Copy link
Copy Markdown
Contributor Author

Could the maintainers please add relevant labels to this PR? Suggested labels:

  • gssoc:approved
  • type:security
  • severity:high
  • area:security

This would help with issue tracking and organization. Thank you!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validation: Username and email lack input sanitization, vulnerable to injection and script attacks if stored in database

1 participant