SW Security CH3 CH6
SW Security CH3 CH6
Software Security
Chapter 3:
Cryptography
• It typically uses three algorithms one for key generation, another for
encryption, and one more for decryption.
Cryptography and Encryption Techniques
▪ Secret Key: is also input to the algorithm; the exact substitutions and transformations
performed by the algorithm depend on the key; larger key size means greater security but
may decrease encryption/decryption speed.
▪ Ciphertext: the scrambled message produced as output. It depends on the plaintext and
the secret key. (the coded message).
▪ Alternatively, the terms encode and decode or encipher and decipher are used instead
of encrypt and decrypt.
Cont…
o For instance, the plaintext message "I want cookies" can be denoted as the
message string <I, ,w,a,n,t, , c,o,o,k,i,e,s>.
o It can be transformed into ciphertext <c1, c2, …, c14>, and the encryption
algorithm tells us how the transformation is done.
Cont. Cryptography and Encryption Techniques
❖ Notation
▪ Given
• P = Plaintext
• C = Ciphertext
▪ C = EK(P) Encryption
▪ P = DK(C) Decryption
P = DK(EK(P))
C = EK(DK(C))
▪ Note : The two basic building blocks of all encryption techniques are substitution and
transposition.
SUBSTITUTION CIPHERS
❖ To substitute a character or symbol for each character of the original message.
❖ This technique is called a monoalphabetic cipher or simple substitution.
❖ Caesar Cipher - Early Example of a Substitution Cipher by JuliusCaesar. Named after the man who
used it.
The Caesar Cipher (the simplest and widely used)
▪ Each letter is translated to the letter a fixed number of places after it in the alphabet.
▪ Caesar used a shift of 3, so plaintext letter pi was enciphered as ciphertext letter ci by the rule
ci = E(pi) = pi + 3
▪ A full translation chart of the Caesar cipher is shown here.
Cont.
❖ Using this encryption, the message TREATY IMPOSSIBLE would be encoded as
▪ TR EATY I M PO S S I B LE
▪ wuh d w b l p s r v vl e o h
Example2:
• Encrypt the message UNIVERSISTY with the Caesar cipher with 4 as the key.
• Thus, the message is encrypted as YRIMZIVWMXC,
• Again if we d ecrypt it again using the Caesar cipher with 3 as the key;
• The Decrypted message will be give as VOFJWFSFTJZ
Advantage and disadvantages of Caesar Cipher
Advantage: it is very simple to implement
Disadvantage: Algorithm has to be secret, Once Algorithm is known all messages can be
decrypted
TRANSPOSITIONS (PERMUTATIONS)
▪A Transposition is an encryption in which the letters of the message are rearranged.
▪ With transposition, the cryptography aims for diffusion, widely spreading the information from the message
or the key across the ciphertext.
▪Transposition is a rearrangement of the symbols of a message, it is also known as a permutation.
Columnar Transpositions (the popular type)
⚫ The columnar transposition is a rearrangement of the characters of the plaintext into columns.
⚫ The following set of characters is a five-column transposition.
⚫ The plaintext characters are written in rows of five and arranged one row after another, as shown here.
THIS IS A MESSAGE TO SHOW HOW A COLUMNAR TRANSPOSITION WORKS
Cryptography Categories
▪ In Modern approaches ,There are two forms of encryption systems
▪ This method is the opposite of asymmetric encryption where one key is used to encrypt and
another is used to decrypt.
▪ During this process, data is converted to a format that cannot be read or inspected by
anyone who does not have the secret key that was used to encrypt it.
Cont.
▪ It also requires a safe method to transfer the key from one party to another.
• Block cipher: splits the plaintext into fixed sized blocks and generates fixed sized blocks of cipher
text.
Stream Cipher
• In stream cipher, one bit (byte) is encrypted at a time while
• In block cipher processes fixed-size blocks simultaneously, as opposed to a stream cipher 6 4
o r~128 bits are encrypted at a time.
▪ By making the key more longer it is also safe against brute force attacks.
▪ The longer the key the stronger security is achieved, preventing any attack.
▪ Keystream can be designed more efficiently by including more number of 1s and 0s, for
making cryptanalysis more difficult.
▪ Considerable benefit of a stream cipher is, it requires few lines of code compared to block cipher.
Cont.
Cont.
For Encryption, For Decryption,
▪ Plain Text and Keystream produces Cipher Text ▪ Cipher Text and Keystream gives the original Plain
(Same keystream will be used for decryption.). Text (Same keystream will be used for encryption.).
▪ The Plaintext will undergo XOR operation with ▪ The Ciphertext will undergo XOR operation with
keystream bit-by-bit and produces the Cipher keystream bit-by-bit and produces the actual Plain
Text. Text.
Example – Example –
Another Stream Cipher Example for Texts
• Scenario:
• Encrypt the plaintext message "HELLO" using a Stream Cipher with the following:
• Key Stream: 01101001 10110100 10001100 11101010 00011100 (Binary)
Convert plaintext to binary using ASCII.
Steps:
1. Convert Plaintext to Binary (ASCII): Each character is converted to an 8-bit ASCII value:
• H = 01001000 E = 01000101 L = 01001100 L = 01001100 O = 01001111
• Thus Plaintext in binary: 01001000 01000101 01001100 01001100 01001111
2. XOR Operation with Key Stream:
Perform bitwise XOR (⊕) operation
between the plaintext and the key
stream.
Steps to Decrypt back to the orginal plain text message
Ciphertext in binary: 00100001 11110001 11000000 10100110 01010011
Block Cipher
▪ Block cipher splits the plaintext into fixed sized blocks and generates fixed sized
blocks of ciphertext.
▪ The ciphertext is obtained from the plaintext by iterating a function F over some
number of rounds.
▪ Block cipher splits the plaintext into fixed sized blocks and generates fixed sized blocks of
ciphertext.
Example 1: Block Cipher
• Encryption
• Given:Plaintext: "HELLO123“
• Block Size: 8 bytes (64 bits).
• Key: KEY12345 (8 bytes for simplicity).
Step 1: Convert Plaintext to Binary
• Each character in the plaintext is converted to its ASCII binary equivalent
• H = 01001000 E = 01000101 L = 01001100 L = 01001100
• O = 01001111 1 = 00110001 2 = 00110010 3 = 00110011
• Step 2: Apply XOR with Key
• The key (KEY12345) is also converted to binary using ASCII:
• K = 01001011 E = 01000101 Y = 01011001 1 = 00110001
• 2 = 00110010 3 = 00110011 4 = 00110100 5 = 00110101
• Resulting encrypted binary:
00000011 00000000 00010101 01111101 01111101 00000010 00000110 00000110
• Step 3: Convert Binary Ciphertext to Hexadecimal
• Group the binary into 2 nibbles (4 bits each) and convert to hexadecimal:
• 00000011 = 0x03
• 00000000 = 0x00
• 00010101 = 0x15 Thus the Encrypted ciphertext in hexadecimal:
• 01111101 = 0x7D
• 01111101 = 0x7D 03 00 15 7D 7D 02 06 06
• 00000010 = 0x02
• 00000110 = 0x06
• 00000110 = 0x06
Decryption Example in Block Cypher
key 56 bit
1/4/2025
37
Cont.
▪ DES utilizes block cipher, which means that during the encryption process, the plaintext is broken into fixed
length blocks of 64 bits
• A block cipher processes the input one block of elements at a time, producing an output block for
each input block; larger block sizes mean greater security but reduced encryption/ decryption speed; a
block size of 128 bits is a reasonable tradeoff and is nearly universal among recent block cipher
designs.
• A stream cipher processes the input elements continuously, producing output one element at a time,
as it goes along.
▪ The key in DES is 56 bits; 8-bit out of the total 64-bit block key is used for parity check (for
example, if odd parity is used, each byte has an odd number of bits)
DES Encryption
▪ Data is divided into 64-bit blocks; the key is 56 bits
▪ The processing has three phases
▪ Phase 1
• The 64-bit plaintext passes through an initial permutation (IP) that rearranges the bits to produce the
permuted input; no elements are added or deleted or replaced, rather the order in which the elements
appear in the sequence is changed
▪ Phase 2
• The 64 bits are then divided into two 32-bit halves called L and R.
• The encryption then proceeds through 16 rounds of the same function, each using the L and R
parts, and a subkey.
• In each round, the new L part is simply a copy of the incoming R part
• The R and Subkeys are processed in the so called
✓ f-function, and exclusive-or of the output of the f-function with the existing L part to create
the new R part
▪ Phase 3
• The pre output is passed through a permutation that is the inverse of the initial permutation (IP-1),
to produce the 64- bit ciphertext
Cont.
In Summery for DES (Data Encryption Standard)
Key Points:
•Block size: 64 bits.
•Key size: 56 bits (often represented as 64 bits with 8 parity bits).
DES Decryption
▪ It uses the same algorithm as encryption, except that the application of the subkeys is
reversed.
▪ Also, the initial and final permutations are reversed.
Example of DES:
• Given: Plaintext: ABCDEFGH (64-bit block)
• Key: 133457799BBCDFF1 (in hexadecimal)
Step 1: Convert Plaintext to Binary
• Convert each character of ABCDEFGH into its ASCII binary form.
Character ASCII (Hex) Binary Representation
A 65 01000001
B 66 01000010
C 67 01000011
D 68 01000100
E 69 01000101
F 70 01000110
G 71 01000111
H 72 01001000
So the plaintext in binary:
01000001 01000010 01000011 01000100 01000101 01000110 01000111 01001000
Step 2: Encrypt Using DES
1.Initial Permutation (IP): Rearranges the bits according to a fixed permutation table.
2.16 Rounds of Feistel Function:
1. Each round uses a different 48-bit subkey derived from the main key.
3.Final Permutation (Inverse IP): Reorders the bits back to produce the ciphertext.
▪ It is very simple.
1/4/2025 47
The AES Cipher - Rijndael
▪ Designed by Rijmen-Daemen in Belgium.
1/4/2025
48
AES Requirements
▪ Private key symmetric block cipher.
1/4/2025
49
AES
▪ It is a combination of both substitution and permutation, and is fast in both software and hardware.
▪ AES is a variant of Rijndael which has a fixed block size of 128 bits, and a key size of 128, 192, or 256 bits.
1/4/2025
50
Advanced Encryption Standard (AES)
▪ The AES Encryption algorithm (also known as the Rijndael algorithm) is a symmetric block cipher
algorithm with a block/chunk size of 128 bits.
▪ It converts these individual blocks using keys of 128, 192, and 256 bits.
▪ Once it encrypts these blocks, it joins them together to form the ciphertext.
▪ It is based on a substitution-permutation network, also known as an SP network.
▪ It consists of a series of linked operations, including replacing inputs with specific outputs
(substitutions) and others involving bit shuffling (permutations).
▪ In AES the number of rounds to be carried out depends on the length of the key being used to encrypt
data. The 128-bit key size has ten rounds, the 192-bit key size has 12 rounds, and the 256-bit key size has
14 rounds.
▪ C = EKE(P)
▪ P = DKD(C)
P = DKD[EKE(P)]
▪ The two keys have the property that deriving the private key from the public key
is computationally infeasible
Cont.
▪ Proposed by Diffie and Hellman in 1976
▪ It is a revolutionary concept since it avoids the need of using a secure channel to communicate the
key
▪ It has made cryptography available for the general public and made many of today’s online
applications feasible
• Public-key algorithms are based on mathematical functions rather than on substitution and
permutation.
• Public-key cryptography is asymmetric, involving the use of two separate keys, in contrast to
symmetric encryption, which uses only one key.
• The use of two keys has profound consequences in the areas of confidentiality, key
distribution, and authentication
Cont.
▪ Properties of Public Key Cryptosystem
• If you have the private key, you can easily decrypt what is encrypted by the public key.
• Otherwise, it is computationally infeasible to decrypt what has been encrypted by the public
key.
3. If Bob wishes to send a confidential message to Alice, Bob encrypts the message using
Alice’s public key
4. When Alice receives the message, she decrypts it using her private key. No other recipient can
decrypt the message because only Alice knows Alice’s private key
At any time, a user can change its private key and publish the companion public key to replace its
old public key.
Cont.
Applications of Public-Key Cryptosystems
▪ RSA - Rivest-Shamir-Adleman
▪ DSS - Digital Signature Standard
▪ Diffie-Hellman
▪ Elliptic Curve Cryptography (ECC) algorithms
▪ You can read about Diffie-Hellman and Elliptic Curve Cryptography (ECC) algorithms
RSA (Rivest-Shamir-Adleman)
▪ The most widely used public-key cryptosystem is RSA
▪ Principle: No mathematical method is yet known to efficiently find the prime factors of large
numbers
▪ In RSA, the private and public keys are constructed from very large prime numbers
(consisting of hundred of decimal digits)
▪ Breaking RSA is equivalent to finding the prime factors: this is known to be computationally
infeasible, i.e., security is based on the difficulty of factoring large integers
▪ It is only the person who has produced the keys from the prime number who can decrypt
messages
• Asymmetric means that it works on two different keys i.e. Public
Key and Private Key.
• As the name describes the Public Key is given to everyone and the Private key
is kept private.
• An example of asymmetric cryptography:
1. A client (for example browser) sends its public key to the server and
requests some data.
2. The server encrypts the data using the client’s public key and sends the
encrypted data.
3. The client receives this data and decrypts it.
• Since this is asymmetric, nobody else except the browser can decrypt the data
even if a third party has the public key of the browser.
▪ RSA - Key Generating Algorithm
1. Choose two large prime numbers, p and q
2. Now First part of the Public key: then Compute n = pq and (phi) φ = (p-1)(q-1)
3. We also need a small exponent say e :
• Choose an integer e, 1 < e < φ, such that GCD(e, φ) = 1
• (Note: The Greatest Common Divisor of two integers is the largest positive integer that exactly
divides both integers) or e and φ are relatively prime (two integers are relatively prime if their only
common positive integer factor is 1)
4. Determine the secret exponent d, 1 < d < φ, such that φ divides (ed-1)
5. The public key is the pair of integers (e, n) and the private key is (d, n), i.e., both sender and
receiver must know the value of n.
o The sender knows the value of e, and only the receiver knows the value of d
▪ Keep all the values d, p, q and φ secret
▪ n is known as the modulus
▪ e is known as the public exponent or encryption exponent
▪ d is known as the secret exponent or decryption exponent
Cont.
▪ RSA- Encryption
▪ Sender A does the following
▪ Obtains the recipient B's public key (e, n)
▪ Represents the plaintext message as a positive integer M
▪ Computes the ciphertext C = Me mod n
▪ Sends the ciphertext C to B
▪ RSA- Decryption
▪ Recipient B does the following
▪ Uses his/her private key (d, n) to compute M = Cd mod n
▪ Extracts the plaintext from the message representative M
• Here's an overview of common attack methods for both symmetric and asymmetric
cryptography, along with strategies to prevent them.
3. Ciphertext Replay
•Attackers capture encrypted messages and resend them to impersonate the sender.
•Weakness exploited: Lack of nonce or timestamp mechanisms.
•Prevention:
• Use unique timestamps for each encrypted message to prevent replay attacks.
• Implement message authentication codes (MACs) to validate the integrity of
messages.
4. Side-Channel Attacks
•Attackers exploit information leakage from the cryptographic process, such as timing,
power consumption, or electromagnetic emissions.
•Weakness exploited: Hardware or implementation vulnerabilities.
•Prevention:
• Use constant-time algorithms to mitigate timing attacks.
• Shield devices against power and electromagnetic side-channel attacks.
Asymmetric Cryptography Attacks
1. Man-in-the-Middle (MITM) Attack
•A hacker intercepts and alters communication between two parties during key exchange.
•Weakness exploited: Lack of mutual authentication or insecure key exchange.
•Prevention:
• Use certificates and trusted Certificate Authorities (CAs) to verify public keys
(e.g., in HTTPS).
• Implement protocols like TLS, which include mutual authentication.
2. Key Theft
•Hackers steal private keys from compromised devices or servers.
•Weakness exploited: Poor storage and management of private keys.
•Prevention:
• Store private keys in secure hardware
• (e.g., Hardware Security Module (HSMs or Trusted Platform Module (TPMs).
• Encrypt private keys with strong passphrases and use access controls.
3. Weak Key Generation
•Predictable or poorly generated keys allow attackers to guess or compute private keys.
•Weakness exploited: Insufficient randomness in key generation.
•Prevention:
• Use cryptographically secure random number generators (CSPRNGs) for key
generation.
• Ensure entropy sources for randomness are robust.
4. Cryptanalysis
•Attackers use mathematical techniques to break the encryption algorithm (e.g., factoring
large numbers in RSA or breaking discrete logarithms).
•Weakness exploited: Weak or outdated algorithms.
•Prevention:
• Use modern cryptographic algorithms (e.g., RSA-2048, ECC-256, AES).
• Regularly update algorithms and protocols to counter emerging threats, like
quantum computing.
General Cryptographic Best Practices
1. Keep Keys Secret
•Symmetric keys and private keys must be securely stored (e.g., in hardware security
modules or encrypted storage).
2. Regular Key Rotation
•Periodically regenerate and redistribute keys to limit the impact of a compromised key.
3. Use Strong Cryptographic Protocols
•Adopt industry-standard protocols like TLS 1.3, SSH, or IPSec for secure communication.
4. Educate Users
•Train users to recognize phishing, social engineering, and other attacks targeting
cryptographic secrets.
5. Monitor and Audit
•Regularly audit cryptographic implementations and monitor for anomalies or
vulnerabilities.
Digital Signature
▪ A digital signature is a cryptographic mathematical technique used to validate the
authenticity, integrity, and non-repudiation of digital messages or documents.
▪ Digital signatures are the public-key primitives of message authentication.
▪ In the physical world, it is common to use handwritten signatures on handwritten or typed
messages. They are used to bind signatory to the message.
▪ Similarly, a digital signature is a technique that binds a person/entity to the digital data. This
binding can be independently verified by receiver as well as any third party.
▪ It is a cryptographic value that is calculated from the data and a secret key known only by the
signer.
▪ In real world, the receiver of message needs assurance that the message belongs to the sender and he
should not be able to reject the origination of that message.
▪ This requirement is very crucial in business applications, since likelihood of a dispute over
exchanged data is very high.
How Digital Signature Works
• Digital signatures rely on asymmetric cryptography (public-key cryptography), where a pair of keys—a
private key and a public key—is used.
Key Pair Generation:
A user generates two cryptographic keys:
Private Key: Kept secret and used for signing messages.
Public Key: Shared with others and used to verify the signature.
Signing the Message:
A hash of the message is created using a hash function (e.g., SHA-256).
The hash is encrypted with the sender's private key to produce the digital signature.
Verifying the Signature:
The recipient decrypts the digital signature using the sender's public key to retrieve the original hash.
The recipient computes their own hash of the message and compares it with the decrypted hash.
If the hashes match, the signature is valid.
Cont …
Step 2: Next, it bundles the message together with the hash digest h and encrypts it using the
Step 5: It compares the newly generated hash with the bundled hash value received along with
▪ A hash function H takes a message m of arbitrary length and produces a bit string h, h=
H(m)
▪ When the hash value h is sent with the message m, it enables to determine whether m
has been modified or not; the principal objective of a hash function is data integrity.
Cont.
▪ When a hash function is used to provide message authentication (integrity), the hash
function value is often referred to as a message digest.
▪ The two most common hashing algorithms are MD5 (Message Digest version 5) and Secure
Hash Algorithm or SHA (SHA-1 and later versions like SHA-256).
Lets more clear based on the following Scenario example
• Alice wants to send a secure message to Bob and sign it digitally.
Step 1: Key Generation
Alice generates a pair of cryptographic keys:
•A Private Key (PrivateKey_Alice) – used to sign messages.
•A Public Key (PublicKey_Alice) – shared with Bob and others to verify the signature.
• Users can query this directory to retrieve the public key of a specific person or entity.
• Directories are trusted here, with properties like Participant Registration, access and allow to modify
values at any time, contains entries like {name, public-key}.
key) to allow key exchange without real-time access to the public authority each time.
▪ The certificate is accompanied by some other info such as period of validity, rights of use, etc.
▪ All of this content is signed by the private key of the certificate authority and it can be verified by
▪ First sender and receiver both request CA for a certificate which contains a public key and
other information and then they can exchange these certificates and can start
communication.
• Advantages:
• Ensures the authenticity and integrity of public keys.
• Widely used in protocols like TLS/SSL.
• Can be verified without contacting a third party every time, as long as the certificate is trusted.
• Disadvantages:
• Requires a robust PKI (Public Key Infrastructure).
• Certificates need periodic renewal and revocation management.
Cryptography
End
Chapter 4: Application and OS Security
• Application code attacks (buffer overflow)
• Prevention:
• System design, robust coding, isolation.
• Users management
• Enforcement of security
• OS Access control, authentication
• Risk management
• Information Security
• Policies and Procedures
• Legal Issues and Information Security
• Computer Forensics
4.1 Application Code Attacks: Buffer Overflow
• Buffer overflow (also known as a buffer overrun) is a software coding error or
vulnerability that can be exploited by hackers to gain unauthorized access to corporate
systems.
• A buffer overflow occurs when:
• A program writes more data to a buffer (a fixed-size memory storage location) than it
can hold.
• Too much information is passed into a container that does not have enough space,
leading to data replacement in adjacent containers.
• The program attempting to write data to the buffer overwrites adjacent memory
locations, potentially causing program malfunction
• It is one of the best-known software security vulnerabilities yet remains fairly common.
• This vulnerability can lead to arbitrary code execution or system crashes.
• Buffer overflow attacks often target vulnerabilities in software that fail to
check or enforce boundaries when handling input data.
Example: A login system expecting a 16-character password might crash or allow
malicious access if fed a 64-character input.
• Stack-based buffer overflows: Occurs when a buffer on the stack (used for function calls
and local variables) is overflowed.
• The attacker can overwrite the return address of a function, redirecting the program’s
execution to malicious code.
• Heap-based buffer overflows: Occurs when a buffer on the heap (dynamically allocated
memory) is overflowed.
• The attacker manipulates pointers or metadata in heap memory to alter program behavior
or achieve code execution.
• Format string attack: takes place when an application processes input data as a
command or does not validate input data effectively.
• This enables the attacker to execute code, read data in the stack, or cause segmentation
faults in the application.
Consequences of Buffer Overflow
Program Crash:
• The program attempts to execute invalid instructions, causing it to crash.
Data Corruption:
• Adjacent memory regions are overwritten, leading to unpredictable behavior.
Code Execution:
• Attackers inject malicious code and manipulate the control flow to execute it.
Privilege Escalation:
• Attackers exploit vulnerabilities to gain unauthorized access or escalate
privileges
Prevention Strategies
1. System Design:
o Use bounds-checking functions.
o Implement address space layout randomization (ASLR).
o Example: Modern compilers like GCC implement stack protection mechanisms.
1. Robust Coding Practices:
o Validate input lengths and sanitize data.
o Example: Use strncpy() instead of strcpy() in C programming.
2. Isolation:
o Restrict processes to run in isolated environments,
o e.g., containers or sandboxes.
o Example: Docker containers isolate applications, preventing buffer
overflow exploits from affecting the host.
Cont…
• Bounds Checking:
•Use safer functions like strncpy instead of strcpy.
• Input Validation:
•Validate and sanitize input data length and content.
• Compiler Protections:
•Use stack canaries and ASLR (Address Space Layout
Randomization).
• Modern Programming Languages:
•Languages like Python, Java, and Rust inherently prevent buffer
overflows
4.2 User Management
• User management is a critical aspect of application and system security.
• It involves creating, managing, and controlling user accounts, their roles,
and access permissions within an application or system.
• Effective user management ensures only authorized individuals have
access to specific resources, protecting sensitive data and functionality.
• User management involves ensuring only authorized users can access
applications and systems.
Examples: Implementing role-based access control (RBAC) in a company’s software tools.
Using LDAP is best for user management
• Requiring strong passwords and multi-factor authentication (MFA).
Components of User Management
• User Authentication
• The process of verifying the identity of a user.
• Common methods:
• Username and password.
• Multi-factor authentication (MFA).
• Biometric authentication.
• User Authorization
• Defines what resources a user can access and actions they can perform based on
their roles and permissions.
• User Roles and Permissions
• Assign roles (e.g., Admin, Editor, Viewer) to users to control access.
• Roles are mapped to specific permissions (e.g., read, write, delete).
• Password Management
• Ensures secure password policies such as complexity, expiration, and
storage mechanisms
• (e.g., hashing).
• Session Management
• Manages user sessions, including session expiration, token revocation,
and secure session handling.
• Audit and Logging
• Tracks user activities for security monitoring and compliance.
Best Practices for User Management
• Secure Authentication:
• Use strong passwords and enforce MFA.
• Avoid storing plaintext passwords; use salted hashes.
• Principle of Least Privilege:
• Assign users the minimum permissions necessary to perform their tasks.
• Regular Access Reviews:
• Periodically audit and revoke unnecessary permissions or accounts.
• Session Security:
• Implement secure session cookies and enforce session timeouts.
• User Monitoring:
• Log and monitor user activities for suspicious behavior.
• Account Lockout Policies:
• Lock accounts after a certain number of failed login attempts to prevent brute-force
attacks.
4.3 Enforcement of Security
• Enforcing security policies ensures compliance with best practices and legal
requirements.
• The enforcement of security involves implementing mechanisms and
practices to protect systems, applications, and data from unauthorized access,
misuse, or breaches.
• Security enforcement ensures that policies, rules, and procedures are followed
to maintain confidentiality, integrity, and availability of resources.
Enforcement of Security…
Strategies
1. Firewalls: Prevent unauthorized access.
o Example: A firewall blocks suspicious traffic from untrusted networks.
2. Intrusion Detection Systems (IDS): Identify and mitigate unauthorized
activities.
o Example: Snort, an open-source IDS, detects network anomalies.
3. Periodic Reviews: Conduct security audits.
o Example: Regular penetration testing helps to review uncover application
vulnerabilities.
• Examples or aspects of Security Enforcement
• Authentication: Verifies the identity of users or systems before granting access.
• Methods: Passwords, biometrics, multi-factor authentication (MFA).
• Authorization: Ensures users or systems have the appropriate permissions to access
resources or perform actions.
• Techniques: Role-Based Access Control (RBAC), Attribute-Based Access Control (ABAC).
• Data Protection: Ensures sensitive data is encrypted during transmission and at rest.
• Tools: TLS/SSL, AES encryption.
• Monitoring and Auditing: Tracks system activity and generates logs for detecting and
responding to security incidents.
• Tools: Intrusion Detection Systems (IDS), SIEM (Security Information and Event
Management).
• Secure Communication: Protects data exchanges between systems or users.
• Protocols: HTTPS, SSH, VPNs., e.g: Enforce SSH configuration to disable password login
4.4 OS Access Control and Authentication
• Operating systems access control and authentication are
fundamental mechanisms to secure system resources.
• Provide mechanisms to enforce access control and authenticate
users.
• They ensure only authorized users and processes can access
specific resources while maintaining the confidentiality, integrity,
and availability of the system.
Components of OS Access Control and Authentication
1.Access Control:
• Regulates which users or processes can access files, directories, and system resources.
• Common models:
➢ Mandatory Access Control (MAC): used to enforce strict policy-based controls
• Example: SELinux: enables fine-grained security policies for processe (Security-Enhanced Linux)
➢ Role-Based Access Control (RBAC)
2. Authentication: Verifies the identity of users or systems trying to access the OS.
▪ Techniques:
➢ Password-based authentication, and Biometric authentication.
➢ Token-based authentication (e.g., smart cards, OTP).
➢ Public Key Infrastructure (PKI).
3. User and Group Management: Users are assigned unique accounts.
• Groups categorize users to simplify permission management.
4. Permissions and Privileges: Defines actions users can perform (read, write, execute).
• Root or administrative privileges provide full system control.
Best Practices for OS Access Control and Authentication
1.Use the Principle of Least Privilege:
•Grant users the minimum permissions required to perform their tasks.
2.Enforce Strong Authentication:
•Use strong passwords methods
•Implement MFA for critical accounts.
3.Regularly Audit Permissions:
•Review and revoke unnecessary permissions.
4.Monitor Access Attempts:
•Enable logging and track failed login attempts.
•Use tools like auditd or Windows Event Viewer.
5.Enable Secure Defaults:
•Disable unused accounts and services.
•Set secure file permissions by default.
4.5 Risk Management
• Is the process of identifying, assessing, and mitigating risks to protect an
organization's assets, including its data, systems, and reputation.
• Identifies and mitigates threats to application and system security.
• In the context of cybersecurity:
• It involves proactive measures to address vulnerabilities and threats while
minimizing their potential impact.
The main Steps of Risk Management
1. Risk Identification: Identify and recognizing potential risks and vulnerabilities that
could affect systems or data.
• Common risks: malware, phishing attacks, insider threats, system failures.
2. Risk Assessment: Evaluating the likelihood and assess the impact of identified risks .
• Methods: Qualitative: Categorizing risks (e.g., High, Medium, Low).
• Quantitative: Assigning numerical values to risk probabilities and impacts.
o Example: Conducting threat modeling to identify attack vectors.
3. Risk Mitigation: Implement strategies or countermeasures to reduce risk.
• Approaches: Avoidance: Eliminating the risk source.
• Reduction: Implementing controls to minimize impact.
• Transfer: Using insurance or third parties to handle risk.
• Acceptance: Acknowledging and preparing for the risk.
o Example: Encrypting sensitive data to prevent data breaches.
4. Risk Monitoring and Review : Using security tools to monitor threats.
• Continuously track systems for potential risks and evaluating the risk environment
to adapt to new threats
• Example: Using Security Information and Event Management (SIEM) tools. This
SIEM tool used for collects and analyzes security logs.
5. Risk Communication: Communicating risks to stakeholders
• Ensuring stakeholders understand the risks and the strategies in place to address them.
• Methods:
• Reports: Regular risk assessment reports for management.
• Meetings: Briefings on current risks and mitigation strategies.
• Dashboards: Real-time visualization of risk levels.
Examples of Risk Management
1. Risk Identification: Scenario: A company identifies risks associated with phishing emails.
• Analysis of Digital Evidence: The goal is to recover, reconstruct, and analyze data
from devices such as computers, smartphones, and servers.
• This includes examining files, metadata, system logs, deleted files, and even memory (RAM)
for traces of illicit activity.
• Preservation of Digital Evidence: Forensic procedures must ensure that evidence is
not modified, altered, or corrupted.
• Presentation of Evidence in Court: Forensic experts often testify in court to explain how
digital evidence was obtained, analyzed, and how it relates to the case.
o Example: Ensuring proper handling of personal data during forensic analysis.
Chapter 5
request
Browser Web
reply site
OS
Hardware Network
▪ Applications, systems, and networks can be made secure through the use of security
protocols, which provide a wide range of encryption and authentication services.
▪ Each security protocol is placed within several layers of a computing infrastructure - that
is, Data link, network, transport, and application layers. 152
Communication Channels
Internet
Client Server
Intranet
Extranet
1/4/2025 153
Cont …
MODEL
Trusted Third
Party
Security Security
Related Related
Transmition Transmition
Opponent
1/4/2025 154
Cont …
• Security Services
✓ Confidentiality
✓ Authentication
✓ Integrity
✓ Non Repudiation
✓ Access Control
✓ Availability
156
Internet Protocol Stack (TCP/IP)
▪ Protocols control the sending and receiving of messages.
✓ e.g., TCP, IP, HTTP
▪ Internet Protocol Stack (TCP/IP)
✓Application: supports network application.
• FTP, SMTP, HTTP
✓Transport: process-to-process data transfer and end-to-end reliability
• TCP, UDP (User Datagram Protocol)
✓ Network: routing of datagrams (packets) from source to destination
• IP routing protocols
✓Data Link: reliable data transfer between neighboring network
elements
• PPP (Point-to-Point Protocol), Address Resolution Protocol (ARP)
✓Physical: bits “on the wire or in the air”
157
Cont …
ISO/OSI Reference Model
▪ Presentation: allows applications to interpret meaning of data,
e.g., encryption, compression, machine specific conventions.
▪ Session: managing sessions such as synchronization, check
pointing, recovery of data exchange.
▪ Internet protocol stack “missing” these layers!
✓ These services, if needed, must be implemented in the
application layer
158
OSI model
Application Allows access to network resources.
Transport
TCP UDP
Network
ICMP IP IGMP
Link
hardware
ARP RARP
interface
Presentation Applications
Session
Segment Port
Transport TCP UDP address
Network Datagram
IP
IP address
Frame
Data Link Protocols defined by Physical
the underlying networks (MAC)
Bits
address
Physical
161
Cont …
1/4/2025 162
Discussion Question
• If an attacker learns the associated TCP state for the connection, then the connection can be
hijacked!
• Attacker can insert malicious data into the TCP stream, and the recipient will believe it came
from the original source.
• Example: Instead of downloading and running new program, you download a virus and
execute it.
165
Cont …
TCP Attacks…
Hana
Aman
1/4/2025 167
Cont …
• TCP Attacks…
• Mr. Big Ears lies on the path between Hana and Aman on the network
– He can intercept all of their packets
1/4/2025 168
Cont …
TCP Attacks…
• First, Mr. Big Ears must drop all of Hana’s packets since they must not be delivered to
Aman.
Packets
The Void
1/4/2025 169
Cont …
TCP Attacks…
• Then, Mr. Big Ears sends his malicious packet with the next ISN (sniffed from the
network)
ISN, SRC=Hana
1/4/2025 170
Cont …
• TCP Attacks…
• Why are these types of TCP attacks so dangerous?
• Malicious user can send a virus to the trusting web client, instead of
the program they thought they were downloading.
▪ IPSec provides
▪ Origin authentication
▪ Confidentiality
▪ Message integrity
▪ Key management
1/4/2025 172
Cont …
Transport Layer :
• TCP RST (TCP reset) and TCP FIN (TCP finish) attacks: these attacks are aimed at
disrupting an already established TCP connection between two hosts.
• An attacker sends a modified packet, as if it is sent from one of the communicating hosts,
with the RST flag set to restart the session.
• In a similar way, if the malicious packet’s FIN flag is set, the session is terminated and the
receiver ignores further packets from the other host.
• Thus RST flag is used to reset a connection between two devices in case of errors or
unexpected conditions. FIN flag also used to gracefully terminate a TCP connection
1/4/2025 173
Cont …
Application layer
DNS spoofing: also known as DNS Cache Poisoning) is a cyberattack where malicious actors
manipulate the Domain Name System (DNS) to redirect users to fraudulent websites
without their knowledge.
• This attack exploits vulnerabilities in the DNS system, which translates domain names .
• An attacker can change the DNS server entries in such a way that a URL is associated with
a wrong IP address.
– Ex: redirecting www. example.com to map to own (attacker’s) IP address.
(e.g., www. inu.edu.et) into IP addresses (e.g., 192.168.1.1).
• Then the user is directed to a fake website resembling the original, where login
credentials are stolen.
• The cache of a DNS name server can be poisoned with false information using some
simple techniques.
1/4/2025 174
• Prevention and Mitigation:
• DNSSEC (DNS Security Extensions):
• Uses cryptographic signatures to verify DNS data integrity and authenticity.
• Regular Cache Clearing:
• Prevents long-term storage of poisoned DNS records.
• Encryption (HTTPS/TLS):
• Ensures secure communication channels and prevents tampering.
• DNS Filtering and Monitoring:
• Detects and blocks suspicious DNS queries.
• Firewalls and IDS/IPS:
• Identifies and blocks DNS spoofing attempts.
Cont …
Application layer: E-mail Security
▪ E-mails transit through various servers before reaching their destinations.
▪ By default, they are visible by anybody who has access to the servers.
▪ SMTP protocol itself has some security holes.
▪ E-mail security can be improved using some tools and protocols.
✓ Example: PGP, S-MIME
PGP: Pretty Good Privacy
S-MIME: Secure Multi-Purpose Internet Mail Extension
1/4/2025 176
Security services within S/MIMEv3:
• Digest and hashing algorithms: these must support MD5 and SHA-1.
• Digital signature algorithms: Both sending and receiving agents must support DSA and
should also support RSA.
• Key encryption algorithms Sending and receiving agents must support Diffie-Hellman
and should also support RSA encryption.
1/4/2025 177
Cont …
Application layer: Security-enhanced application protocols
▪ Solution to most application layer security problems have been found by developing
security-enhanced application protocols
▪ Examples
✓ For FTP => FTPS
✓ For HTTP => HTTPS
✓ For SMTP => SMTPS
✓ For DNS => DNSSEC
1/4/2025 178
Common Network Security Threats
• Unauthorized Access:
• Gaining access to a network or resources without permission.
• Example: A hacker brute-forces login credentials to access a corporate network.
• Man-in-the-Middle (MITM) Attack:
• Intercepting communication between two parties to steal data or inject malicious
content.
• Example: An attacker intercepts login credentials sent over an unencrypted public
Wi-Fi network.
• Denial of Service (DoS) and Distributed Denial of Service (DDoS):
• Overwhelming a network or server with excessive requests to make it unavailable to
legitimate users.
• Example: A botnet floods an e-commerce site’s server with fake traffic, causing
downtime.
• Phishing Attacks:
• Trick users into providing sensitive information by impersonating
legitimate entities.
• Example: A phishing email with a fake VPN login page captures employee
credentials.
• Malware Propagation:
• Malicious software spreads across the network, compromising devices and
stealing data.
• Example: A worm exploits a vulnerability in unpatched devices, infecting
the entire network.
• Network Security Components and Techniques
• Firewalls:
• Act as a barrier between a trusted internal network and untrusted external networks.
• Example: A firewall blocks traffic from suspicious IP addresses or restricts access to specific
services.
• Intrusion Detection and Prevention Systems (IDPS):
• Detect and prevent unauthorized activities by monitoring network traffic.
• Example: An IDPS identifies unusual traffic spikes and blocks a potential DDoS attack.
• Virtual Private Network (VPN):
• Creates an encrypted tunnel for secure communication over public networks.
• Example: Remote employees use a VPN to securely access company resources.
• Network Segmentation:
• Dividing a network into segments to contain threats and limit access.
• Example: Critical servers are isolated in a separate VLAN, accessible only to
authorized personnel.
• Access Control:
• Restricts who can access network resources based on roles and policies.
• Example: Role-based access control (RBAC) ensures only IT staff can modify
firewall settings.
• Encryption:
• Protects data in transit by converting it into unreadable formats.
• Example: Using TLS to secure web traffic and prevent eavesdropping.
Firewalls
▪ A Firewall is a network security device that monitors and filters
incoming and outgoing network traffic based on an
organization’s previously established security policies.
▪ It provide protection against outside cyber attackers by shielding
your computer or network from malicious or unnecessary
network traffic.
▪ It can also prevent malicious software from accessing a
computer or network via the internet.
▪ The main purpose is to allow non-threatening traffic in and to
keep dangerous traffic out.
Firewalls
Cont.
Firewall – Design Goals
▪ All traffic from outside to inside must pass through the
firewall (physically blocking all access to the local network
except via the firewall).
▪ Mobile data security software protects mobile devices from data loss or corruption,
unauthorized access, and malware.
192
Cont …
▪ Mobile security focuses on protecting mobile devices (smartphones, tablets) and the sensitive
data they store from threats.
▪ Some services also protect the user from lost data through the physical device itself
become lost, stolen, or corrupted and unusable, and offer cloud backup and data
protection for this eventuality.
▪ They can also help ensure user privacy via built-in VPN capabilities and data encryption.
▪ Mobile data security software is most applicable to smartphone devices, but can also be
used for laptops, notebooks, removable media, and even IoT devices in some cases.
▪ Some products will also specialize to specific devices, such as Android or iOS-based mobile
devices.
193
Common Mobile Security Threats
• Malware: Malicious software designed to steal data, damage devices, or perform
unauthorized actions.
• Example: A banking Trojan disguises itself as a legitimate app to steal login credentials.
• Phishing Attacks: Fraudulent attempts to trick users into providing sensitive information.
• Example: A fake SMS claiming to be from a bank prompts users to click on a malicious link.
• Unsecured Wi-Fi Networks: Public Wi-Fi can expose devices to eavesdropping and man-
in-the-middle (MITM) attacks.
• Example: An attacker intercepts unencrypted data transmitted over a public Wi-Fi network.
• App Vulnerabilities: Poorly designed apps can have security flaws that attackers exploit.
• Example: A fitness app leaks user location data due to inadequate encryption.
• Device Theft or Loss: Physical loss of devices can result in unauthorized access to sensitive
data.
• Example: A lost phone with unencrypted storage exposes corporate emails.
• Outdated Software: Using devices with unpatched operating systems can leave them
vulnerable to exploits.
• Example: Attackers exploit a known vulnerability in an outdated version of Android.
• Basics in Mobile Security
• Malware Protection: Guarding against malicious apps or software.
• Example: Preventing the installation of spyware that monitors user activities.
• Application Sandboxing: Isolating app processes to prevent unauthorized access to
device resources.
• Example: Android apps run in their own sandbox to enhance security.
• Mobile Device Management (MDM): Allows administrators to secure, monitor, and
manage mobile devices in an enterprise.
• Example: Remote wiping of corporate data from a lost or stolen phone.
• Mitigation Techniques:
• Enforcing strong device passcodes or biometrics.
• Avoiding public Wi-Fi for sensitive transactions.
• Regularly updating mobile OS and apps
Mitigation Techniques:
• Use Trusted Sources for App Downloads: Download apps only from official app stores
like Google Play or Apple App Store.
• Example: Avoid sideloading apps from unknown third-party websites.
• Regular Updates: Keep operating systems and applications up to date to patch vulnerabilities.
• Example: Enable automatic updates for apps and OS.
• Enable Remote Wipe Features: Protect data by remotely erasing it if a device is lost or stolen.
• Example: Use "Find My Device" for Android or "Find My iPhone" for iOS.
• Implement Secure Authentication Methods: Use multifactor authentication (MFA) to
enhance login security.
• Example: Combine passwords with fingerprint or facial recognition.
• Avoid Public Wi-Fi: Use mobile data or secure VPNs when accessing sensitive information.
• Example: Refrain from logging into online banking over public Wi-Fi.
• Monitor App Permissions: Restrict unnecessary permissions requested by apps.
• Example: Deny a weather app access to your contacts and microphone.
Cont …
Best Mobile Data Security Software include:
▪ Lookout.
▪ ZIMPERIUM zIPS.
197
End
Chapter 6
Risk Management
Frameworks and processes
205
Risk management Process…
3. Risk mitigation: developing strategies and techniques to mitigate the potential impact of
identified risks, such as implementing control measures, transferring risk to an insurance
provider, or avoiding the risk altogether.
• Strategies include:
• Technical Controls: Firewalls, intrusion detection systems (IDS), encryption.
• Administrative Controls: Policies, training, and incident response plans.
• Example: An organization implements RBAC to prevent unauthorized data access.
4. Risk monitoring and review: monitoring the effectiveness of the risk management
strategies and reviewing the risk management plan on a regular basis to ensure that it remains
relevant and effective.
• Regularly review risks and the effectiveness of mitigation strategies to adapt to new threats.
Risk management…
Four Basic strategies/techniques of risk management treatment:
1. Risk Avoidance: Avoiding the activity or situation that poses the risk, either by not engaging
in the activity or by changing the approach to eliminate the risk altogether.
2. Risk Prevention and Reduction: Taking steps to reduce the likelihood or impact of the risk.
✓ by implementing controls or safeguards, such as security measures to minimize the chances
of the risk occurring or lessen its impact.
3. Risk Transfer: Transferring the risk to another party, such as an insurance company or a
third-party vendor if not possible to avoid or reduce
4. Risk Acceptance: Accepting the risks and developing a plan to manage them if they occur.
The cost of managing the risk is greater than the potential impact of the risk or when the risk
cannot be avoided, reduced.
207
What is Malware?
• Malware (short for malicious software) refers to software intentionally designed to
disrupt, damage/harm to computer systems, server, client networks, and even allow
attackers to gain unauthorized access to your device (computer systems).
• Malware is software that gets into the system without user consent to steal the user’s
private and confidential data, including bank details and passwords.
• They also generate annoying pop-up ads and change system settings.
• Common Objectives of Malware: Stealing sensitive information.
• Gaining unauthorized access.
• Causing disruption or destruction.
• Generating financial gain (e.g., ransomware).
• It includes worms, viruses, ransomware, spyware, trojans Adware, Rootkits, and other
malicious programs.
Why Do Cybercriminals Use Malware?
• Cybercriminals use malware, including all forms of malicious software including
viruses, for various purposes.
• Using dishonesty to induce a victim to provide personal information for identity theft
• Theft of customer credit card information or other financial information
• Taking over several computers & using them to launch DoS attacks against other networks
• Using infected computers to mine for cryptocurrencies like bitcoin.
• Some types of malware, such as ransomware, encrypt your files and demand payment to
unlock them, while spyware monitors your activities and sends the information back to the
attacker.
• Additionally, malware can spread to other devices on the same network, making it a
significant threat.
Types of Malware
Viruses
• Is a malware that attaches itself to legitimate programs or files and executes malicious
executable code attached to another executable file when the host program runs .
• The virus spreads through file-sharing, email attachments, or infected storage media as
well as when an infected file is passed from system to system.
▪ While the computer user is using the new program, the Trojan horse performs some sort of
malicious action such as opening a security hole in the system for hackers to exploit,
tampering with data, or installing keystroke monitoring software.
▪ Trojan horse varies from a virus because the Trojan binds itself to non-executable files, such
as image files, and audio files.
• Characteristics: Does not replicate on its own.
Creates backdoors for attackers.
▪ Example: Zeus Trojan: Used to steal banking credentials by capturing keystrokes and form
data from infected computers.
213
•Ransomware:
• Is a malware that encrypts files in the computer with a key that is unknown to the user on
a target's system and demands payment for decryption.
• It holds a computer system or the data it contains until the victim makes a payment.
• Ransomware encrypts
• The user has to pay a ransom (price) to the criminals to retrieve data. Once the amount is
paid the victim can resume using his/her system.
•Example:
• CryptoLocker (2013): Spread via malicious email attachments. Then they asked to
demanded Bitcoin payments for decrypting files.
Adware:
• Is a software that automatically displays or downloads unwanted advertisements (ads and
pop-ups ) on the computer to generate revenue for software distributer (attackers) when a
user is online.
• Can slow down system performance of the systems and interfere with user experience.
• Often comes bundled with other software downloads and packages.
• Example:
• Ad-injecting browser extensions that collect user browsing data.
Rootkits:
• A rootkit modifies the OS to make a backdoor. Attackers then use the backdoor to access
the computer distantly.
• It hide malicious processes and files, granting attackers persistent access to a system.
• Most rootkits take advantage of software vulnerabilities to modify system files.
• Example:
• Sony BMG Rootkit (2005): Installed on users' computers via CDs, exposing them to
additional security risks.
Summary for Differences Between Malware Types
Choice Item
1. Which of the following is NOT a type of malware? [1pt.]
A) Worm B) Virus C) Trojan Horse D) Firewall E) Ransomware F) None
Explain part
1. What are the key steps involved in the risk management process? [3pt.]
2. What are the main difference between worms, viruses, and Trojans? [3pt.]
3. Explain the difference between spyware and adware. [2pt.]