Skip to content
Tutorials Center
My learning

Topics

Lesson 3 of 38 ยท Getting Started

Legal and Ethics for Penetration Testers

Understand authorization, computer misuse laws, safe harbor, third-party systems, data handling and the ethical rules every penetration tester must follow.

The technical skills in this course are the same skills that criminals use. What makes your work legal is not the tool but the permission. Laws about unauthorized computer access exist in almost every country, and they rarely care about your good intentions. This lesson explains how authorization works, where testers get into trouble, and the ethical habits that protect both you and your clients. It is general education, not legal advice: when a real engagement involves unusual risk, ask a lawyer.

Authorization is everything

Computer misuse laws (for example the CFAA in the United States, the Computer Misuse Act in the United Kingdom, and equivalents elsewhere) generally make it an offense to access a system without authorization or to exceed the access you were given. "I was only looking" and "I told them afterwards" are not defenses. Before any traffic is sent, you need:

  • A signed agreement (a contract or statement of work) between your company and the client.
  • A written scope listing exactly which systems, addresses, applications and time windows are covered.
  • Authority of the signer. The person who signs must actually control the systems. A marketing manager cannot authorize a test of servers that belong to someone else.

For testers who work alone, the same applies: no paper, no packets.

Before you start

Signed contract Client and tester both agree.
Written scope Exact addresses and dates.
Valid owner Signer controls the systems.
Emergency contact Someone to call at 3 a.m.

Missing any one means stop.

1 / 2

The third-party problem

Clients often think they own more than they do. Typical traps:

  • Cloud and hosting providers. The client owns the account, but the provider owns the hardware. Providers publish policies describing which tests are allowed without prior approval and which are forbidden, such as flooding the shared network.
  • Software as a service. A client cannot authorize you to test a vendor's multi-tenant platform.
  • Managed services and CDNs. Traffic may pass through systems that belong to others.
  • Shared hosting. Other customers share the same server.
  • Employees' own devices. Personal phones on guest Wi-Fi may be out of scope.

The fix is to ask during scoping and to get the third party's written approval when needed. If an address resolves to a provider you did not expect, stop and re-check ownership before you send anything else.

Staying inside the lines

Scope can be crossed accidentally. A redirect sends your browser to another company's site. A scan sweeps a subnet that includes a neighbor's address. A discovered password works on a system that was never listed. The rule is simple and strict:

If it is not clearly in scope, do not touch it. Write it down and ask.

Do not "just check" whether a found credential works elsewhere unless the rules of engagement say you may. Record the discovery as a finding and ask the client for permission to go further.

Handling data responsibly

During a test you may see personal data, health records, payment details or private messages. You are responsible for it.

  • Minimize. Prove access with the least data possible. A screenshot of a file listing, or one redacted record, is better than a bulk copy.
  • Protect. Keep evidence on an encrypted disk and share it only through channels the client agreed to.
  • Retain briefly. Agree on how long you keep data and delete it when the period ends. Confirm deletion in writing if asked.
  • Redact in the report. Mask passwords, card numbers and personal identifiers.
  • Mind privacy laws. Regulations such as the GDPR apply to the data you touch, and sometimes require a data processing agreement with the client.

Disclosure and honesty

  • Report what you did, including mistakes. If a scan crashed a service, tell the client immediately. Hiding an outage costs trust and slows recovery.
  • Report critical findings promptly, not only at the end. A trivially exploitable hole on an internet-facing server cannot wait for the final report.
  • Do not exaggerate. Rank risk by realistic impact.
  • Do not keep access. Remove accounts, files and tools you installed, and tell the client what you changed.
  • Do not trade findings. A vulnerability in a client's system belongs to the client. Selling or publishing it without consent is both unethical and probably illegal.

Responsible disclosure outside engagements

If you find a flaw in a system you do not have a contract for, the safest path is to stop, avoid accessing data, and report it through the organization's published security contact or a vulnerability disclosure policy (often a security.txt file or a bug bounty page). Some organizations offer safe harbor language promising not to pursue researchers who follow the rules, but a policy is only a promise by the organization, not a change in the law. Read it carefully and stay within it.

Professional codes

Certification bodies and professional groups publish codes of ethics. They share common themes: protect the public, act honestly, avoid conflicts of interest, keep skills current, and never exceed authorization. Following such a code is also practical: clients choose testers they can trust.

Stand-in: a pre-flight authorization checklist

The first example turns the preconditions into a checklist function. It refuses to proceed unless every item is satisfied, which is exactly the habit to build.

Python Pre-flight authorization check

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The second example checks addresses against a scope list using Python's ipaddress module. Tools that sweep ranges should do exactly this before sending anything.

Python Is this address in scope?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What turns the same technical actions from a crime into a legitimate test?

    Authorization is the legal difference. Good intentions and after-the-fact notice do not replace permission.
  2. 2. A client asks you to test a server that is hosted by a cloud provider. What should you check?

    The provider owns the underlying infrastructure and sets rules for what customers may test.
  3. 3. During a test you find a password list. What is the safest handling?

    Minimize, protect and report. Using credentials outside the agreed rules exceeds your authorization.
  4. 4. You accidentally crash a production service with a scan. What do you do?

    Prompt honesty lets the client restore service and builds trust.

Summary

  • Written authorization, a defined scope and a signer with authority are required before any testing.
  • Check third parties such as cloud providers, SaaS vendors and CDNs; get their approval when needed.
  • If something is not clearly in scope, do not touch it: record it and ask.
  • Minimize, protect, retain briefly and redact the data you encounter.
  • Be honest about mistakes, report critical issues promptly and clean up after yourself.
  • Outside an engagement, report flaws through official disclosure channels and do not access data.

Next: Building a Safe Practice Lab