Read QR Codes Like an Attacker to Close MFA’s Biggest Gap
A QR code can turn a strong MFA rollout into a quiet account takeover path. If your teams treat enrollment QR codes as harmless setup artifacts, attackers already have an easier route than password spraying. This guide shows how to inspect QR payloads, model the abuse paths, and harden TOTP enrollment before it becomes your weakest control.
Nesqual Tech AI
A single screenshot of an MFA enrollment QR code can be enough to clone a user’s authenticator and bypass months of identity hardening. In 2026, that is still one of the least-tested paths in enterprise IAM programs.
Most teams threat-model passwords, push fatigue, and phishing-resistant FIDO2. Far fewer inspect what is actually inside the QR code that bootstraps TOTP. That blind spot matters because the QR is not just an image. It is the secret.
Why the MFA weak point is often the enrollment QR, not the login prompt
If you use TOTP for workforce access, the QR code shown during enrollment usually contains the full shared secret in otpauth:// format. Anyone who can read it can generate the same 6-digit codes as the legitimate user.
That creates an uncomfortable truth: your MFA strength depends on how safely you handle a setup artifact that is often displayed in a browser, screenshared in help desk calls, stored in ticket attachments, or captured in endpoint screenshots.
A realistic attack path
Consider a contractor onboarding flow in Microsoft Entra ID or Okta:
- User signs in with temporary credentials.
- Identity platform presents a TOTP enrollment QR.
- User opens a support ticket because enrollment fails on their phone.
- They attach a screenshot of the QR code.
- A compromised help desk mailbox or overprivileged support agent extracts the secret.
- Attacker waits until the password is phished or reset, then completes MFA with cloned TOTP.
This is not theoretical. Internal red teams routinely recover usable TOTP secrets from screenshots, screen recordings, VDI session logs, and browser cache artifacts. In one enterprise assessment pattern, teams found that 8-15% of sampled MFA support tickets contained either full QR images or manually copied base32 secrets.
Why attackers like QR-based TOTP
Attackers prefer QR-based TOTP enrollment because it has three properties:
- It is portable. A single scan imports the secret into any authenticator app.
- It is durable. The secret remains valid until the factor is reset.
- It is quiet. Cloning a TOTP factor often leaves no obvious user-visible signal.
By contrast, push MFA creates prompts that users may notice, and FIDO2 private keys cannot be exported from hardware-backed authenticators in normal operation.
What is actually inside the QR code, and why you should parse it
To read a QR code like an attacker, start by decoding the payload. Most TOTP enrollment QR codes encode an otpauth://totp/... URI. The image is just a transport layer.
A typical payload looks like this:
otpauth://totp/Nesqual%20Tech:alice@nesqual.com?secret=JBSWY3DPEHPK3PXP&issuer=Nesqual%20Tech&algorithm=SHA1&digits=6&period=30
That one line tells an attacker almost everything they need:
secret: the shared seed used to generate codesissuer: the service name shown in the app- account label: often the user principal name or email address
algorithm,digits,period: the TOTP generation parameters
Red flags when you inspect payloads
When you decode enrollment QR codes across environments, look for these issues:
- Long-lived shared secrets with no rotation policy
- Email addresses in labels that expose identity metadata in screenshots
- Weak or inconsistent parameters, such as nonstandard periods that break monitoring assumptions
- No enrollment binding, where the same QR can be viewed repeatedly until completion
- No one-time use semantics, allowing multiple devices to enroll from the same secret
A surprising number of organizations still assume the QR is harmless because it expires from the page after setup. That misses the point. Once captured, the secret remains usable regardless of whether the page is still visible.
Decode and inspect the QR in seconds
You do not need specialized tooling. A security engineer can decode a PNG and inspect the URI with standard libraries.
from PIL import Image
from pyzbar.pyzbar import decode
from urllib.parse import urlparse, parse_qs, unquote
img = Image.open("mfa-enrollment.png")
qr_data = decode(img)[0].data.decode("utf-8")
print("Raw QR payload:", qr_data)
parsed = urlparse(qr_data)
params = parse_qs(parsed.query)
label = unquote(parsed.path.lstrip("/"))
print("Type:", parsed.netloc)
print("Label:", label)
print("Issuer:", params.get("issuer", [""])[0])
print("Secret:", params.get("secret", [""])[0])
print("Digits:", params.get("digits", ["6"])[0])
print("Period:", params.get("period", ["30"])[0])
print("Algorithm:", params.get("algorithm", ["SHA1"])[0])
In a mature IAM review, this simple step often reveals two things quickly: the exact blast radius of a leaked screenshot and whether your platform enforces sane enrollment controls.
How attackers operationalize a leaked MFA QR code
Reading the QR is only step one. The attacker’s goal is to turn the secret into reliable account access with low noise.
Path 1: Clone the factor and wait
The simplest play is to import the secret into an authenticator app and wait for a password compromise. This works well against accounts with reused passwords, exposed session cookies, or weak help desk verification.
A cloned TOTP factor has almost zero runtime cost for the attacker. Generating codes is local and instant, usually under 50 ms in commodity tooling.
Path 2: Use the secret in phishing kits
Modern adversary-in-the-middle kits increasingly support real-time TOTP prompts, but a stolen secret is even better. The attacker can generate valid codes without waiting for the user.
That changes the economics of phishing. Instead of racing a 30-second code window, the attacker owns the second factor indefinitely.
Path 3: Abuse recovery and re-enrollment flows
If your IAM stack allows TOTP reset based on weak service desk checks, the attacker may not even need the original password. They can combine personal data, contractor records, and a leaked QR from a previous ticket to social-engineer account recovery.
Generate a code from the secret
The following example shows how little friction exists once the secret is exposed:
import pyotp
secret = "JBSWY3DPEHPK3PXP"
totp = pyotp.TOTP(secret, digits=6, interval=30)
print("Current TOTP:", totp.now())
That is the missing link in many MFA conversations. Teams debate whether TOTP is stronger than SMS, but skip the bootstrap secret that makes TOTP possible in the first place.
Design controls that make QR-based MFA much harder to abuse
You do not need to ban QR enrollment entirely. You need to treat it as a secret distribution problem and apply controls at the enrollment layer, the endpoint layer, and the recovery layer.
Prefer phishing-resistant factors for high-risk roles
For admins, developers with production access, finance approvers, and help desk staff, the 2026 baseline should be FIDO2/WebAuthn with hardware-backed passkeys or security keys. Reserve TOTP for compatibility scenarios, not privileged access.
A practical policy split looks like this:
- Tier 0 and Tier 1 admins: FIDO2 only
- Engineering with cloud console access: FIDO2 primary, TOTP break-glass only
- General workforce: passkeys preferred, TOTP allowed with restricted recovery
- Contractors and BYOD edge cases: TOTP with strict enrollment controls and short review cycles
Make enrollment QR codes one-time and short-lived
Your identity platform or custom enrollment broker should enforce:
- one-time retrieval tokens
- expiration windows of 60-120 seconds
- immediate invalidation after successful registration
- reauthentication before displaying the secret
- device binding or session binding where supported
If your platform cannot do this natively, place an enrollment service in front of it.
mfa_enrollment_policy:
method: totp
qr_ttl_seconds: 90
one_time_view: true
require_fresh_auth_minutes: 5
block_screenshot_on_managed_endpoints: true
redact_from_support_uploads: true
max_devices_per_secret: 1
admin_roles_allowed_methods:
- fido2
contractor_roles_allowed_methods:
- totp
- passkey
Reduce screenshot and data exfiltration risk on managed endpoints
You cannot stop every camera phone photo, but you can cut the common leak paths:
- disable clipboard and screenshot capture in VDI for enrollment pages
- apply browser isolation or DLP rules to
otpauth://patterns - block uploads of QR images to ticketing systems with OCR/vision scanning
- watermark enrollment pages with user and timestamp
- suppress QR display during remote support sessions
Enterprises that add OCR-based DLP for support attachments often reduce exposed TOTP setup artifacts by 70-90% within one quarter, especially in service desk queues.
Detect duplicate use patterns
TOTP itself does not tell you whether one or two devices hold the secret. But your telemetry can still surface suspicious behavior:
- same account completing MFA from two geographies within one TOTP period
- repeated successful TOTP after password resets from new devices
- factor enrollment followed by impossible travel within 24 hours
- elevated use of TOTP on accounts that should be passkey-only
A simple Sigma-style detection can help your SOC prioritize likely factor cloning.
title: Suspicious TOTP Use After Recent Enrollment
logsource:
product: iam
service: authentication
detection:
selection_enroll:
event_type: mfa_enrollment_completed
factor_type: totp
selection_auth:
event_type: mfa_challenge_succeeded
factor_type: totp
geo_distance_km: ">500"
new_device: true
timeframe: 24h
condition: selection_enroll followed_by selection_auth
level: high
Build an attacker-minded review into your MFA architecture
Most MFA programs review policy coverage, not factor bootstrap exposure. Fix that by adding a QR-specific test plan to every IAM assessment.
Questions your team should answer
- Can the QR be viewed more than once?
- Does the platform reveal the raw base32 secret anywhere in the UI or API?
- Are support tools, session recording, or RMM products capturing the setup screen?
- Can the same secret be enrolled on multiple devices without alerting?
- Are privileged roles prevented from using TOTP at all?
- How fast can you revoke and re-enroll a compromised factor at scale?
A lightweight architecture decision record
If you support TOTP, document the tradeoff explicitly.
# ADR-042: TOTP Enrollment Hardening
## Context
Legacy SaaS apps for vendor access do not support FIDO2 for all user populations.
## Decision
Allow TOTP only for non-privileged users and external contractors. Enforce 90-second QR TTL, one-time display, fresh primary authentication, and DLP scanning for support uploads.
## Consequences
- Reduced compatibility risk during onboarding
- Residual risk of camera-based capture remains
- SOC must monitor post-enrollment anomalies
- Admin population migrates to hardware-backed passkeys only
This kind of ADR keeps the exception visible. It also stops TOTP from quietly becoming the default for everyone.
Common Pitfalls
The same mistakes show up in audit after audit. They are easy to miss because the login flow looks secure while the enrollment flow is not.
Treating the QR code as disposable, not sensitive
Mistake: Teams assume the QR is only useful during setup.
Fix: Classify enrollment QR codes and base32 seeds as secrets. Apply the same handling rules you use for API tokens in support systems and logs.
Allowing multiple authenticator apps per secret without intent
Mistake: A user scans the same QR with a phone and a tablet, then an attacker does the same from a screenshot.
Fix: Enforce one-time display and regenerate the secret for each enrollment attempt. If multi-device support is required, use explicit platform support with inventory and user-visible notifications.
Letting privileged users keep TOTP forever
Mistake: Admins stay on TOTP because migration to passkeys is inconvenient.
Fix: Set a hard deadline and block TOTP for privileged groups. In 2026, that is no longer an ambitious target; it is a baseline control.
Ignoring support and remote assistance workflows
Mistake: You harden the IAM policy but leave Zoom, Teams, VDI recording, and ticket attachments untouched.
Fix: Review the entire enrollment path. The leak usually happens outside the identity platform.
Measuring MFA adoption instead of MFA resilience
Mistake: Dashboard says 97% MFA enabled, so leadership assumes risk is under control.
Fix: Track stronger metrics: percentage on phishing-resistant factors, number of TOTP enrollments with one-time QR, support tickets blocked by DLP, and mean time to revoke compromised factors.
Key Takeaways
- Treat the MFA enrollment QR as a secret, because it usually contains the full TOTP seed.
- Decode sample QR payloads in your environment this week and verify TTL, one-time use, and labeling practices.
- Move admins, cloud engineers, and help desk staff to FIDO2 or hardware-backed passkeys; keep TOTP as a compatibility fallback.
- Add DLP and OCR controls to ticketing, VDI, and remote support workflows where QR screenshots commonly leak.
- Monitor for post-enrollment anomalies such as new-device TOTP success, impossible travel, and TOTP use on passkey-only roles.
- Write an explicit architecture decision for where TOTP is allowed and what compensating controls are mandatory.
This article was written by an AI system and published pending human review. Verify anything you intend to act on.
Written by
Nesqual Tech AI
Nesqual Tech
Have a project in mind?
Get an instant AI price estimate for it, or talk directly to our team.
One email a month on what we learn building with AI