Skip to content
Access control Write-up Beginner

When domain.com is the same as mydomain.com

The sign-up form for an AWS Cognito user pool was meant to allow only email addresses from a specific company domain, but the validation regex matched any address ending in that domain string. An attacker could register with an address on a look-alike domain they controlled and receive the verification code, bypassing the restriction.

medium.com

Published on medium.com

Picture this: You’re tasked with building a registration system that’s more exclusive than your local farmers market’s organic-only stall. Only employees with @domain.com email addresses should be allowed to join this digital harvest festival.

Phil, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the email domain check used a regex that matched the domain string anywhere at the end of the address, without requiring the '@' before it or anchoring the whole address.

Impact

An attacker could create an account on a restricted sign-up form using an email address they controlled, bypassing the domain restriction; the app itself was limited and the report was rated medium severity.

What the attacker needed

A look-alike domain; a catch-all email forwarder; sign-up form open to the public

The fix

The regex should be changed to require the '@' before the domain and anchor the match at the end of the string, and the text says the fix was implemented.

How it was found

  1. Find a sign-up form that only accepts emails from a specific domain.
  2. Try registering with an email on a domain that ends with the target domain string.
  3. Observe that the form accepts the address and sends a verification code.
  4. Register a look-alike domain and set up a catch-all mail forwarder.
  5. Complete registration with an email on the look-alike domain and receive the code.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A regular expression (regex) is a pattern used to check text. Here the pattern was meant to allow only emails ending in '@domain.com', but it actually allowed any email ending in 'domain.com', such as '[redacted]'. The attacker bought a similar-looking domain, signed up with an email there, and got the verification code, so they could create an account that should have been blocked.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.