Penetration testing: an authorised attack with rules
A penetration test is an attack carried out on purpose, with the owner's written permission, to show what a real attacker could achieve. It goes further than a scan: the tester uses the weaknesses found to break in and see how far the break-in reaches. No background is assumed. A security professional needs to know how such a test is authorised, how it runs, and how to read the many names given to its variations.
By the end of this unit you will be able to:
- Tell apart a vulnerability assessment and a penetration test by what each proves
- List what rules of engagement must settle before testing starts
- Put in order the four phases of a penetration test and the steps of the attack phase
- Tell apart black, grey and white box tests, blind and double-blind tests, and internal and external tests
- Explain what the red, blue, white and purple teams each do
Two testers arrested at a courthouse at night
In 2019 the court system of the US state of Iowa hired a security firm to test the security of its courts, including whether people could get into its buildings. In the early hours of 11 September 2019 the county sheriff's office arrested two of the firm's staff at the Dallas County Courthouse. They were jailed and charged with burglary.
The courthouse belongs to the county, which also has offices in it, and the sheriff is responsible for its security. Nobody had told the county about any test. The contract, drafted by the security firm and not checked by the court system's lawyers, excluded areas of the court system's own building but listed no exclusions in county courthouses.
The charges were later reduced to trespass, and on 30 January 2020 the county attorney dropped them. Who had the authority to allow the test in that building was disputed, and no court ever decided it.
The court system wanted the test. What was missing that would have stopped the testers being arrested at that building?
A penetration test proves what a weakness would allow
A lists known weaknesses and stops there. A penetration test goes on to use them. The tester behaves as a real attacker would, with the same tools and methods, against the real systems. The aim is to show which weaknesses can actually be used, alone or chained together, and how much access an attacker would end up with.
A survey and a trial break-in
A house surveyor notes that a back window lock is weak. A locksmith hired by the owner opens that window, walks to the study and photographs the safe. The surveyor's report says what might happen. The locksmith's shows that it does.
| Point | Vulnerability assessment | Penetration test |
|---|---|---|
| Question answered | Which known weaknesses are present? | What could an attacker reach by using them? |
| Uses the weaknesses | No | Yes, within agreed limits |
| Done mainly by | Scanning software | Skilled people, helped by tools |
| Breadth and depth | Wide and shallow: every system in scope | Narrow and deep: the routes that lead somewhere |
| How often | Often: weekly or monthly | Seldom: yearly, or after a major change |
| Risk to the systems | Low | Higher: systems can be slowed, changed or stopped |
Because a launches real attacks on real systems, it can damage them. A careful tester reduces that but can never remove it. A test can also include people and buildings as well as computers. Testers may try , such as phoning the help desk and asking for a password reset, or physical entry, such as following staff through a locked door.
Four phases: planning, discovery, attack, reporting
The United States standards body NIST describes a penetration test in four phases in its testing guide, Special Publication (SP) 800-115. Other methods divide the work differently, but the content is the same.
- Planning. The rules are agreed, management approval is documented and the goals are set. No testing happens in this phase.
- Discovery. The tester gathers information: names and addresses of systems, staff names from the organisation's website, and the services each machine offers. Information gathered this way is called reconnaissance. The tester then compares what was found with databases of known weaknesses.
- Attack. The tester tries to use each likely weakness. A success confirms that the weakness is real. Each success usually teaches the tester more about the network, which sends the work back to discovery for another round.
- Reporting. This runs alongside the other three phases. Logs are kept and progress reports given throughout. The final report describes the weaknesses found, rates their risk and says how to fix them.
A penetration test runs in four phases
Read this figure as text
NIST SP 800-115 describes a penetration test in four phases: planning, discovery, attack and reporting. Reporting runs alongside the other three, so it is drawn as the frame around them.
- Planning: the rules are agreed, management approval is documented and the goals are set. No testing happens in this phase. Discovery follows.
- Discovery: the tester gathers information, called reconnaissance, such as system names and addresses, staff names and the services each machine offers, then compares what was found with databases of known weaknesses. The likely weaknesses go to the attack phase.
- Attack: the tester tries to use each likely weakness. The tester gains access, tries privilege escalation, browses the system with the wider rights, and may install extra tools to reach further systems.
- Each success usually teaches the tester more about the network, which sends the work back to discovery for another round.
- At the end, clean-up removes anything the tester installed or created, as the rules of engagement require.
- Reporting runs throughout: logs are kept and progress reports given. The final report describes the weaknesses found, rates their risk and says how to fix them.
The attack phase has its own steps. The tester first gains access to a system through a weakness. Next the tester tries privilege escalation: turning the limited access of an ordinary account into the wider rights of an administrator. With those rights the tester browses the system for information, and may install extra tools to reach further systems from there. At the end, anything the tester installed or created is removed, as the require.
How much the tester knows, and who knows about the test
Tests are described along three separate lines. The first is how much the tester is told in advance.
| Name | Also called | What the tester starts with | What it imitates |
|---|---|---|---|
| Black box | Zero knowledge | Nothing beyond the target's name and public information | An outside attacker |
| Grey box | Partial knowledge | Some information, such as a user account or a list of addresses | An attacker with some inside knowledge, or a quicker outside test |
| White box | Full knowledge | Network diagrams, system details, sometimes source code and administrator accounts | An insider; finds the most in the time available |
The second line is what the defenders are told. In a blind test the tester knows nothing in advance, but the organisation's staff know a test is coming. In a double-blind test neither side is told: the security staff are not warned, so the test also shows whether they notice and respond. In a targeted test the testers and the organisation's own staff work together, and both sides know the targets and the plan. It shows nothing about whether attacks are noticed.
NIST makes the same distinction with other words. An overt test happens with the knowledge of the IT staff. A covert test happens without their knowledge but with the full knowledge and permission of senior management. costs more and carries more risk. In return it shows the security of an ordinary day, because nobody is on special watch.
The third line is where the tester starts. An external test starts outside the organisation's network, as an attacker on the internet would. An internal test starts inside, as an employee, or an attacker who has already got in. When both are done, the external test usually comes first, so that the tester has not yet learned inside details an outsider would not have.
Common misconception
“A double-blind test is one where the tester knows nothing about the target.”
That describes a blind test, or a black box test. The second blind is the defenders: in a double-blind test the security staff are not told the test is happening.
Red, blue, white and purple teams
Larger exercises give each side a colour. United States government guidance defines the first three.
| Team | Role | In the house example |
|---|---|---|
| Red | Authorised to act as the attacker: imitates a real adversary's methods | The locksmith trying to get in |
| Blue | The defenders who keep the organisation secure and try to detect and stop the red team | The household and its alarm company |
| White | Referees and observers: know the plan, enforce the rules, keep the test within its limits and judge the result | The owner's friend who holds the plan and calls a halt if needed |
| Purple | Red and blue working together openly, sharing each attack and each detection so that defences improve | The locksmith and the alarm company walking the house together |
A is usually not a separate group of people. It is a way of working in which the red and blue teams sit together. The difference between a penetration test and a full red team exercise, and when purple teaming is the better choice, is a question of what the organisation wants to learn.
A question, worked through
A logistics firm hires a testing company for an external penetration test of twelve internet-facing servers named in the rules of engagement. On the second day the tester finds a thirteenth server that answers from an address close to the others. It runs an old database and looks easy to break into. The firm's named contact is available by phone.
What should the tester do FIRST about the thirteenth server?
Decide on your answer, then open the reasoning
- The question is about authority. The server is not in the rules of engagement, so the tester has no permission to touch it.
- Rule out a: attacking a system outside the agreed targets is unauthorised access, whatever the intention. The server may not even belong to the firm.
- Rule out b: a scan also needs authorisation, and it is still activity against a system nobody has approved.
- Between c and d: both leave the server alone. An unknown server with an old database is a risk the owner should hear about now, and the owner may want to add it to scope in writing. The rules of engagement name a contact for exactly this. Waiting for the final report leaves the owner unaware for days.
Answer: C. Leave it alone and raise it with the firm's named contact now
Choosing between good answers
- A question asks what must exist before any penetration testing begins
- choose written authorisation from the owner, with agreed rules of engagement. Tools, schedules and team choice come after.
- A question asks whether to test something found outside the agreed scope
- do not test it. Stop and refer it to the owner, who may extend the scope in writing.
- A question asks which test also shows whether the defenders notice an attack
- choose a double-blind or covert test, where the security staff are not warned.
- A question contrasts a test that confirms weaknesses with one that lists them
- confirming by exploiting is a penetration test. Listing is a vulnerability assessment.
Try it
Start at the authority box: see what the owner signed, what is excluded, and what happens to a finding outside that line.
Loading the preview.
Check your understanding
5 questions on this unit, easiest first. Confirm an answer to see the reasoning for it, then the right answer, the other options and the rule to reuse. Your answers are kept in this browser and feed readiness and review.
These questions are drafts that no named reviewer has approved yet.
Question 1 of 5
What to remember
- A penetration test uses weaknesses to show what an attacker could reach. A vulnerability assessment only lists them.
- Testing without written permission from someone entitled to give it is a crime under laws such as the Computer Fraud and Abuse Act and the Computer Misuse Act.
- Rules of engagement fix the scope, targets, exclusions, times, contacts, stop conditions, data handling and reports before testing starts.
- NIST's four phases are planning, discovery, attack and reporting. The attack phase gains access, escalates privileges, browses and installs tools, and loops back to discovery.
- Black, grey and white box describe what the tester knows. Blind and double-blind describe what the defenders know. Red attacks, blue defends, white referees and purple is both working together.
Say it from memory
What is a penetration test, what must be in place before it starts, and what do the red, blue, white and purple teams do?
An authorised attack that uses weaknesses to show what an attacker could reach. It needs written permission from the owner and signed rules of engagement. It runs through planning, discovery, attack and reporting. Red acts as the attacker, blue defends, white referees and keeps the test within its limits, and purple is red and blue working together openly.
How does a penetration test differ from a vulnerability assessment?
A vulnerability assessment lists which known weaknesses are present, mainly by scanning software, wide and shallow, often and at low risk. A penetration test uses the weaknesses, within agreed limits, to show what an attacker could reach. It is done mainly by skilled people, narrow and deep, seldom, and at higher risk to the systems.
Who must authorise a penetration test, and what do the rules of engagement set out?
Written permission must come from someone with the authority to give it: the owner of the systems and buildings, not merely a user. The signed rules of engagement set out purpose and scope, targets and an exclude list, allowed and forbidden activities, schedule, contacts, when to stop, data handling and reporting.
What do black, grey and white box testing describe, and how does a blind test differ from a double-blind test?
How much the tester is told: nothing beyond public information, some information such as an account, or full knowledge such as diagrams and source code. In a blind test the tester knows nothing in advance but staff know a test is coming. In a double-blind test the security staff are not warned either.
Sources
- Legal Update: Senate Committee on Government Oversight Meeting, October 4, 2019, Iowa Legislative Services Agency, Legal Services DivisionThe 2019 contract between the Iowa judicial branch and a security firm, the apprehension of two of its staff at the Dallas County Courthouse on 11 September 2019, the county's ownership and the sheriff's responsibility for courthouse security, the lack of notice to the county, and the contract drafted by the firm without legal review and without exclusions for county courthouses.
- Charges Dismissed Against Coalfire Employees, Coalfire, joint statement with the Dallas County Attorney, via PR NewswireThe arrest of the two employees on 11 September 2019 while testing under a contract with Iowa State Court Administration, and the Dallas County Attorney's decision on 30 January 2020 to dismiss the trespass charges.
- Iowa Prosecutors Drop Charges Against Men Hired to Test Their Security, Krebs on SecurityThe two testers were jailed and charged with felony third-degree burglary and possession of burglary tools, the charges were reduced to trespass and dropped on 30 January 2020, and the testing firm's chief executive described ownership of the building as unclear.
- NIST SP 800-115: Technical Guide to Information Security Testing and Assessment, NISTThe four phases of a penetration test and what happens in each, the attack phase steps and loop back to discovery, the risk of damage that cannot be eliminated, social engineering and physical testing, overt and covert testing, internal and external testing with external first, white, black and grey box for applications, and the contents of the rules of engagement template including the signed form for law enforcement and the exclude list.
- OSSTMM 3: The Open Source Security Testing Methodology Manual, ISECOM (Institute for Security and Open Methodologies)Blind testing, in which the analyst has no prior knowledge and the target is told in advance, and double-blind testing, in which the target is not told.
- 18 U.S. Code 1030: Fraud and related activity in connection with computers, Legal Information Institute, Cornell Law School (text of the United States Code)Accessing a computer without authorization or exceeding authorized access as an offence under the Computer Fraud and Abuse Act.
- Computer Misuse Act 1990, UK ParliamentUnauthorised access to computer material as an offence in the United Kingdom.
- Red Team (NIST CSRC Glossary), NIST Computer Security Resource CenterA red team as a group authorised and organised to emulate a potential adversary's attack or exploitation capabilities.
- Blue Team (NIST CSRC Glossary), NIST Computer Security Resource CenterA blue team as the group that defends an organisation's systems against the red team.
- White Team (NIST CSRC Glossary), NIST Computer Security Resource CenterA white team as observers with prior knowledge of red team activity who keep testing within its limits, and as referees who enforce the rules of an exercise.
- TIBER-EU Purple Teaming Guidance, European Central BankPurple teaming as a collaborative activity involving both the red team testers and the blue team and their offensive and defensive actions.