Skip to content

fix(swagger-ui): escape the title and options embedded in the page - #2219

Merged
yusukebe merged 2 commits into
mainfrom
fix/swagger-ui-escape
Oct 28, 2026
Merged

yusukebe merged 2 commits into
mainfrom
fix/swagger-ui-escape

Conversation

@yusukebe

@yusukebe yusukebe commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

title was inserted into <title> unescaped, and string options were embedded in the inline script as bare '...' literals, so a ', </script> or </title> in an option could break out.

Escape the title with html, and serialize string and JSON options through JSON.stringify() with <, >, U+2028 and U+2029 escaped. String options are now double-quoted in the output.

Reported by @Jeg4nX19.

The author should do the following, if applicable

  • Add tests
  • Run tests
  • pnpm changeset at the top of this repo and push the changeset
  • Follow the contribution guide

@changeset-bot

changeset-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fef4a57

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hono/swagger-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@yusukebe
yusukebe merged commit 28b6f52 into main Oct 28, 2026
6 checks passed
@yusukebe
yusukebe deleted the fix/swagger-ui-escape branch October 28, 2026 11:12
@github-actions github-actions Bot mentioned this pull request Oct 28, 2026
@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.69%. Comparing base (30732e9) to head (fef4a57).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2219   +/-   ##
=======================================
  Coverage   92.69%   92.69%           
=======================================
  Files         119      119           
  Lines        4354     4356    +2     
  Branches     1135     1135           
=======================================
+ Hits         4036     4038    +2     
  Misses        283      283           
  Partials       35       35           
Flag Coverage Δ
swagger-ui 95.45% <100.00%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Jeg4nX19

Copy link
Copy Markdown

Thanks for fixing this, releasing the patched version (0.6.2), and crediting me in the PR.

Would you consider publishing a GitHub Security Advisory for this issue and requesting a CVE ID? The pre-patch behavior allowed a </script> / </title> / single-quote break-out when an integrator passed attacker-influenced values into title, spec, or the string options (url, configUrl, layout, etc.), leading to script execution in the Swagger UI page. That's the same class and impact basis as CVE-2026-33331 (@orpc/openapi), which was accepted as an XSS advisory.

I have a working browser-execution reproduction (plus a command-line curl + headless-Chrome DOM-dump proof) and am happy to share full technical details if useful.

I understand CVE eligibility and severity are ultimately your decision. Thanks again for addressing this.

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.

2 participants