Repository navigation
fix(security): restrict iframe allow policy to low-risk features - #25
Open
herewithme wants to merge 2 commits into
Open
herewithme wants to merge 2 commits into
herewithme wants to merge 2 commits into
Conversation
Release 1.2.1
Users without unfiltered_html could set an arbitrary `allow` value and delegate camera, microphone, geolocation or display-capture to any embedded origin. - Filter `allow` directives against an allowlist (filterable on the front end with `blockparty_iframe_allowed_features`) and drop origin lists, in PHP and in the editor preview. - Stop rendering the obsolete `allowpaymentrequest` attribute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
return in_array( $attribute_name, self::ALLOWED_ATTRIBUTES, true )
|| str_starts_with( $attribute_name, 'aria-' )
|| str_starts_with( $attribute_name, 'data-' );Same in Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #24
What
allowvalues are filtered against a Permissions Policy feature allowlist:accelerometer,autoplay,clipboard-write,encrypted-media,fullscreen,gyroscope,picture-in-picture,web-share.srcorigin.BlockRenderer::sanitize_allow_value()) and in the editor preview (sanitizeAllowValue()inutils.js).allowpaymentrequestis removed from the allowlists.savestays unfiltered on purpose. It must reproduce the old markup for block validation and is never mounted.blockparty_iframe_allowed_features(front end only). The editor preview uses the static list, so features added through the filter are not shown in the preview.Tests
No automated test suite exists in the repo, and CI will run phpcs and eslint. Checks run locally:
php -l includes/BlockRenderer.phpcamera *; microphone *; geolocation *; display-capture *→allowomittedFullscreen; autoplay https://evil.example; camera; autoplay;; encrypted-media 'self'→allow="fullscreen; autoplay; encrypted-media"allowpaymentrequestdroppedallowfullscreenkeptsanitizeAllowValue(),convertAttributesToProps()andconvertAttributesToRawProps()(raw output unchanged)Review notes
allow="camera; microphone"(for example, some video-call embeds) lose those permissions. Sites that need them can extend the list with the filter.🤖 Generated with Claude Code
Note
Medium Risk
Changes security-sensitive iframe permission delegation and alters rendered markup for existing blocks with broad
allowvalues, though the net effect is restrictive rather than expanding trust.Overview
Hardens how the iframe block outputs the
allowPermissions Policy attribute on the front end and in the editor preview, so contributors withoutunfiltered_htmlcannot delegate sensitive capabilities to embedded documents.allowvalues are parsed and filtered to a fixed low-risk feature set (accelerometer,autoplay,clipboard-write,encrypted-media,fullscreen,gyroscope,picture-in-picture,web-share). Directives such as camera, microphone, geolocation, display-capture, and payment are dropped; origin lists are stripped so kept features apply only to the iframesrcorigin. If nothing remains,allowis omitted. PHP addssanitize_allow_value()inBlockRendererand ablockparty_iframe_allowed_featuresfilter to extend the list on rendered output;sanitizeAllowValue()inutils.jsmirrors this forconvertAttributesToProps()(static list in the editor preview).The obsolete
allowpaymentrequestattribute is removed from the PHP/JS attribute allowlists and boolean-attribute handling. CHANGELOG documents the unreleased security changes.Compatibility: blocks that stored permissive
allowstrings (e.g. video-call embeds) will render with fewer permissions unless a site extends the PHP filter.Reviewed by Cursor Bugbot for commit fa1abba. Bugbot is set up for automated code reviews on this repo. Configure here.