Skip to content

Fix: evf_toast_type security fix - #1664

Open
rajatgautam755421 wants to merge 1 commit into
pre-developfrom
fix/xss-toast-type-reflected
Open

Fix: evf_toast_type security fix#1664
rajatgautam755421 wants to merge 1 commit into
pre-developfrom
fix/xss-toast-type-reflected

Conversation

@rajatgautam755421

@rajatgautam755421 rajatgautam755421 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

No description provided.

window.evfShowToast() built its toast markup by concatenating the
caller-supplied `type` directly into a class attribute inside an HTML
string, then handed that string to jQuery's parseHTML/append, which
creates live DOM nodes. The only guard was `type = type || 'info'`,
so any truthy string passed through unescaped.

The admin.js bootstrap on every plugin admin screen reads
`evf_toast_type` straight from the URL query string and passes it to
evfShowToast() with no validation. An unauthenticated attacker could
craft a link like:

  ?page=evf-entries&evf_toast=<base64>&evf_toast_type=x"><img src=x onerror=alert(1)>

closing the class attribute early and injecting a live <img> element
whose onerror handler runs immediately, executing arbitrary JS in the
admin's session (nonces, cookies) with a single click and no prior
site state.

Every legitimate call site across the codebase only ever passes one of
'success', 'error', 'info', or 'warning'. Fixed evfShowToast() itself
(the shared function every caller routes through, including the
vulnerable URL-driven one) to whitelist `type` against that exact set,
falling back to 'info' for anything else - closing the injection point
for this and any future caller regardless of where the value
originates. Applied the equivalent change to admin.min.js, the build
actually loaded with SCRIPT_DEBUG off.

Reported via Patchstack (report #35058).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The XSS fix is applied consistently to both reviewed assets.

Pull request overview

Fixes reflected XSS by validating toast types before inserting them into HTML.

Changes:

  • Whitelists supported toast types and defaults invalid values to info.
  • Applies the fix to both source and minified production assets.
File summaries
File Description
assets/js/admin/admin.min.js Mirrors the production security fix.
assets/js/admin/admin.js Validates toast types before rendering.
Review details
  • Files reviewed: 1/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@rajatgautam755421 rajatgautam755421 self-assigned this Sep 10, 2026
@rajatgautam755421 rajatgautam755421 changed the title Fix: reflected XSS via evf_toast_type query parameter Fix: evf_toast_type security fix Sep 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.

2 participants