Post-Exploitation Boundaries
Suppose a finding has been validated and the RoE allowed a proof of access: the tester has a session on a server as its service account. Technically, a great deal is now possible: read the database, collect password hashes, look through mailboxes, install a tool to come back tomorrow, use the server to reach a network that was never in scope. Professionally, almost none of that is allowed, and the parts that are allowed are done in the smallest way that proves the point. Post-exploitation in a penetration test is about demonstrating what an attacker could do while doing as little of it as possible. This lesson draws the boundaries, turns them into a decision procedure with "minimum evidence" alternatives, and shows how defenders and reviewers notice when a test crossed them.
What is usually in and out
| Usually allowed (if the RoE covers post-exploitation) | Usually forbidden without explicit written agreement |
|---|---|
Record identity and context: id, whoami /all, host name, OS version, network interfaces |
Collecting password hashes or credential material from memory or the SAM//etc/shadow |
| List (not read) directories to show reach: a listing of a database directory or a share | Reading business data, personal data, e-mail, source code beyond what proves the point |
Read a marker file the client placed in advance (C:\pentest\flag.txt) |
Creating accounts, changing passwords, changing configuration |
| Show reachability of the next system (a TCP connect to an in-scope host) | Moving to hosts outside scope, or through the host into networks outside scope |
| Screenshots of the above, with times | Persistence: scheduled tasks, services, keys or agents that survive the session |
| Anything destructive: deleting, encrypting, stopping services, filling disks | |
| Disabling or tampering with security tools and logs |
Two rules sit above the table:
- The goal of the engagement decides the depth. A test that asks "can an Internet attacker reach customer data?" ends at a proof that the data is reachable (a directory listing, a row count, a marker). It does not end with a copy of the data.
- New access is not new scope. Credentials, network routes or trust relationships found after exploitation open systems the RoE may not cover. Using them is a new action that needs the same authorization as the first.
A decision procedure with minimum-evidence alternatives
The function below encodes the RoE's post-exploitation section for one engagement. For each proposed action it returns allowed, forbidden or ask, and, more usefully, the least intrusive action that would provide the same evidence. The actions are what a tester might consider on www after a validated command-execution finding.
ROE = {"post_exploitation": True, "credential_access": False, "lateral_movement": "in-scope hosts, one proof",
"data": "listing and counts only", "in_scope_hosts": {"www", "db01", "files01", "jenkins"}}
ALTERNATIVES = {
"dump_password_hashes": "record that the account can read the credential store (permissions), not its contents",
"copy_customer_table": "SELECT count(*) and the column names; one masked row if the RoE asks for a sample",
"add_ssh_key_for_tomorrow": "agree another window with the client; reconnect through the same finding",
"read_admin_mailbox": "list the mailbox folder names with sizes, or show the permission that allows reading",
"disable_edr_to_continue": "stop and report: the EDR did its job, which is a finding for the blue team",
"scan_partner_network": "note the route and the interface address; ask the client and the partner",
}
def decide(action, target=None):
if action in {"whoami", "hostname", "list_interfaces", "read_marker_file"}:
return "allowed", "record with timestamp and screenshot"
if action == "list_directory":
return "allowed", "names, sizes and times only; don't open files"
if action == "connect_next_host":
if target in ROE["in_scope_hosts"]:
return "allowed", "single TCP connect as proof of reachability; log it"
return "forbidden", "host out of scope: record the route, ask the client"
if action in ALTERNATIVES:
verdict = "ask" if action == "dump_password_hashes" and ROE["credential_access"] else "forbidden"
return verdict, "instead: " + ALTERNATIVES[action]
return "ask", "not covered by the RoE: stop and ask the client lead"
plan = [("whoami", None), ("read_marker_file", None), ("list_directory", "/var/lib/postgresql"),
("copy_customer_table", None), ("dump_password_hashes", None), ("connect_next_host", "db01"),
("connect_next_host", "partner-gw"), ("scan_partner_network", None), ("add_ssh_key_for_tomorrow", None),
("disable_edr_to_continue", None), ("install_monitoring_hook", None)]
for action, target in plan:
verdict, note = decide(action, target)
label = f"{action}({target})" if target else action
print(f"{verdict:<9} {label:<38} {note}")allowed whoami record with timestamp and screenshot
allowed read_marker_file record with timestamp and screenshot
allowed list_directory(/var/lib/postgresql) names, sizes and times only; don't open files
forbidden copy_customer_table instead: SELECT count(*) and the column names; one masked row if the RoE asks for a sample
forbidden dump_password_hashes instead: record that the account can read the credential store (permissions), not its contents
allowed connect_next_host(db01) single TCP connect as proof of reachability; log it
forbidden connect_next_host(partner-gw) host out of scope: record the route, ask the client
forbidden scan_partner_network instead: note the route and the interface address; ask the client and the partner
forbidden add_ssh_key_for_tomorrow instead: agree another window with the client; reconnect through the same finding
forbidden disable_edr_to_continue instead: stop and report: the EDR did its job, which is a finding for the blue team
ask install_monitoring_hook not covered by the RoE: stop and ask the client lead
Every forbidden action comes with an alternative that proves the same thing without the harm. The number of customer records and the column names show the impact of database access as clearly as a copy of the table would, and they create no data-protection incident. The anything-else rule at the end (install_monitoring_hook) is the most important line: an action the RoE doesn't mention is a question for the client, not a judgement call made alone in a shell.
Data minimisation
Personal data that ends up in a tester's evidence is now the tester's responsibility, and under data-protection law the client's too. So:
- prove access with metadata (names, counts, sizes, timestamps, permissions), not content;
- when content is unavoidable (a sample to show the data type), take one record and mask it immediately (
a***@lab.test,**** **** **** 4242); - never take credentials, keys or tokens off the client's systems, and never reuse them outside the agreed scope;
- keep the evidence in the engagement's encrypted store, and delete it on the agreed date (Evidence Collection and Cleanup).
How boundary crossings are noticed
- By the blue team (announced or not): credential-store access (LSASS memory reads,
reg save HKLM\SAM, reads of/etc/shadow), new accounts, new services or scheduled tasks, security-tool tampering, connections to hosts or networks outside the declared scope. These are high-severity alerts whoever does them. - By the client lead at the daily status: actions in the activity log that the RoE doesn't cover.
- By reviewers of the report: evidence containing personal data or credentials, or findings claiming impact beyond what the evidence shows.
How the boundaries are kept
Write the post-exploitation section of the RoE explicitly (allowed, forbidden, ask), agree marker files with the client before the test, log every post-exploitation command with its time, have a second tester review the activity log daily, and default to ask for anything new. In announced tests, agree with the blue team that some actions (credential-store access, for example) are simulated by the client instead of performed by the tester.
Pitfalls
- "While I'm here." Looking around a compromised host out of curiosity creates evidence of over-collection and risk without adding to the finding.
- Treating credentials as trophies. A hash collection in the report appendix is a liability for everyone; a statement of what the account could read is the finding.
- Pivoting through dual-homed hosts. A server with a second interface into a partner or OT network is a finding to report, not a door to walk through.
- Persistence to save time. It creates exactly the artefact a real attacker would leave and that the client's incident responders will later have to explain.
Practice
- Change
ROE["credential_access"]toTrue. What doesdecide("dump_password_hashes")return now, and what should still happen before the action? - A tester on
db01finds that the database server also has an interface on172.20.5.0/24, which is not in scope. List the evidence to record and the message to send.
Answers
ask, with the same minimum-evidence alternative. Even when the RoE allows credential access in principle, the instance should be confirmed with the client lead, the method agreed (preferably the least invasive one) and the handling of the material (encrypted, deleted at the end, never cracked outside agreed limits) written down.- Record the interface name and address, the routing table entry, the time and how it was found (
ip -brief address,ip route), without sending anything into172.20.5.0/24. Message to the client lead: "db01 (10.10.0.40) is dual-homed with an interface in 172.20.5.0/24, which is outside the agreed scope. We have not sent traffic to that network. Please confirm what it is and whether you want it assessed (which would need a scope amendment and possibly the network owner's consent)."
Test yourself
You have a validated session on a server with access to the customer database. What proves the impact with the least harm?
- Copying the customer table
- The row count and column names, with a timestamp
- Reading every customer's records
- Deleting a test row
After exploitation you find credentials that work on a server outside the scope. What do you do?
- Use them, the access was obtained legitimately
- Record the finding and ask the client: new access is not new scope
- Test them once quickly
- Delete them
Why is persistence (a scheduled task or a new SSH key) normally forbidden in a penetration test?
- It is too slow
- It creates a real backdoor that could be used by others, must be cleaned up and looks exactly like an attacker's artefact
- Tools don't support it
- It is required
The RoE doesn't mention an action you want to take. What is the right default?
- Do it if it seems harmless
- Ask the client lead before doing it
- Do it at night
- Do it and mention it in the report