π‘οΈ Sentinel: [security improvement] Fix XSS in JSON-LD structured data#69
π‘οΈ Sentinel: [security improvement] Fix XSS in JSON-LD structured data#69saynchowdhury wants to merge 1 commit into
Conversation
This commit introduces a `safeJsonLd` utility to mitigate Cross-Site Scripting (XSS) risks when injecting structured data into the page. Vulnerability: Using `JSON.stringify` within `dangerouslySetInnerHTML` for script tags does not escape `<` and `>` characters, allowing malicious content to break out of the tag (e.g., `</script><script>alert(1)</script>`). Impact: Potential for arbitrary JavaScript execution if scraped data or user-submitted content contains malicious strings. Fix: Implemented `safeJsonLd` in `lib/utils.ts` which stringifies the data and replaces `<` and `>` with their Unicode escape sequences (`\u003c` and `\u003e`). This utility is now used in all JSON-LD script blocks across the application. Verification: - Added unit tests in `__tests__/lib/utils.test.ts`. - Verified escaping logic with a standalone test script. - Confirmed all existing tests pass and no linting errors are present. Co-authored-by: saynchowdhury <205922286+saynchowdhury@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
π 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the βοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
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. Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
π‘οΈ Sentinel: [security improvement]
π¨ Severity: HIGH
π‘ Vulnerability: Cross-Site Scripting (XSS) in JSON-LD script tags.
π― Impact: Malicious data (e.g., from scraped content or user submissions) can break out of the
<script>tag using</script>and execute arbitrary JavaScript in the user's browser.π§ Fix: Introduced a
safeJsonLdutility inlib/utils.tsthat safely stringifies data for JSON-LD by escaping<and>characters to\u003cand\u003e. Applied this utility toapp/layout.tsx,app/blog/page.tsx,app/blog/[slug]/page.tsx, andapp/opportunity/[id]/page.tsx.β Verification: Added comprehensive unit tests in
__tests__/lib/utils.test.tsand verified the escaping logic with a standalone TypeScript script. Ranpnpm testandpnpm lintto ensure no regressions.PR created automatically by Jules for task 2216569629054552470 started by @saynchowdhury