Skip to content

fix: sanitize CLI plugin descriptions to prevent HTML/script injection#2532

Merged
briwylde08 merged 1 commit into
mainfrom
fix/sanitize-cli-plugin-descriptions
Jun 25, 2026
Merged

fix: sanitize CLI plugin descriptions to prevent HTML/script injection#2532
briwylde08 merged 1 commit into
mainfrom
fix/sanitize-cli-plugin-descriptions

Conversation

@kalepail

Copy link
Copy Markdown
Contributor

Problem

The CLI plugins list page (/docs/tools/cli/plugins-list) is generated at build time by scripts/stellar_cli_plugins.mjs, which queries GitHub for any repo tagged with the stellar-cli-plugin topic and injects each repo's description verbatim into the MDX file.

Because MDX renders HTML/JSX, an attacker-controlled repo description containing a <script> tag executes in visitors' browsers — a stored XSS.

A repo (haqnawaz03329-debug/haqnawaz) exploited this with the description:

This is a cool plugin! <script>alert('Website Hacked by Haq Nawaz!')</script>

…which produced a "Website Hacked by Haq Nawaz!" popup on the published page.

This vulnerability has existed since the feature shipped in #1900 (3010ea33). The malicious payload itself was never committed to this repo — it's pulled in dynamically at build time from the external repo.

Fix

  • Add a sanitize() helper that escapes HTML/MDX-significant characters (& < > { }) in all injected GitHub fields (covers both HTML <script> and MDX/JSX {...} expression injection).
  • Run repo URLs through encodeURI.
  • Exclude the offending repo via excludePlugins.

Anyone can self-tag a repo with the topic, so sanitization — not just blocking one repo — is the durable fix.

Follow-ups (not in this PR)

  • Redeploy is required to clear the popup from the live site (production serves the already-built page).
  • Consider reporting haqnawaz03329-debug/haqnawaz to GitHub for TOS abuse.
  • Consider a Content-Security-Policy disallowing inline scripts as defense-in-depth.

🤖 Generated with Claude Code

The CLI plugins list page is generated at build time by querying GitHub
for repos tagged with the `stellar-cli-plugin` topic and injecting each
repo's description verbatim into MDX. Because MDX renders HTML/JSX, an
attacker-controlled repo description containing a <script> tag executes
in visitors' browsers (stored XSS).

A repo (haqnawaz03329-debug/haqnawaz) exploited this with a description
of `<script>alert('Website Hacked by Haq Nawaz!')</script>`, surfacing a
popup on the published plugins-list page.

Escape HTML/MDX-significant characters (& < > { }) in all injected
GitHub fields, run URLs through encodeURI, and exclude the offending
repo. Anyone can self-tag a repo with the topic, so sanitization is the
durable fix.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 25, 2026 15:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Hardens the build-time generator for the Stellar CLI plugins list page by ensuring attacker-controlled GitHub repository metadata can’t inject executable HTML/JSX into the generated MDX.

Changes:

  • Add a sanitize() helper to escape HTML/MDX-significant characters in injected GitHub fields.
  • Encode GitHub repository URLs before inserting them into MDX links.
  • Add the known offending repository to excludePlugins as a belt-and-suspenders measure.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stellar-jenkins-ci

Copy link
Copy Markdown

@briwylde08 briwylde08 merged commit 043e447 into main Jun 25, 2026
10 checks passed
@briwylde08 briwylde08 deleted the fix/sanitize-cli-plugin-descriptions branch June 25, 2026 15:22
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.

3 participants