Skip to content

fix : harden rehype-sanitize schema against SVG XSS and javascript: URL injection#2422

Closed
tmdeveloper007 wants to merge 1 commit into
nisshchayarathi:mainfrom
tmdeveloper007:#83
Closed

fix : harden rehype-sanitize schema against SVG XSS and javascript: URL injection#2422
tmdeveloper007 wants to merge 1 commit into
nisshchayarathi:mainfrom
tmdeveloper007:#83

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Summary

The default rehype-sanitize schema allows SVG elements which can carry event handlers (onload, onerror) that execute JavaScript. javascript: URLs in href attributes were also not explicitly blocked.

Changes

  • Create lib/utils/markdownSanitization.ts with createStrictMarkdownSchema() that:
    • Strips SVG/foreignObject/use/symbol/defs elements entirely.
    • Blocks javascript:, data:, vbscript: URLs in all URL attributes.
    • Blocks CSS expression() and behavior injection in style attributes.
    • Strips all event-handler attributes (on*) from all elements.
  • Update AIChatInterface, AIRepoMentorSection, AIRepositoryOverlay to use strictMarkdownSchema.
  • Sanitize href with sanitizeMarkdownHref() and add rel="noopener".

Note

Assign to tmdeveloper007

…RL injection

Issue: nisshchayarathi#83

The default rehype-sanitize schema allows SVG elements which can carry
event handlers (onload, onerror, etc.) that execute JavaScript.
javascript: URLs in href/src attributes were also not explicitly blocked.

Changes:
- Create lib/utils/markdownSanitization.ts with createStrictMarkdownSchema()
  that strips SVG/foreignObject/use/symbol/defs elements entirely.
- Block javascript:, data:, vbscript: URLs in all URL-carrying attributes.
- Block CSS expression() and behavior injection in style attributes.
- Strip all event-handler attributes (on*) from all elements.
- Update AIChatInterface, AIRepoMentorSection, AIRepositoryOverlay
  to use strictMarkdownSchema and sanitize href with sanitizeMarkdownHref.
- Add rel="noopener" to external links for additional security.
@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

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

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

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ 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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7a398a7d-96f1-4ca0-9f2f-eb33cfaac628

📥 Commits

Reviewing files that changed from the base of the PR and between d4e21a5 and 47541b3.

📒 Files selected for processing (4)
  • lib/utils/markdownSanitization.ts
  • src/components/ai/AIChatInterface.tsx
  • src/components/ai/AIRepoMentorSection.tsx
  • src/components/ai/AIRepositoryOverlay.tsx
✨ 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.

@github-actions github-actions Bot added the gssoc:invalid GSSoC: Invalid contribution label Jun 20, 2026
@github-actions

Copy link
Copy Markdown

⚠️ GSSoC Quality Check Failed — PR #2422

Hi @tmdeveloper007! 👋 Your PR has been flagged by our automated GSSoC quality check.

Issues found:

  • 🔗 No linked issue — Every PR must be linked to an open issue. Add closes #<issue-number> or fixes #<issue-number> in your description so maintainers know what this PR resolves.

✅ How to fix this

  1. Read the issues listed above carefully
  2. Edit your PR title and description to address them
  3. Make sure your PR is linked to an open issue using closes #<issue-number>
  4. Make sure your changes are meaningful and solve a real problem

Once you've fixed these, a maintainer will review and remove the flag. If you believe this is a mistake, please comment below. 🙏

GSSoC'26 automation · Maintainer: @nisshchayarathi

Comment on lines +50 to +55
return value
.replace(/expression\s*\(/gi, " blocked(")
.replace(/behavior\s*:/gi, " blocked:")
.replace(/url\s*\(/gi, " url(blocked")
.replace(/javascript:/gi, " blocked:")
.replace(/data:/gi, " blocked:");
@tmdeveloper007

Copy link
Copy Markdown
Contributor Author

Closing this PR. The branch is based on an older commit of upstream/main and has drifted from the current main. The upstream repository has received significant updates since this PR was opened, causing CI type-check and test failures due to merge conflicts with the base branch. Please re-open as a fresh PR against the current main if the fix is still needed.

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

Labels

gssoc:invalid GSSoC: Invalid contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants