UNIT II: Malware and Vulnerability: Worms
UNIT II: Malware and Vulnerability: Worms
Adarsh Kumar
Professor, Systems, School of Computer Science, UPES, Dehradun,
Uttarakhand, India
[email protected]
1 Worms
Detection and Prevention Algorithms
Signature-Based Prevention Algorithm
Behavioral Prevention Algorithm
Network-Based Prevention
Patch Management
Access Control
Network Segmentation
Least Privilege Principle
Example Scenario: Let’s consider a simple example where D is a byte stream, and each
signature si is a sequence of bytes.
Signature Database Example:
s1 = 0x90, 0x90, 0x90 (NOP sled)
s2 = 0xDE, 0xAD, 0xBE, 0xEF (Example signature)
Example Scenario: Let’s consider a simple example where D is a byte stream, and each
signature si is a sequence of bytes.
Signature Database Example:
s1 = 0x90, 0x90, 0x90 (NOP sled)
s2 = 0xDE, 0xAD, 0xBE, 0xEF (Example signature)
Data to Scan:
D = 0x00, 0x00, 0x90, 0x90, 0x90, 0xAB, 0xCD
Example Scenario: Let’s consider a simple example where D is a byte stream, and each
signature si is a sequence of bytes.
Signature Database Example:
s1 = 0x90, 0x90, 0x90 (NOP sled)
s2 = 0xDE, 0xAD, 0xBE, 0xEF (Example signature)
Data to Scan:
D = 0x00, 0x00, 0x90, 0x90, 0x90, 0xAB, 0xCD
Matching Process:
For s1 : Scan D for the byte sequence 0x90, 0x90, 0x90.
For s2 : Scan D for the byte sequence 0xDE, 0xAD, 0xBE, 0xEF.
Example Scenario: Let’s consider a simple example where D is a byte stream, and each
signature si is a sequence of bytes.
Signature Database Example:
s1 = 0x90, 0x90, 0x90 (NOP sled)
s2 = 0xDE, 0xAD, 0xBE, 0xEF (Example signature)
Data to Scan:
D = 0x00, 0x00, 0x90, 0x90, 0x90, 0xAB, 0xCD
Matching Process:
For s1 : Scan D for the byte sequence 0x90, 0x90, 0x90.
For s2 : Scan D for the byte sequence 0xDE, 0xAD, 0xBE, 0xEF.
Result:
s1 is found at position 2 in D, so a match is detected, and appropriate action is taken.
s2 is not found in D, so no action is taken for s2 .
Example Scenario: Let’s consider a simple example where D is a byte stream, and each
signature si is a sequence of bytes.
Signature Database Example:
s1 = 0x90, 0x90, 0x90 (NOP sled)
s2 = 0xDE, 0xAD, 0xBE, 0xEF (Example signature)
Data to Scan:
D = 0x00, 0x00, 0x90, 0x90, 0x90, 0xAB, 0xCD
Matching Process:
For s1 : Scan D for the byte sequence 0x90, 0x90, 0x90.
For s2 : Scan D for the byte sequence 0xDE, 0xAD, 0xBE, 0xEF.
Result:
s1 is found at position 2 in D, so a match is detected, and appropriate action is taken.
s2 is not found in D, so no action is taken for s2 .
Note: A NOP sled is a sequence of ”No Operation” (NOP) instructions placed in the memory
area where an attacker intends to execute malicious code. Its purpose is to create a large,
contiguous region of memory that does nothing (i.e., it executes no operations), allowing the
attacker to direct the execution flow to any part of this region and still eventually reach the
malicious payload.
Limitations
Signature-Based Detection Limitations
This approach only detects known threats. It cannot identify new, unknown
threats that do not have corresponding signatures.
The efficiency of the matching process can vary based on the size of the
database and the complexity of the signatures.
Mathematical Extensions
Probabilistic Models
Some systems use probabilistic models or machine learning to improve detection
accuracy and reduce false positives.
Hash-Based Matching
Using hash functions to represent signatures and hashes of data can speed up the
matching process.
where DM (Xt ) is the Mahalanobis distance, µ is the mean vector of normal behavior, and
Σ−1 is the inverse of the covariance matrix.
Thresholding: Compare the Mahalanobis distance with a predefined threshold θ. If
DM (Xt ) > θ, the behavior is considered anomalous.
Alert Generation:
If the behavior is detected as anomalous, generate an alert or log the
event.
Preventive Actions:
Based on the severity of the detected anomaly, take preventive
actions such as blocking the process, isolating the system, or
terminating the suspicious activity.
30 400
32 420
X = 28
390
31 410
29 405
Step 1: Compute the Mean Vector
Mean of CPU Usage:
30 + 32 + 28 + 31 + 29
µCPU = = 30
5
Mean of Memory Usage:
400 + 420 + 390 + 410 + 405
µMemory = = 405
5
Mean Vector:
30
µ=
405
2 (30 − 30)2 + (32 − 30)2 + (28 − 30)2 + (31 − 30)2 + (29 − 30)2
σCPU =
4
0+4+4+1+1
= = 2.5
4
Variance of Memory Usage:
2 (400 − 405)2 + (420 − 405)2 + (390 − 405)2 + (410 − 405)2 + (405 − 405)2
σMemory =
4
25 + 225 + 225 + 25 + 0
= = 125
4
Covariance between CPU and Memory:
(30 − 30)(400 − 405) + (32 − 30)(420 − 405)
+ (28 − 30)(390 − 405) + (31 − 30)(410 − 405)
+ (29 − 30)(405 − 405)
Cov(CPU, Memory) =
4
(0)(−5) + (2)(15) + (−2)(−15) + (1)(5) + (−1)(0) 0 + 30 + 30 + 5 + 0
= = = 16.25
4 h i 4
Covariance Matrix: 2.5 16.25
Σ = 16.25 125
Adarsh Kumar Adarsh[dot]Kumar[at]ddn[dot]upes[dot]ac[dot]in February 21, 2025 12 / 88
Step 3: Anomaly Detection using Mahalanobis Distance
New Observation:
40
Xt =
480
Step 1: Compute the Deviation Vector
40 30 10
Xt − µ = − =
480 405 75
Step 2: Compute the Inverse of the Covariance Matrix
Using the formula for a 2 × 2 inverse matrix:
2
−1 1 σMemory −Cov(CPU, Memory)
Σ = 2
det(Σ) −Cov(CPU, Memory) σCPU
Determinant:
det(Σ) = (2.5 × 125) − (16.25 × 16.25) = 312.5 − 264.0625 = 48.4375
Inverse:
2.58 −0.34
Σ−1 ≈
−0.34 0.052
Adarsh Kumar Adarsh[dot]Kumar[at]ddn[dot]upes[dot]ac[dot]in February 21, 2025 13 / 88
Step 4: Compute Mahalanobis Distance
DM (Xt ) ≈ 2.05
Step 5: Compare with Threshold
Predefined threshold: θ = 2.0
Since DM (Xt ) = 2.05 > 2.0, the behavior is anomalous.
Adarsh Kumar Adarsh[dot]Kumar[at]ddn[dot]upes[dot]ac[dot]in February 21, 2025 14 / 88
Network-Based Prevention
Let:
N : Total number of nodes (hosts) in the network.
t: Time variable (continuous time).
S(t): Number of susceptible nodes at time t.
I(t): Number of infected nodes at time t.
R(t): Number of removed (recovered) nodes at time t.
λ: Infection rate (worm spread rate from infected to susceptible nodes).
δ: Recovery rate (rate at which infected nodes are removed).
dS(t)
= −λS(t)I(t) (1)
dt
dI(t)
= λS(t)I(t) − δI(t) (2)
dt
dR(t)
= δI(t) (3)
dt
dS I
= −β · S ·
dt N
Change in Infected (I):
dI I
=β·S· −γ·I
dt N
Change in Recovered (R):
dR
=γ·I
dt
Initial conditions:
S(0) = 990
I(0) = 10
R(0) = 0
I(0)
∆S = −β · S(0) ·
N
10
∆S = −0.3 · 990 · = −2.97 ≈ −3
1000
Change in Infected (I):
I(0)
∆I = β · S(0) · − γ · I(0)
N
∆I = 2.97 − 1 = 1.97 ≈ 2
Change in Recovered (R):
∆R = γ · I(0)
∆R = 0.1 · 10 = 1
Adarsh Kumar Adarsh[dot]Kumar[at]ddn[dot]upes[dot]ac[dot]in February 21, 2025 22 / 88
Updated Values at Time Step 1
∆R = 0.1 · 12 = 1.2 ≈ 1
S = 990 − 20 = 970, I = 10 + 20 = 30
S = 970 − 50 = 920, R = 0 + 50 = 50
S = 920 − 60 = 860, I = 30 + 60 = 90
S = 0, I = 810 + 40 = 850
S = 0, R = 200
Scenario
An organization with 1,000 computers is at risk of infection from a newly
discovered worm exploiting a zero-day vulnerability in a commonly used
software application.
Scenario
An organization with 1,000 computers is at risk of infection from a newly
discovered worm exploiting a zero-day vulnerability in a commonly used
software application.
Scenario
An organization with 1,000 computers is at risk of infection from a newly
discovered worm exploiting a zero-day vulnerability in a commonly used
software application.
Impact
After 1 hour: 200 computers patched, 800 computers still vulnerable.
After 2 hours: 400 computers patched, 600 computers still vulnerable.
After 3 hours: 600 computers patched, 400 computers still vulnerable.
After 5 hours: All 1,000 computers patched, no computers vulnerable.
Scenario
A multinational organization with 5,000 devices distributed across five locations worldwide faces
a threat from a worm exploiting a known vulnerability in its email client.
Scenario
A multinational organization with 5,000 devices distributed across five locations worldwide faces
a threat from a worm exploiting a known vulnerability in its email client.
Scenario
A multinational organization with 5,000 devices distributed across five locations worldwide faces
a threat from a worm exploiting a known vulnerability in its email client.
Calculation
Total Devices Patched per Hour:
Scenario
A multinational organization with 5,000 devices distributed across five locations worldwide faces
a threat from a worm exploiting a known vulnerability in its email client.
Calculation
Total Devices Patched per Hour:
Outcome
Using centralized patch management, all devices across the organization are patched within 2
hours, minimizing the risk of a worm infection.
Scenario
A healthcare organization with 2,000 devices has a critical vulnerability affecting its patient
management software. The organization decides to prioritize patching high-risk devices first.
Scenario
A healthcare organization with 2,000 devices has a critical vulnerability affecting its patient
management software. The organization decides to prioritize patching high-risk devices first.
Scenario
A healthcare organization with 2,000 devices has a critical vulnerability affecting its patient
management software. The organization decides to prioritize patching high-risk devices first.
Scenario
A healthcare organization with 2,000 devices has a critical vulnerability affecting its patient
management software. The organization decides to prioritize patching high-risk devices first.
Outcome
By prioritizing patch deployment based on risk, the healthcare organization reduces the risk of a
worm infection impacting critical systems within 24 hours while fully securing all devices within
3 days.
Adarsh Kumar Adarsh[dot]Kumar[at]ddn[dot]upes[dot]ac[dot]in February 21, 2025 46 / 88
Example 4: Emergency Patch Deployment Protocol
Scenario
A financial institution with 10,000 endpoints detects a worm exploiting a
zero-day vulnerability. An emergency patch deployment is initiated.
Outcome
The emergency patch deployment protocol patches all endpoints within 10
hours, drastically reducing the potential impact of the worm.
Adarsh Kumar Adarsh[dot]Kumar[at]ddn[dot]upes[dot]ac[dot]in February 21, 2025 47 / 88
Example 5: Cloud-Based Patch Management Solutions
Scenario
A tech company with a distributed workforce (remote) has 3,000 devices connected via the
cloud. A critical security patch is required for a newly identified worm threat.
Scenario
A tech company with a distributed workforce (remote) has 3,000 devices connected via the
cloud. A critical security patch is required for a newly identified worm threat.
Scenario
A tech company with a distributed workforce (remote) has 3,000 devices connected via the
cloud. A critical security patch is required for a newly identified worm threat.
Calculation
After 1 hour: 500 devices patched, 2,500 vulnerable.
After 3 hours: 1,500 devices patched, 1,500 vulnerable.
After 6 hours: 3,000 devices patched, 0 vulnerable.
Scenario
A tech company with a distributed workforce (remote) has 3,000 devices connected via the
cloud. A critical security patch is required for a newly identified worm threat.
Calculation
After 1 hour: 500 devices patched, 2,500 vulnerable.
After 3 hours: 1,500 devices patched, 1,500 vulnerable.
After 6 hours: 3,000 devices patched, 0 vulnerable.
Outcome
The cloud-based patch management system ensures that all remote devices are patched within 6
hours, providing effective and quick mitigation against the worm threat.
Scenario
Initial Vulnerability: 2,000 workstations are potentially vulnerable to worm infections due to
outdated third-party applications. Patch Deployment Rate: ManageEngine Patch Manager
Plus can patch 200 workstations per hour. Patching Schedule: Patches are applied overnight to
minimize disruption.
Scenario
Initial Vulnerability: 2,000 workstations are potentially vulnerable to worm infections due to
outdated third-party applications. Patch Deployment Rate: ManageEngine Patch Manager
Plus can patch 200 workstations per hour. Patching Schedule: Patches are applied overnight to
minimize disruption.
Calculation
After 1 hour: 200 workstations patched, 1,800 vulnerable.
After 5 hours: 1,000 workstations patched, 1,000 vulnerable.
After 10 hours: 2,000 workstations patched, 0 vulnerable.
Scenario
Initial Vulnerability: 2,000 workstations are potentially vulnerable to worm infections due to
outdated third-party applications. Patch Deployment Rate: ManageEngine Patch Manager
Plus can patch 200 workstations per hour. Patching Schedule: Patches are applied overnight to
minimize disruption.
Calculation
After 1 hour: 200 workstations patched, 1,800 vulnerable.
After 5 hours: 1,000 workstations patched, 1,000 vulnerable.
After 10 hours: 2,000 workstations patched, 0 vulnerable.
Outcome
By using ManageEngine Patch Manager Plus, the company can ensure that all third-party
applications across its 2,000 workstations are patched within 10 hours, reducing the risk of worm
infections exploiting known vulnerabilities.
Algorithm Steps
Input: List of vulnerabilities V = {v1 , v2 , . . . , vn }, Patch database
P = {p1 , p2 , . . . , pm }.
Output: Successfully patched systems.
1 Initialization: Set S = ∅, where S is the set of patched systems.
2 For each vulnerability vi in V :
Find corresponding patch pj in P such that pj addresses vi .
If pj is not already applied:
Apply pj to affected systems.
Add affected systems to S.
3 End For
4 Verification: Check that all systems in S have been patched
correctly.
MS17-010 (EternalBlue):
Released by Microsoft in March 2017.
Addressed vulnerabilities in the SMBv1 protocol exploited by the WannaCry ransomware worm.
Importance: Prevented the spread of WannaCry, which affected over 200,000 computers worldwide, by patching
the exploit.
Best Practices:
Regularly scan systems for vulnerabilities.
Test patches in a non-production environment before deployment.
Automate the patching process where possible to ensure consistency.
Keep a backup before applying critical patches.
Educate users about the importance of security updates.
Advantages:
Patch management is a critical component of cybersecurity.
A well-defined patch management process helps in mitigating the
risks posed by worms and other malware.
Regular updates and adherence to best practices ensure the security
and reliability of systems.
Ensures Accountability
Access control mechanisms often include logging and monitoring features that track user
activities, helping to quickly identify and isolate compromised accounts.
Algorithm Steps
Input: User request R, Access Control Policy P , User attributes U ,
Resource attributes Res.
Output: Access granted or denied.
1 Step 1: Validate the user identity U and resource Res.
2 Step 2: Check the access control policy P for user role R and
corresponding permissions.
3 Step 3: Evaluate conditions based on attributes (ABAC model):
Step-by-Step Execution
1 Validate User and Resource: Alice and critical server 01 are valid.
2 Check Access Control Policy:
Alice’s Role: System Administrator (Matches)
Resource Type: Critical Server (Matches)
Department: IT (Matches)
3 Evaluate Conditions:
Example Scenario
User Request: Alice requests access to the financial report R.
Access Control Policy: Policy P requires that only users with the role ”Manager” can access financial reports.
User Attributes: Alice’s role U.role = ”Manager”.
Resource Attributes: The resource type Res.type = ”Financial Report”.
Output: Access granted.
Since Alice’s role is ”Manager” and the resource type is ”Financial Report”, the condition is true.
4 Step 4: Log Alice’s access request and the outcome (Access granted).
5 Step 5: No alert is necessary as access is granted.
Algorithm Steps
Input: User request R, ABAC Policy Pabac , User attributes U , Resource attributes Res.
Output: Access granted or denied.
1 Step 1: Extract attributes: {U.role, U.department, U.security level, . . .} and {Res.type, Res.sensitivity level, . . .}.
2 Step 2: Match user attributes against policy:
Step-by-Step Execution
1 Extract Attributes:
4 Log Outcome: ”Access request by Bob for confidential file.txt was granted.”
5 Notify if Denied: Not required, access was granted.
Example Scenario
User Request: Bob requests access to a classified project file R.
ABAC Policy: Policy Pabac requires that the user must be in the ”Research” department and have a security level of 5
or higher to access classified project files.
User Attributes:
U.role = ”Researcher”
U.department = ”Research”
U.security level = 5
Resource Attributes:
Res.type = ”Classified Project File”
Res.sensitivity level = 4
Output: Access granted.
Example Scenario
3 Step 3: Evaluate any additional conditions defined in Pabac :
4 Step 4: Log Bob’s access request and the decision (Access granted).
5 Step 5: Since access is granted, no notification to the security monitoring system is needed.
Algorithm Steps
Input: User role U.role, RBAC Policy Prbac .
Output: Access granted or denied.
1 Step 1: Identify user’s role U.role.
2 Step 2: Retrieve permissions associated with U.role from Prbac .
3 Step 3: Check if the requested action is within the permissions:
Example Scenario
User Role: John is assigned the role of ”Network Administrator” U.role = ”Network Admin”.
RBAC Policy: The RBAC Policy Prbac specifies that the ”Network Admin” role has permissions to ”Monitor Traffic”
and ”Configure Routers.”
Output: Access granted or denied based on John’s role and the requested action.
2 Step 2: Retrieve permissions associated with the ”Network Admin” role from Prbac .
Permissions retrieved: ”Monitor Traffic,” ”Configure Routers.”
3 Step 3: Check if the requested action is within the permissions:
Algorithm Steps
Input: User U , Resource Res, DAC Policy Pdac .
Output: Access granted or denied.
Example Scenario
User: Alice requests access to a proprietary design document Res.
Resource Owner: The document is owned by Bob Res.owner = ”Bob”.
DAC Policy: The policy Pdac specifies that access is granted if the user is the owner or an admin.
Output: Access granted or denied.
Overview
Network segmentation involves dividing a network into smaller, isolated segments to limit the spread of worms and other
malicious activities. This approach enhances security by controlling traffic flow and reducing the attack surface.
Algorithm Steps
Input: Network topology N , Segmentation policy S, Traffic rules T , Security requirements R.
Output: Segmented network with defined security zones.
Overview
1 Step 4: Apply security controls R within each segment.
Implement security measures such as firewalls, intrusion detection systems, and access controls tailored to each
segment’s requirements.
Monitor(N, S, T, R)
Example Scenario
A company implements network segmentation to prevent the spread of a
worm infection. The network is divided into four segments:
Development
Marketing
Finance
HR
The aim is to contain any worm infection within a single segment and
prevent it from spreading to others.
Implementation Steps
Input: Network topology N , Segmentation policy S, Traffic rules T , Security controls C.
Output: Secured and isolated network segments.
Implementation Steps
1 Step 2: Define access rules T between segments.
Control which segments can communicate with each other.
(
Allowed if Segmenti and Segmentj are permitted to communicate
Tij =
Denied otherwise
Example:
TDev, Mkt = Allowed, TDev, Fin = Denied
C = {Firewall for Dev, IDS for Mkt, Access Controls for HR}
Monitor(N, T, C)
Numerical Example
Consider a network with the following topology and segmentation policy:
Network Topology N :
N = {A, B, C, D, E}
Segmentation Policy S:
Traffic Rules T :
(
Allowed if Segmenti and Segmentj are permitted to communicate
Tij =
Denied otherwise
For example:
T12 = Allowed, T13 = Denied, T23 = Allowed, T24 = Denied
Security Controls R:
R = {Firewalls, IDS, Access Controls}
Traffic Rules: T13 = Denied, IDS: Monitor traffic to/from Segments 1 and 3.
Traffic Rules: T24 = Denied, Access Controls: Restrict external access to segment.
Monitoring:
Monitor(N, S, T, R) = Evaluate effectiveness of segmentation and security controls.
Overview
The Least Privilege Principle dictates that users and systems should be granted the minimum level of access necessary to
perform their functions. This principle helps to limit the spread of worms and other malicious threats by minimizing the
potential damage that can be caused by compromised accounts or systems.
Implementation Steps
Input: User roles R, Resource access requirements A, Security policy P , Current access levels C.
Output: Restricted access permissions.
Implementation Steps
5 Step 4: Review and adjust current access levels C.
Audit existing permissions and adjust to align with the least privilege policy.
6 Step 5: Monitor and enforce compliance with the least privilege policy.
Continuously review access levels and adjust as necessary to maintain minimal access.
Monitor(R, A, C, P )
Implementation Steps
Input: User roles R, Resource access requirements A, Security policy P , Current access levels C.
Output: Restricted access permissions.
1 Step 1: Identify user roles R and their required access levels.
Define roles based on job functions and responsibilities.
Implementation Steps
5 Step 4: Review and adjust current access levels C.
Audit existing permissions and adjust to align with the least privilege policy.
6 Step 5: Monitor and enforce compliance with the least privilege policy.
Continuously review access levels and adjust as necessary to maintain minimal access.
Implementation Steps
Input: User roles R, Resource access requirements A, Security policy P , Current access levels C.
Output: Restricted access permissions.
Implementation Steps
3 Step 3: Define security policy P based on least privilege.
Implement access controls to enforce the least privilege principle.
Implementation Steps
4 Step 4: Review and adjust current access levels C.
Audit existing permissions and adjust to align with the least privilege policy.
5 Step 5: Monitor and enforce compliance with the least privilege policy.
Continuously review access levels and adjust as necessary to maintain minimal access.
Thank You!