Parameter

Black-box, gray-box and white-box penetration testing

Also known as

  • Grey-box testing
  • Clear-box testing

Black-box, gray-box and white-box testing describe how much a penetration tester is told before starting: nothing beyond a target (black-box), partial information such as accounts and API specs (gray-box), or full access to source code, architecture and configuration (white-box).

Last reviewed

What do black-box, gray-box and white-box mean?

They describe the tester's starting knowledge. The PCI SSC's penetration testing guidance defines them in almost identical terms: black-box testing is done without prior knowledge of the internal structure, design or implementation of the target; gray-box with partial knowledge; white-box with knowledge of it. NIST's glossary uses the same split, and SP 800-115 describes gray-box as the combination of white-box and black-box techniques.

The labels describe knowledge, and they are separate from two other choices that often get mixed in:

  • Credentials. Whether the tester logs in is a separate question. A gray-box test is usually authenticated, but a tester can hold source code and still attack only the public surface. See authenticated penetration testing.
  • Staff awareness. NIST SP 800-115 calls testing done without the IT staff's knowledge, but with upper management's permission, "covert," and testing with their knowledge "overt." A black-box test can be overt.

Vendors also stretch the terms. Some call a test with only a URL and logins "black-box" because no documentation was shared; under the PCI definitions that is closer to gray-box. When comparing quotes, ask exactly what the tester receives.

How do the three compare?

AspectBlack-boxGray-boxWhite-box
Tester receivesA target (domain, IP range, app URL) and permissionAccounts for each role, API specs or schemas, architecture notesSource code, infrastructure-as-code, configs, design docs, plus accounts
SimulatesAn outside attacker with no insider helpA customer, a partner, or an attacker with a stolen loginAn insider, or an attacker who has already obtained the code
Strong at findingExposed services, forgotten hosts, unauthenticated flaws, what leaks to the internetBroken access control between roles and tenants, business logic, injection behind loginFlaws in code paths hard to reach from outside, hardcoded secrets, weak crypto use, unsafe deserialization, logic that only reads wrong in source
Tends to missEverything behind login, deep logic, rarely used featuresCode paths no UI or spec revealsProblems that only appear in the deployed system: misconfigured infrastructure, component interactions
Time spentMuch of it on reconnaissance and guessingMostly on attackingSplit between reading code and confirming in the running app
Cost for equal coverageHighestMiddleOften the most efficient per finding for custom code, if testers can read your stack

NIST's Appendix C makes a similar point about application testing: white-box techniques tend to be more efficient for finding defects in custom code, but they cannot detect problems in the interfaces between components or those introduced at build and installation time, which is what black-box techniques are for. Hence gray-box, which does both.

Which one should you pick?

For a SaaS product, gray-box is the usual default: accounts for every role, the API spec, and a short architecture walkthrough. It spends the tester's hours on attack, not reconnaissance. A few rules of thumb:

  1. Choose black-box when the question is "what can someone with nothing find?" This fits an external attack surface review, or a check on whether an acquisition's forgotten hosts are exposed.
  2. Choose gray-box for most application and API tests, and for any test meant to evidence access control.
  3. Choose white-box when the code is the risk: authentication and payment logic, cryptography, a new framework, or a team that wants findings tied to file and line.
  4. Combine them when budget allows: a short black-box reconnaissance phase, then gray-box or white-box testing on what matters.

Whatever you choose, write it into the rules of engagement and make sure the report states it. Reviewers reading a penetration test attestation letter look for this line.

Which approach do compliance frameworks expect?

Mostly the frameworks leave it to you, with two notable exceptions in guidance documents.

  • PCI DSS. The PCI SSC guidance says PCI DSS penetration tests are typically performed as white-box or gray-box assessments, because they yield more accurate results than pure black-box testing. It adds that a black-box assessment may require more time, money and resources to meet PCI DSS requirements. This is guidance, not a requirement in the standard itself.
  • FedRAMP. The Penetration Test Guidance has cloud providers supply privileged accounts in production, and tenant-to-management-system attacks run with the highest permissions available to customer users. A purely black-box test would not meet that.
  • SOC 2 and ISO 27001. Neither names a testing approach. Auditors generally look at whether scope and method are stated and match the system in scope.

Common mistakes

  • Buying a black-box test to save money, then spending the engagement on reconnaissance you could have handed over in an hour.
  • Calling a test white-box when the tester received the repo but no time to read it.
  • Omitting the approach from the report, which leaves reviewers to assume the weakest one.

Written by Parameter · Last reviewed