How to prepare for a penetration test
Penetration test preparation for clients: scope and rules of engagement, test accounts per role, a staging copy, what to freeze, triage and the retest.
Asghar Ali · Chief Technology Officer, Kakushin.io LTD
To prepare for a penetration test, decide what the test must prove and write it into a signed scope and rules of engagement; give the testers working accounts for every role on a staging copy that matches production; fix what you already know is broken; freeze the build for the test window; and name the person who will triage the report and book the retest before testing starts. Most of what a test is worth is decided in the weeks before it.
This is for the founder or engineering lead commissioning a test because a customer, insurer or contract asks for one. It covers scope, access, environment, what to freeze and fix, triage and retest, and what changes when the result decides go-live. If you have not had a source-led review yet, what a security review of an AI-built app covers explains why it usually comes first.
What is a penetration test actually for?
The UK NCSC's penetration testing guidance (published August 2017, reviewed January 2022, read on 24 November 2026) defines it as "a method for gaining assurance in the security of an IT system by attempting to breach some or all of that system's security". It then says what most buyers skip: a test checks your own vulnerability management, "not as a primary method for identifying vulnerabilities". In the ideal case, you already know what the testers will find.
So a test spent rediscovering an exposed admin panel or an old framework is an expensive scan. A test on a system whose known problems are fixed, with working accounts and a clear question, spends its days on what only a person finds: chained issues, business logic and access-control mistakes between roles.
How do you scope a penetration test?
Start with the goal, not the asset list. CREST's Defensible Penetration Test specification (June 2023) calls clearly defined goals and objectives "absolutely imperative" and expects providers to repeat them in the scoping document and the report. "Can one customer reach another customer's data?" is a goal. "Test the app" is not.
NCSC says scoping should involve the risk owners, technical staff who know the system and someone from the test team, and produce a written plan: boundaries, types of test, effort in days, what the testers need from you in advance, and any reporting requirements. CREST's Guide to Penetration Testing (2022) adds sign-off by all relevant parties, liabilities, and follow-up including "Any re-testing needed".
Put exclusions in writing. NIST SP 800-115 (September 2008, still the current final version on 24 November 2026) asks for a named list of systems "not authorized to be examined or tested". The PCI SSC Penetration Testing Guidance (version 1.1, September 2017) says to get the hosting provider's approval first where the agreement requires it. Read your cloud provider's policy: AWS, for example, allows testing of listed services such as EC2 and RDS without prior approval and forbids denial-of-service testing (read on 24 November 2026).
What goes in the rules of engagement?
The rules of engagement are the operating manual for the test window. NIST SP 800-115 has a template in Appendix B, and PCI's guidance lists the questions. This checklist works on its own:
| Item | Decide before testing | Owner |
|---|---|---|
| Goal and success criteria | The question the test answers, and when it is finished | Risk owner |
| In scope, out of scope | Hostnames, apps, APIs, environments; named exclusions | Tech lead |
| Approach | Open box (docs and accounts shared) or closed box | Risk owner with tester |
| Time window | Dates, hours, out-of-hours work, blackout periods | Ops lead |
| Prohibited tests | Denial of service, social engineering, anything else off limits | Risk owner |
| Tester source IPs | So logs and alerts can be matched to the test | Ops lead |
| WAF and monitoring | Tester traffic let through, or the controls tested too | Security lead |
| Point of contact | One technical contact, reachable at short notice | Tech lead |
| Critical findings | Who is told at once, by which channel, out of hours too | Security lead |
| Stop conditions | An outage, signs of a real intrusion, exposed data | Risk owner |
| Data handling | Proof of concept only; how sensitive data seen is reported and deleted | Data owner |
| Clean-up | Test accounts and tester tools removed afterwards | Tester and tech lead |
On the WAF, PCI's guidance advises configuring protection so it does not interfere, because the test is about the service behind it. On stop conditions, NIST recommends activity ceases during an incident until resumption is approved. And tell operations: CREST notes the scope must reach staff "that may mistakenly report testing activities as actual attacks".
What access should the testers get?
Accounts for every role, working on day one. PCI's guidance asks for testing "against all roles or types of access", including roles that should not see sensitive data, and for multi-tenant apps, credentials equivalent to a real customer so testers can check access beyond that customer's data. NCSC gives creating test accounts as an example of what you prepare in advance.
- Two accounts per role, in two tenants, so cross-tenant access can be tested. The method is in BOLA and IDOR testing with two accounts.
- Seeded data in each tenant. An empty account tests nothing.
- Admin and support roles, unless excluded in writing.
- API documentation and current mobile builds, so the tester can tell expected behaviour from a finding.
- Your latest vulnerability scan. NCSC suggests sharing it, so the test can judge how complete it is.
Check every account the day before. A tester waiting for a password reset is a morning you paid for.
Should you test production or a staging copy?
Usually staging, if it really matches production. PCI's guidance allows a separate environment "identical to the production environment", but exploitable findings must then be "corrected on production systems and testing repeated". NIST SP 800-115 names the risk: "usually inconsistencies between the test and production environments", which can hide vulnerabilities. It also recommends test data instead of real personal data.
So make staging honest: same build, configuration, identity settings, headers and storage rules, with synthetic data. Write down every known difference, and test a backup of everything in scope before the window opens.
What should you freeze during the test?
Freeze what the report will describe: the build, configuration and infrastructure of the in-scope environment, with the commit hash written into the scope. If the system changes under the testers, findings cannot be reproduced and the retest has nothing stable to compare against. NIST says a fix can be verified only "if a mirror copy of the original test is performed".
A freeze is not a ban on fixing. PCI's guidance asks you to decide whether you will act on findings during the test. My preference: fix a critical issue at once, log the change with its time, and tell the testers so they check it again before they finish.
What should you fix before the testers arrive?
Everything you already know about. NCSC says "assessing whether defined security controls are functioning is not a valuable use of penetration testing resources". Before the window:
- Patch the known. Run your own scan and dependency audit and update runtimes; the PHP2Shell checker shows the kind of version question involved.
- Get secrets out of anything shipped. On the customer apps of a European national electricity utility I introduced a relay-proxy architecture that removed every client API key from the shipped binaries; API keys in mobile and front-end apps explains the pattern.
- Run the two-account test yourself on every route that takes an ID.
- Remove debug modes, test endpoints and open API consoles from the tested environment.
- Check headers, TLS and cookies against a baseline.
A source-led review reads the code a tester cannot reach; what a source code audit covers explains how the two fit together.
Who triages the findings, and how does fix-and-retest work?
Name one person before the test, with the authority to decide. NCSC is clear that "risk assessment and decisions on the application of fixes are your responsibility", and that re-rating a finding "should not be used to downplay issues". The proposed fix is not the only option: removing an unused component may beat patching it.
Agree what each severity means before the report lands:
| Severity | Action | Release |
|---|---|---|
| High or critical | Fix now, retest | Blocks go-live |
| Medium | Fix, with an owner and a date | Agreed case by case |
| Low | Schedule in the backlog | Does not block |
| Informational | Note, or accept | Does not block |
| Anything you will not fix | Accept in writing: owner, reason, review date | Recorded |
Use the severity scale your contract names (NCSC's CHECK scheme uses HIGH, MEDIUM, LOW and INFORMATIONAL) and write the mapping down.
Then run the cycle. Every finding goes into your tracker. When you fix one, search for the same pattern elsewhere: PCI's guidance notes that one cross-site scripting finding may point to a development practice that repeated it. Test each fix on staging and send it through change control, as NIST asks. Book the retest in the original contract; PCI warns that if remediation drags on, a new test may be needed.
What changes when remediation gates production acceptance?
On the customer apps of a European national electricity utility I drove third-party penetration-test remediation that gated production acceptance. When the retest decides go-live:
- The acceptance rule exists before the test. Which severities block release, and who may accept a residual risk, belongs in the contract, not in a meeting after the report.
- The retest is on the critical path. Its date, scope and the tester's availability are planned like any release dependency, with time for fixes before it.
- "Fixed" means retested. A finding is closed when the retest says so, on the build that ships, not when a ticket is marked done.
- Fixes pass the same gate as features. A rushed fix can fail the next test, so it gets review and its own test.
- Accepted risks are signed, with a named owner and a review date, because someone outside the team will read the list.
A worked example (illustrative)
An invented case, not a client: a B2B invoicing app with three roles and a public API, sold to a larger customer whose contract requires a test before go-live.
Four weeks out, the founders write the goal ("can any role in one company reach another company's invoices?"), sign the scope, and exclude the payment and email providers. Two weeks out, they create two companies with three seeded accounts each and fix two known items: an old framework version and a debug route. On day two of testing, the tester phones in a high finding: a viewer can export another company's invoices through a bulk endpoint. It is fixed that evening, logged, and checked again before the window closes. The mediums get owners and dates, one low is accepted in writing, and the retest is what the customer signs off.
What a penetration test cannot tell you
- It describes one window. NCSC: a test "can only validate that your organisation's IT systems are not vulnerable to known issues on the day of the test".
- It covers the agreed scope. Excluded systems and untested roles are unknown, not safe.
- Staging is not production. Any difference you did not record is a gap in the result.
- A clean report is not a certificate. It is evidence for a customer, not proof that nothing is wrong.
Frequently asked questions
How far ahead should we start preparing?
As soon as the test is booked. Scoping, sign-off, third-party approvals and test accounts take longer than expected, and known fixes need time to land before the freeze. Book the retest date at the same time.
Should we turn off the WAF?
Not off, but configured so the tester's traffic reaches the application, unless the goal includes testing the WAF. PCI's guidance recommends avoiding interference, so the test shows how the service holds up if those controls fail. Agree it in the rules of engagement and log the tester's IPs.
Open box or closed box?
For an application test, open box gets more from the same days: accounts, documentation and your scan let the tester go deeper. NCSC notes that closed box better models an unknown attacker but can leave vulnerabilities undiscovered in the time allowed.
Do we need a CHECK or CREST provider?
In the UK, the NCSC's CHECK scheme is for government departments, public sector bodies and critical national infrastructure; others are pointed to the general guidance. Check what your contract or regulator asks for, and whoever you choose, ask for the named testers, the method and a sample report.
If you want this checked
I can review the app before the test so the obvious findings are gone, help write the scope, accounts and rules of engagement, and work through the fix-and-retest cycle with your team until the retest is clean. The scope is on my hire page.