v1.9.1#763
Open
ilicfilip wants to merge 5 commits into
Open
Conversation
An authenticated Editor (or higher) could create a recommendation via
POST /wp/v2/prpl_recommendations with an HTML payload in the `title`
field (e.g. `<img src=x onerror=alert(1)>`). The dashboard JS template
(views/js-templates/suggested-task.html) renders `title.rendered` with
Underscore's unescaped `{{{ }}}` syntax, so the payload executed when an
admin loaded the dashboard.
Defense in depth:
- Input: add a `rest_pre_insert_prpl_recommendations` filter that strips
tags from `post_title` on every REST insert/update, regardless of the
user's `unfiltered_html` capability. Recommendation titles are plain
text, so this neutralizes the payload at the source.
- Output (JS): route the two raw `{{{ }}}` title sinks through a new
`prplSuggestedTask.sanitizeTitle()` helper, which inert-parses the
value with DOMParser (no script/resource side effects) and re-escapes
it, preserving legitimate entities like `&` without double-encoding
the server-side `esc_html`'d provider titles.
- Output (admin bar): the PRPL debug tool printed `post_title` unescaped
into a `WP_Admin_Bar` node id (an HTML attribute) and title (rendered
as raw HTML), firing the payload on every admin page in debug mode.
Escape the title with `esc_html()`, use the post ID for the node id,
and escape the activities node title too.
- Also switch `updateTaskTitle` to set `.textContent` instead of
`.innerHTML` for the screen-reader label, closing a self-XSS sink.
Adds tests/phpunit/test-class-rest-recommendations-xss.php covering
Editor and Administrator payloads plus a plain-text regression check.
Contributor
|
Test on Playground |
Contributor
A title that is pure markup strips to an empty string. wp_update_post() rejects an update that would leave the title, content, and excerpt all empty, so the malicious title was left in the DB. The plugin never stores title-less recommendations, so delete such rows instead. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
No description provided.