CWE-20
CVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N

Unicode Transformation (Best-Fit Mapping)

Severity:
Medium
Summary

Invicti identified a Unicode Transformation (Best-Fit Mapping).

A best-fit mapping occurs when one Unicode character is substituted by a similar looking character. This might happen, for example, if a Unicode string is converted to an ASCII string. Due to the vast differences in the amount of available characters, many encoding functions try to map complex Unicode characters to a similarly looking character in ASCII. Á becomes A, ò becomes o, and so on.

Impact

A best-fit mapping might affect your application in a negative way. First of all, it's possible that functions which are responsible for sanitizing user input by encoding or removing output context specific special characters are applied to the Unicode string before conversion.

Take the following string as example.

<img src = "x" onload = "alert(1)" >

If you feed this string to a function responsible for removing HTML opening tags nothing will be changed. This is due to the fact that the first character is not an actual opening tag but the Unicode character U+FF1C FULLWIDTH LESS-THAN SIGN < (URL encoded as %EF%BC%9C).

However, if the string is then passed to a function that converts it to ASCII by applying a best-fit mapping, the Unicode character will be converted to an actual opening tag. This will easily lead to an XSS vulnerability, or any other vulnerability that you try to prevent by encoding or removing specific special characters in general to bypass blacklist filters.

Additionally, an XSS vulnerability might be easier to exploit for an attacker, as the difference in input and output could confuse the inbuilt XSS filter of modern browsers. This will effectively prevent them from recognizing the Cross-site Scripting attacks as such.

Remediation

If such a best-fit mapping is necessary for your application in order to function correctly, make sure that you apply functions that encode or remove special characters after you have converted the string, not prior to conversion. Additionally you should be aware that the built-in XSS filters of modern browsers might cease to work correctly if they are confronted with such a best-fit mapping. It is therefore strongly advised to implement Content-Security-Policy (CSP) properly in order to make up for the weakened client side security.

Required Skills for Successful Exploitation
Actions To Take
Vulnerability Index

You can search and find all vulnerabilities

Select Vulnerability
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Featured resources

Blog

Strengthening enterprise application security: Invicti acquires Kondukto

Blog

Modern AppSec KPIs: Moving from scan counts to real risk reduction

Blog

Friends don’t let friends shift left: Shift smarter with DAST-first AppSec

Blog

Vibe talking: Dan Murphy on the promises, pitfalls, and insecurities of vibe coding

Blog

What lies ahead for CMS.

Blog

How to integrate CMS with other tools.

Blog

Improve user experience through CMS.

Blog

How CMS can benefit e-commerce.

Blog

Stay updated on CMS trends.

Blog

Tips for improving CMS performance.

Blog

Learn how to secure your CMS.

Blog

Explore the advantages of CMS.

Blog

A comprehensive guide to CMS.

Build your resistance to threats. And save hundreds of hours each month.