<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/improper-otp-implementation-to-full-account-takeover-okroyeruh" -->

---
title: Improper OTP Implementation to Full Account Takeover
description: A penetration test uncovered a critical authentication bypass where a target API leaked one-time passwords (OTPs) directly in the HTTP response used to trigger...
canonical: https://daily.dev/posts/improper-otp-implementation-to-full-account-takeover-okroyeruh
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Improper OTP Implementation to Full Account Takeover | daily.dev
og:description: A penetration test uncovered a critical authentication bypass where a target API leaked one-time passwords (OTPs) directly in the HTTP response used to trigger...
og:url: https://daily.dev/posts/improper-otp-implementation-to-full-account-takeover-okroyeruh
og:image: https://api.daily.dev/og/posts/oKroYeRuh.png
og:image:alt: Improper OTP Implementation to Full Account Takeover
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Improper OTP Implementation to Full Account Takeover

**[InfoSec Write-ups](https://daily.dev/sources/infosecwriteups)** · 7 min read · 0 upvotes · 0 comments

## Summary

A penetration test uncovered a critical authentication bypass where a target API leaked one-time passwords (OTPs) directly in the HTTP response used to trigger their generation, rather than only via email. Combined with an account-enumeration flaw that exposed internal user IDs and confirmed valid administrator accounts, and OTPs that were not bound to session/device, had no expiry, and could be reused, this allowed a fully unauthenticated attacker to log into an administrator account using only the platform's own public API responses. Remediation includes never returning OTPs in responses, binding codes to user/session/device, enforcing short single-use expiry, generic account-lookup responses, rate-limiting, and auditing client-side JS bundles for leaked identifiers.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://infosecwriteups.com/improper-otp-implementation-to-full-account-takeover-df21e126f10f>

## Questions this post answers

### How can an attacker take over an admin account if an OTP is returned in the API response body?

If a server returns the generated one-time password directly in the JSON response of the request that triggers it, anyone who can call that endpoint can read the code without ever touching the victim's inbox. Combined with an account-enumeration endpoint that confirms valid emails and internal user IDs, and an OTP with no session binding, expiry, or single-use enforcement, an attacker can enumerate an admin account, request its OTP, read the code from the response, and log in directly.

_Track authentication and API security writeups like this one on daily.dev to harden your own OTP flows._

### What should a correct OTP verification API response look like to avoid leaking the code?

The response to an OTP-send request should return only a generic acknowledgment such as {"status":"sent"}, never the code, email, or internal user ID. The server should generate the OTP, persist it server-side bound to the user, session, and a short TTL (30-120 seconds), deliver it exclusively through email or SMS, and invalidate it immediately after one use or expiry, whichever comes first.

_Developers building auth flows can follow security remediation guides like this via daily.dev before shipping OTP endpoints._

### Why is returning an internal user ID from an email-validation endpoint a security risk?

Returning a definitive yes/no plus an internal record ID (idPersonnal) from an email-lookup endpoint enables account enumeration, letting an unauthenticated attacker confirm which emails belong to real, registered accounts and even identify administrators. The fix is to return the same generic response regardless of whether the account exists, relying on the out-of-band OTP delivery itself as the signal to a legitimate user.

_Security-minded engineers use daily.dev to stay sharp on enumeration flaws hiding in everyday login flows._

## Similar posts on daily.dev

- [Broken Authentication: How Attackers Gain Unauthorized Access to Your Application.](https://daily.dev/posts/broken-authentication-how-attackers-gain-unauthorized-access-to-your-application--nodkwynzj) · InfoSec Write-ups · 0 upvotes · 0 comments
- [A $10,000 Bug. One JSON Field. Every Account on the Platform.](https://daily.dev/posts/a-10-000-bug-one-json-field-every-account-on-the-platform--3st5kwrkw) · InfoSec Write-ups · 1 upvotes · 0 comments
- [The Current Landscape of OAuth Attacks](https://daily.dev/posts/the-current-landscape-of-oauth-attacks-apgnaql8v) · Unit 42 · 0 upvotes · 0 comments
- [Millions of people imperiled through sign-in links sent by SMS](https://daily.dev/posts/millions-of-people-imperiled-through-sign-in-links-sent-by-sms-kwbchos6w) · Ars Technica · 1 upvotes · 0 comments
- [Password spraying attacks surge 155x as hackers exploit MFA gaps](https://daily.dev/posts/password-spraying-attacks-surge-155x-as-hackers-exploit-mfa-gaps-itszhorqa) · BleepingComputer · 0 upvotes · 0 comments

---

Tags: [#security](https://daily.dev/tags/security), [#authentication](https://daily.dev/tags/authentication)

[View this post on daily.dev](https://daily.dev/posts/improper-otp-implementation-to-full-account-takeover-okroyeruh)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Improper OTP Implementation to Full Account Takeover","url":"https://daily.dev/posts/improper-otp-implementation-to-full-account-takeover-okroyeruh","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/improper-otp-implementation-to-full-account-takeover-okroyeruh"},"datePublished":"2026-09-08T16:02:21.782Z","dateModified":"2026-09-08T16:02:52.073Z","description":"A penetration test uncovered a critical authentication bypass where a target API leaked one-time passwords (OTPs) directly in the HTTP response used to trigger...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4235b607451f34697afea532413eb573?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/4235b607451f34697afea532413eb573?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"InfoSec Write-ups","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"InfoSec Write-ups","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/f0dc21b5bbfd46fda36f7b4b53dd1705","url":"https://daily.dev/sources/infosecwriteups"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/improper-otp-implementation-to-full-account-takeover-okroyeruh","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"security,authentication","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"InfoSec Write-ups","item":"https://daily.dev/sources/infosecwriteups"},{"@type":"ListItem","position":3,"name":"Improper OTP Implementation to Full Account Takeover"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/improper-otp-implementation-to-full-account-takeover-okroyeruh#faq","mainEntity":[{"@type":"Question","name":"How can an attacker take over an admin account if an OTP is returned in the API response body?","acceptedAnswer":{"@type":"Answer","text":"If a server returns the generated one-time password directly in the JSON response of the request that triggers it, anyone who can call that endpoint can read the code without ever touching the victim's inbox. Combined with an account-enumeration endpoint that confirms valid emails and internal user IDs, and an OTP with no session binding, expiry, or single-use enforcement, an attacker can enumerate an admin account, request its OTP, read the code from the response, and log in directly. Track authentication and API security writeups like this one on daily.dev to harden your own OTP flows."}},{"@type":"Question","name":"What should a correct OTP verification API response look like to avoid leaking the code?","acceptedAnswer":{"@type":"Answer","text":"The response to an OTP-send request should return only a generic acknowledgment such as {\"status\":\"sent\"}, never the code, email, or internal user ID. The server should generate the OTP, persist it server-side bound to the user, session, and a short TTL (30-120 seconds), deliver it exclusively through email or SMS, and invalidate it immediately after one use or expiry, whichever comes first. Developers building auth flows can follow security remediation guides like this via daily.dev before shipping OTP endpoints."}},{"@type":"Question","name":"Why is returning an internal user ID from an email-validation endpoint a security risk?","acceptedAnswer":{"@type":"Answer","text":"Returning a definitive yes/no plus an internal record ID (idPersonnal) from an email-lookup endpoint enables account enumeration, letting an unauthenticated attacker confirm which emails belong to real, registered accounts and even identify administrators. The fix is to return the same generic response regardless of whether the account exists, relying on the out-of-band OTP delivery itself as the signal to a legitimate user. Security-minded engineers use daily.dev to stay sharp on enumeration flaws hiding in everyday login flows."}}]}
```

