Skip to content
XSS Disclosed report Intermediate CVE-2025-1936

jar: URL with embedded null ("%00") can be used to make us misinterpret a file's MIME type

A null byte in the entry name of a jar: URL causes Firefox to misinterpret the file's MIME type and extension, allowing an attacker to execute JavaScript embedded in an image's EXIF data or spoof a file extension. This could lead to cross-site scripting or tricking a user into running a malicious executable.

Surya Dev Singh Follow

Originally disclosed on Mozilla

  • Fixed in 12 days
  • Paid in 17 days
  • Disclosed after 12 days
Text
Created attachment 9445828
XSS_Using_Jar_File.png

Firefox for Android

Steps to reproduce:

A vulnerability in the jar: protocol parser of Mozilla Firefox allows filename and extension spoofing and MIME type manipulation leads to XSS when a null byte (%00) is included in the entry name of a JAR archive. This can result in malicious code execution, such as triggering JavaScript payloads embedded in image files by spoofing the file extension and MIME type. 

[+] Screenshot Attached below , I can only attach one screenshot, if need more details please reach me out!!


Actual results:

Create a Malicious File:

1) Embed a JavaScript payload in the EXIF data of an image file (e.g., hacker.png) using the Exiftool like so : exiftool -Comment=<script>alert('XSS By Surya Dev Singh')</script>" hacker.png

2) Place the image (hacker.png)  file in one folder (lets say hacker) and archive it to zip (jar files are basically zip file only so you can rename the generated zip file to something like hacker.ja) 

3) Try to load the  hacker.png file using the normally using the jar protocol :  jar:file:///C:/Users/Username/Desktop/hacker.ja!/hacker/test2/hacker.png
It will load the image normally.

4) But if you modify the URL by injecting Null Byte , it will terminate the "AUTF8String JAREntry" entry definition from the code . the modified URL would look like this : 
jar:file:///C:/Users/Z004WREN/OneDrive%20-%20Siemens%20Healthineers/Desktop/hacker.ja!/hacker/test2/hacker.png%00.html

5) This will Trigger the XSS payload that we have store in Exif comment data.

6) Now we can use this Null Byte Behavior with some slide modification to change the file name and its extension . which further means that we can change the mime type of the file . Thus will trigger an user to run the malicious file as non malicious file. 

7) to do that we need to to add "://<custom_filename>" after the null byte termination. like so : 

jar:file:///C:/Users/Z004WREN/OneDrive%20-%20Siemens%20Healthineers/Desktop/hacker.ja!/hacker/test2/hacker.png%00://definitely_not_a_hacker_file.exe

This will download the hacker.png file as "definitely_not_a_hacker_file.exe" with executable extension.

-------------------------------------------------------


All this behavior has been trigger due to the vulnerable code base in mozilla :
The two classes GetJARFile and GetJAREntry makes heavy use of nsCString (likely a Mozilla-specific wrapper around std::string or a similar container) and other string types. Functions that process strings could be vulnerable if the null byte is mishandled. Here’s a potential scenario:

In SetSpecWithBase(const nsACString& aSpec, nsIURI* aBaseURL), the code likely constructs and manipulates URLs. If the aSpec string contains a null byte in an unexpected location, the  nsIJARURIMutator function is then not able to handle the input that's coming from the  GetJAREntry . it might cause string manipulation functions (e.g., strlen, strcpy, strcat) to terminate prematurely or lead to buffer overflows/underflows.

The methods that handle strings (such as SetPathQueryRef, SetHostPort, SetRef) could all be susceptible to this issue if they don't handle strings properly


Here are link to codebase : 

https://searchfox.org/mozilla-central/source/__GENERATED__/dist/include/nsIJARURI.h#35




Expected results:

what  should have happened : 

The jar: protocol parser should correctly handle null bytes (\0) in filenames, preventing filename and extension spoofing. 

The MIME type of the file should remain consistent with its actual content and extension, disallowing manipulations.

Files within JAR archives should be securely validated and sanitized to prevent execution of embedded scripts.

No JavaScript payload embedded in non-HTML files should execute, even with manipulated MIME types.

The original report as published on Mozilla's Bugzilla, by Surya Dev Singh. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the jar: protocol parser does not properly handle null bytes in entry names, causing string truncation and incorrect MIME type or extension determination.

Impact

An attacker could execute JavaScript in the context of the jar: URL or trick a user into downloading a file with a spoofed extension, potentially leading to code execution.

What the attacker needed

Victim opens a crafted jar: URL; attacker can host a malicious JAR file

The fix

The jar: protocol parser should correctly handle null bytes in filenames, keep MIME types consistent with actual content, and prevent execution of embedded scripts.

How it was found

  1. Embed a JavaScript payload in the EXIF comment of an image file.
  2. Place the image in a folder and archive it as a ZIP, then rename it to a .ja file.
  3. Load the image using a normal jar: URL to confirm it displays correctly.
  4. Modify the URL by appending a null byte and .html to the entry name.
  5. Observe that the XSS payload from the EXIF comment executes.
  6. Append a null byte followed by ://<custom_filename> to change the downloaded file's name and extension.

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 report has not been written yet. The Original tab links to the source.

A jar: URL is a way to point to a file inside a compressed archive, like a ZIP file. The report says that if you put a special invisible character (a null byte) in the URL, Firefox gets confused about what kind of file it is. That confusion can let an attacker run harmful code or disguise a dangerous file as a harmless one.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Surya Dev Singh

View all

4 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.