AP Cybersecurity · Study guide

Leveraging AI in Cyber Defense

AP® Cybersecurity · Unit 1 · Human-Centered Threats, Authentication & AI Defense

Leveraging AI in Cyber Defense

How defenders use AI tools to review security settings, find flaws in code, and write detection rules, and why a person must check every suggestion.

1Why defenders use AI

Attackers use AI, and so do defenders. A security team may be responsible for thousands of firewall rules, millions of lines of code, and a constant flood of activity records. AI tools can read through all of it quickly and point out what looks risky. That lets a small team cover far more ground.

Three jobs where AI helps defenders:

  • Reviewing security configurations, such as firewall rules and access controls, and recommending safer settings.
  • Analyzing application code to find vulnerabilities and recommend fixes.
  • Suggesting rules for automated detection systems, the tools that watch for attacks.

In all three, the AI tool makes recommendations. A knowledgeable person reviews each one before it is put in place.

Figure 1. Every AI recommendation in defense passes through a knowledgeable human before it changes anything real.

2Reviewing security settings

A security configuration is the set of settings that decides what is allowed. Two common kinds:

  • Firewall rules: a list that decides which network traffic is allowed in or out. Rules are usually checked from top to bottom, and the first rule that matches decides.
  • Access controls: settings that decide who can open, change, or delete which files, folders, and systems.

Over time these settings pile up. Someone adds a quick fix and forgets it; an employee changes jobs but keeps old access. An AI tool can read the whole list and flag problems: rules that allow far too much, rules that can never take effect, accounts with access they no longer need.

Here is a small firewall rule list an AI tool might review:

Firewall rules, checked top to bottom
Rule 1: ALLOW  from any             to web server   port 443 (HTTPS)
Rule 2: ALLOW  from any             to web server   port 80 (HTTP)
Rule 3: ALLOW  from any             to any          port any
Rule 4: ALLOW  from office network  to file server  port 445 (file sharing)
Rule 5: DENY   from any             to any          port any
Figure 2. A broad “allow” high in the list hides every rule below it. AI review tools are good at spotting this pattern across thousands of rules.

An AI review would likely flag Rule 3: it allows any traffic from anywhere to anywhere. Because rules are checked in order, everything that reaches Rule 3 is allowed, so the “deny everything else” Rule 5 never gets a chance. It might also flag Rule 2, which allows unencrypted web traffic.

The AI cannot know why Rule 3 was added. Maybe someone added it while fixing a problem and forgot it, or maybe a system really depends on it. A security technician who knows the network checks before anything changes.

3Finding flaws in code

Applications are built from code, and code has mistakes. Some mistakes are vulnerabilities that attackers can use. AI-powered tools can scan large amounts of code, point to risky lines, explain the problem, and suggest a fix.

An AI tool flags a risky line and suggests a fix
# Risky: the user's typed name goes straight into the database command
query = "SELECT * FROM students WHERE name = '" + typed_name + "'"

# Safer: the database treats the typed name only as data, never as a command
query = "SELECT * FROM students WHERE name = ?"
run(query, [typed_name])

In the risky version, whatever a user types becomes part of the command the database runs, so a cleverly written “name” could change what the command does. The suggested fix keeps the user's input separate from the command. A programmer still reviews it: the fix has to match how the rest of the program works, and AI tools sometimes suggest fixes that break something else or miss a related flaw nearby.

4Suggesting detection rules

A detection rule tells an automated system what to watch for and when to raise an alert. For example: alert when one account has more than 10 failed logins within one minute. AI tools can study past attacks and normal activity and suggest new rules, or point out attacks that current rules would miss.

A detection engineer, the person who builds and tunes these rules, reviews each suggestion. A rule that is too sensitive buries the team in false alarms (alerts about harmless activity). A rule that is too loose lets real attacks through. Only someone who knows what normal looks like on that network can judge the balance.

Where AI helpsWho reviews before it is usedWhat they check
Firewall rules and access controlsA knowledgeable security technicianIs the change correct? Will it block something the organization needs?
Application codeA knowledgeable programmerIs the flaw real? Does the fix work without breaking other features?
Detection rulesA knowledgeable detection engineerWill it catch the attack? How many false alarms will it cause?

5Why a human always checks

AI tools make mistakes, and they make them confidently. They may misread what a setting is for, invent a fix that does not work, or miss the business reason a rule exists. They do not know the organization: which server must stay reachable for the payroll system, which old program cannot handle a change, which odd-looking activity is a normal monthly job.

A wrong security change can cause real harm: blocking the hospital's records system, locking every teacher out of the gradebook, or opening a door that was meant to stay shut. So the rule is: AI recommends, a knowledgeable person reviews, and only then is the change made.

The key idea

AI makes defenders faster, not unnecessary. It finds the needles in the haystack; a person who understands the system decides what to do with each one.

6Worked examples

Worked Example 1 Configuration review

The rule that allows everything

An AI tool reviews the firewall rule list shown above and recommends deleting Rule 3. What should the security technician do?

  1. 1
    Confirm the AI's reasoning: Rule 3 allows any traffic, and because rules are checked top to bottom, Rule 5 (deny everything else) can never apply to traffic that Rule 3 matches. The AI is right that this is risky.
  2. 2
    Find out why Rule 3 exists. Check change records or ask the team. Maybe it was added during an outage and never removed.
  3. 3
    Check what depends on it: are there services that only work because of Rule 3? If so, write narrow rules for those first.
  4. 4
    Make the change, test it, and watch for anything that breaks.
Answer: Agree with the finding, but investigate, replace with narrow rules if needed, then remove Rule 3. The AI found the problem; the technician makes the change safely.
Worked Example 2 Configuration review

The access the AI wanted to remove

An AI tool reviews access controls at a school and recommends removing a counselor's access to the student-records folder, because the counselor has not opened it in 11 months. What should happen?

  1. 1
    The AI is applying a sound idea: people should have only the access they need.
  2. 2
    But the AI does not know the school calendar. Counselors use those records heavily during college-application season, which may not have started yet.
  3. 3
    A technician checks with the counselor's supervisor before removing anything.
Answer: Treat it as a question, not an order. A person who knows how the school works decides whether the access is still needed.
Worked Example 3 Detection rule

Tuning a suggested rule

An AI tool suggests a detection rule: alert when any account has more than 10 failed logins in one minute. The detection engineer knows that the school's shared library computers often see bursts of typos as many students log in at the start of class. What should the engineer consider?

  1. 1
    The rule targets a real sign of password guessing: many failures in a short time.
  2. 2
    On shared library computers, many students failing logins at once could trigger it every morning: false alarms.
  3. 3
    Possible adjustments: count failures per account rather than per computer, add a check for unusual source addresses, or handle the library computers separately.
Answer: The suggestion is a good starting point. The engineer tunes it so it catches attacks without flooding the team with harmless alerts.
Worked Example 4 Code review

The fix that broke search

An AI tool finds a flaw in a website's search feature and suggests a fix. A programmer applies it without review. The flaw is gone, but searches with apostrophes (like “O'Brien”) now fail. What went wrong?

  1. 1
    The AI's fix addressed the security flaw but did not account for how the search feature had to work.
  2. 2
    No knowledgeable programmer tested it against normal use before it went live.
  3. 3
    A review would have caught the broken case and adjusted the fix.
Answer: Skipping human review turned a security fix into a broken feature. Recommendations are reviewed and tested before they are used.

7Common mistakes

Common Mistake 1 · Applying AI recommendations automatically

Every recommendation needs review by someone who knows the system: a security technician for settings, a programmer for code, a detection engineer for detection rules.

Common Mistake 2 · Assuming AI understands the organization

AI sees settings and code, not the reasons behind them. It cannot know that a rule supports payroll or that records are only used in one season.

Common Mistake 3 · Thinking AI replaces security staff

AI speeds up reviewing and spotting. People still decide, test, and take responsibility for changes.

Common Mistake 4 · Trusting a confident explanation

AI tools explain wrong answers as smoothly as right ones. Check the reasoning, not just the tone.

Explain a defensive use of AI like this

“An AI tool can review the firewall rules and flag Rule 3, which allows all traffic and prevents the final deny rule from ever applying. Before anything changes, a knowledgeable security technician should confirm the finding, check whether any service depends on the rule, and test the change, because the tool does not know how the network is used.”

Say what the AI tool does, what it recommends, and who must review the recommendation before it is used.