Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML is stripped from runkit source #1228

Open
joelnet opened this issue Nov 30, 2018 · 9 comments
Open

HTML is stripped from runkit source #1228

joelnet opened this issue Nov 30, 2018 · 9 comments
Labels
area: publishing experience issues related to an authors experience publishing. Tags, series, etc. bug always open for contribution external contributors welcome contribution is welcome! good first issue good first issues for anyone new to programming and new to the project.

Comments

@joelnet
Copy link

joelnet commented Nov 30, 2018

Describe the bug
HTML is incorrectly stripped from runkit code blocks.

To Reproduce

  1. Click WRITE A POST.
  2. Paste into body:
{% runkit %}
const { ValueViewerSymbol } = require("@runkit/value-viewer");

const myCustomObject = {
    [ValueViewerSymbol]: {
        title: "My First Viewer",
        HTML: "<marquee>🍔Hello, World!🍔</marquee>"
    }
};
{% endrunkit %} 
  1. Click SAVE POST
  2. See code in runkit (incorrectly) translated into:
const { ValueViewerSymbol } = require("@runkit/value-viewer");

const myCustomObject = {
    [ValueViewerSymbol]: {
        title: "My First Viewer",
        HTML: "🍔Hello, World!🍔"
    }
};

Expected behavior
Code was expected to keep <marquee> tags.

Additional Info
I can trick the parser by encoding my HTML.

This works:

{% runkit %}
const { ValueViewerSymbol } = require("@runkit/value-viewer");
const atob = require('atob-lite')

const myCustomObject = {
    [ValueViewerSymbol]: {
        title: "My First Viewer",
        HTML: atob('PG1hcnF1ZWU+SGVsbG8sIFdvcmxkITwvbWFycXVlZT4=')
    }
};
{% endrunkit %}

Strangely enough, this does not work:

{% runkit %}
const { ValueViewerSymbol } = require("@runkit/value-viewer");

const myCustomObject = {
    [ValueViewerSymbol]: {
        title: "My First Viewer",
        HTML: ["<", "m", "a", "r", "q", "u", "e", "e", ">", "🍔", "H", "e", "l", "l", "o", ",", " ", "W", "o", "r", "l", "d", "!", "🍔", "<", "/", "m", "a", "r", "q", "u", "e", "e", ">"].join('')
    }
};
{% endrunkit %}

as it (incorrectly) results in this:

const { ValueViewerSymbol } = require("@runkit/value-viewer");

const myCustomObject = {
    [ValueViewerSymbol]: {
        title: "My First Viewer",
        HTML: ["", "🍔", "H", "e", "l", "l", "o", ",", " ", "W", "o", "r", "l", "d", "!", "🍔", ""].join('')
    }
};
@Zhao-Andy
Copy link
Contributor

Hey @joelnet, thanks for raising this. The Runkit tag's implementation could be reworked to solve this, but we'll have to be wary of security concerns.

@Zhao-Andy Zhao-Andy added the bug always open for contribution label Dec 6, 2018
@triage-new-issues triage-new-issues bot removed the triage label Dec 6, 2018
@jessleenyc jessleenyc added the external contributors welcome contribution is welcome! label Jan 11, 2019
@stale
Copy link

stale bot commented Apr 11, 2019

Thanks for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue in 7 days. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If this issue still requires attention, please respond with a comment. Happy Coding!

@stale stale bot added the stale label Apr 11, 2019
@mariocsee
Copy link
Contributor

markdown_parser.rb cleans up some HTML before liquid tags are processed. I have a method in #2160 that saves HTML within the CodePen Prefill Liquid Tag from being erased.

When that PR gets reviewed and possibly merged, I can extend that method to include runkit tag as well, which should prevent it from scrubbing <marquee> in your example.

@stale stale bot removed the stale label Apr 15, 2019
@mariocsee mariocsee added blocked blocked by internal or external issues and removed blocked blocked by internal or external issues labels May 6, 2019
@jessleenyc jessleenyc added area: publishing experience issues related to an authors experience publishing. Tags, series, etc. good first issue good first issues for anyone new to programming and new to the project. labels Aug 1, 2019
@mzaini30
Copy link

I think, you have to write &lt;marquee&gt;

@Oghenebrume50
Copy link
Contributor

Yes from what I can see this is how Runkit works probably because of security issues, @Zhao-Andy please what are the security concerns, and I would like to work on this, I would appreciate pointers on the best way to solve this issue

@rhymes rhymes removed the future label Jul 1, 2020
@cmgorton
Copy link
Contributor

@forem-team is this an issue we would still like contributors to work on? If so could we add more context here for how they should begin working on this so we can highlight it to the community?

@csaltos
Copy link

csaltos commented Mar 5, 2021

The security implication is the following:

If the HTM is not cleaned then a <script> tag can be introduced ... and with that, an attacker can hijack the session of a potential victim or use Javascript to create content without authorization, etc.

IMPORTANT: sadly, as mentioned by @mzaini30 if you change the "<" character for &lt; and ">" for &gt; then the tag will go through (including script tags).

Here a sample of a possible script tag attack vector that is now open ->

{% runkit %}
const { ValueViewerSymbol } = require("@runkit/value-viewer");

const myCustomObject = {
    [ValueViewerSymbol]: {
        title: "My First Viewer",
        HTML: "&lt;script&gt;alert(\\&quot;🍔Hello, World!🍔\\&quot;)&lt;/script&gt;"
    }
};
{% endrunkit %} 

Use it with a new post and when run, the Javascript inside the HTML will run too (not good !!).

CONCLUSION: this ticket should not only fix the cleaning of an HTML for not to be too aggressive (for real valid cases like the present marquee example) but also it should be sanitized for preventing script injection (potential attack cases) ... WHY? -> because the "trick" of removing the "<" or ">" characters to prevent attacks is NOT working and we need a real sanitizer here.

@cmgorton cmgorton added the bug smash Approved bugs for the DEV community bug smash label May 4, 2021
@pawelborkar
Copy link

Hi @cmgorton,
I would like to work on this issue :-)

@cmgorton
Copy link
Contributor

cmgorton commented May 5, 2021

Hey @pawelborkar I just assigned you to Issue #11500 . Did you still want to work on this one as well. If so I will assign it to you. :)

@cmgorton cmgorton added MLH Fellows and removed bug smash Approved bugs for the DEV community bug smash labels Jun 21, 2021
@mirie mirie self-assigned this Sep 14, 2023
@mirie mirie removed their assignment Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: publishing experience issues related to an authors experience publishing. Tags, series, etc. bug always open for contribution external contributors welcome contribution is welcome! good first issue good first issues for anyone new to programming and new to the project.
Projects
None yet
Development

No branches or pull requests