Skip to content

Allow picture, source, srcset, sizes with a dedicated srcset scrubber - #303

Open
kataokatsuki wants to merge 1 commit into
flavorjones:mainfrom
kataokatsuki:add-picture-source-srcset
Open

Allow picture, source, srcset, sizes with a dedicated srcset scrubber#303
kataokatsuki wants to merge 1 commit into
flavorjones:mainfrom
kataokatsuki:add-picture-source-srcset

Conversation

@kataokatsuki

Copy link
Copy Markdown

Part of #155

Adds picture/source and srcset/sizes to the safelists. picture is added as source's parent.

srcset is a list of candidates, so this gives it ATTR_VAL_IS_SRCSET and scrub_srcset_attribute instead of treating it as one URL, which would recreate the CVE-2024-8372 bypass class. The scrubber reads each candidate URL token with StringScanner, validates it with allowed_uri?, and drops the whole attribute if any candidate is disallowed; tests cover the safelists, data: URLs with commas, and fail-closed cases for img and source.

Add `picture`/`source` to ACCEPTABLE_ELEMENTS and `srcset`/`sizes` to
ACCEPTABLE_ATTRIBUTES.

`srcset` is a list of "URL descriptor" candidates, not a single URL, so it
gets a dedicated `scrub_srcset_attribute` (a new `ATTR_VAL_IS_SRCSET`) that
validates each candidate URL with `allowed_uri?` and is fail-closed, rather
than recreating the CVE-2024-8372 bypass class. URLs are split on ASCII
whitespace per the WHATWG rules, so commas in `data:` URLs survive.

part of flavorjones#155
@flavorjones

Copy link
Copy Markdown
Owner

@kataokatsuki Thanks, I'll take some time to review this week.

@kataokatsuki

kataokatsuki commented Jun 9, 2026

Copy link
Copy Markdown
Author

Thanks, no rush🙏

@kataokatsuki

Copy link
Copy Markdown
Author

@flavorjones friendly bump in case this got buried!

@flavorjones

Copy link
Copy Markdown
Owner

@kataokatsuki I've spent most of the last few weeks working on security patches, haven't gotten back to this yet but it's definitely on my to-do list. Thanks for your patience.

@kataokatsuki

kataokatsuki commented Jun 25, 2026

Copy link
Copy Markdown
Author

@flavorjones Thanks for the update, no worries. I appreciate you taking the time.

@kataokatsuki

Copy link
Copy Markdown
Author

Sorry for the noise — my last comment here was meant for a different PR. I've deleted it.

@flavorjones

Copy link
Copy Markdown
Owner

Sorry for the delay here. I've been working on a Loofah security release, but will get to this in the next few days.

@kataokatsuki

Copy link
Copy Markdown
Author

Sounds good, thanks! And sorry again for the stray comment the other day.

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.

2 participants