A small Node filter that keeps passwords and seed phrases out of support chats
The news On November 15, 2026, South Korean crypto exchange Coinone disclosed that an attacker had accessed servers run by MetaM, its outsourced customer support provider, on November 12. The exposed records came from
The news
On November 15, 2026, South Korean crypto exchange Coinone disclosed that an attacker had accessed servers run by MetaM, its outsourced customer support provider, on November 12. The exposed records came from support conversations. Depending on what each customer had shared, they include names, phone numbers, emails, dates of birth, bank account numbers, passwords, national ID numbers, home and wallet addresses, and transaction IDs. Coinone says its trading and wallet systems were separate and show no sign of intrusion, and it warned customers about scammers who may quote details from real past chats. (Cointelegraph, Crypto.news)
The part that caught my eye: passwords were in the leaked support records. That means customers typed them into a chat, and the chat system kept them.
You can't stop users from oversharing. You can stop your tooling from storing it.
What the filter does
redact-chat.mjs takes a message and returns a cleaned copy plus a list of what it found. Each finding is either block (should never reach an agent: passwords, private keys, seed phrases, national ID numbers) or mask (fine to keep partially: emails, phone numbers).
It runs on Node 18+ with no dependencies, so you can drop it into a chat widget's submit handler, a webhook in front of your ticketing system, or a nightly job over an existing archive.
The rules
const rules = [
// "password: hunter2", "pw = ...", "my pass is ..."
{ name: 'password', re: /\b(pass(?:word)?|pw|pwd)\b(\s*(?:is|:|=)\s*)(\S+)/gi, mask: (m, k, sep) => `${k}${sep}[REDACTED]` },
// 64 hex chars, optionally 0x-prefixed: looks like a raw private key
{ name: 'private key (hex)', re: /\b(?:0x)?[0-9a-fA-F]{64}\b/g },
// Bitcoin WIF private keys: 51-52 base58 chars starting with 5, K or L
{ name: 'private key (WIF)', re: /\b[5KL][1-9A-HJ-NP-Za-km-z]{50,51}\b/g },
// South Korean resident registration number: YYMMDD-NNNNNNN
{ name: 'national ID (KR RRN)', re: /\b\d{6}-[1-8]\d{6}\b/g },
{ name: 'email', re: /\b[\w.+-]+@[\w-]+\.[\w.-]+\b/g, partial: true },
{ name: 'phone', re: /(?<![\w-])\+?\d[\d -]{8,14}\d\b/g, partial: true },
];
One catch with the hex rule: a 64-character hex string is also what an Ethereum transaction hash looks like without its context. In a support tool I'd rather flag a tx hash by mistake and let the agent ask again than store a private key.
Seed phrases without the wordlist
A BIP39 seed phrase is 12, 15, 18, 21 or 24 words from a fixed list of 2,048. Checking against that list is the precise way. To keep this file dependency-free, it uses a rougher test: any run of 12 or more lowercase words of 3 to 8 letters on one line.
function findSeedRuns(text) {
const hits = [];
for (const line of text.split('\n')) {
const words = line.trim().split(/\s+/);
let run = [];
for (const w of [...words, '']) {
if (/^[a-z]{3,8}$/.test(w)) run.push(w);
else {
if (run.length >= 12) hits.push(run.join(' '));
run = [];
}
}
}
return hits;
}
Normal sentences rarely produce 12 lowercase words in a row with no punctuation, capital letter or number. If you see false positives, swap in the official wordlist and check that every word is on it.
Running it
The sample message below is made up, the kind of thing a stressed customer writes when a withdrawal is late:
Hi, my withdrawal is stuck since yesterday. Order ID 88213, tx 9f1c2e4b77a0d3c58e1f6b2a9c0d4e7f.
My email is [email protected] and phone +82 10 1234 5678.
ID number 900101-2345678 if you need it.
My password is Sunflower!2024 so you can log in and check.
Also here are my wallet words just in case:
apple river token blanket orbit chalk fossil wagon pencil lunar harbor velvet
node redact-chat.mjs sample-chat.txt prints:
Hi, my withdrawal is stuck since yesterday. Order ID 88213, tx 9f1c2e4b77a0d3c58e1f6b2a9c0d4e7f.
My email is ja****************om and phone +8************78.
ID number [NATIONAL ID (KR RRN) REMOVED] if you need it.
My password is [REDACTED] so you can log in and check.
Also here are my wallet words just in case:
[SEED PHRASE REMOVED]
BLOCK possible seed phrase
BLOCK password
BLOCK national ID (KR RRN)
mask email
mask phone
3 item(s) should never reach a support agent.
The exit code is 2 whenever something in the block group shows up, so a CI job or a pre-send hook can refuse the message and tell the user why.
Where to put it
- Client side, before send. Best for users: show a warning ("Support will never ask for your password") and let them edit.
- Server side, before storage. Catches everything, including messages from old clients. Store only the redacted text.
- Over the archive. Run it across existing tickets and see how many contain passwords. That number is a good argument for the first two.
Nothing here replaces access controls on the support system itself, but a leaked archive full of [REDACTED] is a much smaller problem than the one Coinone's customers are dealing with this week.
The full file
// redact-chat.mjs: mask secrets and over-shared personal data in a support message before it is sent or stored.
// Usage: node redact-chat.mjs <file> (or pipe text on stdin)
// No dependencies. Node 18+.
import { readFileSync } from 'node:fs';
const rules = [
// "password: hunter2", "pw = ...", "my pass is ..."
{ name: 'password', re: /\b(pass(?:word)?|pw|pwd)\b(\s*(?:is|:|=)\s*)(\S+)/gi, mask: (m, k, sep) => `${k}${sep}[REDACTED]` },
// 64 hex chars, optionally 0x-prefixed: looks like a raw private key
{ name: 'private key (hex)', re: /\b(?:0x)?[0-9a-fA-F]{64}\b/g },
// Bitcoin WIF private keys: 51-52 base58 chars starting with 5, K or L
{ name: 'private key (WIF)', re: /\b[5KL][1-9A-HJ-NP-Za-km-z]{50,51}\b/g },
// South Korean resident registration number: YYMMDD-NNNNNNN
{ name: 'national ID (KR RRN)', re: /\b\d{6}-[1-8]\d{6}\b/g },
{ name: 'email', re: /\b[\w.+-]+@[\w-]+\.[\w.-]+\b/g, partial: true },
{ name: 'phone', re: /(?<![\w-])\+?\d[\d -]{8,14}\d\b/g, partial: true },
];
// A seed phrase is 12, 15, 18, 21 or 24 short lowercase words in a row.
// Without the BIP39 list we flag any run of 12+ words of 3-8 letters on one line.
function findSeedRuns(text) {
const hits = [];
for (const line of text.split('\n')) {
const words = line.trim().split(/\s+/);
let run = [];
for (const w of [...words, '']) {
if (/^[a-z]{3,8}$/.test(w)) run.push(w);
else {
if (run.length >= 12) hits.push(run.join(' '));
run = [];
}
}
}
return hits;
}
export function redact(text) {
const found = [];
let out = text;
for (const s of findSeedRuns(out)) {
found.push({ type: 'possible seed phrase', severity: 'block' });
out = out.replace(s, '[SEED PHRASE REMOVED]');
}
for (const r of rules) {
out = out.replace(r.re, (...args) => {
found.push({ type: r.name, severity: r.partial ? 'mask' : 'block' });
if (r.mask) return r.mask(...args);
const m = args[0];
return r.partial ? m.slice(0, 2) + '*'.repeat(Math.max(m.length - 4, 1)) + m.slice(-2) : `[${r.name.toUpperCase()} REMOVED]`;
});
}
return { text: out, found };
}
const isMain = process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, '/').split('/').pop());
if (isMain) {
const input = process.argv[2] ? readFileSync(process.argv[2], 'utf8') : readFileSync(0, 'utf8');
const { text, found } = redact(input);
console.log(text);
console.log('---');
const blocks = found.filter((f) => f.severity === 'block');
for (const f of found) console.log(`${f.severity === 'block' ? 'BLOCK' : 'mask '} ${f.type}`);
console.log(blocks.length ? `\n${blocks.length} item(s) should never reach a support agent.` : '\nNothing that must be blocked.');
process.exitCode = blocks.length ? 2 : 0;
}
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.