Authentication bypass explained: how attackers reach admin panels and customer data

TL;DR

Difficulty: Intermediate

Authentication bypass is any trick that lets a stranger be treated as a logged in user, or a customer as staff, so they reach admin panels and customer data.

  • The usual ways in: weak session handling, predictable tokens, missing checks on sensitive routes, a flawed password reset, and mistakes with JSON web tokens.
  • The prize is customer data, the admin panel's controls, or quiet access for invoice fraud. A reportable breach in the United Kingdom must reach the Information Commission within seventy two hours.
  • AI raises the risk because it covers the happy path and skips the unhappy ones where auth security lives: Veracode found AI code has 2.74 times more vulnerabilities, and around 45% of AI code introduces an OWASP Top Ten flaw.
  • I defend with a proven auth layer, hardened sessions, bcrypt, a before_action guard plus an authorisation check on every sensitive route, secure reset tokens, a second factor, Cucumber scenarios, Brakeman and pen testing with Kali tools.

Every application with accounts does two jobs that sound like one: working out who you are, and working out what you are allowed to do. Authentication bypass is any trick that skips or fools the first, so the application treats a stranger as a logged in user, or a customer as staff. Here is how the door gets opened, what the attacker is really after, why AI written code makes it more likely, and exactly how I keep it shut on a Rails build.

The lock that decides who you are

Every application that has accounts has two jobs that sound like one. The first is authentication: working out who you are. You type an email and a password, the app checks them, and from then on it treats you as that person. The second is authorisation: working out what you are allowed to do once it knows who you are. A customer may see their own orders. A member of staff may see everyone's. The owner may issue refunds and change prices.

Authentication bypass is the name for any trick that lets someone skip the first job, or fool it, so the application treats a stranger as a logged in user, or treats a customer as staff. The product page on this site sums it up in one line: unauthorised access to admin panels and customer data. That is exactly the prize. Get past the lock on the front door and the attacker is inside, looking at names, addresses, order histories, saved cards at the payment provider, and in the worst case the admin panel where they can read every record at once.

I build business critical web applications and Solidus shops in Ruby on Rails, and I pen test every one before it goes live. This article explains, for a non developer, how authentication gets bypassed, what the attacker is really after, why code written by an AI assistant makes this more likely, and exactly how I keep the door shut. There is some code, kept short and illustrative. None of it is a working attack against anyone.

How the door actually gets opened

There is no single authentication bypass. There is a family of them, and almost all of them come down to the same root cause: the application trusts something it should have checked. Here are the five that I see most often, each with a small, safe illustration.

Weak session handling

When you log in, the server cannot keep asking for your password on every click, so it hands your browser a session: a small token in a cookie that says "this browser already proved it is Nadia". Every later request carries that cookie, and the server trusts it. The whole security of the login now rests on that cookie being impossible to guess, impossible to steal, and impossible to reuse once you log out.

Weak session handling breaks one of those three. A session identifier that is a simple counter can be guessed. A cookie sent over plain HTTP can be read on a shared network. A session that never expires, and is not thrown away when you log out, can be replayed weeks later. The classic mistake is session fixation: the app keeps the same session identifier before and after login, so an attacker who plants a known identifier in your browser first is suddenly sharing your logged in session.

Predictable tokens

A token is any string that stands in for a secret: a session identifier, a password reset link, an email confirmation link, an API key. The security of a token is the number of values it could possibly have. If a reset link ends in a nine digit number that counts up, there are only a billion of them and a script can walk the lot. If it is built from the time the request was made, an attacker who knows roughly when you asked for it has narrowed a billion down to a few thousand.

Here is the difference in one line of Ruby. The first is guessable, the second is not:

# Guessable: based on time and the user id
token = Digest::MD5.hexdigest("#{user.id}-#{Time.now.to_i}")

# Unguessable: 32 bytes from a cryptographically secure source
token = SecureRandom.urlsafe_base64(32)

The second line pulls 32 random bytes from the operating system's secure random source. The number of possible values is so large that walking through them is not a plan an attacker can carry out in a human lifetime. The first line can be reproduced by anyone who can guess the user id and the rough second it was made.

Missing checks on sensitive routes

A route is a single address inside the application, such as the page that shows an order or the button that issues a refund. Every sensitive route needs a guard that asks two questions before it does anything: are you logged in, and are you allowed to do this particular thing. Authentication bypass through a missing check happens when a developer puts the guard on the pages people reach through the menu, and forgets the one route that nobody links to but anyone can type.

The admin dashboard links to the orders page, which links to the refund action. A careful developer protects the dashboard. The gap is the refund action itself: if it only checks "are you logged in" and not "are you an admin", then any logged in customer who learns the address can call it directly. The menu hides the route from honest users. It hides nothing from an attacker reading the application's own JavaScript.

A flawed password reset flow

The password reset is the most attacked flow in any application, because it is a legitimate, built in way to take over an account without knowing the password. A reset flow has to get several things right at once, and getting any one of them wrong opens the door:

  • The reset token must be long and random, as above.
  • It must expire quickly, in an hour or two, not next week.
  • It must be usable exactly once, then destroyed.
  • It must be tied to one account and checked against that account, so a token issued for one person cannot reset another.
  • The "enter your email to reset" page must not quietly tell the attacker which emails have accounts, which is a gift for the next attack.

A common and serious mistake is a reset flow that builds the link from the user's email address or id rather than from a random secret, so that changing the address in the link resets a different person's password.

Mistakes with JSON web tokens

A JSON web token, usually written JWT, is a popular way to carry a logged in identity, especially between a front end and an API. It is a small packet with three parts: who you are, how the packet is signed, and the signature itself. The server trusts the packet because the signature proves the server itself issued it. JWTs are powerful and they are also a rich source of authentication bypass, because the packet arrives from the client and the temptation is to trust it.

The famous flaw is the "none" algorithm. A JWT states, inside itself, which algorithm was used to sign it. A library that believes that field will accept a token whose algorithm is set to "none" and whose signature is empty, which means the attacker writes their own identity into the packet and signs it with nothing. Other JWT mistakes are just as damaging: a signing key that is short enough to guess, tokens that never expire so a stolen one works forever, or storing the token where page scripts can read it so a single cross site scripting bug hands over every account at once.

What the attacker is actually after

None of this is done for sport. Follow the money and the motive is always one of a few things.

The direct prize is the data. A shop's customer records are names, email addresses, postal addresses, phone numbers, order histories and, through the payment provider, a way to attempt charges. That set sells, and it feeds the next round of attacks: convincing phishing emails that quote a real recent order, or credential stuffing against other sites using the email addresses harvested here.

The bigger prize is the admin panel. One customer account is one person's data. The admin account is everyone's, plus the controls: issue refunds to an attacker's own card, change the payout bank details, export the whole customer list in a single click, create a new admin user so the attacker still has a key after the hole is closed. An authentication bypass that reaches admin turns a quiet break in into a business ending event.

Then there is the quiet option, which is often the worst. An attacker who gets in and takes nothing visible, but sits inside reading orders and messages for months, is building a picture: who the big customers are, when invoices go out, how the owner writes. That is the raw material for invoice fraud, where a supplier's real payment details are swapped for the attacker's at exactly the right moment.

For a small business the consequences are not abstract. Under the United Kingdom General Data Protection Regulation, reportable personal data breaches must be reported to the Information Commission, the United Kingdom regulator, within seventy two hours of becoming aware of them. Customers have to be told. Trust, once a shop admits it lost its customers' addresses, does not come back with an apology email.

Why AI has made this more likely

A large share of new code is now written by AI assistants, and authentication is one of the places where that shift bites hardest. The reason is specific. An assistant is very good at producing code that works for the happy path, the case where everything goes right. Authentication security lives almost entirely in the unhappy paths: the expired token, the reused token, the logged out session replayed, the customer typing the admin address. Those paths rarely appear in a prompt, so they rarely appear in the generated code.

The measured picture backs this up. Veracode's 2025 GenAI Code Security Report found that AI generated code contains 2.74 times more vulnerabilities than human written code. An Ox Security analysis of more than three hundred repositories in 2025 found the same ten anti patterns in eighty to one hundred per cent of AI generated code, meaning the mistakes are not random, they repeat. Separate research has found that around forty five per cent of AI generated code introduces at least one of the OWASP Top Ten vulnerabilities, the industry's standard list of the most serious web weaknesses, and broken access control sits at the top of that list. A 2026 study of more than three hundred and four thousand commits found that 24.2 per cent of the issues AI introduced were still unresolved later, surviving into the running software. The Georgetown Center for Security and Emerging Technology set out the broader danger in its 2024 report on the cybersecurity risks of AI generated code, and CrowdStrike's 2025 research reached the same conclusion from the attacker's side.

Put that together with how authentication gets built in a hurry and the risk is clear. An assistant asked to "add login" will produce something that lets the right person in. Whether it rotates the session on login, expires and destroys reset tokens, checks authorisation and not just authentication on every sensitive route, and verifies the signature and algorithm on every JWT, is exactly the kind of detail that is missing unless someone who understands it asks for it, and then tests that it is true. When nobody on the team can read the generated code well enough to know whether those checks are there, the shop is trusting a black box with its front door.

How I defend against it

The defences are not exotic. They are a set of habits applied without exception, in a framework that gives me strong defaults to build on. Here is how I hold the door shut on a Rails application.

Start from a proven authentication layer

I do not hand roll authentication from scratch for a business critical build, because the subtle parts are exactly the parts that are easy to get wrong. I start from a well maintained, widely reviewed layer: Devise, or a hardened custom layer built on the primitives Rails now ships, with has_secure_password and the modern authentication generator. Using proven code means the session rotation, the secure comparison of secrets and the password hashing are already done by people who have been attacked and have fixed it. My job is to configure it correctly and to guard every route, not to reinvent the cryptography.

Hold the session properly

A session has to be hard to guess, hard to steal and short lived. On a Rails build that means cookies marked secure, so they only travel over HTTPS, httponly, so page scripts cannot read them, and SameSite=Lax or stricter, so they are not sent along from another site. It means rotating the session identifier the moment someone logs in, which closes session fixation, and destroying the session fully on logout rather than just hiding it. It means an idle timeout, so a session left open on a shared computer does not stay valid for a month.

Hash passwords with bcrypt, and compare secrets safely

A shop should never be able to tell you your own password, because it should never have stored it. I store passwords only as bcrypt hashes, which is what has_secure_password and Devise use by default. Bcrypt is deliberately slow and salted, so even if the database is stolen, the passwords cannot be read back and cannot be cracked at speed. When I compare any secret, a token or a signature, I use a constant time comparison such as ActiveSupport::SecurityUtils.secure_compare, so that the time the check takes does not leak how much of the secret was correct.

Guard every sensitive route, twice

This is the discipline that catches the "missing check" bypass, and it is where I am strictest. Every controller that touches private data starts from a default of locked, not open. In Rails that is a before_action that runs before anything else:

class Admin::OrdersController < ApplicationController
  before_action :authenticate_user!   # are you logged in at all
  before_action :require_admin!       # are you allowed in here

  def refund
    order = Order.find(params[:id])
    authorize! :refund, order          # are you allowed to do THIS
    # ... issue the refund
  end

  private

  def require_admin!
    redirect_to root_path unless current_user&.admin?
  end
end

The point is that both questions are asked, on every action, including the ones nobody links to. Authentication asks "who are you". Authorisation asks "are you allowed to do this to this exact record". I never trust an id that arrived from the browser as proof of anything. The authorize! line, backed by a policy library, is the lock on the individual action, so that learning the address of the refund route buys an attacker nothing at all.

A password reset that cannot be guessed or reused

My reset tokens come from SecureRandom, not from anything about the user. I store only a hash of the token, so a leak of the database does not leak live reset links. The token expires in a short window, is destroyed the instant it is used, and is checked against the one account it was issued for. The "forgot your password" page gives the same calm answer whether or not the email has an account, so it never becomes a tool for listing who banks here. Rails' own reset generators follow this shape, and I test every one of those properties rather than assume them.

Offer a second factor

A password, however well handled, is one secret, and secrets leak. For any account that can reach money or other people's data, and always for the admin panel, I offer and encourage a second factor: a one time code from an authenticator app, or a passkey. A second factor means that a stolen or guessed password is not, on its own, a key to the building. For staff accounts I make it mandatory.

Lock the behaviour down with Cucumber

Every one of these rules is a decision the business is making, so I write it down as a test that a person can read, using Cucumber, which lets the test be plain English backed by real code:

Feature: Only staff can issue refunds

  Scenario: a logged in customer is refused the refund route
    Given I am signed in as an ordinary customer
    When I send a request to the refund route for any order
    Then I am refused and no refund is created

  Scenario: an expired reset link does nothing
    Given I asked to reset my password three hours ago
    When I open the reset link now
    Then I am told the link has expired
    And my password is unchanged

These scenarios run automatically on every change, before anything reaches customers. They are the difference between "I believe the refund route is protected" and "a machine checks, on every release, that a customer is refused". When the owner asks how they know a stranger cannot reach the admin panel, the answer is a list of scenarios they can read, not my reassurance.

Brakeman first, then a real attacker with Kali

Before release I run Brakeman, the static analysis tool for Rails, which reads the code and flags common security mistakes, including routes with no authentication and unsafe handling of parameters. Then I do what an attacker would do. Using the tools on Kali Linux, the standard penetration testing distribution, I go at the running application: Burp Suite and OWASP ZAP to intercept and tamper with sessions, cookies and tokens, to replay a logged out session, to change an id in a request and see whether the authorisation check holds, and to probe the reset flow and any JWT handling for the flaws above. The point of pen testing is to find the missing check before someone who means harm does.

Why testing and pen testing make this insurable work

There is a reason I do it this way rather than simply trusting that the login "works". Authentication is invisible when it is right and invisible when it is wrong, until the day it is tested in anger. The only way to know the door is shut is to try the handle, deliberately and repeatedly, and to write down what you found.

That is what owned, readable code and a full test suite give a business. Every path is tested, including the unhappy ones that attackers live in. Every security decision is a scenario the owner can read. Every release passes through a gate that a red test can stop. When something does go wrong, there is a log and a test to add, not a shrug at a black box nobody understands. This is the difference between software you can stand behind and software you merely hope about, and it is the difference an insurer, an auditor or a serious customer will ask you to demonstrate.

AI can write a great deal of an application, and I use it. What it cannot do is decide what "secure" means for your business and prove, on every release, that the decision still holds. That judgement, and that proof, are the work.

A last, honest word

If you run a shop or an application with customer accounts and you are not certain whether every sensitive route is guarded, whether your reset links expire, or whether your sessions are held safely, that uncertainty is worth resolving before someone else resolves it for you. It is almost always cheaper to check the door than to report that it was open.

If you would like a clear answer, book the free workshop. We go through your login, your password reset, your admin panel and your sessions together, I show you where the real risks are in plain language, and the first two weeks of work are on me.

Not sure whether every sensitive route is guarded, whether your reset links expire, or whether your sessions are held safely? Book the free workshop: we go through your login, your password reset and your admin panel together, and the first two weeks of work are on me.

Shelter

I’m running the London Marathon for Shelter. Sunday 25 April 2027

My personal fundraiser. Shelter, the National Campaign for Homeless People Limited, registered charity 263710 (England and Wales) and SC002327 (Scotland), registered with the Fundraising Regulator.