Skip to content

fix(security): restrict iframe allow policy to low-risk features - #27

Merged
herewithme merged 4 commits into
mainfrom
fix/iframe-allow-policy
Nov 11, 2026
Merged

herewithme merged 4 commits into
mainfrom
fix/iframe-allow-policy

Conversation

@herewithme

@herewithme herewithme commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #24. Deploys to main the ticket branch already merged into develop through #25.

Why

Users without unfiltered_html could set any allow value on the iframe and delegate camera, microphone, geolocation or screen capture to an embedded third-party page.

What

  • allow keeps only low-risk Permissions Policy features (accelerometer, autoplay, clipboard-write, encrypted-media, fullscreen, gyroscope, picture-in-picture, web-share) and drops origin lists. The list can be extended with the blockparty_iframe_allowed_features filter.
  • The obsolete allowpaymentrequest is no longer rendered.
  • The editor preview uses ServerSideRender, so filtering lives only in BlockRenderer. Adds the @wordpress/server-side-render dependency (6.20.0).

Details and review history: #25.

Test plan

  • npm run lint:js src, phpcs, npm run build
  • Block editor (WordPress 7.1.4, wp-env): sensitive allow directives and onload dropped in the preview and on the front end
  • Preview fills the block wrapper (16/9, default square, 4/3 changed in the editor)
  • "View" before "Add iframe" previews the typed iframe, filtered
  • Contributor account
  • blockparty_iframe_allowed_features applied to the preview

Release note

.plugin-data still says 1.2.1, which is already tagged, so the version check on main will fail until the version is bumped (previous releases did this in a release/* branch).

🤖 Generated with Claude Code


Note

Medium Risk
Changes security-sensitive iframe attribute sanitization and the editor preview path; regressions could affect preview layout or which allow directives appear, but the change narrows delegated permissions rather than expanding them.

Overview
Tightens iframe Permissions Policy handling so the allow attribute only keeps a fixed set of low-risk features, strips origin lists (features apply to the iframe origin only), and drops obsolete allowpaymentrequest output. Site owners can extend the feature list via the new blockparty_iframe_allowed_features filter.

The block editor preview no longer renders a client-side <iframe> with duplicated JS allowlists; it uses ServerSideRender so preview and front end both go through BlockRenderer.php, where attribute/allow filtering is the single security boundary. Adds @wordpress/server-side-render and editor CSS so the nested preview fills the block wrapper dimensions.

Reviewed by Cursor Bugbot for commit e9d9e51. Bugbot is set up for automated code reviews on this repo. Configure here.

herewithme and others added 4 commits November 5, 2026 23:02
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 <[email protected]>
Render the editor preview through BlockRenderer so iframe attribute
filtering lives in PHP only, and the
`blockparty_iframe_allowed_features` filter applies to the preview too.

- Use ServerSideRender (default import, WordPress 6.7 compatible) with
  skipBlockSupportAttributes; drop convertAttributesToProps(),
  sanitizeAllowValue() and the JS ALLOWED_FEATURES list.
- Make the nested preview markup fill the block wrapper in the editor.
- Check aria-*/data-* attribute prefixes with str_starts_with() and
  startsWith() instead of a regex.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The server-side preview used the saved block attributes, while "View"
shows the form before "Add iframe" saves it. A new block or a
"Replace" edit then previewed an empty or stale iframe. Merge the form
state into the attributes sent to ServerSideRender, as the former JS
preview did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
skipBlockSupportAttributes keeps `style.dimensions`, so the server-side
preview markup got the aspect ratio again inside the block wrapper and
overflowed it. Drop `align` and `style` from the preview attributes:
the editor wrapper already applies them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@herewithme
herewithme merged commit 8905e9b into main Nov 11, 2026
5 of 6 checks passed
@herewithme
herewithme deleted the fix/iframe-allow-policy branch November 11, 2026 16:24
This was referenced Nov 11, 2026
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