uiwjs / uiwjs/react-md-editor

rehype pluguns doesn't affected (XSS Vulnerable)

Open
#574 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.9k
Forks
201
Avg merge
12m
Merged PRs (30d)
1

Description

I try to implement this into my next js project using app next js version.

And I wanna try to test the security using this inside the string markdown;

<IFRAME SRC="javascript:javascript:alert(window.origin);"></IFRAME>

And this is my code.

import "@uiw/react-md-editor/markdown-editor.css";
import "@uiw/react-markdown-preview/markdown.css";
import { useState } from "react";
import MDEditor from "@uiw/react-md-editor";
import rehypeSanitize from "rehype-sanitize";

const PostEditor = () => {
  const [value, setValue] = useState<string | undefined>(
    '**Hello world!!!** <IFRAME SRC="javascript:javascript:alert(window.origin);"></IFRAME>'
  );

  return (
    <div className="container">
      <MDEditor
        value={value}
        onChange={setValue}
        previewOptions={{
          rehypePlugins: [rehypeSanitize],
          transformLinkUri: null,
          skipHtml: true,
        }}
      />
      <MDEditor.Markdown source={value} style={{ whiteSpace: "pre-wrap" }} />
    </div>
  );
};

export default PostEditor;

And then javascript dialog still up there.
Screenshot 2023-09-28 at 20 17 32
How to avoid that dialog appear to our website, especially during production.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied iframe payload with the Next.js example, comparing the rehype configuration on MDEditor with the separate MDEditor.Markdown rendering path shown. Inspect the preview rendering entry point and verify that the payload cannot execute in production; add coverage for the affected behavior if the repository’s test structure supports it.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.