Bypass CSP Using WordPress By Abusing Same Origin Method Execution
WordPress ships with a JSONP endpoint that accepts a callback parameter restricted to word characters and dots, and this restriction can be bypassed using Same Origin Method Execution to call DOM methods and click buttons. An attacker who already has HTML injection on a site with a strict CSP can use this to execute script from the trusted origin, escalating to actions such as installing a plugin and achieving remote code execution.
Published on octagon.net
There are two scenarios found in which CSP can be bypassed if Wordpress is hosted on the website that uses CSP:
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the JSONP callback validation only blocks non-word characters but still allows arbitrary property and method chains, which can be abused via Same Origin Method Execution to invoke DOM methods.
Impact
An attacker with an HTML injection on a site that hosts WordPress anywhere on the same origin could bypass a strict CSP, execute script in the trusted origin, and potentially install a plugin leading to remote code execution.
What the attacker needed
HTML injection on the target origin; WordPress reachable on same origin or subdomain; Victim visits attacker page; Victim is logged in for admin actions
The fix
WordPress should restrict or remove the user-controllable JSONP callback so that it cannot be used to invoke arbitrary DOM methods, but the text does not state that a fix was applied.
How it was found
- A malicious site opens a new child window.
- The child window has a window.opener pointing to the attacker site.
- The attacker site redirects itself to the victim page where the action should happen.
- The child window now has a window.opener pointing to the victim site.
- The child window is redirected to the XSS payload that references the opener window.
- Because both windows share the same origin, the child window can access and modify its opener.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A Content Security Policy (CSP) is a browser rule that only allows scripts from the site itself. WordPress has a feature that returns data wrapped in a function name you supply, and it only allows letters, numbers, underscores and dots in that name. By using a trick called Same Origin Method Execution, an attacker can chain those allowed words and dots to reach a button on the page and click it, so the browser runs code that looks like it came from the trusted site.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.