GHSA-xr97-25v7-hc2q UnoPim has Stored Cross-site Scripting vulnerability in user creation functionality
SummaryAffected Functionality: User creation
Endpoint: `/admin/settings/users/create`Detailshttps://github.com/unopim/unopim/blob/a0dc81947a59ada69e19e1e4313dd591d4e277b4/packages/Webkul/Core/src/Traits/Sanitizer.php#L9-L19
See the mimetype is checked for validation.
Mime-type is usually identified by analysing the first few bytes of the file content, which contains the File signature or Magic bytes
for e.g. GIF file starts with GIF87a or GIF89a. We can mislead the sanitizer to think the uploaded file is gif ( based on magic byte provided ) while actually it is a .svg file.File containing <svg> is considered as svg and is sanitized:
![image](https://github.com/user-attachments/assets/bcb0ce04-6bbe-4058-81da-927331247d3d)![image](https://github.com/user-attachments/assets/47d33392-632e-442b-8e51-5ba5189385ca)Sanitization bypass using MIME type manipulation:
![image](https://github.com/user-attachments/assets/c4fa13a6-3c3a-4530-8d4e-68c203848a86)![image](https://github.com/user-attachments/assets/18197b3c-391a-4083-a610-51db6cca476a)PoCUpload `POC.html` as image.
File content:I changed extension to .html because even though POC.svg successfully bypassed the sanitization. 
When accessing the URL, the page didn't render as it should starts with <.
![image](https://github.com/user-attachments/assets/fb428dd8-44a1-4701-a4f5-1058afd0997a)
![image](https://github.com/user-attachments/assets/03d6f082-66af-4fad-b6a9-e19fc1cb73dc)
Since html doesn't have any such limitation we can access it.
Access the image URL to see the XSS popup.
![image](https://github.com/user-attachments/assets/edff5f12-a95e-4134-8894-af8a4972fe2a)ImpactSuppose another admin visits the image link, the attacker can perform any operation as the victim.
The session cookie is marked as http-only that disallow fetching cookies using javascript which is good thing. ( this prevent exfiltrating the cookie but still an attacker can perform any action behalf of the victim )Examplecreate a product behalf of victim.John doe (default admin ) creates another admin ( victimadmin@test.com )
When the victim-admin logs in and access the endpoint containing stored XSS, the script runs on behalf of victm-admin and the product is created. 
![image](https://github.com/user-attachments/assets/d7b25732-b05d-445c-9df0-09e8bdc62cfd)
![image](https://github.com/user-attachments/assets/c61086cd-6335-4c56-838f-9df88574de13)
// info shows that victim-admin created the product. Since this image can be accessed by other admins, it can be performed behalf on any admin. It'll be recorded as done by whoever visited the link.
Please see the detailed POC video for more details:
https://drive.proton.me/urls/KCKTSWHA3C#W2Zus8hWucj2Extended POC for performing the action shown in video:
POC.html:// make sure to update the cookies and CSRF tokens in the script to the attacker's.Recommendation:
Check file extension: whitelist allowed extensions.
Check mime type matches with file extension ( in this case GIF89 ( mime type GIF ) and extension: svg. They are not matching so reject it.
Check file extension ( endswith .svg ) and if it is svg then perform the sanitization that is in place.Affected Version: 0.1.6
![image](https://github.com/user-attachments/assets/e0e6115a-4932-4807-bb2b-ba192d4d5989)
CVSS v3.1 score: 6.8