Six PII patterns — what is found and where it goes wrong
Detection starts with six value shapes and finishes with validation and column names.
The short answer
Find by shape first, filter with Luhn and checksums, then fill the gaps with column names. Changing that order increases false positives.
The six shapes
The types sqlmask looks for by default, and the point people most often get wrong about each.
| Type | Example | Check | Common false positive |
|---|---|---|---|
| user01@example.invalid | dot in the domain | part of a file name | |
| Phone | 010-0000-0001, +82 10-0000-0001 | 9–11 digits domestic, 8–15 international | dates, version numbers |
| Card | 4111-1111-1111-1111 | Luhn (optional) | order numbers, 16-digit IDs |
| Resident no. | 000000-3000000 | 13-digit checksum (optional) | part of an account number |
| IPv4 | 192.168.0.1 | octets 0–255 | version string 1.2.3.4 |
| IPv6 | 2001:db8::1 | group count and shape | time 12:34:56 |
When to keep validation on
Luhn for cards and the checksum for Korean resident numbers remove most false positives. They also drop genuine values that fail the check.
If a column really holds customer cards, turning validation off and relying on a column-name rule is safer. Both rules work together: when the shape is not recognised, a column named card_no is still masked as a card.
How column names fill the gaps
Names such as email, phone, rrn, card_no, ip_addr, full_name and address declare the type. A short or malformed value is still handled as that type.
An email column containing only ‘unknown’ is masked to its first and last character rather than an email shape. The basis column in the comparison table shows which rule fired.
Shapes that are easy to miss
Detection is weakest here. If your data uses these forms, add a custom regex.
- Phones with brackets or spaces in odd places: 010) 0000 0001
- Full-width digits or hyphens
- Personal data that exists only inside SQL comments — comments are never changed
- Login identifiers that are not email addresses
- Several values joined by semicolons in one field — each value is found, the separator is kept
Try it
Paste this statement into the workbench to see the types split apart.
INSERT INTO members (id, email, phone, rrn, last_ip)
VALUES (1, 'user01@example.invalid', '010-0000-0001', '000000-3000000', '192.168.0.9');
Questions
What changes if I turn card validation off?
Every 13–19 digit number is treated as a card, so long order numbers are masked too.
Are column-name rules enough on their own?
They are strong when the name is exact, but not when it is user_ref or data1. Combine them with patterns.
Can IPv6 be confused with a time?
A time such as 12:34:56 has only two colons and is rejected. An IPv6 candidate needs at least two colons with a valid group count and shape.
Sources
Every example here can be pasted into the workbench as it is.
Open the workbench