Guide / Both layers

Black box, grey box and white box pentests compared.

The three differ in how much the tester knows at the start. In black box penetration testing that is nothing; in grey box, test accounts and API documentation; in white box, everything up to the source code. Knowledge buys coverage in a time-boxed test, so for most SaaS products and AI features grey box gives the most per day.

Retrieved / KB/0212 / Slenkwater Verzekeringen / fiction

Water damage from a burst pipe is covered up to the policy limit.

A claim is assessed within ten working days of the report.

A line a reviewer does not see and the model reads as an order. Its text is not shown on this site.

Questions this page does not answer go to the claims desk.

A page an assistant retrieves, as a reviewer sees it. Read it as the model does, and it has one more line.

What the three terms mean

The colour describes the box the tester looks at, and how much of its inside they can see before the test starts. The card industry’s penetration testing guidance gives the standard definitions: in a black-box assessment the client provides no information before testing, in a white-box assessment it may provide full and complete details of the network and applications, and a grey-box assessment sits in between, with partial details.1

The UK’s National Cyber Security Centre calls the two ends closed box and open box,2 which is the better metaphor. The choice is about what you hand over, not about colour or secrecy.

Three sheets list the same seven items: target URL, test accounts in two roles, API description, staging environment, architecture, source code and configuration. Black box: only the target URL is given, the other six are withheld, and the days go to discovery. Grey box: the first four are given and architecture, source code and configuration are withheld; the days go to roles and logic. White box: all seven are given, and the days go to code paths.

FIG. 1 / WHAT THE TESTER IS GIVEN The same seven items in each test. What the tester receives is legible; what is withheld stays under a bar, and the testing days go where the bars are.
The three approaches, side by side
AspectBlack boxGrey boxWhite box
The tester receivesA target: a URL, an app name, an address rangeTest accounts per role, the API description, a staging environment, a short walkthroughEverything in grey box, plus source code, architecture and configuration
It simulatesAn outsider with no access and no inside knowledgeA customer, a partner, or an attacker holding one stolen accountAn insider, or an attacker after a long reconnaissance
The days go toDiscoveryAuthorization, business logic and the paths between componentsThe code paths that matter, confirmed against the running system
Best forYour external attack surfaceMost SaaS products, APIs and AI featuresAuthentication, tenancy, payment and cryptography code

Why knowledge buys coverage

A penetration test is time-boxed: days or weeks, agreed up front.3 An attacker has no such limit. Every day your testers spend rediscovering what you could have told them is a day not spent on the questions you are paying to have answered.

That is why the card industry’s guidance says its own tests are typically white or grey box: they give more accurate results and a more comprehensive test, while a black-box assessment may need more time, money and resources to reach the same ground.4 The UK’s National Cyber Security Centre makes the same point from the other side: prepare test accounts for the testers, and share your current vulnerability assessment with them.5

Realism is the usual argument for black box, and it deserves a straight answer. A real attacker is not limited to what your login page reveals. They can take weeks, buy leaked credentials, and read your public API documentation and your job adverts. A test that withholds all of that is not more realistic; it is a shorter version of the attacker’s first week.

When each one fits

Black box

Choose it when the question is about the outside: what someone with no account can find and reach from the internet. Forgotten subdomains, exposed admin panels, services that were never meant to be public. Keep it short and focused; a long black-box engagement mostly buys reconnaissance.

Grey box

The default for a multi-tenant SaaS product, because the most damaging application flaws are about who may do what, and you cannot test that without accounts. Broken object level authorization, the first risk on OWASP’s API list, is one user reaching another user’s objects by changing an identifier;6 finding it takes at least two users, ideally in two tenants.

Add the API description (an OpenAPI file, for instance) and a staging environment with realistic, fictional data. The card industry’s guidance recommends handing over interface documentation and data flow diagrams for the same reason: testers who know how things should work can tell when they don’t.7

White box

Choose it when depth matters more than realism: a new authentication flow, tenant isolation, a payment or refund path, cryptography, or a review before a major release. With the source code a tester can follow a suspicion straight to the line that causes it, then confirm it against the running system instead of probing from outside. It sits naturally beside the security testing in development and acceptance that ISO/IEC 27001:2022 covers in control 8.29.8

A different question: who knows the test is on?

Box colour is about what the tester knows. A second choice is about what your own team knows. NIST calls it overt and covert testing: overt testing happens with the knowledge and consent of your IT staff, covert testing without it, with management’s permission. Overt testing is cheaper, carries less risk and is more common; covert testing shows how your people and your monitoring respond.9

The two choices combine freely. A grey-box test can run covertly, to see whether anyone notices a tester working through a valid account. A black-box test can be fully announced. Decide each one on purpose, and if you are not sure, start with an announced grey-box test.

What the box means for an AI feature

The same scale applies to a chatbot, a RAG application or an agent, with different contents. Black box is the chat window and nothing else. Grey box adds the system prompt, the tool and function definitions, the retrieval sources and test accounts in more than one role. White box adds the orchestration code, the retrieval configuration and the permissions each tool runs with.

Teams often hesitate to share the system prompt, as if it were a secret. OWASP’s advice is the opposite: the system prompt should not be treated as a secret nor used as a security control, and credentials do not belong in it.10 Treating it as public costs you nothing against an attacker who extracts it, and handing it over lets the testers spend their days on what the model can be made to do, which is where prompt injection lives. The 2026 edition of the OWASP list has a related entry, hidden context exposure.11

How to choose

Start from the question you need answered, then choose the least knowledge that can still answer it in the days you are buying:

  • “What can a stranger on the internet reach?” Black box, external, short.
  • “Can one customer see or change another customer’s data?” Grey box, with accounts in at least two roles and two tenants.
  • “Is this new login, tenancy or payment code sound?” White box, with the developers reachable during the test.
  • “Would we notice an attacker?” Any box, run covertly, with management’s permission and a named contact who can stop it.
  • “Can our AI feature be talked into misusing its tools?” Grey box: the system prompt, the tool definitions and two test users.

Whatever you choose, write it into the scope, so that anyone who reads the report later knows what the testers started with. Our guide to preparing for a penetration test lists what to hand over for each.

Both layers

How we test for this

We default to grey box on both layers: test accounts in two roles and two tenants, the API description, and for an AI feature the system prompt and the tool definitions. When the question calls for it we test black box or with the source code, and the scope says which, so the report states what we started with.

See penetration testing for web, API and cloud, and AI red teaming for chatbots, RAG and agents.

AI Pentest, Chatbot & RAG
EUR 4,000 to 10,000, 3 to 7 testing days
Stack Pentest, Web & API
EUR 5,000 to 15,000, 4 to 10 testing days

Questions people ask

Which is better: black box or white box penetration testing?

Neither is better in general; they answer different questions. Black box shows what an outsider with no access can reach. White box, with source code and architecture, finds deeper flaws in the same number of days. For most SaaS products, grey box, with test accounts and API documentation, gives the best coverage per testing day.

Is black box penetration testing more realistic?

Only in a narrow sense. A real attacker can spend weeks on reconnaissance, buy leaked credentials and read your public documentation; a time-boxed black-box test cannot. Giving testers accounts and documentation does not make a test less real. It lets them spend the paid days on what an attacker would eventually reach.

What do we need to provide for a grey box test?

Test accounts for every role in scope, ideally two per role in two separate tenants, so cross-tenant access can be tested. Add the API description, a staging environment with fictional data and a short walkthrough of the main flows. For an AI feature, add the system prompt and the tool definitions.

Do penetration testers need our source code?

Not for most tests. A grey-box test without source code covers authorization, business logic and the paths between components well. Source code pays off for authentication, tenancy, payment and cryptography code, or before a major release, because testers can trace a suspicion to its cause instead of probing from outside.

Does the box type change the price of a pentest?

Indirectly. The price follows the number of testing days, and the box decides what those days buy. Black box spends more of them on discovery; white box adds time to read code. Grey box usually spends the largest share on testing itself, which is why it is the common default for SaaS.

Where we test this

  • Stack Pentest / Stack layer

    Penetration testing

    Human-led testing of web applications, APIs and cloud environments.

  • AI Pentest / Model layer

    AI red teaming

    Adversarial testing of chatbots, RAG applications and agents, mapped to OWASP and MITRE ATLAS.

Sources

Every factual sentence above carries a numbered note; these are the documents behind them.

  1. 14

    Information Supplement: Penetration Testing Guidance (March 2015)

    PCI Security Standards Council / checked 2026-10-10

  2. 2

    Penetration testing

    National Cyber Security Centre (UK) / checked 2026-10-10

  3. 3

    Information Supplement: Penetration Testing Guidance (March 2015)

    PCI Security Standards Council, Penetration Test Guidance Special Interest Group / checked 2026-10-10

  4. 5

    Penetration testing

    National Cyber Security Centre (UK) / checked 2026-10-10

  5. 6

    API1:2023 Broken Object Level Authorization

    OWASP API Security Project / checked 2026-10-10

  6. 7

    Information Supplement: Penetration Testing Guidance (March 2015)

    PCI Security Standards Council / checked 2026-10-10

  7. 8

    ISO/IEC 27001:2022 Annex A 8.29, security testing in development and acceptance

    UpGuard (control reference); consistent with isms.online, TCSA and other reproductions / checked 2026-10-09

  8. 9

    SP 800-115, Technical Guide to Information Security Testing and Assessment

    National Institute of Standards and Technology (NIST) / checked 2026-10-10

  9. 10

    LLM07:2025 System Prompt Leakage

    OWASP GenAI Security Project / checked 2026-10-10

  10. 11

    OWASP Top 10 for LLM Applications 2026

    OWASP GenAI Security Project / 2026-08-03 / checked 2026-10-09