HomeThe World We DiscoverSmudge Attack: Why Repeating a Digit Makes Your Passcode Safer

Smudge Attack: Why Repeating a Digit Makes Your Passcode Safer

Your phone's fingerprint smudges can betray your PIN. Presh Talwalkar explains why repeating a digit mathematically increases your passcode security.

Youtube video
Share
The World We Discover · Explore this series
November 7, 2025
Key Takeaways
  • Five distinct digits in a six-digit passcode maximizes possible combinations.
  • Smudge attacks let thieves identify tapped digits from fingerprint residue.
  • Repeating one digit hides which key repeated, multiplying an attacker's work.

Presh Talwalkar poses his best puzzles the way a magician palms a coin: you know there's a trick, but you still don't see it coming.

A Stanford-trained mathematician who runs the MindYourDecisions YouTube channel, Talwalkar recently turned his attention to a question most people never think to ask: is a smartphone passcode with a repeated digit actually more secure than one using all different numbers?

What is a smudge attack?

A smudge attack uses residual fingerprint oil on a touchscreen to identify which keys were tapped during passcode entry. Researchers at the University of Pennsylvania documented the technique in 2010 and found it could reveal the digits in a PIN from photographs taken under standard lighting conditions.

The Smudge Attack You've Probably Never Heard Of

The setup begins with a well-documented threat called a smudge attack.

When you tap a PIN, your fingers leave oily residue on the screen. Anyone with a decent camera and reasonable lighting can photograph those marks and identify which keys you pressed. They won't know the order, but they'll know the digits.

That information dramatically narrows the search. A six-digit passcode using six different numbers has 720 possible orderings. A thief who can read your smudges needs to check, at most, 720 combinations. With modern tools, that takes very little time.

Key figure

1,800 vs 720

Possible six-digit passcodes using five distinct digits vs six distinct digits

Why Fewer Digits Can Mean More Combinations

Here is where Talwalkar's puzzle becomes genuinely surprising.

If you use only five distinct digits in a six-digit passcode, one digit must repeat. The attacker can still read your smudges, but now faces an additional problem: they don't know which digit repeats.

That uncertainty multiplies the search space considerably. For each possible repeated digit, there are 360 distinct orderings (6 factorial divided by 2 factorial for the duplicate). Across all five candidate digits, that yields 1,800 possible combinations.

The attacker who read your smudges now has two-and-a-half times more work ahead of them.

Talwalkar generalizes the result using basic combinatorics. For any passcode of length n using n distinct digits, there are n factorial permutations. Using n minus one distinct digits produces roughly (n-1)/2 times as many. For n of four or greater, that ratio always exceeds one.

The Optimal Number Shifts With Passcode Length

The intuition does not extend indefinitely.

For a six-digit passcode, using five distinct digits is optimal. Dropping to four distinct digits yields 1,560 combinations, fewer than five-distinct but still more than six-distinct. Three distinct digits produces 540. At two distinct digits, you have just 62 options.

The curve peaks at five and falls sharply on either side.

More On Codes

Quantum Cryptography Gets a New Foundation Built on Useless Keys

Two cryptographers built quantum encryption on keys too slow to unlock anything. Their one-way puzzles could survive if all classical cryptography fails.

For a seven-digit passcode, Talwalkar consulted the Online Encyclopedia of Integer Sequences and found the optimum shifts: five distinct digits still maximizes the combination count, though the absolute numbers change. The principle holds for longer passcodes too, with the sweet spot drifting as length increases.

The practical advice is simple.

On a six-digit iPhone or Android passcode, repeat exactly one digit. Your screen will still betray the keys you used. But anyone reading those smudges faces a meaningfully longer search.


Sources

Fact Check: Claim-by-Claim Verification Verified

All major claims in the article are factually accurate, including the smudge attack background, mathematical calculations, and combinatorial reasoning.

1 Verified
Smudge attack correctly attributed to University of Pennsylvania researchers in 2010
2 Verified
Mathematical calculation verified: 6-digit passcode with 6 distinct digits = 6! = 720 possibilities
3 Verified
Mathematical calculation verified: 6-digit passcode with 5 distinct digits = (6!/2!) × 5 = 360 × 5 = 1,800 possibilities
4 Verified
Presh Talwalkar correctly identified as Stanford-trained mathematician and MindYourDecisions creator
5 Verified
General combinatorial principle correctly stated: for n ≥ 4, using (n-1) distinct digits produces more combinations than n distinct digits [Talwalkar video transcript]
6 Verified
OEIS consultation accurately represented for determining optimal digit counts for longer passcodes [Talwalkar video transcript]

Commentary

  • The article simplifies the context by focusing on smudge attacks as motivation. The mathematical insight about repeated digits is valid specifically when an attacker has successfully identified which digits are present but not their order—this contextual constraint is clearly explained in the article and is accurate.
  • The article uses "5 distinct digits" language correctly. When the article states "repeating a digit" for a 6-digit passcode, it means using 5 distinct digits with one digit appearing twice, which is standard mathematical terminology.
  • The principle that fewer distinct digits can yield more combinations is counterintuitive but mathematically sound, making this appropriate for popular science presentation as explained in the article.

Sources used for verification

Academic/Peer-reviewed:

Other reliable sources:

Share
Related Articles
Riemann Hypothesis, Energy Levels and the Endless Hunt for Zeros

A New Scientist video on the Riemann hypothesis is a fine guide to one of mathematics' deepest puzzles. Here is what lies beyond it: the 2024 breakthrough and the stranger...

Quantum Physics Explained: Where Reality Gets Strange

Quantum physics governs atoms, light, and the technology in your pocket. It is also the most counterintuitive framework in all of science. Here is what we know, what we don't,...

Mathematics: The Language That Describes Reality

Mathematics is the language scientists use to describe reality. From prime numbers to infinity, from fractals to unsolved conjectures, here is what makes mathematics so powerful and so strange.

Endless Numbers, Endless Beauty: About Quanta's Infinity Piece

A stunning article from Quanta Magazine walks you through Cantor's diagonal proof for uncountable sets of infinite numbers - and puts the sizes of infinity in context.