Lesson 3 of 3 Malicious Code and Activity

Countermeasures and Behaviour Analytics

Malicious code and activity are countered by layers of technical, procedural and human controls. This lesson explains malware countermeasures, containment and remediation, software security, broader countermeasures against malicious activity, and how behaviour analytics with machine learning and AI detects what signatures miss.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe malware countermeasures and software security.
  • Describe containment and remediation of malware.
  • Identify countermeasures against malicious activity.
  • Explain behaviour analytics and the role and limits of AI.

Malware countermeasures

Anti-malware software on endpoints and servers detects malware using signatures (known patterns), heuristics (suspicious characteristics) and behaviour monitoring (suspicious actions such as encrypting many files quickly). Modern endpoint protection platforms add machine learning models and exploit protection. Scanners check files at gateways: email gateways scan attachments and links, web proxies scan downloads, and sandboxes detonate suspicious files in isolated environments to observe them before delivery. Signatures and engines must update continuously, and scanning should cover servers and cloud storage as well as laptops.

Software security reduces what malware can exploit: secure development practices, code review and testing, code signing so that systems can verify software publishers, prompt patching, removal of unnecessary software, and application allow listing so that only approved programs run.

Select all that apply

Malware countermeasures

Exam skills 7.1.2 · 7.1.4

Identify effective malware countermeasures.

Log in to try this activity Interactive activities are free with an account.

Containment and remediation

When malware is found, the response follows the incident response process. Containment comes first: isolate the infected host from the network (EDR isolation or a quarantine VLAN), block the malware's command-and-control domains and file hashes across the organisation, and check whether other systems are affected using indicators of compromise.

Remediation removes the malware and its effects. Simple, well-understood infections may be cleaned by anti-malware tools, but for serious infections, especially rootkits, backdoors and anything with administrative access, reimaging from a trusted image is more reliable. Remediation also resets credentials that may have been stolen, closes the entry point (patching, blocking the phishing sender) and restores data from clean backups. Systems are monitored after remediation for reinfection.

Countermeasures against malicious activity

The outline names five broader countermeasures. The following list describes each.

  • User awareness and training: teaches people to recognise and report phishing, social engineering and suspicious activity, supported by simulations.
  • System hardening: removes unnecessary services, software and accounts, applies secure configuration baselines and restricts macros and scripting.
  • Patching: closes known vulnerabilities, prioritised by exploitation and exposure.
  • Isolation: separates systems and activities, through network segmentation, sandboxing of untrusted files, browser isolation that runs web content remotely, and quarantining of compromised hosts.
  • Data loss prevention: detects and blocks sensitive data leaving through email, web, USB and cloud channels.

These combine with least privilege, MFA, email authentication (SPF, DKIM, DMARC), egress filtering, backups and incident response. No single control stops everything; the aim is defence in depth.

Behaviour analytics

Signature-based tools detect what is already known. Behaviour analytics detects what is unusual. User and entity behaviour analytics (UEBA) builds baselines of normal behaviour for each user, host, service account and application, using data analytics (statistics over large volumes of log data) and machine learning, which learns patterns without explicit rules. It then scores deviations, such as a user accessing far more files than usual, logging in at an unusual time from a new location, a service account logging in interactively, or a server connecting to a country it never contacts.

Behaviour analytics is effective against insider threats, compromised accounts, fileless malware and novel attacks. Artificial intelligence also helps analysts triage alerts, correlate events, summarise incidents and search data in natural language. Its limitations must be managed: models produce false positives and false negatives, need representative training data, can be evaded by attackers who move slowly, and can be manipulated (for example by poisoning training data). Analysts must validate AI-generated conclusions. Attackers use AI too, for convincing phishing, deepfake voices and faster exploitation. The following comparison summarises detection approaches.

Signature-based
DetectsKnown malware and attacks
StrengthAccurate for known threats
WeaknessMisses new and fileless threats
Heuristic
DetectsSuspicious characteristics of code
StrengthSome new variants
WeaknessFalse positives
Behaviour analytics
DetectsDeviations from normal behaviour
StrengthInsiders, compromised accounts, novel attacks
WeaknessNeeds baselines; false positives; can be evaded

The following diagram shows the risk score building from individually allowed actions.

Why UEBA flagged a database administrator when no rule fired. Over three weeks she queried customer tables she had never used, at night, and copied the results to a staging folder. Each action was allowed, but together they deviated from her baseline in data, timing and staging, and UEBA accumulated them into a high risk score.
The score curve is schematic.
Scenario questions

Behaviour analytics

Exam skills 7.1.6

Use behaviour analytics to spot unusual activity.

Log in to try this activity Interactive activities are free with an account.
Worked example

Responding to an infection

An analyst confirms a remote access trojan on a finance workstation that the user had used to log in to the payment system. List the response steps.

Contain: isolate the workstation and block the trojan's C2 domains and hashes everywhere; search for the same indicators on other hosts. Remediate: reimage the workstation from a trusted image, and reset the user's passwords and payment system credentials from a clean device, because they may have been captured. Review payment system activity for fraud, find and close the entry point, and monitor the user's accounts.

Worked example

What behaviour analytics found

UEBA raises a high risk score for a database administrator who, over three weeks, queried customer tables she had never used before, at night, and copied the results to a staging folder. No rule matched any single action. Why did UEBA detect it?

Each action was allowed by her permissions, so rules and signatures did not fire, but together they deviated from her baseline: new data, unusual times and staging behaviour typical of exfiltration. UEBA scores and accumulates such deviations. The finding should be escalated and investigated with HR and legal as a possible insider threat or compromised account.

Check yourself

Why is reimaging preferred to cleaning after a rootkit infection?

Show answer

Rootkits hide and may alter the operating system or firmware, so tools running on the infected system cannot be trusted to find and remove everything.

Exam Tips

Remember for the exam

  • Contain first, then remediate; reimage after serious infections and reset exposed credentials.
  • Countermeasures: awareness, hardening, patching, isolation, DLP, in layers.
  • Behaviour analytics detects deviations that signatures miss; AI output needs human validation.