All Files in ‘SENG406 (2022-S2)’ Merged

01. Principles

Security is a process, not a product

Bruce Schneier

Course

SENG406: brand-new course.

Assessment items:

Description Marks Due date
OWASP threat model (small groups) 10% Week 4
Secure coding (improved codebase from lab) 20% Week 6
Literature review (individual) 20% Week 8
Security audit (open source software) 20% Week 12
Final exam (in-person) 30% N/A

Exam will cover mainly content covered in class. Additional resources covered in class are examinable.

Lecture content:

Weeks 11, 12: time for final assignment.

Labs:

Software security is different from software engineering in general in that new attacks, threat vectors, and actors are coming out all the time, making it critical that we stay up to date. We must be proactive and ensure we are constantly monitoring the systems.

This course is about:

It is not about:

Log4j:

Group discussion

Scenario:

Vulnerability discovered in GPS library (fix ready, assume similar to log4j):

  1. What information do you need to evaluate the impact of the vulnerability?
  1. What action plan would you put in place?
  1. Postmortem

Step 1, first response:

Step 2, communication:

Step 3, postmortem:

Security Engineering

Six goals:

Terminology:

Security violations and attacks:

Risk assessment:

02. Threat Modeling

‘Classic’ plan-based process:

Secure development lifecycle (SDLC):

It is wrong to assume that if you can’t measure it, you can’t manage it - a costly myth

W. Edwards Deming

e.g. how well-trained are users in detecting phishing attempts? Even if you can’t measure it, you can still implement training.

Security assessment:

Architecture:

Modelling data flows:

                                       Trusted Space
                                     |
                         _____       
---------    data      /       \     | sanitized     ----------
| Actor |  ------->   | Process | ----------------->  Database
---------              \       /     |   data        ----------
                         -----  
                                     |
Element Spoof. Tamper. Repudiat. Info. Discl. DoS Priv. Elev.
Data flow x x x
Store x x x
Process x x x x x x
Actor x x

Software detailed design:

Development and coding:

Release and deployment:

OWASP Threat Modeling Process:

Uber Eats Scenario:

03. Attack Tactics

Adversaries:

Targeting individuals is harder than targeting everyone:

Psychology Aspects

The User

Education:

Ability to detect deception:

Behavioral Economics

Present bias and hyperbolic discounting:

Defaults and ‘choice architecture’:

Privacy control settings give people more rope to hang themselves

George Loewenstein

Intentionality and cognition

Education must be fit for audience:

Deception Techniques

Common sales techniques:

Stajano and Wilson’s 7 principles of scam (2011):

User Credentials

Passwords

Passwords:

Advanced tools to safely reuse accounts:

Password recovery is not just a ‘send a magic link’

Good password practices:

Memorability (Yan et al., ‘Password memorability and security, empirical results’, 2004):

Guidelines and real life:

Non-phishing Attacks

(Automated) systems to get illegitimate access to a particular account:

(Automated) systems to get details of all accounts:

(Automated) systems to block accounts:

If your encryption, OS and network security mechanism are trusted, it comes down to two factors:

Security and Organization

Security players:

Types of malware:

Knowledge Bases

Mitre Att&ck:

Tactics:

Assignment

04. Web Communications and Vulnerabilities

News of the week

https://www.socialmediatoday.com/news/twitter-reports-new-security-flaw-which-has-led-to-the-exposure-of-54-mill/629037/

Feature: connecting to people whose email and phone number you know.

Flaw allowed association of anonymous accounts with emails and phone numbers.

Introduced June 2021, disclosed after 6 months by security researcher, announced August 2022.

Web Communication

Encryption works. Properly implemented strong crypto systems are one of the few things that you can rely on. Unfortunately, endpoint security is so terrifically weak that NSA can frequently find ways around it.

Edward Snowden

Encryption works. The problem is everything else.

OSI model protocols:

URL format:

   Unqualified hostname
          |--|
  https://foo.bar.example.com:443/some/path/to/a/file?query=cat
  |___|       |   |_________|
 Scheme       | Second-level domain
              |_____________|
                 Subdomain

OWASP Top 10

Open Web Application Security Project

A07:2021 – Identification and Authentication Failures

Insecure Design

Security flaws caused by:

Secure design lifecycle as a drier:

05. Secure Coding Principles

OWASP Top 10 (Class)

  1. Broken Access Control:
  1. Cryptographic failure:
  1. Injection attack:
  1. Insecure Design
  1. Security Misconfiguration:
  1. Vulnerable Components
  1. Authentication Failure
  1. Security Logging/Monitoring Failures
  1. Server-side request forgery

Unsafe Constructs

See OWASP Secure Coding Practices

TOCTOU Race

When there is a time lapse between time-of-check to time-of-use:

Overflow Issues (Mostly C/C++)

This may cause the system may crash or read garbage data. However, an attacker may be able to exploit this.

Weak type safety: C will silently convert integers by keeping the least significant bits. After overflow of a signed integer, the value will be the maximum negative number.

Pointer arithmetic:

Buffer overflow and NOP slide:

Coding practices:

06. Cryptography 101

Anyone who tries to create his or her own cryptographic primitive is either a genius or a fool. Given the genius/fool ratio of our species, the odds aren’t very good.

Bruce Schneier

Current Events: Experian

Experian: US credit score service.

Past month:

Principles

Security protocols are more than passwords.

At the core, security protocols are about preventing malicious people from doing bad things.

Security protocols exist outside of software:

Eavesdropping risks:

Simple Authentication Principle

Notation:

TG:T,{T,N}KT T \rightarrow G : T, \left\{ T, N \right\}_{KT}

Where:

The nonce is used to prevent replay attacks.

Challenge and Response

Often used by car transponders:

ET:NTE:T,{T,N}KT \begin{aligned} E \rightarrow T &: N \\ T \rightarrow E &: T, \left\{ T, N \right\}_{KT} \end{aligned}

Where:

Early 2FA

SU:NUP:N,PINPU:{N,PIN}KUS:{N,PIN}K \begin{aligned} S \rightarrow U &: N \\ U \rightarrow P &: N, \text{PIN} \\ P \rightarrow U &: \left\{ N, \text{PIN} \right\}_K \\ U \rightarrow S &: \left\{ N, \text{PIN} \right\}_K \end{aligned}

Where:

Physical 2FA Devices

A physical device is used to generate authentication numbers:

Generation algorithm (protocol):

Reflection Attack

Adversary finds a legitimate ‘password’ generator and then performs a MITM attack.

SA:NAU:NUA:{N}KAS:{N}K \begin{aligned} S \rightarrow A &: N \\ A \rightarrow U &: N \\ U \rightarrow A &: \left\{ N \right\}_K \\ A \rightarrow S &: \left\{ N \right\}_K \end{aligned}

Where:

Failures

Failures are often in the protocol:

Reducing the amount of failures:

General Encryption Principles

C=E(P,K)P=D(C,K)P=D(E(P,K),K) \begin{aligned} C =& E(P, K) \\ P =& D(C, K') \\ P =& D(E(P, K), K') \end{aligned}

Where:

Examples:

Cipher Examples

Ceasar Cipher:

Vernam cipher:

Playfair block cipher:

Feistel cipher:

Hash functions and control keys:

Key Management

User-defined keys are relatively weak:

Public key infrastructure:

07. Access Control and Policies

Restricting access to the system.

Christchurch hot pools: stored proof of residence (driver’s license, passports) in system; had vulnerable plugin which allowed hacker to access this data. NZ privacy laws: data was not needed after initial verification, so they should have destroyed the data instead of storing it.

Early Memory Access Model

Processes are isolated from each other:

Relies on a privileged bit to control access to the descriptor register. It must be stored in read-only memory.

Limitations:

Multics

Each process has an array of segment descriptors:

This allowed the creation of an access control matrix:

Exercise: Assignment 2

Unix - Discretionary Access Control

Everything is a file.

Is directory
|
v | user | group | other |
d | rwx  |  rwx  |   rwx |
      ^       ^        ^
      |       |        |
setuid (s) setgid (s) t-bit (t)
Special bits replace the execute bit

Mandatory Access Control

Security policies are not under the user (or even admin’s) control. In comparison, discretionary access control gives owners (e.g. creator of the file) full control.

This was:

Influenced other access control mechanisms:

Rings of protection:

Windows

Access control appeared in Windows NT (NB: UC’s domain is UOCNT):

Can create domains of users:

Lots of users, lots of permissions, lots of programs: a nightmare for admins, and incorrect permissions being assigned (and possibly even just giving admin access to everyone).

Take two:

Attack surface hardened with a closed kernel, TPM added, and most drivers were removed from the kernel:

Cleaner abstractions with principals and objects:

Web Browsers

Reign of cookies:

Security measures:

Cross-origin:

Hardware-level Protection Mechanisms

08. Monitoring and Detecting Intrusions

Simplicity is the ultimate sophistication

Intrusion detection systems: IDS

In recent news: Microsoft Teams GIFShell Attack

Convince user to install a stager. Once done:

Hardware

Hardware-level Protection Mechanisms

Intel requires that privilege level can only be changed by kernel processes:

ARM uses TrustZone to:

Hardware sandboxing with CHERI (ARM):

Issues with enclaves:

Mobile Platforms

OS:

App management:

Permissions:

Monitoring and Response

MAPE-K control loop

(Monitor, Analyze, Plan, Execute), Knowledge.

Circa 2003, need for autonomic managers overlooking the functioning of running systems:

Using a knowledge source (log files, system events):

Exercise: MAKE-K on Assignment 2 Codebase

Quality attributes:

Base Rate Fallacy

Assuming that ‘interesting’ events are uncommon:

People cannot go through a thousand events to find the one true positive:

Intrusion Detection Systems

These can be categorized into three main techniques:

Factors to consider:

Snort:

All IDSes have a pipe-and-filter architecture, with the fastest, most basic rules being applied first to remove the most obvious bad packets.

Networking

LANs:

Ethernet:

TCP:

DDoS:

IDSs contain rules to detect suspicious activities:

DNS poisoning:

09. Data Privacy and Sovereignty

Current Events: GitLab RCE

Any user with a login could remotely execute code through the GitHub import feature.

Patched in 15.3.1/15.2.3/15.1.5

Communication:

Current Events: Optus Hack

2nd largest telecommunications company in Australia. 5 million drivers’ license/passports stolen.

Broken access control: faulty API which allowed the attacker to dump a large amount of data.

Initially released 10K entries as proof and requested million dollar ransom; apparently changed their mind and deleted the data.

Data Privacy

NZ Data Privacy Act 2020:

NZ Google Street View Wi-Fi collection (2010):

EU GDPR:

digital.govt.nz on GDPR:

While the GDPR imposes additional obligations on agencies, and provides additional privacy rights to EU residents, an agency is likely to comply with most of its obligations under the GDPR if it complies with the Privacy Act.

No…

Web Usability Standard 1.3

ISO 27000:

NZ Information Security Manual:

OWASP Secure Code Review Guide V2:

OWASP Secure Coding Practices Quick Reference Guide V2:

Secure Code Review Best Practices:

Penetration testing on live systems:

Māori Data Sovereignty:

Patriot Act (9/11), CLOUD Act (2018):

China National Intelligence Law:

Local legal agreements can prevent data transfer:

VPNs vs Tor: