Skip to content
Offensive Security Glossary / Black Box, Gray Box and White Box Testing

Black Box, Gray Box and White Box Testing: How Much the Tester Knows

The three knowledge levels for security testing, what each is good at, and how to choose.

What Is Black Box, Gray Box and White Box Testing

Black box, gray box and white box testing describe how much information a tester has before a security test. In black box testing the tester has no internal knowledge or credentials; in gray box testing the tester has partial knowledge, typically user credentials and documentation; in white box testing the tester has full access to source code, architecture and configuration.

The choice is a trade-off between realism and coverage per hour. Black box best reflects an unauthenticated outside attacker. White box finds the most per unit of effort because nothing has to be guessed. Gray box sits in between and is the usual default for application testing.

Comparison

AspectBlack boxGray boxWhite box
Information givenTarget name or URL onlyCredentials, API specs, some architectureSource code, configs, architecture, credentials
SimulatesExternal attacker with no accessAuthenticated user or attacker with stolen credentialsInsider or attacker with full knowledge
StrengthsRealistic view of external exposure, recon qualityCovers authenticated functionality and authorization efficientlyDeepest coverage, finds code-level flaws
WeaknessesTime spent on discovery; may miss authenticated areasDepends on quality of information givenLess representative of external attacker; more effort to review
Related toolingDASTDAST plus authenticated testingSAST, code review

How to Choose

  • External exposure assessment: black box, to see what an outsider finds.
  • Web applications and APIs: gray box, with credentials for each role and tenant, so authorization and business logic are covered.
  • High-risk components (auth, payments, crypto): white box review in addition to testing.
  • Compliance: PCI SSC guidance notes that penetration tests are typically performed as white-box or gray-box assessments to make efficient use of testing time.

FireCompass Testing Modes

FireCompass AI agents can test black box from the outside and gray box with supplied credentials for authenticated coverage. See AI penetration testing.

Sources and Standards

Frequently Asked Questions

What is black box penetration testing?

Testing with no prior knowledge or credentials, simulating an external attacker.

What is gray box penetration testing?

Testing with partial knowledge, usually user credentials and documentation, simulating an authenticated user or an attacker with stolen credentials.

What is white box penetration testing?

Testing with full access to source code, architecture and configuration, giving the deepest coverage.

Which is best for web applications?

Gray box is the usual choice, because authenticated testing with multiple roles is needed to find authorization and business logic flaws.

Further Reading

Reviewed against the primary sources cited on this page. Verified 2026-12-02.

Test From the Outside and the Inside

Run a free AI pentest and get proof-of-exploit findings.

Free AI Pen Test

No credit card. Findings include reproducible steps and exploit code.

Firecompass ranked #1 AI on HackerOne. Read more →