Skip to content

[Security] Prevent XSS attack in captions#378

Open
MrPetovan wants to merge 1 commit intomiromannino:masterfrom
MrPetovan:patch-1
Open

[Security] Prevent XSS attack in captions#378
MrPetovan wants to merge 1 commit intomiromannino:masterfrom
MrPetovan:patch-1

Conversation

@MrPetovan
Copy link
Copy Markdown

@MrPetovan MrPetovan commented Feb 5, 2023

We're using Justified Gallery over at Friendica and we've been reported a security vulnerability related to this Javascript library. Image captions, even correctly escaped in the source page HTML, end up being interpreted as literal HTML in the Justified Gallery output.

This is because jQuery $('<div>' + caption + '</div>') treats caption as literal HTML. However, this value comes from HTML attributes that shouldn't contain literal HTML themselves.

The fix is simple and ensures jQuery uses the .createTextNode() DOM method internally, which escapes literal HTML in the output HTML tag.

I have checked for any other place the replaced structure would make sense.

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

Successfully merging this pull request may close these issues.

1 participant