Lab Safety Rules, Test Accounts and Synthetic Data
A student practises password attacks in her lab. To make the exercise "realistic" she loads the target app with a copy of her club's member list, uses her own email password on the test admin account so she won't forget it, and leaves the target running over the weekend on a bridged network card. Nothing in the exercise was illegal. But by Monday real people's data sits in a deliberately vulnerable app, a real password is stored in a lab database she is about to dump for practice, and a vulnerable machine has been on the home network for two days.
Lab safety is the set of habits that keeps practice from turning into an incident. It protects three things: other people's systems (nothing leaves the lab), real data and real credentials (none enter the lab), and your own host (what happens in the lab can be undone). The network side was covered in Hypervisors, VM Networks and Snapshots and Lab Machines and Vulnerable Apps; this lesson turns it into rules you can check.
The rules
| # | Rule | Protects | How to check |
|---|---|---|---|
| 1 | Vulnerable targets only on internal or host-only networks; never bridged, never NAT | others, you | VM network settings; a target can't ping a public address |
| 2 | Containers bound to 127.0.0.1 or on internal: true networks |
others | docker ps shows no 0.0.0.0: ports |
| 3 | Only lab addresses and names as targets: 10.10.0.0/24, *.lab.test |
others | tool commands and scope file use only those |
| 4 | Snapshot before every experiment; revert after | you | snapshot list has a recent "before" |
| 5 | Test accounts only, with lab-only passwords never used anywhere else | you, your employer | passwords come from a generator, kept in a lab file |
| 6 | Synthetic data only: no copies of real users, customers or logs | other people | data comes from a seeded generator |
| 7 | No real credentials, tokens or keys typed into a lab app or saved in notes | you | grep your journal for secrets |
| 8 | Shared folders, clipboard and drag-and-drop off for targets | your host | VM settings |
| 9 | Host OS, hypervisor and Kali kept updated | your host | update dates |
| 10 | Malware samples and unknown files only on a not-attached VM | everyone | the VM has no network card |
They follow directly from the roadmap's lab rules (use isolated networks, never expose vulnerable machines, snapshot, use test accounts and synthetic data, keep the host updated) and from the law: rule 3 is how you stay inside your own authorization (Authorization, Scope and Rules of Engagement).
Test accounts and synthetic data
Realistic data makes exercises better: a password-spraying lab needs a few hundred users, a log-analysis lab needs thousands of events. The answer is to generate them. A generator with a fixed seed gives the same data every time (so a write-up is reproducible), uses reserved names (lab.test, the 10.10.0.0/24 network), and marks every value as lab-only.
The script below creates test accounts for a lab directory. In this example the seed is fixed so the output is stable; for passwords that protect anything, even in a lab, draw them from secrets instead (shown in the last line).
import random, secrets, string
rng = random.Random(2026) # fixed seed: same lab every time
FIRST = ["an", "binh", "chi", "dung", "lan", "minh", "nga", "quang", "thao", "vy"]
DEPTS = ["sales", "it", "hr", "finance"]
def lab_password(r): # "lab-" + 12 random letters and digits
return "lab-" + "".join(r.choice(string.ascii_lowercase + string.digits) for _ in range(12))
users = []
for i in range(6):
first = rng.choice(FIRST)
user = f"{first}.{i:02d}"
users.append({
"user": user,
"email": f"{user}@lab.test",
"dept": rng.choice(DEPTS),
"ip": f"10.10.0.{100 + i}",
"password": lab_password(rng),
})
for u in users:
print(f"{u['user']:9} {u['email']:20} {u['dept']:8} {u['ip']:12} {u['password']}")
print("unique users:", len({u['user'] for u in users}), "| all emails in lab.test:",
all(u['email'].endswith('@lab.test') for u in users))
print("real lab password length:", len(lab_password(secrets.SystemRandom())))binh.00 binh.00@lab.test hr 10.10.0.100 lab-66go90952paf
binh.01 binh.01@lab.test hr 10.10.0.101 lab-g2a5unzqwwy6
binh.02 binh.02@lab.test hr 10.10.0.102 lab-f98ss3jtbxx3
nga.03 nga.03@lab.test sales 10.10.0.103 lab-z95h165z7q04
thao.04 thao.04@lab.test sales 10.10.0.104 lab-oid7g14j4oh3
quang.05 quang.05@lab.test hr 10.10.0.105 lab-9zt964z1msra
unique users: 6 | all emails in lab.test: True
real lab password length: 16
Each username carries a number, so names repeat without colliding; every email is under lab.test; every address is in the lab network. The password prefix lab- is a reminder in any dump you produce later that these are practice values. A real person's name list, an export from work or a breach dump would make the same exercise a privacy problem, and possibly a crime in some countries even inside your own lab.
A lab-safety checker
Rules are easy to forget at 11 p.m. when an exercise "almost works". A checker you run before each session catches the common slips. The inventory below is the kind of file you keep for the mini project: one line per machine or container, with its network attachment, the address its services listen on, its target names and whether it has a recent snapshot.
import ipaddress
LAB_NET = ipaddress.ip_network("10.10.0.0/24")
SAFE_SUFFIXES = (".test", ".example", ".invalid", ".localhost", # RFC 6761
".example.com", ".example.org", ".example.net") # RFC 2606
inventory = [
# name, vulnerable, attachment, listen, targets, snapshot_age_days
("kali", False, "internal+nat", "-", ["srv01.lab.test"], 3),
("srv01", False, "internal", "10.10.0.10", [], 12),
("msf2", True, "internal", "10.10.0.40", [], 1),
("juice-shop", True, "docker", "0.0.0.0:3000", [], 0),
("dvwa", True, "bridged", "192.168.1.77", [], 40),
("recon-notes", False, "-", "-", ["shop.example.com", "portal.acme-corp.com", "10.10.0.0/24"], 0),
]
def problems(name, vulnerable, attach, listen, targets, snap_age):
out = []
if vulnerable and attach in ("bridged", "nat"):
out.append(f"vulnerable target on {attach} network")
if listen.startswith("0.0.0.0") or listen.startswith("[::]"):
out.append(f"listens on all interfaces ({listen})")
elif listen not in ("-",) and not listen.startswith("127.0.0.1"):
host = listen.split(":")[0]
if ipaddress.ip_address(host) not in LAB_NET:
out.append(f"address {host} is outside {LAB_NET}")
for t in targets:
try:
if not ipaddress.ip_network(t).subnet_of(LAB_NET):
out.append(f"target {t} outside lab network")
except ValueError:
if not t.endswith(SAFE_SUFFIXES):
out.append(f"target {t} is not a reserved lab name")
if vulnerable and snap_age > 7:
out.append(f"last snapshot {snap_age} days ago")
return out
total = 0
for row in inventory:
found = problems(*row)
total += len(found)
print(f"{row[0]:12} {'OK' if not found else '; '.join(found)}")
print("problems:", total)kali OK
srv01 OK
msf2 OK
juice-shop listens on all interfaces (0.0.0.0:3000)
dvwa vulnerable target on bridged network; address 192.168.1.77 is outside 10.10.0.0/24; last snapshot 40 days ago
recon-notes target portal.acme-corp.com is not a reserved lab name
problems: 5
shop.example.com passes because example.com and its subdomains are reserved for documentation (RFC 2606), while portal.acme-corp.com looks like a real company's domain: if it is one, pointing a tool at it is testing someone else's system. That line on its own is the most important finding of the run. The checker is deliberately simple; extend it with the rules from the table that your lab needs.
How slips are detected
- Run the checker (or your own list) at the start of each lab session, and after changing any VM or container.
- From outside the lab (your phone on the home Wi-Fi), the lab's ports must not answer.
- Search your learning journal and lab notes for secrets before sharing them:
grep -rniE 'password|passwd|token|secret|api[_-]?key' notes/. - Watch the host: an unexpected outbound connection from a lab VM (in the host firewall or router log) means an isolation rule failed.
How it is fixed or prevented
- Make the safe choice the default: templates for VMs with an internal card, a Compose file with
internal: true, a scope file with the lab network. - Keep a written lab inventory and scope next to your journal and update them with every change.
- Generate all data and accounts; keep their seeds and generators with your notes so exercises can be repeated.
- Revert targets to their snapshot after each session and shut them down.
Pitfalls
- "It's only for a minute." Bridged mode or a public port "just to test something" is how lab machines end up exposed.
- Real-looking data that is real. Scraped profiles, a work export or a public breach dump are real people's data; synthetic means generated.
- Lab passwords that leak out. A lab password reused on a real account turns a dumped lab database into a real compromise.
- Mixing lab and real browsing in the same browser profile: a lab proxy's certificate or a malicious lab page can then touch your real sessions. Use a separate profile or the Kali VM's browser.
Practice
- Fix the inventory so the checker reports no problems for
juice-shopanddvwa. What did you change? - Why does the checker accept
shop.example.combut rejectportal.acme-corp.com? - Add a rule to the checker: a vulnerable machine must not have the attachment
host-onlywithout a note explaining why. Which line would it flag in the inventory?
Answers
juice-shop: listen on127.0.0.1:3000(or no published port on an internal network).dvwa: attachmentinternal, an address in10.10.0.0/24(e.g.10.10.0.31), and a fresh snapshot (age 7 days or less).example.comis reserved for documentation by RFC 2606 and can never belong to a real organisation;acme-corp.comis an ordinary domain that may well be registered by someone.- None in this inventory: no vulnerable machine is on
host-only. It would flag a line such as thewin2022VM from Hypervisors, VM Networks and Snapshots, which had an extra host-only card.
Test yourself
Why generate lab data with a fixed seed?
- It is more secure
- The same data appears every time, so exercises and write-ups are reproducible
- Seeds are required by Kali
- It makes the data real
Which target name is safe to use in a lab tool command?
portal.acme-corp.comwww.lab.test- a public webmail site you use
- your employer's intranet name
A container shows 0.0.0.0:3000->3000/tcp in docker ps. What does it mean for the lab?
- Only the host can reach it
- Every network the host is on can reach the vulnerable app
- The port is closed
- It is on an internal network
Which is NOT synthetic data?
- Users made by a seeded generator
- Log lines written by a script with lab addresses
- An export of your club's real member list with names changed slightly
- Events from a lab VM generated during an exercise