0

I am thinking if using one-way function like SHA-512 is considered to be safe for application on credit card numbers.

The credit card number is 13-19 number with known BIN range (6-8 numbers) and the last one is determined as Luhn check. So there is a space of 10 number in ideal case which can be permuted.

Someone can compute hash tables using graphic cards like GTX 1080 Ti or similar to determine card number which is associated with some particular hash in a second.

When I consider price of such graphic cards and time and space I need to perform such attack, I feel it is practical and available to everyone.

Is it considered to be secure?

  • 4
    Safe and secure for what kind of application? And, SHA-512 of all 10 digit permutations can be precomputed and takes only a couple of gigabyte storage - which then allows really fast lookup. – Steffen Ullrich Jul 15 '17 at 18:16
  • You need to read pcisecuritystandards.org/documents/… for official guidance on hashing credit card numbers. The short answer to your question is "no". The long, expensive, complex answer is a very tentative "maybe", and you're still going to need a cryptographically solid design and expensive auditing. – John Deters Jan 20 '18 at 23:29
2

Not if the broad purpose of the application is to protect the credit card numbers from discovery.

In real-world attacks, hashcat can guess billions of SHA512 per second. If we assume worst case (unknown BIN range), and modest "prosumer" hardware, while it could take five years or more to fully traverse an 18-digit number:

Session..........: hashcat
Status...........: Running
Hash.Type........: SHA-512
Hash.Target......: 82a9dda829eb7f8ffe9fbe49e45d47d2dad9664fbb7adf72492...e5082f
Time.Started.....: Sat Jan 20 13:37:27 2018 (17 secs)
Time.Estimated...: Sat Mar 11 13:51:06 2023 (5 years, 50 days)
Guess.Mask.......: ?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d [18]
Guess.Queue......: 1/1 (100.00%)
Speed.Dev.#1.....:  1031.2 MH/s (619.87ms)
Speed.Dev.#2.....:  1017.4 MH/s (630.72ms)
Speed.Dev.#3.....:  1031.0 MH/s (622.62ms)
Speed.Dev.#4.....:  1027.8 MH/s (624.04ms)
Speed.Dev.#5.....:  1031.3 MH/s (621.75ms)
Speed.Dev.#6.....:  1030.8 MH/s (622.39ms)
Speed.Dev.#*.....:  6169.5 MH/s
Recovered........: 0/1 (0.00%) Digests, 0/1 (0.00%) Salts
Progress.........: 98959360000/1000000000000000000 (0.00%)
Rejected.........: 0/98959360000 (0.00%)
Restore.Point....: 81920000/1000000000000000 (0.00%)
Candidates.#1....: 121456006378999999 -> 689748844341234567
Candidates.#2....: 123456847101234567 -> 681748029669999999
Candidates.#3....: 123453859230000000 -> 681742421698999999
Candidates.#4....: 123452013019999999 -> 681749596777899999
Candidates.#5....: 123457762001234567 -> 681743859230000000
Candidates.#6....: 123451310341234567 -> 681744563019999999
HWMon.Dev.#1.....: Temp: 51c Fan: 80% Util:100% Core:1797MHz Mem:4513MHz Bus:8
HWMon.Dev.#2.....: Temp: 50c Fan: 80% Util:100% Core:1759MHz Mem:4513MHz Bus:4
HWMon.Dev.#3.....: Temp: 53c Fan: 80% Util:100% Core:1784MHz Mem:4513MHz Bus:16
HWMon.Dev.#4.....: Temp: 48c Fan: 80% Util:100% Core:1784MHz Mem:4513MHz Bus:4
HWMon.Dev.#5.....: Temp: 51c Fan: 80% Util:100% Core:1784MHz Mem:4513MHz Bus:1
HWMon.Dev.#6.....: Temp: 53c Fan: 80% Util:100% Core:1771MHz Mem:4513MHz Bus:1

... this worst-case performance can be significantly reduced if the BINs are known. A static string on the left-hand side significantly reduces hashcat performance, but if we assume a single BIN number (and ignore the Luhn), then for a 16-digit card number, the performance is quite reasonable.

On this example system, it would take about 30 seconds per six-digit BIN to acquire all possible 16-digit card numbers:

$ echo -n '4111119875914850' | sha512sum
4e65a06d53242aade56bd09f79dbda13cb945f459fd6544fccb320e76fdc56a11b9db0d412721280e11cef6082b5bad6d9529ec2b0f0a181e0312fa6cde5894a  -

$ cat target.hash
4e65a06d53242aade56bd09f79dbda13cb945f459fd6544fccb320e76fdc56a11b9db0d412721280e11cef6082b5bad6d9529ec2b0f0a181e0312fa6cde5894a

$ hashcat -m 1700 -w 4 -O -a 3 411111.hash 411111?d?d?d?d?d?d?d?d?d?d
hashcat (v4.0.1-90-gbb806d77+) starting...

OpenCL Platform #1: NVIDIA Corporation
======================================
* Device #1: GeForce GTX 1080, 2028/8113 MB allocatable, 20MCU
* Device #2: GeForce GTX 1080, 2028/8114 MB allocatable, 20MCU
* Device #3: GeForce GTX 1080, 2028/8114 MB allocatable, 20MCU
* Device #4: GeForce GTX 1080, 2028/8114 MB allocatable, 20MCU
* Device #5: GeForce GTX 1080, 2028/8114 MB allocatable, 20MCU
* Device #6: GeForce GTX 1080, 2028/8114 MB allocatable, 20MCU

[...]    

Session..........: hashcat
Status...........: Running
Hash.Type........: SHA-512
Hash.Target......: 4e65a06d53242aade56bd09f79dbda13cb945f459fd6544fccb...e5894a
Time.Started.....: Sat Jan 20 13:46:42 2018 (11 secs)
Time.Estimated...: Sat Jan 20 13:47:25 2018 (32 secs)
Guess.Mask.......: 411111?d?d?d?d?d?d?d?d?d?d [16]
Guess.Queue......: 1/1 (100.00%)
Speed.Dev.#1.....: 38982.9 kH/s (13.97ms)
Speed.Dev.#2.....: 38976.0 kH/s (13.99ms)
Speed.Dev.#3.....: 39000.6 kH/s (13.88ms)
Speed.Dev.#4.....: 39012.3 kH/s (13.94ms)
Speed.Dev.#5.....: 39035.2 kH/s (13.87ms)
Speed.Dev.#6.....: 39023.6 kH/s (13.93ms)
Speed.Dev.#*.....:   234.0 MH/s
Recovered........: 0/1 (0.00%) Digests, 0/1 (0.00%) Salts
Progress.........: 2327838720/10000000000 (23.28%)
Rejected.........: 0/2327838720 (0.00%)
Restore.Point....: 2301624320/10000000000 (23.02%)
Candidates.#1....: 4111112434163321 -> 4111117770560506
Candidates.#2....: 4111112108660506 -> 4111117372904221
Candidates.#3....: 4111112618532506 -> 4111117112038069
Candidates.#4....: 4111112366342221 -> 4111117513116069
Candidates.#5....: 4111112184375069 -> 4111117355891106
Candidates.#6....: 4111112792116069 -> 4111117068532506
HWMon.Dev.#1.....: Temp: 36c Fan: 80% Util:100% Core:1911MHz Mem:4513MHz Bus:8
HWMon.Dev.#2.....: Temp: 34c Fan: 80% Util:100% Core:1873MHz Mem:4513MHz Bus:4
HWMon.Dev.#3.....: Temp: 41c Fan: 80% Util:100% Core:1898MHz Mem:4513MHz Bus:16
HWMon.Dev.#4.....: Temp: 37c Fan: 80% Util:100% Core:1898MHz Mem:4513MHz Bus:4
HWMon.Dev.#5.....: Temp: 36c Fan: 80% Util:100% Core:1911MHz Mem:4513MHz Bus:1
HWMon.Dev.#6.....: Temp: 36c Fan: 80% Util:100% Core:1898MHz Mem:4513MHz Bus:1

4e65a06d53242aade56bd09f79dbda13cb945f459fd6544fccb320e76fdc56a11b9db0d412721280e11cef6082b5bad6d9529ec2b0f0a181e0312fa6cde5894a:4111119875914850

Session..........: hashcat
Status...........: Cracked
Hash.Type........: SHA-512
Hash.Target......: 4e65a06d53242aade56bd09f79dbda13cb945f459fd6544fccb...e5894a
Time.Started.....: Sat Jan 20 13:46:42 2018 (17 secs)
Time.Estimated...: Sat Jan 20 13:46:59 2018 (0 secs)
Guess.Mask.......: 411111?d?d?d?d?d?d?d?d?d?d [16]
Guess.Queue......: 1/1 (100.00%)
Speed.Dev.#1.....: 38816.8 kH/s (13.96ms)
Speed.Dev.#2.....: 38787.9 kH/s (14.00ms)
Speed.Dev.#3.....: 38828.3 kH/s (13.88ms)
Speed.Dev.#4.....: 38838.4 kH/s (13.94ms)
Speed.Dev.#5.....: 38859.5 kH/s (13.87ms)
Speed.Dev.#6.....: 38835.6 kH/s (13.93ms)
Speed.Dev.#*.....:   233.0 MH/s
Recovered........: 1/1 (100.00%) Digests, 1/1 (100.00%) Salts
Progress.........: 3722444800/10000000000 (37.22%)
Rejected.........: 0/3722444800 (0.00%)
Restore.Point....: 3664773120/10000000000 (36.65%)
Candidates.#1....: 4111112711801292 -> 4111117015095686
Candidates.#2....: 4111112665095686 -> 4111117129388822
Candidates.#3....: 4111112146389722 -> 4111117312215722
Candidates.#4....: 4111112178902022 -> 4111117392510186
Candidates.#5....: 4111112457267744 -> 4111117730075586
Candidates.#6....: 4111112334315722 -> 4111117552619950
HWMon.Dev.#1.....: Temp: 36c Fan: 80% Util: 78% Core:1911MHz Mem:4513MHz Bus:8
HWMon.Dev.#2.....: Temp: 35c Fan: 80% Util: 61% Core:1873MHz Mem:4513MHz Bus:4
HWMon.Dev.#3.....: Temp: 41c Fan: 80% Util: 57% Core:1898MHz Mem:4513MHz Bus:16
HWMon.Dev.#4.....: Temp: 38c Fan: 80% Util:100% Core:1898MHz Mem:4513MHz Bus:4
HWMon.Dev.#5.....: Temp: 37c Fan: 80% Util:100% Core:1911MHz Mem:4513MHz Bus:1
HWMon.Dev.#6.....: Temp: 36c Fan: 80% Util: 78% Core:1898MHz Mem:4513MHz Bus:1

Started: Sat Jan 20 13:46:16 2018
Stopped: Sat Jan 20 13:47:02 2018

... and only ~11 hours to bruteforce all single six-digit-BIN, 19-digit card numbers:

Session..........: hashcat
Status...........: Running
Hash.Type........: SHA-512
Hash.Target......: bd1676ab2c153ab78807527a60d5e13405881c6ebf55bbe66a6...e73a72
Time.Started.....: Sat Jan 20 13:50:26 2018 (3 secs)
Time.Estimated...: Sun Jan 21 01:10:25 2018 (11 hours, 19 mins)
Guess.Mask.......: 411111?d?d?d?d?d?d?d?d?d?d?d?d?d [19]
Guess.Queue......: 1/1 (100.00%)
Speed.Dev.#1.....: 40725.9 kH/s (14.01ms)
Speed.Dev.#2.....: 40794.1 kH/s (14.04ms)
Speed.Dev.#3.....: 40879.9 kH/s (13.86ms)
Speed.Dev.#4.....: 40907.3 kH/s (13.92ms)
Speed.Dev.#5.....: 40896.8 kH/s (13.86ms)
Speed.Dev.#6.....: 40899.5 kH/s (13.91ms)
Speed.Dev.#*.....:   245.1 MH/s
Recovered........: 0/1 (0.00%) Digests, 0/1 (0.00%) Salts
Progress.........: 692060160/10000000000000 (0.01%)
Rejected.........: 0/692060160 (0.00%)
Restore.Point....: 665845760/10000000000000 (0.01%)
Candidates.#1....: 4111112755122023234 -> 4111117051874189999
Candidates.#2....: 4111112172530023234 -> 4111117394829956789
Candidates.#3....: 4111112452329723234 -> 4111117735530023234
Candidates.#4....: 4111112669569723234 -> 4111117122329723234
Candidates.#5....: 4111112384829956789 -> 4111117530661956789
Candidates.#6....: 4111112625903023234 -> 4111117139850189999
HWMon.Dev.#1.....: Temp: 33c Fan: 80% Util:100% Core:1911MHz Mem:4513MHz Bus:8
HWMon.Dev.#2.....: Temp: 31c Fan: 80% Util:100% Core:1885MHz Mem:4513MHz Bus:4
HWMon.Dev.#3.....: Temp: 38c Fan: 80% Util:100% Core:1911MHz Mem:4513MHz Bus:16
HWMon.Dev.#4.....: Temp: 35c Fan: 80% Util:100% Core:1911MHz Mem:4513MHz Bus:4
HWMon.Dev.#5.....: Temp: 33c Fan: 80% Util:100% Core:1911MHz Mem:4513MHz Bus:1
HWMon.Dev.#6.....: Temp: 34c Fan: 80% Util:100% Core:1911MHz Mem:4513MHz Bus:1
  • 1
    Consider adding the the fact that the last 4 digits of a PAN are permitted by PCI to be preserved for printing on the receipt, matching card numbers on returns, etc. When you subtract those 4 additional digits from the set of possible guesses (you can still use the Luhn check digit to exclude 9 out of 10 guesses as invalid) you're down to guessing only five digits for a given 16-digit PAN with a pre-determined BIN. The system you described above could crack those literally in real time. – John Deters Jan 20 '18 at 23:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.