Security: escape attacker-influenced data rendered in admin views (XSS)#1381
Security: escape attacker-influenced data rendered in admin views (XSS)#1381vuckro wants to merge 2 commits into
Conversation
…s (XSS) Several network-admin views rendered untrusted data as HTML: - Event::interpolate_message() substituted payload values (customer display names, site titles/descriptions, etc.) into HTML message templates without escaping; the result is rendered with Vue v-html in the activity-stream widget — a stored XSS. Escape each interpolated value with esc_html() while preserving the template's own markup. - views/events/widget-payload.php rendered the JSON payload dump with v-html; switched to v-text (it is preformatted debug text). - Template library: short_description / price_html come from the remote marketplace API and are rendered with v-html; sanitize them server-side with wp_kses_post() so injected script is stripped while formatting is kept. - Webhook list table column_name interpolated the webhook name/event/url into HTML and data-* attributes unescaped; apply esc_html()/esc_attr()/esc_url(). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR hardens output escaping and sanitization across admin webhook listing, event message interpolation, template library HTML fields, and the event payload widget to prevent HTML injection and XSS. ChangesOutput Escaping & Sanitization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
inc/list-tables/class-webhook-list-table.php (1)
100-103:⚠️ Potential issue | 🟠 Major | ⚡ Quick winSame XSS pattern in multiple column methods. Both
column_webhook_url()andcolumn_event()interpolate model data into HTML without escaping. Since this security PR already fixescolumn_name(), consider applying the sameesc_html()treatment to these adjacent methods for consistency.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@inc/list-tables/class-webhook-list-table.php` around lines 100 - 103, column_webhook_url() and column_event() are interpolating model data directly into HTML causing an XSS risk; update both methods to escape output (use esc_html() or equivalent) when outputting values (e.g., wrap the trimmed URL and event string with esc_html()) following the same pattern used in column_name() so the returned span contains escaped content rather than raw model values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@inc/list-tables/class-webhook-list-table.php`:
- Around line 100-103: column_webhook_url() and column_event() are interpolating
model data directly into HTML causing an XSS risk; update both methods to escape
output (use esc_html() or equivalent) when outputting values (e.g., wrap the
trimmed URL and event string with esc_html()) following the same pattern used in
column_name() so the returned span contains escaped content rather than raw
model values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b6745c40-1f6b-4e51-9cc1-eb8fdf9dd2f9
📒 Files selected for processing (4)
inc/list-tables/class-webhook-list-table.phpinc/models/class-event.phpinc/template-library/class-api-client.phpviews/events/widget-payload.php
…w-up) Apply the same esc_html() treatment to column_webhook_url() and column_event() that column_name() received, so all webhook list-table columns escape model data before output. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
Several network-admin views render untrusted data as HTML, allowing stored XSS
that fires in an admin's browser.
Changes
Event::interpolate_message()substituted payload values (customer displaynames, site titles/descriptions, …) into HTML message templates without
escaping; the result is rendered with Vue
v-htmlin the activity-streamwidget. Escape each interpolated value with
esc_html()while preserving thetemplate's own markup.
views/events/widget-payload.phprendered the JSON payload dump withv-html; switched tov-text(it is preformatted debug text).short_description/price_htmlare fetched from theremote marketplace API and rendered with
v-html; sanitize them server-sidewith
wp_kses_post()so injected script is stripped while formatting is kept.column_nameinterpolated the webhook name/event/urlinto HTML and
data-*attributes unescaped; applyesc_html()/esc_attr()/
esc_url().No functional change for non-malicious data.
Summary by CodeRabbit