Skip to content

Sanitizer: block data: URI scheme while keeping data:image for images - #9417

Merged
Alkarex merged 3 commits into
FreshRSS:edgefrom
lordmarrik:fix/sanitizer-uri-schemes
Oct 11, 2026
Merged

Alkarex merged 3 commits into
FreshRSS:edgefrom
lordmarrik:fix/sanitizer-uri-schemes

Conversation

@lordmarrik

@lordmarrik lordmarrik commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Defense-in-depth hardening, same class as GHSA-3fw6-j8m4-82vj / #9272. Private security advisory filed alongside this PR per SECURITY.md: GHSA-5pmx-x7q6-hv7m. SimplePie part: FreshRSS/simplepie#92.

What

FreshRSS_SimplePieCustom only disallowed the javascript scheme, so data:text/html,... URIs in feed content survived sanitization on <a href>, <iframe src>, <audio|video|source|track src>. They are harmless on FreshRSS's own pages thanks to the default CSP, but can execute in clients or deployments without that CSP (API WebViews, extensions calling amendCsp(), proxies stripping headers).

How

  • lib/simplepie/simplepie/src/Sanitize.php: new is_allowed_uri(string $tag, string $attribute, string $uri) — element/attribute-aware. When data is disallowed it still permits data:image/... on img[src], image[src], video[poster] (inert and widely used by feeds). replace_urls() now uses it. is_allowed_scheme() is unchanged, so this is backward compatible for other SimplePie users.
  • app/Models/SimplePieCustom.php: disallow_uri_schemes(['javascript', 'data']).
  • tests/app/Models/SimplePieCustomTest.php: 4 blocked-input cases, a data:image keep-alive test, and an unsafe: prefix test.

Checks

  • New tests fail on edge without the patch and pass with it.
  • vendor/bin/phpunit — OK (757 tests, 1437 assertions).
  • vendor/bin/phpcs and vendor/bin/phpstan — clean on changed files.

AI assistance

Found and drafted with Claude Code (Claude Fable 5.1), reviewed by me, per SECURITY.md and AGENTS.md.

@Inverle

Inverle commented Oct 8, 2026

Copy link
Copy Markdown
Member

Thanks for the PR. Could you please also file a PR against our SimplePie fork? (https://github.com/FreshRSS/simplepie for the SimplePie changes)

Comment thread app/Models/SimplePieCustom.php Resolved
@lordmarrik

Copy link
Copy Markdown
Contributor Author

Thanks for the review.

@lordmarrik lordmarrik changed the title Sanitizer: block data: and vbscript: URI schemes while keeping data:image for images Sanitizer: block data: URI scheme while keeping data:image for images Oct 10, 2026
FreshRSS_SimplePieCustom only disallowed the `javascript` scheme, so
`data:text/html,...` URIs in feed content survived
sanitization on <a href>, <iframe src>, <audio|video|source|track src>.
The default CSP neutralises these on FreshRSS pages, but clients and
deployments without that CSP (API WebViews, extensions using amendCsp(),
proxies stripping headers) could execute them. Same class as
GHSA-3fw6-j8m4-82vj / FreshRSS#9272.

- Sanitize::is_allowed_uri(): element/attribute-aware check that still
  permits inert `data:image/...` on img[src], image[src], video[poster]
  while blocking `data:` elsewhere; replace_urls() now uses it.
  is_allowed_scheme() is unchanged for backward compatibility.
- SimplePieCustom: disallow_uri_schemes(['javascript','data']).
- Tests: 4 blocked-input cases, a data:image keep-alive test and an
  `unsafe:` prefix test. They fail without the patch and pass with it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@lordmarrik
lordmarrik force-pushed the fix/sanitizer-uri-schemes branch from 509a08e to d4a808c Compare October 10, 2026 15:08
lordmarrik added a commit to lordmarrik/simplepie that referenced this pull request Oct 10, 2026
…ithout losing data:image

replace_urls() only consulted is_allowed_scheme(), a plain scheme blocklist,
so consumers could not disallow `data:` without also breaking inert
`data:image/...` on <img>. Add is_allowed_uri(tag, attribute, uri): when
`data` is disallowed it still permits data:image/... on img[src],
image[src] and video[poster], and blocks `data:` everywhere else
(<a href>, <iframe src>, media src, ...). is_allowed_scheme() is unchanged.

Companion to FreshRSS/FreshRSS#9417.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Alkarex pushed a commit to FreshRSS/simplepie that referenced this pull request Oct 10, 2026
…ithout losing data:image (#92)

replace_urls() only consulted is_allowed_scheme(), a plain scheme blocklist,
so consumers could not disallow `data:` without also breaking inert
`data:image/...` on <img>. Add is_allowed_uri(tag, attribute, uri): when
`data` is disallowed it still permits data:image/... on img[src],
image[src] and video[poster], and blocks `data:` everywhere else
(<a href>, <iframe src>, media src, ...). is_allowed_scheme() is unchanged.

Companion to FreshRSS/FreshRSS#9417.

Co-authored-by: Claude Fable 5.1 <[email protected]>
@Alkarex
Alkarex merged commit 0187b15 into FreshRSS:edge Oct 11, 2026
3 checks passed
Alkarex pushed a commit that referenced this pull request Oct 16, 2026
Adds ImperfectBlu to CREDITS.md, following #9417 and FreshRSS/simplepie#92.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants