Skip to content

Keep the full URI reachable in the prompt URL confirmation dialog - #332937

Merged
Martin Aeschlimann (aeschli) merged 6 commits into
microsoft:mainfrom
Carrotstudiosoftwarehouse:fix/prompt-url-full-uri-a11y
Nov 3, 2026
Merged

Martin Aeschlimann (aeschli) merged 6 commits into
microsoft:mainfrom
Carrotstudiosoftwarehouse:fix/prompt-url-full-uri-a11y

Conversation

@Carrotstudiosoftwarehouse

@Carrotstudiosoftwarehouse Carrotstudio.it (Carrotstudiosoftwarehouse) commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

The confirmation dialog shown when installing a prompt / instructions / agent file from a URL has two problems that can make it show a host other than the one being requested.

1. The label is truncated in the middle.

uriLabel = `${uriLabel.substring(0, 35)}...${uriLabel.substring(uriLabel.length - 15)}`;

The host can end up entirely inside the hidden part. For example

https://raw.githubusercontent.com.cdn.example.com/copilot-instructions.md

renders as

https://raw.githubusercontent.com.c...instructions.md

which reads as a raw.githubusercontent.com URL, while the request goes elsewhere.

2. The dialog shows a different string than the one requested. shouldBlockInstall rendered url.toString(), while the fetch uses the raw urlString. URI.toString() reserializes, so https://user%[email protected]/file was shown as https://[email protected]%40evil.test/file: it reads as example.com, while the request goes to evil.test.

The change

  • The dialog now takes the string that is actually requested.
  • The full URL is kept in a title on the link, as extensionUrlHandler already does for its own dialog (Provide a way to reveal the entire URI in an 'Allow extension to open URI" dialog (fix #239272) #239527). aria-label is not used because allowedMarkdownHtmlAttributes does not allow it.
  • The URL is attacker-controlled and is now inside raw HTML, so both the attribute and the visible label are escaped with the existing helpers (strings.escape, escapeDoubleQuotes, escapeMarkdownSyntaxTokens).

What was run. The escaping was run on hostile URLs (quotes, <img>, <b>, underscores): no tag or attribute survives, and the same check without escaping catches them. I have not run the rendered dialog itself.

A note on accessibility: since the link has text content, its accessible name is still the truncated label; title is exposed as the description. So this helps screen reader users reach the full URL, but it is not a complete accessibility fix.

Related to #239272 (the same problem in the extension URI dialog, already fixed there).

The label is truncated in the middle, so the host can fall entirely inside
the hidden part. Carry the full URI in title and aria-label, as
extensionUrlHandler already does since microsoft#239527.
Copilot AI balanced review requested due to automatic review settings August 27, 2026 13:44

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

Improves URL confirmation dialogs by exposing the full URI while retaining a truncated visible label.

Changes:

  • Adds full-URI title and aria-label attributes.
  • Uses an HTML anchor for consistent interaction.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.


private async shouldBlockInstall(promptType: PromptsType, url: URI): Promise<boolean> {
let uriLabel = url.toString();
const uriString = url.toString();
Comment on lines +128 to +129
// The label is truncated in the middle, which can hide the real host. Carry the full URI in
// `title` and `aria-label` so it stays reachable, as `extensionUrlHandler` already does.
The dialog rendered `url.toString()` while the request is made with the raw
`urlString`. `URI.toString()` reserializes, so a URL such as
`https://user%[email protected]/file` is displayed as
`https://[email protected]%40evil.test/file`, which reads as if the host were
`example.com` when the request actually goes to `evil.test`.

Pass the string that is actually requested into the confirmation and escape it
for the attribute context, so the label, the tooltip and the accessible name all
describe the URL that will be fetched.
`allowedMarkdownHtmlAttributes` in markdownRenderer.ts permits `title` but not
`aria-label`, and the confirmation dialog renders with the default sanitizer
config (dialogHandler.ts passes no `sanitizerConfig`), so the attribute never
reaches the DOM. `title` alone supplies the accessible name.
@Carrotstudiosoftwarehouse

Copy link
Copy Markdown
Contributor Author

Thanks — addressed, and the review caught a real mismatch rather than just a style issue.

The dialog and the request disagreed. shouldBlockInstall rendered url.toString() while the fetch below uses the raw urlString. Since URI.toString() reserializes, https://user%[email protected]/file was shown as https://[email protected]%40evil.test/file — it reads as example.com while the request goes to evil.test. The confirmation now takes the string that is actually requested, so what is displayed and what is fetched cannot diverge.

Escaping. The URL comes from decodeURIComponent(uri.query), so it can contain ". Interpolated straight into title="…" that terminates the attribute early and the remainder is parsed as markup. The sanitizer blocks scripting, but tags on the allowlist survive, so the text in a security confirmation could still be shaped by the attacker. Hence the escape for the attribute context.

Dropped aria-label. It does not survive: allowedMarkdownHtmlAttributes in markdownRenderer.ts permits title but not aria-label, and dialogHandler.ts renders the detail with the default sanitizer config, so the attribute never reaches the DOM. title alone supplies the accessible name.

Verified by reading the sanitizer configuration; I have not run the rendered dialog itself.

Separately, extensionUrlHandler.ts (around the <div title=…> construction) interpolates the URL into attributes the same unescaped way. Happy to open a separate PR for it rather than widening this one.

@Carrotstudiosoftwarehouse

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

A local node_modules.nativi-backup/ directory was picked up by the first
commit on this branch. It is unrelated to the change and is removed here,
so the diff is limited to promptUrlHandler.ts.
The label is attacker-controlled text inside raw HTML: escape it like the
title attribute, and escape markdown tokens so underscores in a URL are not
rendered as emphasis. Use strings.escape and escapeDoubleQuotes instead of a
local replace chain.
@Carrotstudiosoftwarehouse

Copy link
Copy Markdown
Contributor Author

Martin Aeschlimann (@aeschli) — small fix in the prompt install confirmation: the dialog showed URI.toString() while the request uses the raw string, and the middle truncation can hide the host entirely (e.g. https://raw.githubusercontent.com.cdn.example.com/… is shown as https://raw.githubusercontent.com.c...instructions.md). Happy to add before/after screenshots or adjust anything.

@aeschli
Martin Aeschlimann (aeschli) merged commit 59444e2 into microsoft:main Nov 3, 2026
51 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 3, 2026
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.

5 participants