Skip to content

Instantly share code, notes, and snippets.

@Slowftw
Last active September 24, 2022 05:05
Show Gist options
  • Select an option

  • Save Slowftw/c872da1cf8611b8095b9e77b56dc5d11 to your computer and use it in GitHub Desktop.

Select an option

Save Slowftw/c872da1cf8611b8095b9e77b56dc5d11 to your computer and use it in GitHub Desktop.
Security Report: HTML attribute injection on https://mcuserna.me

Stored HTML attribute injection via lookup parameter

Summary

It's possible to inject new attributes that DOMPurify considers "safe" by default in the anchor tag due to insufficient/improper encoding/escaping of the user's hypixel button.

Vulnerability description from Acunetix

HTML Attribute Injection is an attack that is conceptually similar to Cross-site Scripting (XSS), and closely related to HTML Injection. It can be able to inject a new attribute into an existing HTML tag, but unable to inject arbitrary HTML or JavaScript code. When an application does not properly handle user supplied data, an attacker can supply valid HTML code, typically via a parameter value, and inject their own attributes and possibly attribute values, thereby altering the behavior of the page. This attack is typically used in conjunction with some form of social engineering, as the attack is exploiting a code-based vulnerability and a user's trust.

Affected domain Severity Weakness Reported Resolved
https://mcuserna.me Low/Medium Reflected DOM Injection 09/23/2022, 01:17am UTC-3 09/23/2022, 01:52pm UTC-3

Impact

Someone with bad intentions could cover the screen with NSFW content and/or use it as an ip-grabber.
All attributes accepted by DOMPurify, except href, can be rewritten/injected.

Steps To Reproduce

  1. Join mc server hypixel.net
  2. Type /profile on chat
  3. Select Social Media -> Hypixel Forums
  4. Paste payload on chat: hypixel.net/members/"style="font-size:50vw".0
  5. Open your mcun profile and voilà!

Hypixel chat response

encoded . = %2E
hypixel-chat-response
They strangely accepts inputs like in this regex:
^(https?\:\/\/)?hypixel\.net\/members\/[^.]*\.\d+$
I haven't tried to inject more than 222 characters
but the payload can probably be longer than that.

Proof of Concept

All payloads have been tested and proven internally.
Burp Suite was used to prevent anyone from finding the flaw in my profile
and because I can't record with minecraft open (lag)

NSFW content

hypixel.net/members/"class="x"style="z-index:1;top:0;left:0;position:fixed;width:100%;height:100%;background:url(//505%2Enetlify%2Eapp/.1
mcun-poc-attr-injection-nsfw-poc.mp4

IP-grabber

hypixel.net/members/"class="x"style="background:url(//505%2Enetlify%2Eapp/.2
mcun-poc-attr-injection-ipgrabber-poc.mp4

Suggested Remediation

Escape the user input instead of trying to sanitize it further, i.e. encodeURI function:

Not escaped: A-Z a-z 0-9 ; , / ? : @ & = + $ - _ . ! ~ * ' ( ) #

  • Safe - inserting the controlled user input in href using double quotes safe-innerhtml-js-encodeuri-1 safe-innerhtml-js-encodeuri-2
  • Unsafe - inserting the controlled user input in href using single quotes unsafe-innerhtml-js-encodeuri

I created this regex in case you guys want to use it to check the input before creating the button:
^(https?\:\/\/)?hypixel\.net\/members\/[a-zA-Z0-9_]{1,50}\.\d{1,9}$

Reporter

References

Resolved

Date: 09/23/2022, 01:52pm UTC-3

@Slowftw
Copy link
Author

Slowftw commented Sep 23, 2022

@lucky-swede You're welcome, now it's public, tysm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment