Security teams drown in data
A log is a record that a computer keeps about what happened. "Maya logged in at 9:02 AM." "Devon downloaded a file." Every login, every file, every website visit and every app click can leave a log line.
Large companies and school districts can produce millions of log lines in a single day. No person can read that many. That is the starting point for the question how is AI used in cybersecurity? One of its biggest jobs is sorting through the flood and picking out the few lines a human should look at.
Here are ten log lines. One of them is not like the others.
Which line is the odd one?
The sixth line. Priya's account pulled 4,200 MB (about 4 GB) on a device nobody had seen before, when other downloads were around 12 MB. It might be harmless. It might be a stolen password. Now picture finding that line among five million.
The honest version: AI does not "stop hackers by magic." In most security teams it works like a very fast assistant that sorts a giant pile and says, "look at these first." People make the decisions.
First, learn what "normal" looks like
Think about your own habits. You probably log in to your school account on weekdays, from home or school, on the same laptop. That pattern is your baseline: what normal looks like for you.
An anomaly is an event that is far from the baseline. Logging in from another country at 3 AM would be an anomaly. Anomaly detection is software that learns the baseline from past data, then flags new events that are far from it.
Anomaly detection works in four steps:
- Collect lots of past events, like logins and downloads.
- Measure what is typical and how much it usually varies.
- Compare each new event to that typical pattern. How far away is it?
- Alert a person if the event is too far away.
Unusual does not always mean evil. A student who travels, a teacher who works at midnight, or a big school-photo upload can all look strange. An anomaly is a reason to look. It is not proof of an attack.
Find the odd ones out
Each dot below is one login. Left to right is the time of day. Up is how many megabytes (MB) that login downloaded. A megabyte measures file size, and a song is roughly 4 MB. Five of the 60 events are attacks.
Click or tap the dots you think are suspicious. You can pick up to 6. Then reveal what a simple detector flagged.
Login monitor: round 1 of 3
You marked 0 of 6- One login
- Your pick
- Flagged by detector
- Real attack (after reveal)
How the detector works: it measures how far each dot is from its three closest neighbors, then flags dots that are far from everyone. This is a simplified method. Real systems use many more clues than two.
Rules or learning?
There are two main ways to build a detector. Real security tools usually use both.
Rules and signatures
The most-wanted poster
A signature is the fingerprint of a known attack, like a bad file or a web address attackers already used. A rule says, "if you see this, raise an alert." It works like a most-wanted poster: it only catches people who are already on it.
- Fast and clear. It is easy to see why it fired.
- Few false alarms when the rule is precise.
- Blind to new attacks. If it is not on the list, the rule stays quiet.
- Needs constant updates as attackers change small details.
Machine learning
Learns patterns from examples
Machine learning means a program finds patterns in data instead of following a list someone typed in. It can learn from examples of past attacks, or it can learn only what normal looks like, which is anomaly detection.
- Can catch new things that nobody wrote a rule for.
- Handles huge piles of data without getting tired.
- Makes mistakes. Odd but harmless events get flagged, and clever attacks can blend in.
- Depends on its data. Bad or old examples teach it the wrong lesson, and it can be hard to explain why it flagged something.
Two kinds of mistakes
No detector is perfect. Whenever one makes a decision, it can be right or wrong in two different ways. Here are false positives and false negatives explained in plain words.
A false alarm
The detector raises an alert, but nothing was wrong. It is the boy who cried wolf.
Cost: wasted time. Too many of them cause alert fatigue: people get so tired of false alarms that they start skimming past them, including real ones.
A missed attack
A real attack happens, and the detector stays quiet. The wolf walked right in.
Cost: damage nobody sees coming. Data can be stolen for weeks before anyone notices.
Why you cannot get rid of both
A detector needs a threshold: a cutoff for "unusual enough to alert." Think of the metal detector at an airport. If it is set too sensitive, it beeps for belt buckles. If it is set too relaxed, it misses a real weapon.
The tricky part is that attacks and normal events overlap. Some attacks are sneaky and look almost normal. Some normal events look strange. So lowering the threshold catches more attacks but also flags more normal events. Raising it quiets the alerts but lets more attacks slip by. You can move the dial, but you cannot make both numbers zero.
Which mistake is worse depends on the job. A hospital might accept many false alarms rather than miss one attack. A tiny team with no time to check alerts needs the opposite. Try it yourself in the lab.
Detector Lab
Below is a stream of 200 events, like logins plus transfers. Hidden inside it are 12 real attacks. Each dot shows how much data an event sent and how many failed logins per minute came with it. Move the sensitivity slider and watch the two kinds of mistakes trade places.
Detector Lab (simplified simulation, 200 events, 12 attacks)
Rules do not use a sensitivity dial. They either match the list or they do not.
- Caught attack
- Missed attack
- False alarm
- Normal, ignored
- New kind of attack
Scoreboard (confusion matrix)
| Detector: alert | Detector: quiet | |
|---|---|---|
| Really an attack | 0Caught (true positive) | 0Missed (false negative) |
| Really normal | 0False alarm (false positive) | 0Rightly ignored (true negative) |
Total events counted: 0 of 200
Analyst workload
Missed attacks nobody was told about
False alarms normal events flagged
Simplified: made-up data from a fixed seed, so everyone sees the same stream. The learner computes real averages and z-scores on this data. Real detectors look at many more features, update as they go, and are tested on data they have not seen.
Things to try: 1) Drag the slider all the way to Sensitive. Watch missed attacks fall to near zero while false alarms and the workload meter climb. 2) Go back to Relaxed. The alerts go quiet, but attacks slip by. 3) Switch to Rules only, then press "Release a brand-new kind of attack." 4) Switch back to Learns normal and see which of the new attacks it still catches, and what that costs.
For the curious: the simplest anomaly detector
The "Learns normal" detector in the lab uses one of the simplest tools in statistics. You can skip this part and still follow everything else.
Mean, standard deviation, and the z-score
The mean is the average. The standard deviation (sd) tells you how spread out the numbers usually are. A small sd means events hug the average. A big sd means they wander.
The z-score says how many standard deviations an event is from the mean:
Here is a tiny set of ten normal downloads, in MB:
The rule here is "flag it if z is bigger than 3 in either direction." For bell-shaped data, about 99.7 out of 100 normal events land within 3 standard deviations, so anything beyond that is rare. That is where the lab's slider comes from: it sets the cutoff for z.
Limits: z-scores work best when normal data is roughly bell-shaped. One huge outlier can stretch the standard deviation and hide itself. Real detectors use many features at once and more robust methods, but the core idea is the same: measure distance from normal.
Where you already meet these detectors
Spam and phishing filters
Email services combine both approaches. A list of known bad links and senders catches repeat offenders. A learning model, trained on huge numbers of messages, scores everything else for spam or phishing.
It makes both mistakes. Spam in your inbox is a false negative. A real school email in the spam folder is a false positive. Marking a message as spam can help the filter learn.
A purchase from a new country
Card companies compare each purchase to your usual places, amounts, and times. A $400 purchase in a country you have never visited stands out. They may block it and text you, "Was this you?"
Your answer matters. If it was you on vacation, the system learns a little more about your normal.
A 3 AM data download
A staff account usually downloads about 20 MB in the afternoon. At 3 AM it pulls 4,000 MB. Both the time and the size are far from baseline, so the detector raises an alert.
An analyst checks. It could be a stolen password. It could also be a scheduled backup. That check is why people stay in the loop.
A login from an impossible place
A user logs in from Chicago. A few minutes later the same account logs in from Singapore. No one can travel that fast. This check is called impossible travel.
Drag the slider to change the time between the two logins.
A passenger jet flies about 900 km/h. A nonstop flight between these cities takes roughly 17 to 19 hours.
False positive warning: a VPN can make one person look like they are in another country. That is why this alert usually triggers a check, not an instant ban.
The detector says "look here." A person decides.
Many organizations have a SOC, short for Security Operations Center. It is a team that watches alerts all day. A SOC analyst takes each alert and does triage, a word borrowed from emergency rooms. It means sorting by urgency: escalate this one to senior people, ignore that one.
Why not let the AI decide everything? Analysts know things the detector does not: who is traveling, what the school scheduled, what a normal Monday looks like. They are also accountable for the decision. And what they decide can be fed back so the detector gets better.
Mini-game: be the analyst
Five alerts just came in. Open the notes on each one, then pick Escalate (send it to the senior team) or Ignore (log it and move on).
Alert queue
Good calls: 0 / 0Alert 1: login from a new country
Watchmaya.k signed in from Lisbon, Portugal at 09:02. Usual location: Chicago.
Check the notes
Maya posted in the staff chat last week that she is presenting at a conference in Lisbon. She passed the two-step sign-in check on her usual phone.
Alert 2: huge download at night
Alertstudent-files account pulled 4,200 MB at 03:12. Usual: about 20 MB in the afternoon.
Check the notes
The login came from a device the account has never used. A "reset your password" email was sent to this account two days ago and was never opened by the owner.
Alert 3: busy printer
WatchPrinter in room 204 sent 15 times more data than usual between 14:00 and 14:20.
Check the notes
The print queue shows one job from a teacher: a 300-page yearbook proof. The printer never contacted any outside address.
Alert 4: impossible travel
Alertdevon.r signed in from Chicago at 08:01, then from Singapore at 08:09.
Check the notes
Devon is not on the VPN list. The Singapore sign-in used only a password and skipped the two-step check, which is unusual for this account.
Alert 5: many failed logins, then success
Alertadmin account: 50 failed sign-ins in 1 minute, then one success, from an address in another country.
Check the notes
The admin is on vacation and has not logged in for a week. This account can change anyone's permissions.
The scenarios are made up. In a real SOC the notes come from other tools and from talking to people, which is something a detector cannot do.
Attackers use AI too
AI is a tool, and tools work for anyone. This is not a how-to. It is a quick tour of what defenders now have to expect, and the steps people take against it.
More convincing phishing
AI can write clean, personal-sounding messages with no spelling mistakes. That makes an old warning sign, bad grammar, less reliable.
Defense: check who is really asking and why, not just how the message sounds. Read How AI Is Changing Scams and Phishing.
Voice clones
With a short audio sample, AI can sometimes copy a voice well enough to fool a listener on a phone call, like a "family member" asking for money.
Defense: hang up and call back on a number you already know, or agree on a family code word. Read What Is an AI Voice Clone Scam?
Faster, wider scanning
Programs that probe computers for weak spots existed long before AI. AI can help automate and speed up some of that work, so weaknesses get found sooner.
Defense: install updates quickly, use two-step sign-in, and let detectors watch for the probing itself.
Attacks on the AI itself
The AI that defends a network can be a target. Hidden text can trick an AI that reads it, and bad training data can teach a detector the wrong lesson. Attackers may also act in ways that look normal to a detector.
Defense: treat outside text as data, check training data, and keep humans reviewing risky actions. Read What Is Prompt Injection? and What Is Data Poisoning?
An arms race
Neither side wins for good. Each improvement pushes the other side to adapt:
- Defenders build a detectorIt learns from past attacks and normal activity.
- Attackers adaptThey change tricks so old patterns no longer match.
- The detector misses somethingA new attack gets through, or looks normal.
- Defenders learn from itThe new example is added and the detector is updated.
and around again
Not hopeless: defenders know their own systems and can share what they learn with each other. Layers of protection help too. No single detector has to be perfect when several different ones, plus people, are watching.
Jobs where AI and cybersecurity meet
People who can work with both security and data are in demand. A few of the roles:
SOC analyst
Watches alerts, does triage, and decides what gets escalated.
Detection engineer
Writes the rules and builds the models that raise alerts, then tunes them to cut false alarms.
Threat hunter
Goes looking for attackers the alerts missed, using hunches and data.
Incident responder
Steps in when an attack is real: contains it, cleans up, and writes down what happened.
Security data scientist
Uses statistics and machine learning on security data, including ways to measure mistakes.
AI security researcher
Studies how AI systems can be fooled or poisoned, and how to harden them.
Good starting skills: basic programming (Python is common), how networks and logins work, a little statistics, careful reading, and curiosity. Many people begin with a computer science class and a cybersecurity club or capture-the-flag contest. Want hands-on practice? Try the CodeHS Cyber Range or explore CodeHS AI courses.
Quick answers
How is AI used in cybersecurity?
Security teams use machine learning to sort huge numbers of log lines, flag unusual logins and network traffic, filter spam and phishing, and rank alerts so people look at the riskiest ones first. People still decide what to do about each alert.
What is anomaly detection?
Anomaly detection is software that learns what normal activity looks like, then flags events that are far from normal. An anomaly is unusual, which is not always the same as harmful.
What are false positives and false negatives?
A false positive is a false alarm: the detector raised an alert but nothing was wrong. A false negative is a miss: a real attack happened and the detector stayed quiet. Making a detector more sensitive usually lowers false negatives and raises false positives.
Can AI replace cybersecurity analysts?
Not today. AI can take over repetitive sorting, but it makes mistakes, it lacks context about the people and systems it watches, and attackers keep changing their tactics. Human analysts check alerts and make the final calls.
How can students start learning AI cyber defense?
Learn basic programming and how networks work, practice reading data and spotting patterns, and try hands-on practice such as the CodeHS Cyber Range and CodeHS AI courses.
Quick quiz
1. A detector flags a teacher who logged in from a hotel while traveling. It was really the teacher. What is this called?
2. You make an anomaly detector more sensitive. What is most likely to happen?
3. Which attack is a known-bad list (rules only) most likely to miss?
Keep learning about AI and cybersecurity
Now you know how detectors work and where they fail. Next, see how attackers use AI to make scams more convincing, or practice real cybersecurity skills with CodeHS.
Related: What Is the CIA Triad?