Fix: evf_toast_type security fix - #1664
Open
rajatgautam755421 wants to merge 1 commit into
Open
Conversation
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>
There was a problem hiding this comment.
🟢 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.
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.