From 3f5221b837025604bb747af61dc7bdea3645d278 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 18 Nov 2026 18:37:36 -0800 Subject: [PATCH] Withhold an SSN's last four, a code before ", thanks" and a recovery phrase written with commas or numbers "ssn ending 1234" and "ssn last four 1234" are private again, as before this change; a code may be followed by a comma, "cheers", "thanks a lot" or more than one "!"; a recovery phrase is twelve BIP39 words in a row, so commas, numbering, a closing period or "my seed is" before it no longer hide it. The spelled-out email patterns start only at a word, which keeps long inputs fast. Co-authored-by: Manjunath Paparaju --- docs/CURRENT-STATE.md | 11 ++++---- src/search/placeSuggestions.js | 38 +++++++++++++++++----------- src/search/placeSuggestions.test.mjs | 20 +++++++++++++++ 3 files changed, 49 insertions(+), 20 deletions(-) diff --git a/docs/CURRENT-STATE.md b/docs/CURRENT-STATE.md index 89be93a338..af4bd7243f 100644 --- a/docs/CURRENT-STATE.md +++ b/docs/CURRENT-STATE.md @@ -8070,14 +8070,15 @@ digits and ten more letters or digits (an IBAN's shape); "password", "passcode", "passwd", "pw" or "pwd" followed by anything, "bearer" followed by anything but a short capitalised name or a place word such as island or lake ("Bearer Island", "bearer island" are places), -"ssn" followed by a digit ("SSN Station" is a place), "token", "secret", +"ssn" followed by a digit, also after "ending", "ends in" or "last four" +("SSN Station" is a place), "token", "secret", "api key", "key" or "pass" followed by ":" or "=", a licence, plate, passport, membership, account, policy, ticket, booking, confirmation or reference number with a digit after its label ("license ABC1234", "passport no. 123456"), "ID" in capitals followed by a number ("ID AB123"), "otp", "2fa", "mfa", "cvv", "cvc" or a verification, one-time, security, auth or login code followed by a code (any value after a label -in lower case, "verification code Abc", also before "thanks"; after a label +in lower case, "verification code Abc", also before "thanks", ", thanks", "cheers" or "thanks a lot"; after a label written as a name, any value that is not one: "OTP Bank" and "Security Code Plaza" are places), a "pin" or door, access, gate, alarm or entry code followed by a value in mixed case ("PIN aBcD"), a @@ -8114,9 +8115,9 @@ Street", "Hauptstraße 12". A nine-digit number or a short phone number written with no such word still gets the row: only picking it sends anything. One-time and verification codes, OTP, 2FA, MFA, CVV and CVC values, "card ending" digits, passphrases, -recovery or seed phrases (twelve to twenty-four words, every one on the -BIP39 English list in `src/search/bip39Words.js`, so a long question or -request still goes to Ask GEV), "my secret is …", an email spelled +recovery or seed phrases (twelve words in a row on the BIP39 English list +in `src/search/bip39Words.js`, also with commas, numbered or after "my seed +is", so a long question or request still goes to Ask GEV), "my secret is …", an email spelled out ("john at example dot com", "punto com", or letter by letter), a door, alarm or lockbox number ("code 4821"; "zip code 90210" and "area code 415" are places), "Authorization: Bearer …", a code in a link (`?code=…`), a diff --git a/src/search/placeSuggestions.js b/src/search/placeSuggestions.js index 6b3803ec93..5ad854a31d 100644 --- a/src/search/placeSuggestions.js +++ b/src/search/placeSuggestions.js @@ -154,13 +154,13 @@ function privacyReason(text) { return 'other'; if ( /[\p{L}\p{N}._%+-]\s*[([{<]\s*at\s*[)\]}>]\s*[\p{L}\p{N}-]/iu.test(line) || - /\b\S+\s+at\s+\S+\s+(?:dot|punto|ponto|period|punkt|[([{<]\s*dot\s*[)\]}>])\s+\p{L}{2,24}\b/iu.test( + /(?])\s+\p{L}{2,24}\b/iu.test( line, ) || - /\b\S+\s+at\s+[\p{L}\p{N}-]+\s*[([{<]\s*dot\s*[)\]}>]\s*\p{L}{2,24}\b/iu.test( + /(?]\s*\p{L}{2,24}\b/iu.test( line, ) || - /\b[\p{L}\p{N}._%+-]+\s+at\s+[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)*\s*\.\s*(?:com|net|org|edu|gov|mil|io|co|me|info|biz|app|dev|ai|[a-z]{2})\b/iu.test( + /(?= 12 && words.length <= 24 && words.every(isBip39Word)) - return 'other'; + // A wallet's recovery phrase ("abandon ability able …"): twelve words in + // a row on the BIP39 list ("can you tell where the most …" is a + // question). Too long to be sent for suggestions anyway, it is kept from + // the assistant too. + // Written with commas, numbered ("1. abandon 2. ability") or after a few + // words ("my seed is …"): twelve of the list's words in a row. + let run = 0; + for (const token of line.toLowerCase().split(/[\s,;]+/)) { + const word = token.replace(/^\d+[.)]?/, '').replace(/[^a-z]+$/, ''); + if (!word && token) continue; + run = isBip39Word(word) ? run + 1 : 0; + if (run >= 12) return 'other'; + } // Coordinates and grid references are a spot, not a number to keep: only // text the place search itself reads as coordinates, as typed ("١٢٣٤, // ٥٦٧٨" folded would read as a spot, but is not one). @@ -256,7 +262,7 @@ function privacyReason(text) { // but a capitalised name is a token, and a social security number has // digits. bearerToken(line) || - /\bssn\b(?:\s+(?:is|no\.?|number|#))*\s*[:=#]?\s*(?:\d|[x*]{2})/i.test( + /\bssn\b(?:\s+(?:is|are|no\.?|number|#|ending|ends?|in|with|last|four|4|digits))*\s*[:=#]?\s*(?:\d|[x*]{2})/i.test( line, ) || // The word for "password" in the interface's languages. @@ -284,7 +290,9 @@ function privacyReason(text) { line, ) || // An email spelled out to slip past a filter: "john at example dot com". - /\b\S+\s+at\s+\S+\s+dot\s+(?:com|net|org|edu|gov|io|co)\b/i.test(line) || + /(? { + for (const unit of ['a-', 'a.', '1-', 'a ', '//[a:']) { + const started = performance.now(); + mayBePrivate(unit.repeat(10000)); + assert.ok(performance.now() - started < 1000, unit); + } +});