Your Customer Table Is Your Breach Report: Three November Incidents, Read as a Schema
Your Customer Table Is Your Breach Report: Three November Incidents, Read as a Schema Three breaches in three weeks, and none of them involved a clever exploit worth studying. What they involved was data that existed,
Your Customer Table Is Your Breach Report: Three November Incidents, Read as a Schema
Three breaches in three weeks, and none of them involved a clever exploit worth studying. What they involved was data that existed, in fields someone chose to create, retained for longer than anyone had a reason for. Read as engineering problems, they are almost boring. That is what makes them useful.
I wrote a longer version of this for shop owners on the WardenBit blog. This is the version for people who own the schema.
The three data points
Tower Records Japan, 19 November. Unauthorized access detected on the Tower Records Online store at about 17:10 JST; service stopped, store still closed days later. Disclosed: 10,214,652 login records (email, member ID, password hash), 2,784,514 member profiles (name, furigana, nickname, date of birth, gender, postal code), 776,953 delivery records (address, recipient name, phone). No card data. Accounts closed up to three years ago were included, on the reasoning that the company kept them in case former customers asked a question.
Iris Ohyama, disclosed late October / early November. A suspicious file in an external cloud service used by the Iris Plaza store. Up to 5.8 million members and former members plus 1.9 million non-members β 7.7 million people β with names, addresses, phones, emails, gender, dates of birth and account passwords. The passwords were described as stored "in encrypted form", scheme unspecified.
KEPCO, confirmed 20 November. Two systems, one billing portal and one procurement platform. About 1.5 million people. The billing portal tier included card numbers, card issuers, bank names, bank account numbers and account holder names for 650,487 customers.
Read that list again as a reviewer with a red pen. Which of those fields would you approve in a pull request?
The retention decision is an engineering decision
Three years of post-closure retention does not happen by accident. Somebody wrote it, or more often nobody wrote anything and the default became forever. On WooCommerce, forever is the actual default: every order keeps one address row, one email, one phone, with no expiry.
WooCommerce's high-performance order storage introduced four tables β wc_orders, wc_order_addresses, wc_order_operational_data and wc_orders_meta. The addresses table is the one that matters here: first_name, last_name, company, address_1, address_2, city, state, postcode, country, email, phone, keyed on order_id with an address_type of billing or shipping. Nothing in that design ever removes anything.
Count your exposure:
Before writing SQL, check whether you need to. WooCommerce ships retention controls under Settings β Accounts and privacy for inactive accounts plus pending, failed, canceled, refunded and completed orders β each with a period after which the personal data is anonymized. Legacy data, custom plugins and non-standard policies are what the queries below are for.
SELECT COUNT(*) AS orders_older_than_24_months
FROM wp_wc_orders
WHERE date_created_gmt < DATE_SUB(UTC_TIMESTAMP(), INTERVAL 24 MONTH);
Then clear the identifying fields while keeping what finance and tax reporting need:
UPDATE wp_wc_orders
SET billing_email = '', ip_address = '', user_agent = ''
WHERE date_created_gmt < DATE_SUB(UTC_TIMESTAMP(), INTERVAL 24 MONTH);
UPDATE wp_wc_order_addresses a
JOIN wp_wc_orders o ON o.id = a.order_id
SET a.first_name = '', a.last_name = '', a.company = '',
a.address_1 = '', a.address_2 = '', a.phone = '', a.email = ''
WHERE o.date_created_gmt < DATE_SUB(UTC_TIMESTAMP(), INTERVAL 24 MONTH);
ip_address is personal data under UK GDPR, which is why it is in that first statement, and every order usually has two rows in wc_order_addresses β billing and shipping β so the row count is about double the order count. Pre-HPOS installs keep the same values in wp_postmeta as _billing_email, _customer_ip_address and _customer_user_agent; check Settings β Advanced β Custom data stores before querying the wrong table.
Test on a restored copy first, and get the retention period signed off by whoever owns the tax obligation. In the UK, a limited company is expected to keep accounting records for six years from the end of the financial year they relate to; the name and street line are not part of that requirement.
Hash format is a security control, not a detail
The Tower Records notice does not say which algorithm produced those 10 million hashes. Iris Ohyama said "encrypted" and stopped. In a breach notice, "encrypted" without a scheme name is a shrug.
You can answer the question for your own database in one query:
SELECT CASE
WHEN user_pass LIKE '$P$B%' THEN 'phpass (pre-6.8)'
WHEN user_pass LIKE '$wp$2y$%' THEN 'bcrypt (6.8+)'
WHEN user_pass LIKE '$argon2id$%' THEN 'argon2id'
WHEN user_pass LIKE '$argon2i$%' THEN 'argon2i'
WHEN user_pass LIKE '$2y$%' THEN 'bcrypt, raw prefix'
WHEN user_pass LIKE '$1$%' THEN 'md5-crypt'
WHEN user_pass REGEXP '^[0-9a-f]{32}$' THEN 'md5 hex, unsalted'
ELSE CONCAT('other: ', LEFT(user_pass, 6))
END AS scheme,
COUNT(*) AS users
FROM wp_users
GROUP BY scheme
ORDER BY users DESC;
Do not use LEFT(user_pass, 4) for this: the modern formats start $wp$2y$ and $argon2id$, so four characters give you $wp$ and $arg and match nothing below.
| Prefix | Meaning |
|---|---|
$P$B |
phpass, WordPress before 6.8 |
$wp$2y$ |
bcrypt, WordPress 6.8 and later |
$argon2id$ |
Argon2id, plugin or custom code |
$1$ or a bare 32-character hex digest |
legacy or hand-rolled β treat as urgent |
The trap in the phpass rows is that WordPress rehashes on next successful login. So the rows that stay on the weak format are the accounts nobody has logged into β the dormant ones, which are exactly the population an attacker with a leaked list wants, because dormant accounts do not notice a takeover and dormant passwords are the most likely to be reused on a high-value service. If your result is mostly $P$B, forcing a reset for dormant accounts is worth more than any header you could add this week.
The current OWASP guidance for new passwords is Argon2id, then scrypt, then bcrypt with a work factor that costs real time. Anything that produces a raw MD5 or SHA-1 digest is not a password store, it is a delay.
Every copy of the data is in scope
Iris Ohyama's incident was not in its own infrastructure β it was in an external cloud service the store used. The 1.9 million non-members are the detail to sit with: people who never registered, whose data nonetheless existed in a commercial system.
The same pattern in a small shop looks like this:
cd /path/to/wordpress
find . -type f \( -name '*.sql' -o -name '*.sql.gz' -o -iname '*customer*.csv' -o -iname '*export*.csv' \) \
-not -path './wp-content/cache/*' -not -path './node_modules/*' \
-printf '%TY-%Tm-%Td %10s %p\n' | sort -r | head -20
A migration dump in the web root is a complete copy of your customer table with a URL. A CSV of the mailing list handed to a printer and never deleted is a second breach waiting for its own incident report. Staging environments cloned from production and left with weak credentials are the same problem with a different hostname.
Also enumerate the services that hold your data:
wp plugin list --status=active --field=name
Every plugin that talks to a marketing, analytics or support platform is a processor. If you cannot name the fields it receives and the region it stores them in, you have not assessed it.
What to do about a leak after it happens
Two commands make a disclosure survivable, and both should be in a runbook before you need them. Killing every session on the site:
wp user list --field=ID | xargs -I{} wp user session destroy {} --all
And rotating the salts, which invalidates every auth cookie in one move:
wp config shuffle-salts
Neither of those is useful unless the message that goes out tells people the thing Tower Records' notice, as reported, did not say: that the password is now public, and that it must be changed anywhere it was reused. Hashes are the site's problem. Reuse is the user's problem, and only the notice can solve it.
The reviewer's question
If a breach report about your own schema were written tomorrow, what would be in the fields column that you could not defend in a code review? That is the list. It is usually shorter than people fear and more embarrassing than they expect β a date of birth for a campaign nobody ran, a nickname, a phone number from 2019.
Delete one this week. It is the cheapest security work available to you.
Stanley A. is the founder of WardenBit, a UK-based security assessment practice. The full case study, with sources and the disclosure timeline, is here.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.