Skip to content

πŸ›‘οΈ Sentinel: [security improvement] Fix XSS in JSON-LD structured data#69

Draft
saynchowdhury wants to merge 1 commit into
mainfrom
sentinel/fix-jsonld-xss-2216569629054552470
Draft

πŸ›‘οΈ Sentinel: [security improvement] Fix XSS in JSON-LD structured data#69
saynchowdhury wants to merge 1 commit into
mainfrom
sentinel/fix-jsonld-xss-2216569629054552470

Conversation

@saynchowdhury

Copy link
Copy Markdown
Member

πŸ›‘οΈ 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 safeJsonLd utility in lib/utils.ts that safely stringifies data for JSON-LD by escaping < and > characters to \u003c and \u003e. Applied this utility to app/layout.tsx, app/blog/page.tsx, app/blog/[slug]/page.tsx, and app/opportunity/[id]/page.tsx.
βœ… Verification: Added comprehensive unit tests in __tests__/lib/utils.test.ts and verified the escaping logic with a standalone TypeScript script. Ran pnpm test and pnpm lint to ensure no regressions.


PR created automatically by Jules for task 2216569629054552470 started by @saynchowdhury

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>
@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
foundery.space Error Error Jul 8, 2026 9:07am

@google-labs-jules

Copy link
Copy Markdown

πŸ‘‹ 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.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: df2d8461-33a2-4ccd-8a63-95fe92ce4efb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • πŸ” Trigger review
✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sentinel/fix-jsonld-xss-2216569629054552470

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.

@supabase

supabase Bot commented Jul 8, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project tpvpacwoquygbykcjqle because there are no changes detected in /supabase/supabase directory. You can change this behaviour in Project Integrations Settings β†—οΈŽ.


Preview Branches by Supabase.
Learn more about Supabase Branching β†—οΈŽ.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant