English
Bugs and incidents
Almost every Unicode problem comes down to one sentence: two components disagree about "the same string". Encoding, length, case, normalization, display: a disagreement at any layer can become a bug or a vulnerability.
This page groups cases by "which layer disagrees", and most come with a minimal reproduction you can try in your own environment.
Databases
MySQL's utf8 cannot store emoji
MySQL's utf8 is really utf8mb3: at most 3 bytes per character, so it cannot store anything outside the BMP. Emoji are what people hit most often, followed by rare Han characters such as 𠮷. This is how most people first hear about utf8mb4.
sql
CREATE TABLE t (name VARCHAR(20)) CHARACTER SET utf8;
INSERT INTO t VALUES ('Alice😀');
-- strict mode: ERROR 1366: Incorrect string value: '\xF0\x9F\x98\x80' for column 'name'
-- non-strict mode: behavior varies by MySQL version; there is no guarantee what value is kept or truncatedIn older versions, truncation in non-strict mode has also become a vulnerability: WordPress CVE-2015-3438 used a four-byte UTF-8 character or an invalid character to trigger truncation in the database layer, so the HTML seen when the comment was checked differed from what was stored, resulting in stored XSS. WordPress fixed it in 4.1.2 on April 21, 2015. This is a different bug from the truncation of comments over 64 KiB reported the same month. See the CVE record and the WordPress announcement.
How to avoid it: use utf8mb4 for both tables and connections (SET NAMES utf8mb4, or set it in the driver's connection settings), and enable strict mode so data that cannot be stored raises an error instead of being truncated.
Collation makes different strings equal
sql
SELECT 'a' = 'á', 'a' = 'A'; -- utf8mb4_general_ci / unicode_ci: 1, 1
SELECT 'admin' = 'admin '; -- PAD SPACE collation: 1The application thinks these are two accounts while the UNIQUE index thinks they are one (or the other way around), which can lead to account collisions or takeover.
How to avoid it: normalize identifiers such as usernames and emails into a single form in the application, and compare them in the database with a NO PAD binary collation (for example utf8mb4_0900_bin, available from MySQL 8.0.17), so both sides mean the same thing by "equal".
A glibc upgrade corrupts PostgreSQL indexes
glibc 2.28 (2018) changed the collation rules of many locales. After an OS upgrade, PostgreSQL databases that use libc collations may have text-keyed B-tree indexes still ordered by the old rules, inconsistent with the new ones, causing wrong query results or broken UNIQUE constraints. The affected indexes must be rebuilt and the recorded collation version updated afterwards; running REFRESH VERSION alone does not repair the indexes. PostgreSQL also supports other providers such as ICU, so not every database uses glibc. See the PostgreSQL wiki page on the glibc 2.28 upgrade and the official notes on collation versions.
Lesson: collation rules are a dependency outside your code, and they change with OS upgrades. Columns that do not need language-aware sorting can use COLLATE "C"; check collation versions before upgrading the OS.
Case mapping
GitHub password reset vulnerability (2019)
js
'mıke@example.com'.toUpperCase() === 'mike@example.com'.toUpperCase()
// true: 'ı' (U+0131 Turkish dotless i) uppercases to 'I'The JavaScript above only illustrates the case collision; it does not show that GitHub's backend used toUpperCase(). The report published in 2019 by its finder, John Gracey, and the GitHub response it quotes confirm that email normalization during account lookup made different addresses match, while the reset token was sent to the address the user typed. The attacker also had to be able to get an address with a Unicode local part on the same domain; GitHub's response states that its outgoing mail server does not allow Unicode in the domain part, so a look-alike domain such as gmaıl.com cannot be used to impersonate Gmail and similar services.
Lesson: the form used for comparison must be the form actually used. After a successful match, send the email to the address in the database, not the address the user typed.
The Turkish locale
java
Locale.setDefault(Locale.forLanguageTag("tr-TR"));
"TITLE".toLowerCase(); // "tıtle"
"i".toUpperCase(); // "İ"
"title".equals("TITLE".toLowerCase()); // falseJava's toUpperCase() / toLowerCase() use the system locale by default. On Turkish computers, many programs break when matching HTTP headers, SQL keywords and enums.
How to avoid it: always specify Locale.ROOT when handling protocol strings and identifiers (in .NET, use the invariant culture).
Case mapping changes length
js
'ß'.toUpperCase() // 'SS'
'fi'.toUpperCase() // 'FI'
'İ'.toLowerCase().length // 2: 'i' + U+0307Code that assumes "changing case does not change length" computes wrong offsets, for example when it searches a lowercased string and uses the position to highlight the original; in C it can overflow a buffer.
Bypassing a WAF with case mapping
js
'ſ'.toUpperCase() // 'S' (U+017F long s)
'K'.toLowerCase() // 'k' (Kelvin sign)
/k/iu.test('K') // trueIf a WAF or input check blocks <script> and the backend changes case afterwards, <ſcript> passes the check and ends up as <SCRIPT>. Regex /i combined with Unicode mode produces similar surprise matches.
Normalization and equivalence
Spotify account hijacking (published retrospective, 2013)
Spotify's engineering post from June 2013 looks back on an earlier incident without giving the exact year it happened. Usernames were normalized with Twisted's nodeprep; after an upgrade from Python 2.4 to 2.5, the implementation no longer rejected input outside Unicode 3.2, and the transformation lost idempotence:
ᴮᴵᴳᴮᴵᴿᴰ →(first pass)→ BIGBIRD →(second pass)→ bigbirdAn attacker registers ᴮᴵᴳᴮᴵᴿᴰ and, after two rounds of normalization, can reset the password of bigbird.
Lesson: normalization must be idempotent (f(f(x)) == f(x)), and ideally it happens exactly once, in one place in the system.
Git CVE-2014-9390
Name comparison on macOS HFS+ ignores certain characters (such as U+200C), so .git can be treated as .git; case-insensitive file systems on Windows can also treat .GIT as .git. Git's checks for these equivalent names were incomplete at the time, so a malicious repo could overwrite .git/config during clone / checkout and run arbitrary commands. See GitHub's announcement from December 18, 2014.
Lesson: the file system's idea of "the same name" is another layer of normalization, and security checks must use the same rules as the file system.
NFD file names on macOS
python
'café' == 'café' # False
unicodedata.normalize('NFC', 'café') == 'café' # TrueA café.txt coming from a Mac is often NFD, and on Linux it is a different file from the NFC file with the same visible name. Git needs core.precomposeunicode, rsync needs --iconv.
Encodings and conversion
WorstFit
Under certain code pages, Windows best-fit mapping may map ", ¥ and the soft hyphen to ", \ and -. The original report on CVE-2024-4577 confirms that PHP-CGI on Windows, under certain locale settings, suffers argument injection through this kind of conversion, leading to RCE. Other best-fit mappings can also cause path traversal; see Best Fit / WorstFit (in Chinese). The mapping for each character is not the same across all code pages.
IIS Unicode directory traversal (2000, MS00-078)
GET /scripts/..%c0%af../winnt/system32/cmd.exe?/c+dirC0 AF is a UTF-8 overlong encoding of / (0x2F), which is invalid under the current UTF-8 specification. IIS 4.0 / 5.0 did not check specially encoded paths well enough, letting attackers leave the web root and possibly run programs on the server, with the privileges of the IUSR_machinename account rather than administrator privileges. See Microsoft's MS00-078 bulletin from 2000.
Lesson: UTF-8 decoders must reject overlong sequences; checks must happen after decoding, on the final form.
The Big5 "許功蓋" problem
功 = A5 5C
└─ 5C happens to be ASCII \Programs that do not understand Big5 treat the second byte as an escape character, producing mojibake ("許\功\蓋") or broken escaping logic. In C source code it can even make a comment swallow the next line; see Pitfalls by language (in Chinese).
GBK wide-character SQL injection
Input BF 27 ¿'
After addslashes BF 5C 27 ¿\'
MySQL reads it as GBK [BF 5C] 27 縗' ← BF 5C is one Han character, so ' escapesPHP's addslashes() escapes byte by byte and does not know that BF 5C is a single character in GBK.
How to avoid it: use prepared statements; if you must escape, use mysql_real_escape_string and set the connection encoding correctly, so the escaping function and the database see the same encoding.
Truncation that splits characters
js
const s = '中文😀'
new TextDecoder().decode(new TextEncoder().encode(s).slice(0, 4)) // '中�'
s.slice(0, 3) // '中文\uD83D': lone surrogateTruncating UTF-8 by bytes leaves half a character; truncating by UTF-16 code units leaves a lone surrogate, which breaks JSON serialization, database writes and data passed between languages. Truncate by grapheme instead (see String indexing, in Chinese).
BOM (U+FEFF)
An invisible EF BB BF at the start of a file causes:
#!/bin/shto stop working.- PHP to report "headers already sent".
- JSON parsers to fail.
- The first CSV column name to carry an invisible extra character, so
row['id']is not found.
Yet Excel needs a BOM to open UTF-8 CSV files without mojibake.
Input validation
\d is not just 0–9
python
re.fullmatch(r'\d+', '١٢٣') # matches (Arabic-Indic digits)
re.fullmatch(r'\d+', '123') # matches (fullwidth)
int('١٢٣') # 123In Python 3 and .NET regexes, \d matches all Unicode digits by default, so a "digits only" check may let in unexpected characters. The same goes for \w, isalpha() and isdigit(): their Unicode-aware versions cover far more than you might think. Use [0-9] or re.ASCII when you need ASCII.
Validate, then transform
Any "validate → normalize / change case / convert encoding / truncate → use" flow can be bypassed: what validation sees is not the string that is finally used. Most cases on this page follow this pattern.
Principle
Transform into the final form first, then validate; validation and use must see the same representation.
Verification scope (2026-11-12)
Years, CVEs and advisory numbers for the incidents on this page were checked against the original reports and official announcements linked above; for Spotify, the year of the published post and the year of the incident are stated separately. Code snippets illustrate the mechanism; database warnings, substitution or truncation behavior still depend on version and configuration.