I have had one-time passwords sent to my phone via SMS. Those one-time passwords include those for 2FA and the occasional password reset.

Should I delete those SMS messages after the one-time passwords have been used?

The used one-time passwords cannot be reused, but I am wondering if the history of used one-time passwords present a security vulnerability. Say if the authentication of the site use an insecure algorithm for the one-time password generation. Given enough history of the one-time passwords, someone who manages to retrieve the SMS stored on my phone could derive the next one-time password in the sequence.

Out of scope of this question: Assume the SMS messages are not intercepted.

  • 1
    On a side note, researcher are recommending to move away from SMS to other forms of 2FA / OTPs as much as possible. This is due to recent attacks against crypto coin wallets which revealed that it's fairly easy to intercept those messages as indicated by Mike O in his answer. theverge.com/2017/9/18/16328172/… – sir_k Sep 17 '18 at 10:26
  • 1
    If the OTP is not predictable, once used the password should be considered useless. If the OTP is predictable, which shouldnt be, then the OTP should be deleted. Obviously if the SMS are intercepted you are screwed regardless the sms deletion or not. – bradbury9 Sep 17 '18 at 14:48
  • @sir_k Definitely. That's why I stated that SMS interception is out of scope of this question. SMS is not secure. You all here answered my question to my satisfaction. The key info is the OTP algorithms available out there. – Anonymous Sep 19 '18 at 0:59

As usual, let's start by defining the threat model: you're worried about someone getting a hold of your phone and looking through your SMS history. But you're not worried about the SMSes being intercepted. That's a bit of an odd security model cause intercepting SMSes is really easy, and stealing your phone and getting through a strong password is relatively hard. But ok.

Say if the authentication of the site use an insecure algorithm for the one-time password generation. Given enough history of the one-time passwords, someone who manages to retrieve the SMS stored on my phone could derive the next one-time password in the sequence.

Of course I can't guarantee that every site on the internet does OTP properly, but it's a pretty strictly defined standard. See wikipedia/Time-based_One-time_Password (and the more general wikipedia/HOTP). Since this is based on strong cryptographic hash functions, there is no risk of an attacker deriving future values from the past ones. Or if they can, then the hash function would be considered broken and they would retire it in favour of a better one.

It's also possible that a website isn't properly enforcing the "one-time" part of one-time-passwords, but I mean, that's a pretty basic part of implementing an OTP system.

  • may I know how an adversary can intercept my SMS? Is it by detecting all the signals sent to my phone? Isnt the communication encrypted? – black panther Sep 17 '18 at 0:28
  • 1
    @blackpanther That question has a very complex answer. It's encrypted from the tower to your phone, but not while bouncing around the phone network backend. When they designed the phone network system in the 1930's, or whenever, they didn't have digital security in mind. Look up "ss7 hacking" for an example. – Mike Ounsworth Sep 17 '18 at 0:38

As the name suggests the OTP is for one time usage and mostly implemented with a time limit (2 to 3 min). Hence once you used your OTP (came through SMS) or the time limit elapsed, the OTP is no more valid.

Hence the probability of someone stealing your phone and use the OTP is very very low. And the attacker should know what's the site you are accessing to use this OTP.

But the OTP can be captured by attackers before delivering to your mobile. There are advanced solutions like HOTP (HMAC-based One-time Password algorithm) to overcome this Man in the Middle attacks on OTP transferring.


This algorithm relies on two basic things: a shared secret and a moving factor (a.k.a counter). As part of the algorithm an HmacSHA1 hash (to be precise it’s a hash-based message authentication code) of the moving factor will be generated using the shared secret. This algorithm is event-based, meaning that whenever a new OTP is generated, the moving factor will be incremented, hence the subsequently generated passwords should be different each time.

Source: https://blogs.forgerock.org/petermajor/2014/02/one-time-passwords-hotp-and-totp/

Hope this clarifies your concern.

  • 1
    +1 Answer would be better if you expand on how HOTP prevents MitM? – Mike Ounsworth Sep 17 '18 at 12:58

If the site sending the one time passwords uses a good algorithm (such as HOTP) and implpements it correctly, there is no value in deleting the old messages. On the other hand, if the site uses some dumb homebrew or just failed at implementing things correctly, deleting the messages could be useful.

So how do you know what case it is? You don't. You'll have to think about how valuable the information you are trying to protect is, and how much you trust the people running the site. Personally, I have never bothered with deleteing these messages, and I don't think I would recommend "normal" users to do so either.

And one more aspect: If someone is able to read old messages from your phone, wouldn't they be able to read new ones as well? If so, deleting the old ones does not help, since the attacker can just trigger a new one and read that (assuming she knows the first factor).

  • You say, "the attacker can just trigger a new one and read that", but if the SMS was a 2FA OTP, then the attacker would typically need to be able to use the first factor in order to do that. – sampablokuper Sep 17 '18 at 9:51
  • @sampablokuper Fair point. I'm operating under the asumption that the first factor is already cracked, but that is not always true. I'll update my answer. – Anders Sep 17 '18 at 10:21

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.