The difference between black box and white box pentesting lies in how much information the testing team receives about the system under assessment. In a black box test, the team is given only the application address or the name of the mobile app and has to map the attack surface on its own, with no credentials, no source code and no explanation of what the system does. In a white box test, it receives the addresses, valid accounts, a description of how the system works and, frequently, access to the source code. Gray box sits between the two extremes.

For application pentests (web, mobile and APIs), we recommend white box. The goal of a pentest is to find as many vulnerabilities as possible so that they can be fixed, and white box is the modality that comes closest to that. Black box leaves behind vulnerabilities the team cannot reach for lack of access, and those are precisely the ones that may later give rise to an incident.

The most common argument in favor of black box, that it would simulate a real attack, does not hold up. We explain why below, and what your company needs to provide so that a white box test delivers the coverage it promises.

What black box pentesting is

In a black box pentest, the company tells the team only where the application is: the address of the web system or API, or the name of the mobile app. It provides no credentials, gives no access to the source code and does not even have to explain what the system does.

From there, the team maps the attack surface visible from outside. If it manages to exploit a flaw that grants access to part of the system, it moves on from there with new exploitation attempts and checks. If it does not, the test stays limited to whatever responds without authentication, which in most corporate applications is a small fraction of what the system does: the login screen, password recovery, a few public pages and the endpoints that accept requests without a token.

What white box pentesting is

In a white box pentest, the team receives the addresses of the applications and the names of the apps, and also valid accounts in the system, with username and password. It generally also receives an explanation of how the system works: which screens exist, what they are for, what the system's purpose is and who its audience is. Frequently, it receives access to the source code.

With that material, the team tests the application the way it is actually used, as authenticated users and with the access profiles that exist in the system, and reads the implementation to know where to look. It is the modality we recommend in the pentests of web applications, APIs and mobile apps that we carry out.

What about gray box pentesting?

Gray box is any intermediate combination between the two extremes. The most common format is for the team to receive valid accounts and some documentation, but no access to the source code.

What the team receivesBlack boxWhite box
Application address or app nameYesYes
Valid accounts (username and password)NoYes, for each profile
Description of how the system worksNoYes
Access to the source codeNoYes, generally

Does a black box pentest simulate a real attack?

No. This is the most repeated argument in favor of black box, and it rests on a premise that does not hold up: that it is possible to simulate the attacker who will target your application.

That attacker has motivations the pentest team cannot predict with any precision. They have a level of knowledge nobody knows. And they have an amount of resources, time and money, that is also not known in advance. Depending on the scenario, an attacker may invest a day or two years trying to gain access to a specific application.

Contracting a black box test to simulate that agent is an attempt to reproduce someone whose three main variables are unknown. The test may happen to match the profile of whoever would attack, but there is no way of knowing. The result is subjective, and it does not deliver what the company needs from a pentest.

Why white box finds more vulnerabilities

The goal of a pentest (what it is and what it is for) is to find every vulnerability an attacker could exploit, or at least most of them, so that they can be fixed. That is also the goal of any company's security team. The right modality is the one that comes closest to it.

In black box, the result depends heavily on the team's tooling and knowledge, plus a dose of luck. If the test stops at automated scanning, anyone using the same tool arrives at the same result. And automated tools do not reach what is specific to the application and its environment (business rules, custom flows, access profiles), which only a test conducted by people brings to light. Combined with limited access, this means black box does find vulnerabilities, but falls well short of finding all of them.

Source code shortens the path

With access to the code, the team quickly identifies how authentication and authorization were implemented, two of the most common sources of vulnerability in applications. Reading the code points to where the problem probably is, and the team works backwards: it goes to the running application and exercises that point to confirm whether the vulnerability exists and is exploitable. What goes into the report is the finding confirmed in the application, not a suspicion raised in the code.

Authorization is the clearest example. Broken Access Control remains in first place in the OWASP Top 10:2025, the position it already held in the 2021 edition. A frequent pattern is for the application to check whether the user is authenticated, but not whether the record being requested belongs to them: changing an identifier in the request is enough to read or alter someone else's data. In the code, the absence of that check is visible endpoint by endpoint. From the outside and without accounts, this test does not even begin, because demonstrating that user A can access user B's data requires having both. Access control and authentication flaws were also at the center of the attack on the Civil Defense alert system, which we analyzed here on the blog.

In the tests we run, the number of vulnerabilities found is consistently higher when there is access to the source code and to valid credentials provided for that purpose.

One flaw left behind is enough

Picture a company that contracts black box testing several times a year for the same application. The vulnerabilities the team cannot reach, whether because of access or tooling limitations, are still there in every round. They stay dormant until an attacker finds the one flaw that was left behind and it gives rise to an incident. The investment repeats, and so does the blind spot.

The car service

Think of having your car serviced before a long trip. Nobody wants to test whether the mechanic can service the car without the key, or whether they will find on their own the noise you have been hearing from the front right wheel. You hand over the key, mention the noise and the vibration you noticed and ask for the most complete service possible, because you do not want to take risks on the road.

Black box is making the mechanic's job harder. White box is collaborating with them, giving the access and the information you already have so that the diagnosis is complete and the problems get fixed.

What to provide the team in a white box pentest

For the test to have white box coverage, the team needs to receive:

  • the addresses of the applications and APIs in scope, or the names of the apps in the stores;
  • valid accounts for every existing access profile (regular user, administrator and intermediate profiles), preferably two accounts per profile, in order to test one user's access to another user's data;
  • a description of how the system works: screens, the purpose of each one, the system's objective and its audience;
  • read-only access to the source code of the applications in scope.

The accounts do not have to be production accounts. A staging environment, or an environment created specifically for the pentest, works, as long as it reflects the version that is in production or about to be. This also allows more invasive testing without risk to operations.

Does a white box pentest find every vulnerability?

Not necessarily in a single round. White box leads to the largest possible number of vulnerabilities in that period and with the techniques available at that moment. But software changes, new features bring new flaws, and verification techniques that emerge later may reveal problems in code that had already been tested.

This is normal, and it is the reason why pentesting an application under active development needs to repeat at the pace of the software's changes, not just once a year. The choice between a point-in-time pentest and PTaaS depends precisely on that pace. In both formats, white box is what gives the team the conditions to reach the largest number of vulnerabilities in each cycle.

Frequently asked questions

What is the difference between black box and white box pentesting?

The amount of information the testing team receives. In black box, only the application address or the name of the app. In white box, also valid accounts, a description of how the system works and, generally, access to the source code.

What is gray box pentesting?

It is an intermediate modality. The team usually receives valid accounts and partial documentation, but not the source code. It covers the authenticated areas of the system, but without reading the code.

Which pentest modality is recommended for applications?

White box. Since the goal of a pentest is to find and fix as many vulnerabilities as possible, the modality that gives the team accounts, context and source code is the one that produces the most result for the same investment.

Does a white box pentest have to be performed in production?

No. The accounts and the environment can be from staging or from an environment created for the test, as long as they reflect the version of the application that is in production or about to be.

Is it safe to hand over the source code to the pentest company?

Access must be read-only, with no permission for commits, changes or deletions, and restricted to the repositories in scope. At BrownPipe, source code is treated as confidential information: it is not stored permanently, it is not shared with third parties and it is not used for any purpose beyond the contracted test.

If your company is going to contract an application pentest and wants to understand what to prepare for a white box test (accounts per profile, a staging environment and access to the code), we can discuss the scope. See how we run pentests of web applications, APIs and mobile apps or get in touch with our technical team.


Vinícius Serafim is a partner at BrownPipe and technical lead for pentesting. He holds a master's degree in Computer Science from UFRGS, has worked as an information security consultant since 2001 and hosts the Segurança Legal podcast with Guilherme Goulart. This article was produced from a video in which he discusses the topic: watch it on YouTube.