Skip to content

fix(dashboard): allowlist URL schemes in rendered markdown - #3637

Merged
Daniel Meppiel (danielmeppiel) merged 5 commits into
mainfrom
danielmeppiel/dashboard-markdown-url-hardening
Nov 12, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 5 commits into
mainfrom
danielmeppiel/dashboard-markdown-url-hardening

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

Hardens markdown rendering in the contributor dashboard. renderMarkdown() now validates link and image URLs against a scheme allowlist before emitting href/src:

  • Links: http, https, mailto, or relative / fragment URLs.
  • Images: http, https, or relative URLs.
  • Anything else renders as plain text (the link label or the image alt).

Scheme detection removes ASCII whitespace and control characters first, as browsers do, and fails closed. Links also get rel="noopener noreferrer".

Other changes:

  • The committed dashboard bundle (.apm/extensions/issue-monitor/dist) is rebuilt from source, so the change takes effect for installed dashboards.
  • The existing tests/markdown.test.mjs suite now runs in CI. It was not wired in before.

Issue and approved scope

Issue: private security coordination. Report details are intentionally not disclosed.

Human scope-approval comment: approved by Daniel Meppiel (@danielmeppiel) through private security coordination.

Does this PR complete the issue, or what remains? It completes the fix for the dashboard markdown renderer.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally: node --test packages/apm-contributor-dashboard/tests/logic.test.mjs packages/apm-contributor-dashboard/tests/markdown.test.mjs packages/apm-contributor-dashboard/tests/server.test.mjs passes 248/248.
  • All existing tests pass.
  • Added tests for new functionality. 20 new allowlist tests fail against the previous renderer and pass with this change.

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

Links render only for http, https, mailto and relative URLs, and images
only for http, https and relative URLs. Anything else renders as plain
text. Scheme detection ignores ASCII whitespace and control characters
the same way browsers do. Links also get rel="noopener noreferrer".

Rebuild the dashboard bundle and run the existing markdown tests in CI.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 15:31
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

Unicode whitespace bypasses Markdown URL validation, allowing forbidden javascript: links and data: image URLs in both the source and committed dashboard bundle.

1 open issue
What changed in this PR

This PR hardens the contributor dashboard’s Markdown renderer by restricting link and image URL schemes and shipping the updated renderer in the installed dashboard.

Changes:

  • Adds URL scheme allowlists, plain-text fallbacks, and rel="noopener noreferrer" for links.
  • Adds security regression tests and includes the Markdown suite in both CI test commands.
  • Rebuilds the committed dashboard assets and records the change in the changelog.
File Description
packages/​apm-contributor-dashboard/​tests/​markdown.test.mjs Tests URL filtering and link attributes.
packages/​apm-contributor-dashboard/​client/​src/​utils/​markdown.js Adds URL validation to link and image rendering.
packages/​apm-contributor-dashboard/​.apm/​extensions/​issue-monitor/​dist/​index.html References the rebuilt JavaScript bundle.
packages/​apm-contributor-dashboard/​.apm/​extensions/​issue-monitor/​dist/​assets/​index-CtQNTi1o.js Ships the updated dashboard renderer.
packages/​apm-contributor-dashboard/​.apm/​extensions/​issue-monitor/​dist/​assets/​index-CRBU6-pe.js Removes the previous bundle.
CHANGELOG.md Documents the Markdown URL restrictions.
.github/​workflows/​ci.yml Adds Markdown tests to both dashboard test commands.

Review effort: Balanced

Comment on lines +26 to +30
const compact = unescapeHtml(escapedUrl).replace(/[\u0000-\u0020\u007f-\u009f]/g, "");
if (!compact) return null;
const scheme = compact.match(/^([a-zA-Z][a-zA-Z0-9+.\-]*):/);
if (scheme && !allowedSchemes.has(scheme[1].toLowerCase())) return null;
return escapedUrl.trim();
Fail closed on any whitespace or control character in markdown link and
image URLs, and emit exactly the string whose scheme was checked.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 5b8f92f into main Nov 12, 2026
16 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel/dashboard-markdown-url-hardening branch November 12, 2026 16:09
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
Pick up 5b8f92f (#3637). CHANGELOG.md conflicted textually under
### Fixed; resolved by keeping main's #3637 entry and this PR's #3604
entry (no entry dropped).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel) added a commit to McNultyyy/apm that referenced this pull request Nov 12, 2026
Refresh microsoft#2627 against current main; CHANGELOG Fixed entries from both
sides kept (microsoft#2627 entry plus main's microsoft#3637 entry and microsoft#3642 Removed section).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 19, 2026
* docs(changelog): make 0.36.0 onwards legible and concise

Rewrites [Unreleased], [0.36.1] and [0.36.0] as one short line per user-visible change, with Highlights and a Breaking changes and upgrade notes list per version, grouped PRs and internal-only entries dropped (#3637, #3771, #3794, #3796, #3877). Credits, PR references, the 0.36.1 issue closures and the live Azure DevOps caveat are kept. Sections from 0.35.1 down are unchanged. The changelog instructions now describe this style.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* chore(lock): record the new changelog instructions hash

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* docs: note the shared .mcp.json and VS Code Local mode in 0.37 upgrade notes

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* docs(changelog): restore accuracy qualifiers flagged in review

Restores the static env caveat for .mcp.json, the pack default-format
qualifier, Copilot CLI scope for COPILOT_HOME, the 0.36.1 frozen-lockfile
recovery step, and the bundle install --target qualifier.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: danielmeppiel <danielmeppiel@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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