Yes, hacking is illegal when it involves accessing a computer without authorization or exceeding authorized access. In the US, the Computer Fraud and Abuse Act (18 U.S.C. § 1030) makes it a federal crime, with penalties from up to one year for simple unauthorized access to up to 20 years for repeat or serious offenses.
Key takeaways
- Unauthorized access to a protected computer is a federal crime under the Computer Fraud and Abuse Act, even if no data is stolen.
- Ethical hacking is legal only with clear, written permission that defines exactly what may be tested.
- The Supreme Court's Van Buren decision narrowed the CFAA: misusing access you already have is not automatically a federal crime.
Hacking is not one crime. It is a range of acts — from guessing a password to shutting down a hospital — and the law turns on one question above all: did you have permission?
Is hacking illegal?
Yes, hacking is illegal when it involves accessing a computer without authorization or exceeding authorized access. In the United States, that is a federal crime under the Computer Fraud and Abuse Act (CFAA).
The CFAA, codified at 18 U.S.C. § 1030, was enacted in 1986 and has been expanded since. It protects federal computers, bank computers, and computers used in or affecting interstate or foreign commerce — which, in practice, means almost any computer connected to the internet. FindLaw's guide to hacking laws and punishments summarizes the federal and state picture.
That breadth matters. Hacking a protected computer is a federal crime, so federal prosecutors can bring charges, and the same conduct can also violate state computer crime laws. The penalties range from a misdemeanor to a felony with up to 20 years in prison.
This article explains US law for general information. It is not legal advice. If you are facing a hacking charge or planning security testing, talk to a lawyer.
What does the Computer Fraud and Abuse Act prohibit?
The CFAA prohibits seven kinds of conduct under 18 U.S.C. § 1030(a): accessing a computer to commit espionage, accessing a computer to obtain information, trespassing in a government computer, accessing a computer to commit fraud, damaging a computer, trafficking in passwords, and threatening to damage a computer.
The core idea is simple: intentionally accessing a computer without authorization, or exceeding authorized access, and obtaining information is a crime. Attempts and conspiracies to commit any of these offenses are also crimes under § 1030(b).
A "protected computer" is defined broadly. It includes any computer used in or affecting interstate or foreign commerce, which covers computers connected to the internet, as well as computers used by the federal government and financial institutions.
The CFAA also creates a civil cause of action under § 1030(g), so a victim who suffers loss or damage from a violation can sue for money damages and other relief, separate from any criminal prosecution.
What are the penalties for hacking under the CFAA?
Penalties depend on the offense, the intent, the loss caused, and whether it is a first or repeat offense. They range from up to one year for simple unauthorized access to up to 20 years, or life if death results from intentional computer damage.
| Offense | First conviction | Second conviction |
|---|---|---|
| Obtaining national security information | Up to 10 years | Up to 20 years |
| Accessing a computer to defraud and obtain value | Up to 5 years | Up to 10 years |
| Accessing a computer and obtaining information | Up to 1 year | Up to 10 years |
| Intentionally damaging by knowing transmission | Up to 10 years | Up to 20 years |
| Extortion involving computers | Up to 5 years | Up to 10 years |
| Trafficking in passwords | Up to 1 year | Up to 10 years |
Fines can reach $250,000 for many felony offenses, and courts can order restitution to victims and forfeiture of property used in the offense. Federal sentencing also uses the US Sentencing Guidelines, so the actual sentence depends heavily on the financial loss calculated in the case.
Other federal laws can apply to the same conduct, including the Stored Communications Act, the Electronic Communications Privacy Act, wire fraud, identity theft, and extortion statutes. A single hack can therefore lead to several charges.
What counts as hacking under the law?
Hacking, in legal terms, is breaking into a computer system without consent. The method does not matter — guessing a password, phishing credentials, exploiting a vulnerability, or using a stolen session all count if the access is unauthorized.
Common acts that can be prosecuted include accessing someone else's email or social media account, breaking into a company network, installing malware or ransomware, launching a denial-of-service attack, stealing data, changing or deleting files, and trafficking in passwords that can be used to access a computer.
Accessing a system you are allowed to use, but in a way that reaches files, folders or databases that are off-limits to you, can also be a violation. That is the "exceeds authorized access" part of the law.
What does not count is using a computer you own, testing a system you have permission to test, or accessing information you are entitled to access. Permission is the dividing line.
What did Van Buren v. United States decide?
In Van Buren v. United States, decided June 3, 2021, the Supreme Court held that a person does not violate the CFAA merely by accessing information they are authorized to obtain, even if they do so for an improper purpose.
The case involved former police sergeant Nathan Van Buren, who used a law enforcement database he was authorized to use to look up a license plate in exchange for money, in violation of department policy. He was convicted, but the Supreme Court reversed in a 6–3 opinion by Justice Barrett.
The Court held that a person "exceeds authorized access" only when they access areas of a computer — such as files, folders or databases — that are off-limits to them. Using authorized access for the wrong reason is not, by itself, a CFAA violation. Congress's summary of the Van Buren decision explains the 6–3 ruling and its implications.
The decision narrowed the CFAA and resolved a split among lower courts. It matters for security researchers, employees, and scraping disputes, but it does not legalize hacking: accessing a system without any authorization at all is still a crime.
When is hacking legal? Ethical hacking explained
Ethical hacking is legal only with clear, written permission from the system owner. The hacker has the appropriate consent or authorization to test the system, within a defined scope.
That permission should name the systems, the techniques allowed, the time window, and who to contact if something breaks. A verbal "go ahead and test us" is not enough — get it in writing before you touch anything.
Legal routes into security testing include penetration testing under contract, bug bounty programs with published rules, capture-the-flag exercises on your own systems, and testing in a lab you control. Each of these gives you authorization for a defined target.
Stay inside the scope. Testing a system that was not listed, accessing data you were not authorized to see, or keeping data after the test can turn a legal engagement into a violation. If you find something outside the scope, stop and report it through the agreed channel.
What are the different types of hackers?
The labels describe intent and authorization, not skill. A white-hat hacker tests systems with permission. A black-hat hacker breaks in without permission for profit, theft or damage. A grey-hat hacker breaks in without permission but claims a helpful motive.
Grey-hat hacking is still illegal. Good intentions do not create authorization, and "I was only showing you the flaw" is not a defense under the CFAA. If you find a vulnerability in a system you do not own, report it through the vendor's disclosure channel instead of exploiting it.
Other terms you will hear include red teams, who simulate attackers with permission to test defenses, and blue teams, who defend. Both work under authorization, which is what makes their work legal.
Careers in this field are growing. Information security analysts earned a median $129,180 in May 2025, with employment projected to grow 21% from 2025 to 2035 and about 14,100 openings a year, according to the Bureau of Labor Statistics. The legal path into hacking is through authorized testing, not unauthorized access.
What are real examples of hacking prosecutions?
Real cases show the range of the law, from fake suppliers to ransomware gangs, and the sentences that follow when unauthorized access causes large losses.
In one well-documented case, a man impersonated the supplier Quanta Computer and convinced Facebook and Google to wire about $122 million in fake invoices between 2013 and 2015. He pleaded guilty in 2019 and was sentenced to five years in prison.
Ransomware operators face longer sentences. Intentional damage to a protected computer carries up to 10 years for a first offense and up to 20 years for a repeat offense, before restitution and forfeiture are added.
Even "small" hacks are prosecuted. Accessing a former partner's email, guessing a colleague's password, or using a stolen credential to read private messages can lead to federal charges, state charges, and civil lawsuits — even when no money is taken.
What should you do if you are accused of hacking?
If you are accused of hacking, stop accessing the systems involved, preserve evidence, and speak to a criminal defense lawyer before answering questions from investigators or the system owner.
Do not delete logs, messages, or files. Deleting evidence can create a separate obstruction charge and makes your position worse. Do not discuss the facts on social media or with colleagues.
A lawyer can assess whether you had authorization, whether the access was within scope, and whether the Van Buren decision helps your case. The difference between authorized and unauthorized access is often a factual question about what permission was actually given.
If you are a victim of hacking rather than the accused, preserve logs, change passwords from a trusted device, and report the crime to the FBI's Internet Crime Complaint Center at ic3.gov and to local law enforcement.
How do you learn hacking legally?
Learn on systems you own or have permission to test: a home lab, a virtual machine, a cloud account in your name, or a published bug bounty target within its rules.
- Build a home lab. Run vulnerable virtual machines and attack them on your own network.
- Join a bug bounty program. Read the rules, stay in scope, and report through the program.
- Play capture-the-flag. CTF competitions are designed to be attacked, legally.
- Study for a certification. Structured courses teach the same techniques inside authorized labs.
- Report what you find. Use a vendor's coordinated disclosure channel, and never demand payment for a report.
Good password habits help too: use a password manager and unique passwords, so a single guessed password cannot open many accounts. You can test a password's strength with our free password strength checker.
The bottom line
Hacking without permission is illegal under the CFAA, with penalties that rise sharply with intent, damage and prior convictions. Hacking with clear, written permission — as a penetration tester, a bug bounty hunter, or a student in a lab — is a legitimate and growing career.
The rule to remember is simple: permission first, testing second. If you are not sure you have permission, you do not have it. For practical defenses, start with our small business cybersecurity checklist.
Our guide to how to know if your phone is hacked helps you spot unauthorized access to your own devices.
Frequently asked questions
Is hacking illegal in the US?
Yes, when it is done without authorization. The Computer Fraud and Abuse Act makes it a federal crime to intentionally access a protected computer without authorization or to exceed authorized access, with penalties ranging from up to one year to up to 20 years depending on the offense.
Is ethical hacking legal?
Yes, when you have clear written permission from the system owner that defines the scope, the systems, and the time window. Without that permission, the same technical act can be a crime, even if your intentions are good.
What is the punishment for hacking?
It depends on the offense. Simple unauthorized access carries up to one year in prison. Access to defraud or obtain value carries up to five years for a first offense. Intentional damage carries up to ten years, and repeat offenses up to twenty years.
Is it illegal to hack your own computer?
No. Hacking a computer you own, or one you have permission to test, is not a CFAA violation. The crime is accessing someone else's computer without their authorization.
Is guessing someone's password illegal?
Yes, if you use it to access their account or computer without permission. Unauthorized access is the crime, however you get in, whether by guessing, phishing, or exploiting a vulnerability.
Can you go to jail for hacking a Wi-Fi network?
Yes. Accessing someone else's Wi-Fi network or router without permission can be prosecuted as unauthorized access under the CFAA and under state computer crime laws, even if you only use it to browse the internet.
Does the CFAA apply to violating a website's terms of service?
After Van Buren v. United States in 2021, merely violating a policy or using authorized access for an improper purpose is not automatically a CFAA violation. The CFAA targets accessing areas or information that are off-limits to you.
Is hacking illegal in other countries?
Yes, in most countries. The UK has the Computer Misuse Act 1990, the EU has the Directive on attacks against information systems, and most other countries have similar computer crime laws. Penalties and definitions vary by country.
Sources
- FindLaw — Hacking Laws and Punishments
- Congressional Research Service — Cybercrime: A Sketch of 18 U.S.C. 1030
- Congress.gov — Van Buren v. United States: Supreme Court Holds Accessing Information for Unauthorized Purposes Not Federal Crime
- US Supreme Court — Van Buren v. United States, 593 U.S. 374 (2021)
- Esfandi Law — Federal Computer Hacking Under 18 U.S.C. § 1030
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against 18 U.S.C. § 1030 as summarized by the Congressional Research Service and FindLaw, and the Supreme Court's Van Buren decision.
How we write and fact-check →