Gray Box Testing: How It Works and How It Compares to Black and White Box
Gray box testing is a security test where the tester starts with partial knowledge of the target, such as user logins, API documentation or architecture diagrams, but not full source code. It sits between black box (no knowledge) and white box (full access), and for most business applications it finds more real flaws per testing day than either.
Gray Box vs Grey Box and What Testers Get
“Gray box” is the US spelling and “grey box” the UK spelling. They describe the same method. UK providers and NCSC-related material often use “grey”.
In a typical gray box engagement, testers receive:
- Test accounts at each user role, such as customer, staff and admin
- API documentation or a collection of sample requests
- A high-level architecture diagram and list of in-scope hosts
- Notes on known weak spots or recent changes
They do not usually get source code or administrator access to servers.
How Gray Box Testing Works
Most gray box tests follow four stages.
Step 1: Scoping and Knowledge Handover
The client and tester agree targets, testing windows, rules of engagement and what information is shared. Clear scope prevents surprises in production.
Step 2: Mapping the Application and Attack Surface
Using the documentation and accounts, testers map every page, API endpoint and function. This takes hours instead of the days a black box tester might spend discovering the same things.
Step 3: Authenticated Testing and Privilege Escalation
Testers log in at each role and try to do things the role should not allow: viewing another customer’s records, changing prices, or reaching admin functions. Broken access control sits at the top of the OWASP Top 10 (2021), and authenticated testing is the most direct way to find it.
Step 4: Reporting and Retesting
The report ranks findings by risk, shows how to reproduce them and recommends fixes. A retest confirms the fixes work.
Gray Box Testing Techniques
These techniques come from software quality testing and carry over into security work.
Matrix Testing
Testers list every variable and business risk, then check how inputs affect them across roles.
Regression Testing
After a fix or release, testers repeat earlier tests to confirm nothing broke and old flaws did not return.
Orthogonal Array Testing
A statistical method that covers many input combinations with fewer test cases, useful for complex forms and APIs.
Pattern Testing
Testers study past defects in similar systems and look for the same patterns in the target.
Black Box vs White Box vs Gray Box Testing
The three approaches differ mainly in how much the tester knows, which changes time, cost and coverage.
| Factor | Black box | Gray box | White box |
|---|---|---|---|
| Tester knowledge | None | Partial (logins, docs) | Full (code, configs) |
| Simulates | External attacker | Insider or attacker with a stolen login | Full design review |
| Time spent on discovery | High | Moderate | Low |
| Depth of coverage | Surface-level | Deep in authenticated areas | Deepest, including code |
| Relative effort | Varies | Usually best value for apps | Highest |
Black Box Testing: The Outsider View
Black box shows what an attacker with no inside knowledge can find. It is realistic but spends much of the budget on discovery and may never reach logged-in functions.
White Box Testing: Full Access
White box includes source code review and configuration access. It is thorough and well suited to critical systems, but needs more tester time and client preparation.
Gray Box Penetration Testing in Cyber Security
In security, gray box most often appears in two forms.
Web App and API Gray Box Tests
Testers get accounts and API specs, then focus on access control, business logic, input handling and session management.
Internal Network Gray Box Tests
Testers get a standard staff account and a network connection, simulating a phished employee or rogue insider. They test how far that foothold can reach.
Pros and Cons of Gray Box Testing
Gray box is efficient and realistic, but it has trade-offs.
Pros
- More of the budget goes on finding flaws rather than discovery
- Covers authenticated areas, where the most sensitive data usually sits
- Reflects the common real-world case of stolen credentials
Cons
- May miss issues an outsider would find through pure reconnaissance
- Results depend on the quality of information shared
- Does not replace code review for deeply hidden flaws
When to Use Gray Box, Black Box or White Box
Use this decision rule. If your main worry is “what can someone on the internet do with nothing”, choose black box. If it is “what can a customer, employee or attacker with one stolen login do”, choose gray box. If you are releasing a high-risk system and can share code, choose white box. For most business web apps and internal networks, the stolen-login question matters most, so gray box is the sensible default.
Gray Box Testing Example: A Customer Portal
Picture an illustrative insurance broker launching a portal where customers download policy documents. The broker gives testers two customer accounts, one staff account and the API documentation.
On the first day, testers map the API and notice that document downloads use a numeric ID. Logged in as customer A, they change the ID and download customer B’s policy. That is an insecure direct object reference, a form of broken access control. A black box tester without accounts might never have reached that function. A white box tester would have found it too, but after reading far more code.
Testers then check the staff account and find that a support role can export all customers to a spreadsheet, more access than the job needs. The report gives two high-risk findings with clear fixes: check ownership on every document request, and restrict exports to managers.
The practical takeaway: when buying a gray box test, always provide at least two accounts at the same role and one at each higher role. Without two same-level accounts, testers cannot check whether one customer can reach another’s data, which is the most damaging flaw in most portals.
Standards and Buying a Test in the US and UK
NIST SP 800-115 is the long-standing US technical guide to security testing and assessment. PCI DSS requires regular penetration testing for organizations in scope. In the UK, many buyers look for CREST-accredited providers, and NCSC CHECK covers testing for government and critical systems. Ask any provider which approach they recommend for your target and why.
FAQs
For most business applications it gives the best balance of depth and effort, but the right choice depends on the risk you want to test.
Small web apps often take several days of testing. Larger apps or networks take longer, based on scope.
They overlap. Authenticated testing is a core part of gray box, which can also include documentation and architecture knowledge.
White box testers get source code and full configuration access. Gray box testers get partial information, such as logins and documentation.
Yes. Giving testers a normal user account reflects what a malicious insider or an attacker with stolen credentials could do.
At least yearly for important applications and after major changes, with retests after fixes.
Choosing Your Next Gray Box Test
Gray box testing works best when you share enough for testers to go deep, especially accounts at every role. If you want help scoping a test that matches your real risk, Cyber Security Solutions Ltd offers a free, no-obligation assessment through our contact page.
