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 allowed on any page (XSS) #12

Open
codeling opened this issue Apr 4, 2021 · 2 comments
Open

HTML allowed on any page (XSS) #12

codeling opened this issue Apr 4, 2021 · 2 comments

Comments

@codeling
Copy link

codeling commented Apr 4, 2021

Looking at this recent commit, I wondered why only links and images should be specially treated for html entities; what specific forms of XSS are prevented by that?

The wiki in its current form allows for HTML to be entered as far as my tests are concerned; entering

<script>alert('Hello');</script>

on a page brings up an alert box...

Doesn't the htmlentities handling need to happen earlier (on $inText at the start of toHTML)? The one happening right before the end of toHTML doesn't do anything ($inText isn't used anymore after that), and would break the previously inserted images/links etc. anyway...

I've tried a fix in my fork: codeling@77cb75d
and it seems to at least prevent the simple XSS shown above.

@panicsteve
Copy link
Owner

Part of the Markdown spec is to allow HTML tags to be passed through. However, this does pose a problem with script tags.

In 3cdc651, the script will now replace those with empty strings.

@codeling
Copy link
Author

codeling commented Jun 13, 2023

In 3cdc651, the script will now replace those with empty strings.

Sorry for reviving an old topic. But the linked solution will still not prevent inserting script tags that have attributes or whitespace, e.g. <script type="text/javsscript">alert('Hello');</script >; I dimly remember having read somewhere that a "blacklisting" approach is not recommended for XSS prevention, as it's often easy to work around.

@panicsteve panicsteve reopened this Jun 27, 2023
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

No branches or pull requests

2 participants