📱
Security

How Secure Are SMS Codes? Weak Points and Proper Use

25.11.2026
← All articles

Logging in to a banking app, confirming an order, registering on a government portal: almost everywhere a six-digit code arrives on your phone. SMS codes are so familiar that many people consider them bulletproof. They are clearly better than a password alone, since an attacker now needs your phone as well, but they have weak points that both users and site owners should understand.

What SMS codes protect against

Two-factor authentication combines something you know with something you have. If your password leaks from another site, the password alone is no longer enough. Most mass attacks rely on automated password stuffing, and SMS codes stop them well. Having SMS codes is always better than no second factor.

Threat one: you read the code out yourself

In practice codes are stolen by deception more often than by hacking. A scammer posing as a bank employee, courier or classifieds buyer says "a code is coming, read it to me" while starting a login or card linking on your account. Real-time phishing pages do the same, relaying your password to the real site and then asking for the SMS code. The rule is simple: never share a verification code with anyone, and read the whole message to check which action it confirms.

Threat two: SIM swapping

Here the attacker takes over your number by convincing the operator, with fake documents or a "lost phone" story, to move it to a new SIM. All codes then go to them, and your phone suddenly shows "Emergency calls only". If that happens without reason, contact your operator immediately, check your banking apps, and ask whether extra checks or a block on SIM replacement are available.

Threat three: malware and network flaws

Android apps installed outside the official store, often spread on Telegram as "photos" or "parcel tracking" APKs, can read SMS and forward codes. The old SS7 signalling protocol also has known weaknesses that let well-resourced attackers intercept messages, which is one reason NIST treats SMS as a restricted authenticator.

MethodSIM swap resistancePhishing resistance
Password + SMS codeLowLow
Password + TOTP appHighLow
Passkey or security keyHighHigh

For site owners: implementing SMS codes properly

Codes must be random, short-lived, single-use and limited in attempts, and stored hashed. Put the site name and a "do not share" warning in the message, and end it with @misol.uz #123456: the WebOTP format, which lets supporting browsers offer the code only to pages on that domain.

// Generate and store the code
$kod = str_pad((string) random_int(0, 999999), 6, '0', STR_PAD_LEFT);
$_SESSION['otp'] = [
    'hash'     => password_hash($kod, PASSWORD_DEFAULT),
    'telefon'  => $telefon,
    'muddat'   => time() + 300,   // 5 minutes
    'urinish'  => 0,
];
sms_yubor($telefon, "misol.uz tasdiqlash kodi: $kod. Uni hech kimga aytmang.\n\n@misol.uz #$kod");

// Verify the code
$otp = $_SESSION['otp'] ?? null;
if (!$otp || time() > $otp['muddat'] || $otp['urinish'] >= 5) {
    unset($_SESSION['otp']);
    exit('Kod eskirgan, yangisini so\'rang');
}
$_SESSION['otp']['urinish']++;
if (password_verify($_POST['kod'], $otp['hash'])) {
    unset($_SESSION['otp']);   // one-time use
    // verified
}

Also limit sending. Bots abuse sign-up forms to send SMS to thousands of numbers at your expense, so cap messages per number and per IP, add a 60-second resend timer and show a captcha on suspicious activity.

Example: a flower delivery service in Tashkent

A flower shop in Mirabad lets customers log in to example.uz with a phone number and SMS code. One week its SMS bill multiplied: logs showed a bot requesting codes for foreign numbers from several IPs. Limits of three SMS per number and ten per IP per hour, Uzbek numbers only and a resend timer brought costs back to normal.

When to move beyond SMS

For ordinary accounts SMS is a reasonable compromise. For admin panels, payments and domain or hosting management, offer a TOTP app or passkey and keep SMS as a fallback.

Related articles

⚛️ RCE vulnerability in Next.js and React: how to check your project 🗝️ Passkeys: How Passwordless Sign-In Actually Works 🛡️ Disabling PHP in the Upload Folder: Apache and Nginx Rules 🗂️ 644 and 755: Correct File Permissions for Websites
🌐 Language
🇺🇿 O⁠'zbek 🇺🇿 Özbek (yangi) 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓