Security

All it took was knowing an email: how we found (and got fixed the same day) an account takeover during a pentest

5 min read

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)
  1. 1The context: an authorized pentest, not an intrusion
  2. 2The flaw: the concierge who hands the key to anyone
  3. 3Why it's serious
  4. 4It wasn't the only problem (and it almost never is)
  5. 5Timeline: all within the same day
  6. 6How it's closed: three rules and a checklist
  7. 7What we take away from this
  8. 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

  1. Discovery. During today's test it emerges that the password recovery process does not verify account ownership.

  2. Reporting. The flaw is immediately communicated to the portal's developers, with a description sufficient to reproduce and fix it.

  3. 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.

Try KeideaCMS for Free

Frequently Asked Questions

The portal accepted and completed a password reset request without verifying that the person making it was actually the account holder: it was enough to know a user's email to set a new password of choice for them and log in as them.
The accounts contained personal data, documents and files, and whoever took control of them could read, modify and act on behalf of the victim, leaving the account holder locked out without understanding what had happened. It didn't require any particular skills or prior access, just an email address that was often easy to find.
The site must not change the password based on the request alone, but must send a secret link via email that is valid for a few minutes and can be used only once. Only whoever opens that link proves they have access to the mailbox and are therefore the account holder.
User enumeration, no limit on login attempts, sessions valid for a year, open redirects, overly permissive caching, missing security headers, and debug maps published in production were all found.
The flaw was discovered, reported to the developers, and fixed all on the same day, with the addition of token validation by the portal's developers.
The reset must always require a server-generated token, valid for a few minutes and usable only once; the system's responses must not reveal whether an email is registered; finally, limits on attempts and revocable sessions are needed.

Do you need an e-commerce store or a website redesign?

Let's talk
  • Specialised consultation
  • Tailor-made solutions
  • Concrete results

Everythingin a singleSoftware

Talk to us for real

Our phone support is available every day from 09:00 to 18:00

+39 0835 239 514 Call us

Not your usual Web Agency

We follow you and always meet you halfway, even on spreading out your investment

Our projects

Need help

For information, quotes, or support, write to us

info@keideacms.it