FA-72741 / Check-digit algorithms / Open access
CPF accepts repeated-digit numbers · case 01
Placeholder numbers such as 111.111.111-11 pass both check digits.
ROOT CAUSE
The rule rejecting numbers made of one repeated digit is missing.
VERIFIED REPAIR
Reject any CPF whose eleven digits are all the same.
Unsuccessful approach: Rejecting only 00000000000 still admits the other nine repdigits.
Case contract
Brazilian CPF taxpayer number: dots and hyphens removed, then 11 ASCII digits that are not all the same digit (else "malformed"). k1 = (sum of digits 1-9 weighted 10..2) * 10 mod 11 mod 10; k2 = (digits 1-9 and the computed k1 weighted 11..2) * 10 mod 11 mod 10. Return [k1, k2, whether digits 10-11 equal them].
Why this case matters
Onboarding and invoicing flows validate CPF numbers before tax reporting.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(s):
t = s.replace('.', '').replace('-', '')
if len(t) != 11 or not t.isascii() or not t.isdigit():
return 'malformed'
d = [int(ch) for ch in t]
k1 = sum(w * x for w, x in zip(range(10, 1, -1), d[:9])) * 10 % 11 % 10
k2 = sum(w * x for w, x in zip(range(11, 1, -1), d[:9] + [k1])) * 10 % 11 % 10
return [k1, k2, d[9] == k1 and d[10] == k2]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["42765277574"]', ['42765277574'], [9, 1, False]], ['control ["04160821863"]', ['04160821863'], [1, 2, False]], ['control ["11181886176"]', ['11181886176'], [6, 3, False]], ['control ["54166960081"]', ['54166960081'], [1, 6, False]], ['control ["80112861152"]', ['80112861152'], [0, 5, False]]], [['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["61682621036"]', ['61682621036'], [5, 7, False]], ['control ["91615291602"]', ['91615291602'], [8, 7, False]], ['control ["38203173222"]', ['38203173222'], [5, 0, False]], ['control ["71865383378"]', ['71865383378'], [9, 2, False]], ['control ["11888021888"]', ['11888021888'], [6, 1, False]]], [['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["02970275879"]', ['02970275879'], [1, 3, False]], ['control ["33143111705"]', ['33143111705'], [6, 3, False]], ['control ["29622049718"]', ['29622049718'], [0, 2, False]], ['control ["22747397622"]', ['22747397622'], [5, 3, False]], ['control ["25998738965"]', ['25998738965'], [4, 2, False]]], [['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["52682522850"]', ['52682522850'], [3, 1, False]], ['control ["47444770261"]', ['47444770261'], [0, 4, False]], ['control ["78829380673"]', ['78829380673'], [8, 7, False]], ['control ["72986172530"]', ['72986172530'], [7, 1, False]], ['control ["37134793981"]', ['37134793981'], [9, 0, False]]], [['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["529.982.247-25"]', ['529.982.247-25'], [2, 5, True]], ['control ["52998224725"]', ['52998224725'], [2, 5, True]], ['control ["529.982.247-26"]', ['529.982.247-26'], [2, 5, False]], ['control ["1234567890"]', ['1234567890'], 'malformed'], ['control ["123.456.789-09"]', ['123.456.789-09'], [0, 9, True]]]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression ["111.111.111-11"] | [1, 1, True] | malformed | Failed |
| regression ["00000000000"] | [0, 0, True] | malformed | Failed |
| partial-repair ["22222222222"] | [2, 2, True] | malformed | Failed |
| control ["42765277574"] | [9, 1, False] | [9, 1, False] | Passed |
| control ["04160821863"] | [1, 2, False] | [1, 2, False] | Passed |
| control ["11181886176"] | [6, 3, False] | [6, 3, False] | Passed |
| control ["54166960081"] | [1, 6, False] | [1, 6, False] | Passed |
| control ["80112861152"] | [0, 5, False] | [0, 5, False] | Passed |
SHA-256 / c5d49129d9deb4e2997224a6d9c4bc1b5edebfe4c0b3911a68bca7b5169b391c
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(s):
t = s.replace('.', '').replace('-', '')
if len(t) != 11 or not t.isascii() or not t.isdigit():
return 'malformed'
if t == '0' * 11:
return 'malformed'
d = [int(ch) for ch in t]
k1 = sum(w * x for w, x in zip(range(10, 1, -1), d[:9])) * 10 % 11 % 10
k2 = sum(w * x for w, x in zip(range(11, 1, -1), d[:9] + [k1])) * 10 % 11 % 10
return [k1, k2, d[9] == k1 and d[10] == k2]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["42765277574"]', ['42765277574'], [9, 1, False]], ['control ["04160821863"]', ['04160821863'], [1, 2, False]], ['control ["11181886176"]', ['11181886176'], [6, 3, False]], ['control ["54166960081"]', ['54166960081'], [1, 6, False]], ['control ["80112861152"]', ['80112861152'], [0, 5, False]]], [['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["61682621036"]', ['61682621036'], [5, 7, False]], ['control ["91615291602"]', ['91615291602'], [8, 7, False]], ['control ["38203173222"]', ['38203173222'], [5, 0, False]], ['control ["71865383378"]', ['71865383378'], [9, 2, False]], ['control ["11888021888"]', ['11888021888'], [6, 1, False]]], [['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["02970275879"]', ['02970275879'], [1, 3, False]], ['control ["33143111705"]', ['33143111705'], [6, 3, False]], ['control ["29622049718"]', ['29622049718'], [0, 2, False]], ['control ["22747397622"]', ['22747397622'], [5, 3, False]], ['control ["25998738965"]', ['25998738965'], [4, 2, False]]], [['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["52682522850"]', ['52682522850'], [3, 1, False]], ['control ["47444770261"]', ['47444770261'], [0, 4, False]], ['control ["78829380673"]', ['78829380673'], [8, 7, False]], ['control ["72986172530"]', ['72986172530'], [7, 1, False]], ['control ["37134793981"]', ['37134793981'], [9, 0, False]]], [['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["529.982.247-25"]', ['529.982.247-25'], [2, 5, True]], ['control ["52998224725"]', ['52998224725'], [2, 5, True]], ['control ["529.982.247-26"]', ['529.982.247-26'], [2, 5, False]], ['control ["1234567890"]', ['1234567890'], 'malformed'], ['control ["123.456.789-09"]', ['123.456.789-09'], [0, 9, True]]]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression ["111.111.111-11"] | [1, 1, True] | malformed | Failed |
| regression ["00000000000"] | malformed | malformed | Passed |
| partial-repair ["22222222222"] | [2, 2, True] | malformed | Failed |
| control ["42765277574"] | [9, 1, False] | [9, 1, False] | Passed |
| control ["04160821863"] | [1, 2, False] | [1, 2, False] | Passed |
| control ["11181886176"] | [6, 3, False] | [6, 3, False] | Passed |
| control ["54166960081"] | [1, 6, False] | [1, 6, False] | Passed |
| control ["80112861152"] | [0, 5, False] | [0, 5, False] | Passed |
SHA-256 / 6e8689b2044111317a5f40182df4e46ed99e2eec247c2189c20a5ca0f0904052
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(s):
t = s.replace('.', '').replace('-', '')
if len(t) != 11 or not t.isascii() or not t.isdigit():
return 'malformed'
if len(set(t)) == 1:
return 'malformed'
d = [int(ch) for ch in t]
k1 = sum(w * x for w, x in zip(range(10, 1, -1), d[:9])) * 10 % 11 % 10
k2 = sum(w * x for w, x in zip(range(11, 1, -1), d[:9] + [k1])) * 10 % 11 % 10
return [k1, k2, d[9] == k1 and d[10] == k2]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["42765277574"]', ['42765277574'], [9, 1, False]], ['control ["04160821863"]', ['04160821863'], [1, 2, False]], ['control ["11181886176"]', ['11181886176'], [6, 3, False]], ['control ["54166960081"]', ['54166960081'], [1, 6, False]], ['control ["80112861152"]', ['80112861152'], [0, 5, False]]], [['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["61682621036"]', ['61682621036'], [5, 7, False]], ['control ["91615291602"]', ['91615291602'], [8, 7, False]], ['control ["38203173222"]', ['38203173222'], [5, 0, False]], ['control ["71865383378"]', ['71865383378'], [9, 2, False]], ['control ["11888021888"]', ['11888021888'], [6, 1, False]]], [['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["02970275879"]', ['02970275879'], [1, 3, False]], ['control ["33143111705"]', ['33143111705'], [6, 3, False]], ['control ["29622049718"]', ['29622049718'], [0, 2, False]], ['control ["22747397622"]', ['22747397622'], [5, 3, False]], ['control ["25998738965"]', ['25998738965'], [4, 2, False]]], [['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["52682522850"]', ['52682522850'], [3, 1, False]], ['control ["47444770261"]', ['47444770261'], [0, 4, False]], ['control ["78829380673"]', ['78829380673'], [8, 7, False]], ['control ["72986172530"]', ['72986172530'], [7, 1, False]], ['control ["37134793981"]', ['37134793981'], [9, 0, False]]], [['regression ["111.111.111-11"]', ['111.111.111-11'], 'malformed'], ['regression ["00000000000"]', ['00000000000'], 'malformed'], ['partial-repair ["22222222222"]', ['22222222222'], 'malformed'], ['control ["529.982.247-25"]', ['529.982.247-25'], [2, 5, True]], ['control ["52998224725"]', ['52998224725'], [2, 5, True]], ['control ["529.982.247-26"]', ['529.982.247-26'], [2, 5, False]], ['control ["1234567890"]', ['1234567890'], 'malformed'], ['control ["123.456.789-09"]', ['123.456.789-09'], [0, 9, True]]]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression ["111.111.111-11"] | malformed | malformed | Passed |
| regression ["00000000000"] | malformed | malformed | Passed |
| partial-repair ["22222222222"] | malformed | malformed | Passed |
| control ["42765277574"] | [9, 1, False] | [9, 1, False] | Passed |
| control ["04160821863"] | [1, 2, False] | [1, 2, False] | Passed |
| control ["11181886176"] | [6, 3, False] | [6, 3, False] | Passed |
| control ["54166960081"] | [1, 6, False] | [1, 6, False] | Passed |
| control ["80112861152"] | [0, 5, False] | [0, 5, False] | Passed |
SHA-256 / 0eb59f7853a41518b76491d6f39149ff343b7c83105f64fbd45e30cfd2f92ad1
Verification & scope
A deterministic, bounded teaching model of the named scheme under the stated contract; not a certified validator. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:48:41.174992+00:00.
Case digest / a0bba163e03ac500d8c2ae719f4e561af247c38cb0c9897aa52113c657cfea3b