Skip to content

Fix double-unescaping in decodeEntities (CodeQL alert #32)#1757

Merged
aaronpowell merged 3 commits into
mainfrom
copilot/fix-code-scanning-alert-32
May 19, 2026
Merged

Fix double-unescaping in decodeEntities (CodeQL alert #32)#1757
aaronpowell merged 3 commits into
mainfrom
copilot/fix-code-scanning-alert-32

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

Pull Request Checklist

  • I have read and followed the CONTRIBUTING.md guidelines.
  • I have read and followed the Guidance for submissions involving paid services.
  • My contribution adds a new instruction, prompt, agent, skill, or workflow file in the correct directory.
  • The file follows the required naming convention.
  • The content is clearly structured and follows the example format.
  • I have tested my instructions, prompt, agent, skill, or workflow with GitHub Copilot.
  • I have run npm start and verified that README.md is up to date.
  • I am targeting the staged branch for this pull request.

Description

Fixes CodeQL alert #32 (js/double-escaping, CWE-116/CWE-20) in skills/md-to-docx/scripts/md-to-docx.mjs. The decodeEntities function decoded &amp;& first, enabling double-unescaping: &amp;lt; would resolve to &lt; and then to <. Fix moves &amp; decoding last.

// Before (vulnerable — &amp; decoded first)
return str
  .replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">")
  .replace(/&quot;/g, '"').replace(/&#39;/g, "'");

// After (correct — &amp; decoded last)
return str
  .replace(/&lt;/g, "<").replace(/&gt;/g, ">")
  .replace(/&quot;/g, '"').replace(/&#39;/g, "'")
  .replace(/&amp;/g, "&");

Type of Contribution

  • New instruction file.
  • New prompt file.
  • New agent file.
  • New plugin.
  • New skill file.
  • New agentic workflow.
  • Update to existing instruction, prompt, agent, plugin, skill, or workflow.
  • Other (please specify):

Additional Notes

Security fix only — no behavior change for correctly encoded input. Affects the md-to-docx skill's HTML entity decoding path.


By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.

Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code scanning alert #32 Fix double-unescaping in decodeEntities (CodeQL alert #32) May 19, 2026
Copilot AI requested a review from aaronpowell May 19, 2026 02:04
@aaronpowell aaronpowell marked this pull request as ready for review May 19, 2026 02:20
Copilot AI review requested due to automatic review settings May 19, 2026 02:20
@github-actions github-actions Bot requested a review from dvelton as a code owner May 19, 2026 02:20
@github-actions github-actions Bot added branched-main PR appears to include plugin files materialized from main targets-main PR targets main instead of staged labels May 19, 2026
@aaronpowell aaronpowell merged commit 25f213c into main May 19, 2026
22 of 23 checks passed
@aaronpowell aaronpowell deleted the copilot/fix-code-scanning-alert-32 branch May 19, 2026 02:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

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

Labels

branched-main PR appears to include plugin files materialized from main targets-main PR targets main instead of staged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants