Skip to content
cloudgrip

$ man black-box-gray-box-white-box-testing

//Offensive testing

What are black-box, gray-box and white-box testing?

The three box colors label a penetration test by the information handed to the tester in advance: only the target (black-box), partial knowledge such as user accounts and API documentation (gray-box), or full access to source code and configuration (white-box).

  • Offensive testing
  • 3 min read
  • updated Nov 11, 2026

What the three terms mean

The three labels describe how much information and access the tester starts with. They say nothing about skill, effort or the tools used.

  • Black-box. The tester gets a target, such as a URL or an IP range, and nothing else. This imitates an outsider who has never seen the system.
  • Gray-box. The tester gets some inside knowledge. Typical inputs are user accounts for each role, API documentation and a short description of the architecture.
  • White-box. The tester gets everything: source code, infrastructure configuration, design documents and often a developer to ask questions.

The labels sit on a scale. Many real engagements land between two of them.

How they compare

Black-box Gray-box White-box
Tester starts with A URL or IP range Accounts per role, API documentation Source code, configuration, architecture diagrams
Imitates A stranger on the internet A logged-in user, or someone holding stolen credentials Someone with inside knowledge and plenty of time
Time spent on discovery High Moderate Low
Coverage Narrowest Broad Broadest
Good at finding What a stranger can see and reach Authorization flaws, logic flaws, tenant isolation gaps Hidden code paths, weak cryptography, hardcoded secrets, root causes
Typical gap Most things behind the login page Flaws only visible in code The outsider's view of what is easy to discover

Which one to choose

Start from what you need to learn.

You want to know what a stranger can do. Choose black-box. It shows how exposed you look from the internet and whether your monitoring notices an attack. It is a weak choice for measuring how secure an application is, because the tester spends much of the time guessing what exists.

You want to know whether customers are separated and roles are limited. Choose gray-box. With accounts and documentation, the tester goes straight to the logged-in features where most serious flaws live. This is the sensible default for web applications and APIs, and it overlaps heavily with authenticated penetration testing.

You need the highest assurance before a major launch. Choose white-box. Reading the code lets the tester find paths that no amount of outside probing reveals, such as a debug route behind a feature flag. It pairs well with a secure code review.

Time is the practical constraint. A test has a fixed length, and every hour spent guessing endpoint names is an hour not spent attacking them. Real attackers have no deadline, so giving the tester a head start usually makes the result more realistic, not less.

Hydra starts gray-box: setup is a URL and two test logins. Read access to a repository adds reachable vulnerabilities in code, leaked keys and CI to the scope, which moves the test toward white-box.

What compliance frameworks expect

Most frameworks do not prescribe a knowledge level. They care about scope, the tester's independence and qualifications, and whether findings were fixed and retested.

The penetration testing guidance published by the PCI Security Standards Council describes all three approaches and leaves the choice to the organization and its assessor. In practice, auditors read the methodology section of the report to see what the tester was given, so record the approach in the rules of engagement before work starts. If a customer or regulator has a specific expectation, get it in writing first.

Common misunderstandings

"Black-box is the most realistic test." It is realistic only for an attacker with no information and a two-week deadline. Attackers buy leaked credentials, read your public documentation and take months.

"White-box means code review." A white-box pentest still attacks the running system. The code guides the tester to weak spots, and each finding is confirmed against the live application.

"Gray-box is a half measure." It is the approach that tests authorization most directly, and broken access control is the first entry in the OWASP Top 10.

"The labels are standardized." They are not. One provider's gray-box is another's white-box. Ask exactly which accounts, documents and code the tester will use.

See what an attacker would find.

Give us a URL and two test logins. If there’s something to find, your first exploited findings land within 24 hours.

You talk to the people who build Hydra and Cerberus. No sales script.

or write to founders@cloudgrip.ai