Penetration Testing
Authorized simulated attacks against a system to find security vulnerabilities before real attackers do. White-hat hackers probe for weaknesses in a controlled environment.
What is Penetration Testing?
In short
Penetration testing is an authorized, simulated cyberattack against a system, network, or application, carried out by security professionals to find and exploit real vulnerabilities before a malicious attacker does. The goal is to prove what an attacker could actually reach and steal, then report it so the issues get fixed.
What Penetration Testing Actually Is
A penetration test, or pentest, is a controlled attack. A security professional, often called an ethical hacker or red teamer, is given written permission to break into a target the same way a criminal would. The difference is the rules of engagement: there is a signed scope, a time window, and an agreement on what is off-limits. When the test ends, the tester hands over a report instead of stealing data.
Pentesting is different from a vulnerability scan. A scanner like Nessus or Qualys lists weaknesses it thinks exist. A pentester proves which ones are real by chaining them together into a working exploit. A scanner might flag an outdated library; a pentester uses that library to get a shell, pivot to the database, and dump customer records, showing the true blast radius.
Tests come in three flavors based on how much the tester knows up front. Black box means they start with nothing but a domain name, mimicking an outside attacker. White box gives them source code, credentials, and architecture diagrams for a deep review. Gray box sits in the middle, often simulating a logged-in user or a compromised contractor.
How a Test Runs Under the Hood
Most engagements follow a repeatable cycle. First comes reconnaissance, where the tester gathers public data: subdomains, exposed S3 buckets, employee emails, leaked credentials, and open ports found with tools like nmap. Then comes scanning and enumeration to map services, versions, and likely entry points.
Next is exploitation. The tester turns a finding into access using frameworks like Metasploit, custom scripts, or hand-crafted payloads for things like SQL injection, server-side request forgery, or broken authentication. The Burp Suite proxy is the standard tool for attacking web apps because it lets you intercept and tamper with every request.
After the first foothold comes post-exploitation: privilege escalation to admin or root, lateral movement to other machines, and persistence to survive a reboot. This stage answers the question that matters to the business: once in, how far can the attacker go? The engagement closes with a report that ranks each finding by severity, usually with CVSS scores, and gives concrete remediation steps.
When To Use It and the Trade-offs
Run a pentest before launching a new product, after a major architecture change, and on a regular cadence such as annually or quarterly for sensitive systems. Many compliance frameworks force the issue: PCI DSS requires annual penetration tests plus tests after significant changes, and SOC 2 and HIPAA audits expect them too.
The main trade-off is that a pentest is a point-in-time snapshot. It tells you the system was exploitable on the days it was tested, not that it is secure forever. Deploy new code the next week and the result can go stale. This is why teams pair scheduled pentests with continuous scanning and a bug bounty program for ongoing coverage.
Cost and risk are the other considerations. A quality external pentest from a firm like NCC Group or Bishop Fox can run from a few thousand to well over fifty thousand dollars depending on scope. There is also real operational risk: an aggressive test can crash a fragile service, so production tests need careful scoping, rate limits, and a clear escalation contact.
A Concrete Example
Say a fintech startup hires a tester to assess its customer portal. In recon the tester finds a forgotten staging subdomain, staging.bank-app.com, still pointing at a live server. The login page there has a SQL injection flaw in the username field.
The tester confirms it with a single payload that dumps the users table, including bcrypt password hashes and an admin account. They crack a weak admin password offline, log into the staging admin panel, and discover it shares a database with production. From there they read live customer balances.
None of these flaws were critical alone: a stale subdomain, one injectable field, a weak password, a shared database. Chained together they expose real customer money. The report walks the team through that exact chain and recommends decommissioning staging, using parameterized queries, enforcing strong admin passwords with MFA, and isolating the production database. That story, not a list of isolated scanner hits, is what makes pentesting valuable.
Where it is used in production
Microsoft and Google Red Teams
Both run full-time internal red teams that continuously attack their own production cloud and product surfaces to find holes before outsiders do.
HackerOne and Bugcrowd
Crowdsourced platforms that connect companies with thousands of vetted testers, blending pentest-style engagements with ongoing bug bounties.
PCI DSS payment processors
Any company handling credit card data is contractually required to run annual penetration tests to keep processing payments.
Tesla
Runs public pentest contests like Pwn2Own where researchers attack its vehicles and infotainment systems for cash prizes and fixes.
Frequently asked questions
- What is the difference between a vulnerability scan and a penetration test?
- A vulnerability scan is automated and just lists potential weaknesses. A penetration test is done by a human who actively exploits those weaknesses, chains them together, and proves what an attacker could actually achieve, like reaching a database or escalating to admin.
- Is penetration testing legal?
- Yes, when you have explicit written authorization from the system owner that defines the scope and rules. Doing the same actions without permission is a crime under laws like the US Computer Fraud and Abuse Act.
- How often should you run a penetration test?
- At least once a year for most systems, and again after any major change such as a new feature, infrastructure migration, or merger. Compliance standards like PCI DSS make annual testing mandatory.
- What is the difference between a pentest and a red team engagement?
- A pentest aims to find as many exploitable vulnerabilities as possible within a defined scope, usually announced to the defenders. A red team is a stealthier, goal-driven exercise that tests whether the security team can detect and respond to a realistic attacker over weeks or months.
- What tools do penetration testers use?
- Common ones are nmap for network mapping, Burp Suite for web app attacks, Metasploit for exploitation, Nessus for scanning, and password crackers like Hashcat. Most testers work from a Kali Linux distribution that bundles these together.
Learn Penetration Testing hands-on
This page explains the idea. The full lesson lets you step through the ring as servers join and leave, read the implementation, and check yourself with a quiz. It is one of 760+ lessons in the System Design Masterclass, from your first API call to distributed consensus. Eleven Foundation lessons are free, no signup. Lifetime access is ₹499 in India or $7.99 worldwide, one payment, no subscription.
See also
Related glossary terms you might want to look up next.
WAF
Web Application Firewall: filters and monitors HTTP traffic between a web application and the internet. Blocks SQL injection, XSS, and other OWASP top-10 attacks.
Zero Trust
A security model that never trusts any request by default, even from inside the network. Every request must be authenticated, authorized, and encrypted regardless of origin.
Chaos Engineering
Deliberately injecting failures into a system to test its resilience. Netflix's Chaos Monkey randomly kills servers to ensure the system survives.
Threat Modeling
A structured process for identifying security threats, attack surfaces, and mitigations during system design. STRIDE and DREAD are common frameworks.
Incident Response
The structured process for detecting, containing, eradicating, and recovering from security incidents. Includes communication plans, runbooks, and post-incident reviews.
Security Audit
A systematic evaluation of a system's security posture against standards and best practices. Covers access controls, encryption, logging, vulnerability management, and compliance.