Black box, grey box and white box: which type of pentest do you need

By Kike Gandia · Co-Founder & CEO, OSCP · Last updated:

The three types of pentest differ in the information the pentester receives before starting. In black box they get nothing but a URL or an IP; in grey box they get credentials for users of several roles; in white box they also get the source code. For a web application or a SaaS with user roles, grey box is the usual choice and the one that pays off most. Think of a building: black box is trying the doors from the street; grey box is doing it with an employee badge and trying other people's doors; white box is doing it with the floor plans in hand.

Comparison: black, grey and white box at a glance

Black boxGrey boxWhite box
What the pentester knowsOnly the URL, domain or IPUsers of several roles and, sometimes, API documentationCredentials, source code and architecture
What is testedWhat an anonymous external attacker sees: exposed services, technologies and versionsThe application from the inside, logged in as each roleThe code and the logic behind it, on top of the rest
What it findsMisconfigured services, vulnerable versions and flaws exploitable without authenticationAuthorization flaws: IDOR, role changes, other accounts' data, modification of other people's dataFlaws invisible from outside: secrets in the code, missing validations, insecure flows
What it does NOT findWhat sits behind the loginFlaws in code that no request ever triggersHow the deployed system behaves, if it is not also tested while running
When to choose itInfrastructure and services exposed to the internetWeb applications, SaaS and APIs with several rolesSecond cycle, critical code or secure development requirements
DeliverableReport of findings visible from outsideReport of findings per role, with evidence of the improper accessCode audit report with the file and line of each flaw

Black box: the external attacker's point of view

In a black box test the pentester starts from the same position as someone with no relationship to the company. They identify which services are exposed (a website, an FTP server, SSH access), which technologies and versions they run and what can be exploited without credentials.

A common misunderstanding is worth clearing up: black box is not running brute force against thousands of URLs. Discovering paths is only one part of reconnaissance. What follows is what matters: manually testing what has turned up, chaining flaws and checking whether any of them can really be exploited.

It is the natural test for exposed infrastructure, and a good gauge of what a website leaks before anyone logs in. What it cannot assess is what happens after login, which is where an application's most serious flaws begin.

Grey box: the common denominator of web applications and SaaS

In grey box the pentester receives test accounts for several roles. On a typical platform these would be, for example, an operator, a supervisor and an administrator. With them they test the application as a malicious employee or customer would use it:

  • Impersonation and role changes: whether an operator can perform actions that only an administrator should have, even if the button does not appear on their screen.
  • Access to another account's data: changing an identifier in a request (an order number, a user or an account) and checking whether the application returns data that is not theirs. This is the flaw known as BOLA or IDOR.
  • Modification of other people's data: editing or deleting records of another user or another account.

A generic example: the administrator of account A changes the account identifier in a request to that of account B and receives its data. To the browser everything works normally; the flaw is that the server does not check who each piece of data belongs to. No scanner and no test without credentials sees it. That is why grey box is the type most often commissioned for web applications and SaaS.

White box: when the pentester also reads the code

White box adds the source code and the architecture. It is, in essence, a source code audit combined with tests on the running application. It makes it possible to find secrets written in the code, permission checks missing on routes that almost nobody calls and design errors that would be very hard to deduce from outside.

It usually pays off more in a second cycle. Once the first pentest has fixed the obvious, reviewing the code helps locate what remains hidden and confirms that the fix addresses the cause, not the symptom.

Your client says "white box" and means "grey box"

In security questionnaires and tender documents it is common to read "a white box pentest is required". Often the person writing it means a test with credentials, which strictly speaking is grey box, and not a code review.

Before asking for a quote, confirm with your client exactly what they expect:

  • If they require a source code review, you need a code audit, with the scope, timeline and cost that implies.
  • If they require authenticated tests with several roles, you need grey box.

Settling this in writing avoids paying for a test that the client later does not accept as evidence.

Decision tree: which type of pentest do I need

1. What are you going to test? If it is exposed infrastructure (servers, VPN, email, open services), start with black box.
2. Does the application have users with different permissions? If so, you need grey box: authorization flaws are not detected without accounts for each role.
3. Are you required to review the code? If a client, a standard or an auditor explicitly asks for it, add white box.
4. Is it your first pentest? Start with black and grey; white box pays off more once the obvious is already fixed.
5. Unsure? Define the scope with a scoping form and discuss with whoever is quoting what you want to demonstrate.

Where to start

The most common sequence is a black box test on the exposed infrastructure, to see what anyone can see from the internet (external ethical hacking covers exactly that), followed by a grey box test on the application, which is where the highest-impact findings usually are. Then, if the client or a standard requires it, or if it is worth going deeper once flaws have been fixed, comes the code review.

On what each combination costs, there is a separate guide: how much does a pentest cost. And if any term sounds like jargon, the glossary explains it.

FAQ

What is the difference between black, grey and white box?

The starting information. In black box the pentester only knows a URL or an IP and attacks from outside, without credentials. In grey box they receive users of several roles and test the application from the inside. In white box they also have the source code and the architecture, and combine testing with code review.

My client asks for white box, do I have to hand over the code?

Not necessarily. "White box" is often used to mean a test with credentials, which strictly speaking is grey box. Before asking for a quote, ask your client whether they require source code review or authenticated tests with several roles: the scope, timeline and cost change.

Is a black box pentest brute force on URLs?

No. Discovering paths is only one step of reconnaissance. Exposed services, technologies and versions are identified, and what turns up is exploited by hand. What it does not assess is what is behind the login: for that you need grey box, with user accounts.

Which type does a web application or SaaS with several roles need?

Grey box. Its most serious flaws tend to be authorization flaws: an IDOR that shows another account's data, going from operator to administrator or modifying other people's records. None is detected without credentials, so accounts for each role are needed to test what each one can do.

Which one do you start with?

The usual order is a black box test on the exposed infrastructure and then a grey box test on the application. White box, which is code auditing, pays off more in a second cycle, when the obvious is already fixed and the goal is to locate what remains hidden.

Related service

manual web penetration testing

Related content

Request a web or SaaS pentest quote