Please enable JavaScript to use CodeHS

Cybersecurity · Careers

Red Team vs. Blue TeamHow cybersecurity teams attack and defend

Some security experts get paid to break in. Others get paid to keep them out. Learn what each team does, why permission is everything, and then take the blue team's seat to defend a school network.

Security ~18 min Middle / High school
The Big Idea

What is a red team vs. a blue team?

In cybersecurity, a red team plays the attacker and a blue team plays the defender. The red team tries to break into an organization's computers, the same way a criminal might. The blue team tries to stop them, spot them, and kick them out.

Here is the twist: both teams work for the same side. The red team attacks only with the owner's permission. Its job is to find weak spots first, so they get fixed before a real criminal finds them. Think of a fire drill. Nobody wants a real fire, so the school practices to see what goes wrong when the stakes are low.

Red team

Thinks like an attacker

Asks: "If I were a criminal, how would I get in?"

  • Tests defenses on purpose
  • Works inside agreed rules
  • Writes a report on how to fix what they found
Blue team

Thinks like a defender

Asks: "How do we notice an attack and stop it fast?"

  • Watches systems all day and night
  • Builds and fixes defenses
  • Responds when something goes wrong

Where the names come from

The idea started with armies, long before computers. Military planners have played war games for over 200 years: practice battles where one side plays the enemy so commanders can test their plans.

1800s

Tabletop war games

Prussian army officers played a war game called Kriegsspiel on maps, with red and blue pieces for the two sides.

Cold War

"Red" plays the enemy

U.S. military exercises often called the pretend enemy force the red team and the home force the blue team.

Today

Cyber war games

Companies, governments, and even schools run the same kind of practice, but on computer networks instead of battlefields.

Attackers With Permission

The red team: attackers with a permission slip

A red team is a group of security experts hired to act like real attackers. They might send a practice phishing email (a fake message that tries to trick someone), look for computers that are missing updates, or check whether a door badge can be copied. When they find a way in, they don't steal or break anything. They write it down so it can be fixed.

Red team work is a kind of ethical hacking: using hacking skills to help, not to harm. The thing that makes it ethical and legal is one simple word: permission.

Rules of engagement

Before any test starts, the red team and the system's owner sign an agreement called the rules of engagement. It spells out the scope: exactly which systems the red team may test, when, and how. Anything outside the scope is off-limits. Here is what a simple one might look like:

Rules of EngagementPractice exercise · Maple Ridge School (fictional)
In scope
Staff email, the school Wi-Fi, two test laptops, the practice grade server
Out of scope
Student devices, real grades, the cafeteria payment system, anything not listed above
When
Saturdays, 9 a.m. to 3 p.m., for two weeks
Not allowed
Deleting data, slowing down systems people need, sharing anything found
Emergency stop
Call the IT director if anything real breaks. Testing pauses right away.
OwnerJ. RiveraRed team leadA. Okafor

No permission means no red team. It is just a crime. Breaking into a system you don't own, without written permission, is illegal under laws like the U.S. Computer Fraud and Abuse Act, even if you "just wanted to look" or planned to report it. Real red teamers never step outside their scope. Practice only on systems built for practice.

Defenders On Watch

The blue team: defenders who never stop watching

The blue team protects an organization every single day, not just during practice. Real attacks can come at 3 a.m. on a holiday, so many blue teams work in a security operations center, or SOC (say "sock"). A SOC is like a control room where analysts watch screens full of alerts and decide which ones are real trouble.

The blue team's toolkit

Monitoring
Tools that watch the network and computers and raise an alert when something looks strange.
Logs
Records of what happened: who logged in, from where, and when. Like a security camera's recording, but in text.
Firewalls
Gatekeepers that decide which network traffic is allowed in or out, based on rules.
Patching
Installing updates that fix known security bugs, before attackers can use them.
Incident response
The plan for when an attack gets through: find it, contain it (stop it from spreading), clean it up, and recover.
Hardening
Turning off features nobody uses, requiring strong logins, and locking down settings so there are fewer ways in.

Much of blue team work is reading logs and spotting the one line that doesn't fit. Here is the kind of thing an analyst might see:

auth.log (example)
07:58 login OK ms.chen from school-wifi normal
08:03 login OK mr.davis from school-wifi normal
02:14 login FAIL ms.chen from unknown-country x14
02:15 login OK ms.chen from unknown-country ALERT: odd time + odd place

Fourteen failed tries, then a success, at 2 a.m., from somewhere Ms. Chen has never been? That's worth a closer look. A blue team would lock the account, call Ms. Chen, and check what that login touched.

More Colors

Purple teams and white teams

Red and blue get most of the attention, but real exercises often use two more colors.

Red

Attacker

pretends to be the threat

Tries to get in, within the rules, and reports how.

Blue

Defender

protects and responds

Watches, blocks, and cleans up after attacks.

Purple

Red + blue together

shares lessons live

Each attack becomes a new alert or defense right away.

White

Referee

runs the game

Sets rules, keeps score, and can pause the exercise.

Purple teaming fixes a common problem. In a classic exercise, the red team keeps its tricks secret until a final report weeks later. In purple teaming, the two sides sit together. The red team says, "I'm trying this now," and the blue team checks, "Did our tools notice?" If not, they fix it on the spot. Purple can be a separate team, or just a way of working.

The white team is the referee. It sets up the exercise, writes the rules of engagement, judges whether each attack stayed in scope, and keeps score. If a real emergency happens in the middle of a practice, the white team calls a time-out.

Sorting game · Which team does this?

Score: 0 / 0
Task 1 of 10

Loading…

Pick the team that does each job.
How It Plays Out

Attack steps vs. defense layers

Real attacks rarely happen in one move. Security experts describe them as a chain of steps, sometimes called the attack lifecycle. Professionals use detailed versions like the Cyber Kill Chain or MITRE ATT&CK, but four simple steps capture the idea. The good news for defenders: breaking any link in the chain stops the attack.

Click each step to see what the red team tries, how the blue team answers, and what might show up in the logs.

Red tries

Scout

Blue answers

Log

Defense in depth: never trust one wall

No single defense is perfect. Filters miss some emails. People click links. Updates arrive late. So blue teams stack many layers, like a castle with a moat, a wall, guards, and a locked vault. This is called defense in depth. If an attacker gets past one layer, the next one is waiting.

Defense in depth: five rings of protection around the data at the center 1 PEOPLE 2 PERIMETER 3 DEVICES 4 NETWORK DATA
  1. People: training so staff spot fake emails and report them.
  2. Perimeter: firewalls, email filters, and locked-down Wi-Fi at the edge of the network.
  3. Devices: updates, antivirus, and strong logins with multi-factor authentication on every laptop.
  4. Network: splitting the network into zones so one hacked laptop can't reach everything.
  5. Data: encryption and backups for the most important stuff. Around all of it: monitoring that watches every layer.
Your Turn

Play: defend the school network

You are the blue team at Maple Ridge School (a made-up school). The district hired a red team for a practice exercise, and you know their goal: reach the grade server and grab a practice "flag" file. You have 9 security credits to spend. Pick your defenses, lock them in, and then watch the red team's plan play out one move at a time.

Tip: think in layers. Where could you stop them at the door? What if the door fails?

Exercise: Maple Ridge · Blue team console Phase 1: Plan your defenses

Defense shop

Credits used0 / 9

Red team Outside
Staff email Waiting
School Wi-Fi Waiting
Teacher laptop Waiting
Grade server Waiting

    The red team's moves will appear here, turn by turn.

    Notice that the red team didn't give up after one blocked move. Real attackers try a Plan B, then a Plan C. That is why one strong wall is not enough. And in real life, nothing is 100 percent: filters miss things and people make mistakes. Extra layers turn "we got lucky" into "we were ready."

    Practice And Careers

    Where students practice, and jobs for every color

    You don't have to wait for a job to try red and blue team work. These are safe, legal places to practice, built so you can learn without hurting anyone.

    Practice exercises

    All teams

    Companies, governments, and some school districts run red vs. blue exercises to test their real defenses. Some colleges hold competitions where student blue teams defend a network while professional red teams attack it.

    CyberPatriot

    Blue skills

    A national youth competition for middle and high school teams. Students get practice computers full of security problems and race to find and fix them. That's blue team work.

    Capture the flag

    Red + blue

    CTF games hide "flags" (secret bits of text) inside puzzles about codes, websites, and files. Free student games like picoCTF from Carnegie Mellon University are a great start.

    Bug bounties

    Red skills

    Companies publish rules inviting people to find and report security bugs, and they pay rewards. The rules are the permission. Many programs require you to be 18 or have a parent's permission.

    Jobs on each team

    RoleWhat you'd doStrong skills
    Penetration tester
    Red
    Test a company's systems with permission and write a report on how to fix each weak spot.Networking, web apps, creative thinking, clear writing
    Red team operator
    Red
    Run longer, sneakier exercises that copy how real attacker groups behave.Patience, planning, programming, stealth tricks
    SOC analyst
    Blue
    Watch alerts, decide which ones are real, and start the response. A common first security job.Logs, networking, attention to detail
    Incident responder
    Blue
    Lead the team when an attack gets through: contain it, clean it up, and recover.Staying calm, teamwork, Linux, investigation
    Threat hunter
    Blue
    Search for hidden attackers before any alert goes off, using hunches and data.Curiosity, data analysis, Python, thinking like an attacker
    Detection engineer
    Purple
    Turn red team tricks into new alerts and test that they work.Both sides' skills, programming, teaching others

    What to learn now

    01

    Cybersecurity basics

    CodeHS cybersecurity courses cover the CIA triad, encryption, networks, and ethics, with safe practice labs.

    02

    Networking

    Learn how devices talk: IP addresses, ports, Wi-Fi, and how data moves across the internet.

    03

    Linux

    Most servers and security tools run on Linux. Get comfy with the command line, files, and permissions.

    04

    Python

    Both teams write small programs to sort logs, automate checks, and solve CTF puzzles.

    Career matcher · Which color fits you?

    Answer five quick questions. There are no wrong answers, and every color needs people.


    FAQ

    Red team and blue team questions, answered

    What is the difference between a red team and a blue team?

    A red team plays the attacker. With permission, it tries to break into an organization's systems the way a real criminal would, so weak spots get found and fixed. A blue team plays the defender. It watches the systems, blocks attacks, and responds when something goes wrong. Both teams want the same thing: a safer organization.

    Is red teaming legal?

    Red teaming is legal only when the owner of the systems gives written permission first. The red team and the owner agree on rules of engagement that list what is in scope, what is off-limits, and when testing happens. Breaking into a system without permission is a crime, even if you mean well.

    What is a purple team in cybersecurity?

    A purple team is red and blue working together. Instead of keeping secrets until a final report, attackers and defenders share what they are doing as they go. Each attack the red team tries becomes a lesson the blue team uses to build better alerts and defenses.

    What does a white team do in a cybersecurity exercise?

    The white team is the referee. It writes the rules, sets up the exercise, keeps score, and makes sure both sides stay inside the agreed scope. If a real problem pops up during the exercise, the white team can pause the game.

    Should I start on the red team or the blue team?

    Many security professionals start on the blue team, in jobs like SOC analyst or IT support, because those roles teach how real systems work and how attacks look from the inside. Good red teamers need that same knowledge. Try both in student competitions and see which one you enjoy more.

    How can students practice red team and blue team skills?

    Students can join CyberPatriot, a national competition where teams find and fix security problems on practice computers, or play free capture the flag (CTF) games like picoCTF. CodeHS cybersecurity courses also include safe practice labs. Always practice on systems built for practice, never on real ones.

    What skills do red and blue team jobs need?

    Both sides need networking basics, comfort with Linux and the command line, and some programming, often in Python. Red teamers add creative problem solving and clear report writing. Blue teamers add patience with logs and data and staying calm under pressure. Everyone needs strong ethics and good communication.


    Check Yourself

    Quick quiz

    1. What makes a red team's hacking legal and ethical?

    2. A SOC analyst notices a strange 2 a.m. login and locks the account. Which team are they on?

    3. What is purple teaming?

    4. What does "defense in depth" mean?

    5. In CyberPatriot, what do student teams mostly practice?

    Part of the Cybersecurity Skills and Careers tutorial series.