Skip to content

Typo in marked.js sanitization regex #111257

Closed

Description

  • VSCode Version: N/A
  • OS Version: N/A

pending PR

Diff:

-		const match = markdown.isTrusted ? html.match(/^(<span[^<]+>)|(<\/\s*span>)$/) : undefined;
+		const match = markdown.isTrusted ? html.match(/^(<span[^>]+>)|(<\/\s*span>)$/) : undefined;

There was / is a typo in markdownRenderer.js that allowed any trusted document to pass arbitrary HTML through the marked.js sanitizer provided it is wrapped in <span></span> tags, or similar.

What could you have done with this? Not much that was not already possible in trusted mode, which, as far as I can tell is used just for Jypiter Notebooks that pretty much definitionally can execute Python anyway.

Insane strips everything worthwhile except <a data-href=''/> which you can use to send command: URIs on click (javascript: URIs are disabled at a higher level of abstraction), but the ability to do this is already allowlisted (L141) for trusted documents.

Activity

  1. mjbvz commented on Jan 8, 2021

    @mjbvz
    Contributor

    Alex Ross (@alexr00) Was this issue also fixed by the fix for #112606?

  2. alexr00 commented on Jan 8, 2021

    @alexr00
    Member

    Matt Bierner (@mjbvz) since the fix for #112606 only restricted the tag attributes, I think that we could still gain from a specific fix for this issue.

  3. added
    unreleased
    on Jan 15, 2021
  4. added
    bug
    and removed
    unreleased
    on Jan 15, 2021
  5. added
    verified
    verification-found
    and removed
    verified
    on Jan 29, 2021
  6. JacksonKearl commented on Jan 29, 2021

    @JacksonKearl
    Contributor

    Ignore the above, I don't think this warrants full verification-found, but I also don't think the final regex ended up in a good state. The regex /^(<span[^>]+>)|(<\/\s*span>)$/ is parsed as ^(<span[^>]+>) or (<\/\s*span>)$, I imagine you wanted it to be more like ^(?:(<span[^>]+>)|(<\/\s*span>))$. In this case the sanitizer is only called with the actual tag, so it's probably not a big deal either way.

  7. locked and limited conversation to collaborators on Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions