Skip to content
Info disclosure Disclosed report Beginner CVE-2018-5173

browser.downloads.download should remove \u202E (RLO) chars

The browser's downloads API did not strip the right-to-left override character from filenames, so a file named with that character could appear to have a different extension in the downloads panel. An attacker could use this to disguise an executable as an image, potentially tricking a user into opening it.

Abdulrahman Alqabandi Follow

Originally disclosed on Mozilla

  • Fixed in 43 days
  • Paid in 48 days
  • Disclosed after 43 days
Text
Created attachment 8950753
PoC

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36

Steps to reproduce:

Added "\u202E" to a filename passed to downloads.download() results in a filename spoof.


Actual results:

Downloading with filename="test\u202Egpj.bat" results in a filename appearing to be "testtab.jpg" in the downloads panel.

When attempting to open this file, the prompt that appears reminding user that this is an executable is all reversed text and illegible. 


Expected results:

Strip "\u202E"

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

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 5 min read.

What the report shows

The target is the WebExtensions API in Mozilla's browser, specifically the downloads.download() function. The researcher, Abdulrahman Alqabandi, reported a filename spoofing issue: a Unicode right-to-left override character (\u202E, RLO) passed inside a filename is not stripped, so the saved file's displayed name can be made to look like a different file type.

The steps to reproduce are short. The researcher added \u202E to a filename passed to downloads.download(). The payload used was:

Text
test\u202Egpj.bat

With that filename, the download appears in the downloads panel as testtab.jpg. The RLO character reverses the display order of the characters that follow it, so gpj.bat is rendered as tab.jpg, and the whole name reads as a harmless image file.

The second part of the finding concerns what happens when the user tries to open the file. The browser shows a prompt warning that the file is an executable, but because the filename contains the RLO character, the prompt's text is reversed and illegible. The warning that should help the user make a safe decision is itself degraded by the same character.

The expected result, as stated in the report, is simply to strip \u202E from the filename. The text does not describe a fix commit, a bounty amount or further discussion.

Root cause

The observed behaviour is that the filename string is used as provided, so the RLO character reaches the downloads panel and the warning prompt. Unicode bidirectional formatting characters are legitimate for rendering right-to-left scripts, but when they appear in a filename they change how the name is displayed without changing the underlying bytes. The underlying characters are unchanged; only their presentation is altered. Any UI that renders the raw name, including the executable warning prompt, inherits the reordering.

Impact

A filename passed to downloads.download() containing the RLO character can make an executable appear to be an image in the downloads panel. A user who trusts the displayed extension may try to open the file, though the executable warning prompt still appears. The report notes that the executable warning prompt is still shown, but its text is reversed and illegible, which weakens the one control meant to stop the user at that point. The report does not demonstrate code execution or any behaviour beyond the spoofed display and the degraded prompt.

How this kind of bug works

Unicode defines bidirectional control characters so that text mixing left-to-right and right-to-left scripts can be laid out correctly. The right-to-left override, U+202E, forces all following characters in the same run to be displayed in reverse order. Software that treats a filename as plain text for display purposes will honour these characters, while the filesystem stores the literal code points. The result is a mismatch between what the user sees and what the system will execute or open.

The bug class appears wherever user-controlled strings are rendered without filtering bidi controls: download managers, file upload listings, attachment names in mail clients, archive extractors, and any UI that shows a name next to an icon or an action. The defence is to strip or reject the known bidi control characters (U+202A through U+202E, U+2066 through U+2069, and related marks) from filenames and other identifiers before display, or to render them in a context that neutralises directionality, such as isolating the string or escaping the controls.

How to test for it

  1. Identify features where a user-supplied name is displayed back: download APIs, upload endpoints, file rename functions, attachment handling, archive listings.
  2. Submit a name containing a bidi override immediately before a misleading extension, for example a name ending in an override followed by gpj.bat, so that the rendered result looks like tab.jpg.
  3. Observe the rendered name in every place it appears: the main list, confirmation dialogs, warning prompts, notifications and logs. A positive result is a displayed name whose apparent extension differs from the stored one, or a prompt whose text order is visibly scrambled.
  4. Confirm the stored value is unchanged, for example by checking the downloaded file's actual name on disk or the API response, so you can show the mismatch is presentation only.
  5. Test the same character in related fields, such as suggested filenames, content-disposition headers and archive entry names, since filtering is often applied in one place and missed in another.

Common false positives: a UI that escapes or strips the character and shows it literally, a name that is reordered only in a debug view the user never sees, or a case where the operating system refuses to save the file at all. A finding is only meaningful when the spoofed name reaches a decision point, such as a warning prompt or an open action.

How it is fixed

The report's expected result is to strip \u202E from the filename. Where the characters must be preserved for legitimate scripts, the display layer should isolate the string so directionality cannot leak across it, and security-relevant prompts should render the filename in a way that cannot be reordered. Regression tests should cover the override characters in both the stored name and the warning UI.

Hunting notes

This class tends to hide in features that combine a user-controlled name with a security decision: download panels, executable warnings, attachment previews, and archive extraction. Recon signals include APIs that accept a filename or suggested name parameter, endpoints that echo names back in responses, and any UI that shows a file type next to a name. To make a report land, show the exact input, the rendered output, and the stored value side by side, and point to the specific decision the user is misled about. Where a warning prompt exists, show that it is affected too, since that is what turns a cosmetic oddity into a security issue.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 5 min read.

What happened, in plain words

This report is about a small trick that can make a dangerous file look harmless. It was found in Mozilla's browser, in a feature called WebExtensions. WebExtensions are the add-ons you can install to change how the browser behaves, and they can ask the browser to do things like start a download. The researcher, Abdulrahman Alqabandi, found that one of these download functions, downloads.download(), does not clean up a special invisible character in the filename it is given. That character can flip the order in which letters are shown, so a file that is really a program can appear to be a picture.

The steps to reproduce are short. The researcher added the character \u202E to a filename passed to downloads.download(). The payload used was:

Text
test\u202Egpj.bat

Here \u202E is a single invisible character, not six visible ones. It is called a right-to-left override, or RLO. In plain text it tells the display to show everything after it in reverse order. So the visible part gpj.bat is drawn backwards as tab.jpg, and the whole name appears as testtab.jpg. The hidden character is still in the name, but the downloads panel shows the reversed version. That is why the file looks like a harmless image.

The second part of the finding is about what happens when the user tries to open the file. The browser does show a prompt warning that the file is an executable, which is the right thing to do. But because the filename contains the RLO character, the text of that prompt is also reversed and becomes illegible. The one warning meant to stop the user is itself broken by the same trick.

The expected result, as the report states, is simply to strip \u202E from the filename. It does not describe a fix commit, a bounty amount or further discussion.

In general, how this kind of bug works

Unicode is the standard that gives every character in every writing system a number, so computers can store and exchange text. It includes special control characters for bidirectional text, which is text that mixes left-to-right scripts like English with right-to-left scripts like Arabic or Hebrew. These controls tell the display which direction to use. The right-to-left override, U+202E, forces everything after it in the same run to be shown in reverse order. Software that treats a filename as plain text for display will honour these characters, while the filesystem stores the literal code points. The result is a mismatch between what the user sees and what the system will actually open or run.

This bug class appears wherever a user-controlled string is shown back without filtering bidi controls: download managers, file upload listings, attachment names in mail clients, archive extractors, and any interface that shows a name next to an icon or an action. The defence is to strip or reject the known bidi control characters (U+202A through U+202E, U+2066 through U+2069, and related marks) from filenames and other identifiers before display, or to render them in a context that neutralises directionality, such as isolating the string or escaping the controls.

How to test for it

  1. Identify features where a user-supplied name is displayed back: download APIs, upload endpoints, file rename functions, attachment handling, archive listings.
  2. Submit a name containing a bidi override immediately before a misleading extension, for example a name ending in an override followed by gpj.bat, so that the rendered result looks like tab.jpg.
  3. Observe the rendered name in every place it appears: the main list, confirmation dialogs, warning prompts, notifications and logs. A positive result is a displayed name whose apparent extension differs from the stored one, or a prompt whose text order is visibly scrambled.
  4. Confirm the stored value is unchanged, for example by checking the downloaded file's actual name on disk or the API response, so you can show the mismatch is presentation only.
  5. Test the same character in related fields, such as suggested filenames, content-disposition headers and archive entry names, since filtering is often applied in one place and missed in another.

Common false positives: a UI that escapes or strips the character and shows it literally, a name that is reordered only in a debug view the user never sees, or a case where the operating system refuses to save the file at all. A finding is only meaningful when the spoofed name reaches a decision point, such as a warning prompt or an open action.

How it is fixed

The report's expected result is to strip \u202E from the filename. Where the characters must be preserved for legitimate scripts, the display layer should isolate the string so directionality cannot leak across it, and security-relevant prompts should render the filename in a way that cannot be reordered. Regression tests should cover the override characters in both the stored name and the warning UI.

Hunting notes

This class tends to hide in features that combine a user-controlled name with a security decision: download panels, executable warnings, attachment previews, and archive extraction. Recon signals include APIs that accept a filename or suggested name parameter, endpoints that echo names back in responses, and any UI that shows a file type next to a name. To make a report land, show the exact input, the rendered output, and the stored value side by side, and point to the specific decision the user is misled about. Where a warning prompt exists, show that it is affected too, since that is what turns a cosmetic oddity into a security issue.

Glossary

  • WebExtensions: the system Mozilla's browser uses for add-ons, letting them interact with browser features such as downloads.
  • downloads.download(): a function in the WebExtensions API that starts a download and accepts a suggested filename.
  • Unicode: the standard that assigns a number to every character in every writing system.
  • Right-to-left override (RLO, U+202E): an invisible Unicode control character that makes following characters display in reverse order.
  • Bidirectional control character: a Unicode character that tells software how to lay out text mixing left-to-right and right-to-left scripts.
  • Spoofing: making something appear to be something else, here making a program look like an image.
  • Payload: the specific input used to trigger a bug, here the filename containing the RLO character.
  • Downloads panel: the browser interface that lists files being downloaded and recently downloaded.
  • Executable: a file that runs as a program when opened, such as a .bat file on Windows.
  • Sanitise: to clean input by removing or escaping characters that could cause problems.
  • Bidi control characters: the set of Unicode characters, including U+202A through U+202E and U+2066 through U+2069, that control text direction.
  • Content-disposition header: an HTTP response header that suggests a filename for a downloaded file.
  • False positive: a test result that looks like a bug but is not actually a security problem.

More by Abdulrahman Alqabandi

View all

33 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.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.