Wordpress Mobile Detector Incorrect Fix Leads To Stored XSS
The WordPress Mobile Detector plugin's fix for a remote code execution vulnerability whitelisted the SVG extension, allowing an attacker to upload an SVG file containing JavaScript that executes when the file is viewed, leading to stored cross-site scripting. An attacker could host a malicious SVG, have it fetched and saved to the cache directory, and then trick a victim into visiting the uploaded file.
Published on rafaybaloch.com
(�/�X\�z�1��̺n��S�~\�ZNޥ��J%�w�?S���'@۶Mn���)��KS8��� ,��b�Q���ȸ�H0��"�%�t�!| 0X5��@(���>�=��@�X��)w�;E��Uw�v@w���� >������\��� E��}WZ�%b�� �D.X�r�DX�@��r](� �|��~�眱�5��P� ������ Zy�; �}���'q��-z�C�ƾ�2 ���;K��E���uku���C����Q����hU���ؿF�V �(��6���W�(G�t��������O�+��G�����,�eU�…
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
The fix whitelisted the SVG extension, which can contain executable JavaScript, without sanitising the file content.
Impact
An attacker could execute JavaScript in a victim's browser when they view the uploaded SVG, leading to stored XSS; the exploit requires allow_url_fopen to be enabled on the server.
What the attacker needed
Allow_url_fopen enabled on server; attacker can host a file remotely; victim visits the uploaded file
The fix
The SVG extension should be removed from the whitelist, uploaded files should be renamed, directory listing disabled, and servers should restrict allowed extensions and set security headers.
How it was found
- Host a malicious SVG file on a remote server.
- Request the plugin's resize.php with the src parameter pointing to the remote SVG.
- The plugin saves the SVG to its cache directory.
- Visit the uploaded SVG file in the cache directory to trigger the JavaScript.
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.
The plugin lets you give it a web address, and it downloads that file to its cache folder. The fix tried to allow only image files, but it included SVG, which is a kind of image that can contain JavaScript. So an attacker can upload a harmful SVG that runs code in a victim's browser when they open it, which is called stored cross-site scripting.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.