All it took was knowing an email: how we found (and got fixed the same day) an account takeover during a pentest
In this guide (8)
- 1The context: an authorized pentest, not an intrusion
- 2The flaw: the concierge who hands the key to anyone
- 3Why it's serious
- 4It wasn't the only problem (and it almost never is)
- 5Timeline: all within the same day
- 6How it's closed: three rules and a checklist
- 7What we take away from this
- 8Why we chose to build KeideaCMS
Let me give a brief introduction. Our company Keidea s.r.l. has staff dedicated to various areas. This allows us to offer a range of services, from the development of web platforms, e-commerce, SEO and ads to artificial intelligence and cybersecurity services. I personally handle these last two areas. We have clients who have signed up for our service, which we affectionately named KeSecurity. In addition to the usual daily checks, this service includes running a black box Pentest every month.
During the monthly pentest on a company portal we work for, we found a flaw in the password recovery process: basically, any user who simply knew the email address of a registered user could reset their password and log into their account.
In this article we describe the flaw without providing a recipe for recreating it, what we found alongside it, and which rules prevent this kind of mistake. This is not an advisory: it is the account of a real case, written for those who develop or manage a restricted-access area.
The context: an authorized pentest, not an intrusion
We carry out a security test once a month on a portal with a members' area, a management system for professionals. The activity is agreed upon and authorized in writing: scope, rules of engagement and limits are defined before starting. This is not a bureaucratic detail. Without written authorization, attempting to access someone else's system is a criminal offense (art. 615-ter of the Italian Criminal Code), even if the intention is good.
The tests were carried out only on authorized accounts, at a deliberately slow pace so as not to disrupt the service. The client's name, domain and technical details that would allow the attack to be replicated are deliberately omitted.
The flaw: the concierge who hands the key to anyone
Imagine a hotel. A guest forgets their key and asks for it at reception. Before handing over a new one, the concierge must verify that this is indeed the guest staying in that room: ID, booking confirmation.
The "forgotten password" procedure works the same way. The site must not change the password upon request alone: it must first send a secret link by email, valid for a few minutes and usable only once. Only whoever opens that link proves they have access to the mailbox, and therefore that they are the account owner. That link is the ID document.
On the portal examined, this check was not performed. The request for a new password was accepted and carried out without verifying that the requester was the account owner. Simply knowing a user's email was enough to set a password of one's choosing, log in as them, and see everything they could see.
Why it's serious
Accounts of this type of portal contain personal data, documents and case files. Whoever takes control of them can read, modify and act on behalf of the victim. The rightful owner, meanwhile, risks being locked out without understanding what happened.
In the standard vulnerability classification, a flaw of this kind ranks among the most serious: it requires no particular skills, no prior access is needed, and the "key" to exploit it is an email address, a piece of data that is often public or easy to find.
It wasn't the only problem (and it almost never is)
A flaw like this rarely exists on its own. In the same test we found other weaknesses, less serious individually but dangerous together. We summarize them without going into detail:
User enumeration. The site responded differently for a registered email and a non-registered one. It's the first step in choosing a target.
No limit on attempts. Logins and requests could be repeated rapidly without slowdowns or blocks.
Sessions valid for a year. A compromised session remained usable for a long time.
Open redirects, overly permissive caching, and missing security headers. Minor individually, but they facilitate other attacks.
Frontend code published with debug maps, useful to anyone wanting to study how the site works.
The part that worked: data access rules at the database level withstood our unauthorized read and write attempts, and new user registration gave no way to bypass them. Where the architecture was well built, it did its job. The problem lay in the authentication logic.
Timeline: all within the same day
Discovery. During today's test it emerges that the password recovery process does not verify account ownership.
Reporting. The flaw is immediately communicated to the portal's developers, with a description sufficient to reproduce and fix it.
Fix. Their developers add token validation and close the flaw, on the same day.
The step that completes the cycle is the retest: repeating the test to verify that the fix really holds. A reported flaw is not a closed flaw until someone has retested it.
How it's closed: three rules and a checklist
1. Reset always requires a token. The password must not be changed based solely on the request. A code generated by the server is needed, sent by email, valid for a few minutes, tied to that account and usable only once. This is exactly what the developers added.
2. Responses must not reveal who is registered. For "forgotten password" and login, an existing email and a non-existing one must receive the same response.
3. Limited attempts and revocable sessions. A few failed attempts should trigger a slowdown or temporary lockout, and there must be a way to invalidate active sessions.
Checklist for anyone managing a members' area:
Verify that no password change occurs without a valid token that hasn't expired or already been used.
Notify the user by email of every password or address change.
Apply a limit on attempts per account and per IP address on login and recovery.
Give sessions a reasonable duration and a way to revoke them.
Do not publish debug maps in production.
Enable standard security headers and do not cache pages containing personal data.
Have the authentication flow tested by someone who didn't write it, at least once a year.
What we take away from this
Password recovery is the application's back door. It seems like a minor detail, yet it decides who you are. A flaw like this doesn't come from code written badly in a general sense, but from a verification step skipped at the most delicate point.
It happens even to those who do good work. The portal was built with care and the data protections worked. All it takes is one missing check in a flow to undo the rest.
A periodic test costs less than an incident. The difference between finding a flaw of this kind in a test and finding it in production is a few lines of code and a few hours of work. Better to get there first, and with written authorization.
Why we chose to build KeideaCMS
Authentication, password recovery, sessions: these are the parts that generic CMSs entrust to third-party modules and plugins, each with its own history of errors. That's why we developed KeideaCMS, a proprietary CMS with no additional plugins, where these flows are written and verified by us.
If you run an online business and have doubts about the solidity of your platform, write to us: a chat costs nothing.