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

XSS using Mastodon Posts #85

Closed
myyxl opened this issue Apr 11, 2024 · 3 comments
Closed

XSS using Mastodon Posts #85

myyxl opened this issue Apr 11, 2024 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@myyxl
Copy link

myyxl commented Apr 11, 2024

Hotfix cffc0e8 did not fix the initial XSS vulnerability, but implemented another XSS vulnerability. I would have made a merge request to fix it, but it's a bit more complicated and I'm not too familiar with Mastodon and the Fediverse.

When fetching messages using the Mastodon API, user submitted HTML tags are encoded using HTML entities. This would prevent XSS by default, but createTextComponent in MessageView converts it to text again, which resolves the HTML entities.

final String messageText = Jsoup.parse(message.html()).text();

The converted text is then used in the truncateMessageText method if the length is bigger than 500 characters. This was the initial XSS vulnerability. Before the hotfix, if the message length was less than 500 characters it would have taken message.html() where the HTML entities are not resolved yet. Since the hotfix replaces it with the converted messageText, XSS is also possible using less than 500 characters now.

One way to fix it might be to use message.html() everywhere. The issue is, I'm not sure if a malicious mastodon instance could push posts where HTML entities are not encoded. So it might be safer to use some sanitizer.

@McPringle McPringle added this to the v2 milestone Apr 11, 2024
@McPringle McPringle self-assigned this Apr 11, 2024
McPringle added a commit that referenced this issue Apr 12, 2024
@McPringle McPringle added the bug Something isn't working label Apr 12, 2024
McPringle added a commit that referenced this issue Apr 13, 2024
@McPringle
Copy link
Owner

Hi @myyxl

Thank you very much for your report. As you might have already noticed, I made some changes to prevent XSS attacs through Mastodon posts. I installed an instance for testing using the nightly build, which is available here: https://apus.fihlon.swiss/

This instance is configured to scan for messages with the tag #TestTheWall. I would be happy if you can confirm that your attac does no longer work.

Thank you very much!

@myyxl
Copy link
Author

myyxl commented Apr 16, 2024

Looks good to me!

@myyxl myyxl closed this as completed Apr 16, 2024
@McPringle
Copy link
Owner

Thanks @myyxl for your report and review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants