CS 4337

studied byStudied by 3 people
0.0(0)
Get a hint
Hint

Countermeasures of Buffer Overflow Attacks

1 / 109

flashcard set

Earn XP

Description and Tags

110 Terms

1

Countermeasures of Buffer Overflow Attacks

Array bounds checking

Non-executable stack/heap

Safe C library

Compiler solutions, e.g., StackGuard, RAD

Type safe language, e.g., Java

Static source code analysis

Anomaly Detection

Code Randomization

Memory Address Obfuscation/ASLR

New cards
2

Array bounds checking

Fundamental solution for all kinds of buffer overflow attacks.

High run-time overhead.

New cards
3

Non-executable memory

Memory used by a process (program in execution) consists of different segments.
Program counter should point to the code segment, not to heap, stack, or data segments.

New cards
4
  1. TF

    Making these segments non-executable makes it impossible for an attacker to execute their malicious code that they manage to get into some stack or heap allocated buffer.

  1. T

New cards
5

Modern architecture introduces ____ to help OS manage execution permission.

the NX bit

New cards
6

Non executable Stack

Does not block buffer overflows, but prevents the shellcode from being executed

To compile a C program, just use the -z noexecstack option to mark the stack segment non-executable.

New cards
7

Shellcode:

sequence of machine code, or executable instructions, that is injected into a computer's memory with the intent to take control of a running program.

New cards
8

StackGuard

Put a canary word before each return address in each stack frame.

New cards
9
  1. TF
    When a buffer overflow attack is launched, only the return address will be overwritten

  1. F

New cards
10

Random canary:

Choose random string at startup
Insert canary string into every stack frame.
Verify canary before returning from function

New cards
11
  1. TF
    To corrupt random canary, attacker must learn current random strong.

  1. T

New cards
12

Low performance overhead

Weakness: Change the layout of the stack frame of a function. this mechanism

New cards
13
  1. TF
    Low performance overhead is not compatible with some programs, e.g., debugger.

  1. T

New cards
14

RAD

When a function is called, a copy of its return address is saved in a well-protected area.
(Return Address Defender)
Low performance overhead

New cards
15
  1. TF
    RAD is a region of memory that isn’t difficult to corrupt

  1. F

New cards
16

When the function finished, before returning to its caller:

the callee checks the return address in its stack frame to see whether the RAD has a copy of that address. If no such address in the RAD, then a buffer overflow attack is alarmed.

New cards
17
  1. TF
    RAD does not alter the structure of the stack frame, therefore, it is not compatible with unmodified debuggers.

  1. F

New cards
18

Weakness of RAD

Only protect return address

New cards
19

Type Safe Language

New cards
20

Static source code analysis

Analyze source code to find potential program statements that could result in buffer overflow vulnerabilities.

New cards
21

Weakness of static source code analysis

False positives/negatives

Difficulty to obtain source code

Limited understanding of runtime behavior.

New cards
22

Anomaly Detection

A technique used to identify

New cards
23

Code randomization

Involves randomization of the code that is executed in a process

Encrypts instructions of a process and decrypts instructions when they are prepared to be executed.
Because attackers don’t know the key to encrypt their code, their injected code can not be decrypted correctly.

New cards
24

Weakness of code randomization

Main assumption is that most attackers use injected code

Performance overhead

New cards
25

Memory address obfuscation

Introduction of random length gaps

New cards
26

ASLR

Address Space Layout Randomization
Randomizes layout of process components in main memory; hence attackers can only guess.

New cards
27

Random length gaps introduced by memory address obfuscation

Padding in stack frames

Padding between malloc allocations

Padding between variables and static data structures

random length gaps in code segments

New cards
28

DEP

Data Execution Prevention

New cards
29

EIP control

movement restricted.

Can’t jump to heap or stack

New cards
30

How can an attacker defeat DEP

Borrow bits and pieces of code that already exist in executable regions of the process

New cards
31

Orchestrating Code Execution

Assume a series of cards where each card indicated an operation to be performed.
The code for that operation is present in the executable regions of the process memory. (Binary or shared library)

New cards
32
  1. TF
    An example of orchestrating code execution is breaking complex parts down into simpler cards

  1. T

New cards
33

Trusted code

applets that originate from a trusted source could be trusted

introduced in Java 1.1

applets could be digitally signed

unsigned applets and applets signed by an untrusted principle restricted to sandbox

New cards
34

Signed applets

Containing a signature that the browser should perify through a remotely running, independent certificate authority server

New cards
35

Policy file

A configuration file used by Java Runtime Environment to determine the granted permissions for each java program.

New cards
36

Fine grained access control

Every code has access to the system resources based on what is defined in the policy file

Introduced in Java 2

New cards
37
  1. TF

    Protection domains are determined by the policy file

  1. F

New cards
38

3 pillars of Java security

Security Manager

Class Loaders

Bytecode Verifier

New cards
39

Security manager

ensured that the permissions specified in the policy file are not overriden

implements a checkPermission() method, which returns a yes or a no based on the code source and the permissions granted for that code source in the policy file.

New cards
40

Class loaders

separate name spaces

classes belong to the same name space

Established the protection domain for a loaded class

Enforce a search order that prevents trusted system classes from being replaced by classes from less trusted sources

New cards
41
  1. TF

    A class in one name space cannot access a class in another name space

  1. T

New cards
42

Class loading process

Every class loader has a “parent” class loader

New cards
43

Bytecode Verifier

Checks the code to ensure that:
Variables are initialized before they are used.

Rules for accessing private data and methods are not violated

Local variable accesses fall within the runtime stack.

The runtime stack does not overflow.

No “illegal” data conversions will occur

Bytecode instructions will have appropriately-typed parameters

New cards
44

illegal data conversions are stopped due to:

The verifier will not allow integers to serve as pointers

This ensures that variables will not be granted access to restricted memory areas.

New cards
45

Java Security APIs

JCE - Java Cryptography classes

JSSE - Java Secure Sockets Extension

JAAS - Java Authentication and Authorization Services

New cards
46

HTTP

Hypertext transfer protocol

Browser sends HTTP requests to the server

Methods: GET, POST, …

Get: To retrieve a resource (html, image, script, CSS,…)

Post: To submit a form (login, register, …)

Server replies with an HTTP response

New cards
47

Stateless request/response protocol

Each request is independent of previous requests

New cards
48

Cookies

A name/value pair created by a website to store information on your computer

New cards
49
  1. TF

    Http is a state protocol. Cookies make it stateless

  1. F

New cards
50
  1. TF

    Cookies are stored in the server

  1. F

New cards
51

JavaScript

embedded in web pages and executed inside browser

New cards
52

How XSS works

2 stages

  1. Run malicious JavaScript code in a victim’s browser, an attacker must first find a way to inject malicious code (payload) into a web page that the victim visits

  2. After, victim must visit web page with malicious code. .

New cards
53

Most common XSS Attack tags

<script> tag

<body> events

New cards
54

What does <script> tag refer to?

External JavaScript code or

can embed the code within the script tag itself.

New cards
55

What are <body> events?

JavaScript event attributes such as onload and onerror can be used in many different tags.

New cards
56
  1. TF

    An XSS payload can be delivered inside the <script> by using event attributes

  1. F

New cards
57

Client-side scripting is:

powerful and flexible, and can access several resources

New cards
58

What resources can client-side scripting access?

Local files on the client-side host (read/write local files)

Webpage resources maintained by the browser (Cookies, Document Object Model objects)

  • Steal private info

  • control what users see

  • impersonate user.

New cards
59

Types of XSS Attacks

Reflected XSS

Stored XSS

DOM-based XSS

New cards
60

Reflected XSS

1

Not saved permanently, but the malicious code will be reflected back to user.

Found in phishing attacks.

New cards
61

Stored XSS

Malicious script comes from website’s database.

New cards
62

DOM-based XSS

A convention for representing and working with objects in an HTML or XML document.

New cards
63

Impact of Reflected XSS Attacks

If an attacker can control a script that is executed in the victim’s browser, then they can typically fully compromise that user.

New cards
64

What can attackers do with Reflected XSS attacks?

View any info that the user is able to view.

Modify any info the user can modify.

New cards
65

What does a DOM-Based XSS attack result in

Steal the cookies of the user

Change the page’s behavior as the attacker like

New cards
66

Sandbox

A security mechanism for separating/limiting running programs

New cards
67

Same Origin Policy (SoP)

Browser must have a security policy to provide separation among mutually untrusted scripts.

Origin = domain name + protocol + port. (All three must be equal for origin to be considered the same.

New cards
68

What does Same original policy control?

Manipulating browser windows

URLs requested via the XmlHttpRequest

manipulating frames and documents

manipulating cookies

New cards
69

Problems with SOP

Poorly enforced on some browsers

Limitations if site hosts unrelated pages

Can be bypassed in XSS attacks

New cards
70
  1. TF

    SOP is mainly poorly enforced on new browsers

  1. F

New cards
71

Preventing XSS

Secure input handling is needed

New cards
72

2 fundamentally different ways of performing secure input handling

Encoding

Validation

New cards
73

Encoding

escape user input so that the browser interprets it as data, not code.

Involves transforming special characters in user input into their respective HTML entities. E.g., ‘<‘ becomes “&lt;” and ‘>‘ becomes “&gt;”

New cards
74

Validation

Sanitize the user input so that the browser interprets it as code without malicious intent.

Classification strategies:

  • Blacklisting: specify what isn’t allowed

  • Whitelisting: specify what is allowed

New cards
75

Popular encoding libraries

OWASP

ESAPI

Microsoft AntiXSS and PHP’s (htmlspecialchars()

New cards
76

Validate outcome:

input identified as malicious can be either rejected or sanitized.

New cards
77

Functional programming

Programming paradigm that threats computation as the evaluation of mathematical functions.

New cards
78

Pure functional programming

No side effects-

  • output of a function depends only on its input

  • Function does not change anything in the evaluation

  • Can be evaluated in any order (many times, never, etc)

More complex function based on recursion

  • No for/while cycle

  • Natural problem decomposition - mathematical induction

New cards
79

Lambda calculus

Formal theory of computation older than TM (Turing Machine)

Based on mathemetical recursive function theory.

New cards
80

Lisp

List Processing

  • early practical programming language

  • second oldest higher level language after Fortran

New cards
81
  1. TF

    Lisp is older than Fortran

  1. F

New cards
82

ML

Meta language

  • Lisp with types, used in compilers

New cards
83

Haskell

First name of Curry

standard for functional programming research

New cards
84

List of functional languages

LISP

  • Common LISP

  • Scheme

  • PLT Scheme

  • Racket

  • Clojure

ML (Meta Language) is a general-purpose functional programming language.

  • Haskell

  • Scala

  • Caml

  • OCaml

F#

Erlang

Miranda

New cards
85

REPL

Read-Eval-Print Loop

New cards
86

Racket Built-In Datatypes

Booleans:

Numbers

Characters

Strings

Bytes and Byte Strings

New cards
87

Boolean

New cards
88

Racket Syntax

Almost everything is an expression

New cards
89
  1. TF

    All expressions in Racket Syntax are represented as lists

  1. T

New cards
90
  1. TF

    Lists are always evaluated in Racket

  1. F

New cards
91

The first element of every list in Racket is:

Assumed by the compiler to be a function

New cards
92

S-Expression

Symbolic expression

Notation for nested list (tree-structured data), invented for and popularized by the programming language Lisp.

New cards
93
  1. TF

    Conventions for user defined names are less strict than traditional imperatives languages, like the C-family.

  1. T

New cards
94

What happens when we apply cons to 2 atoms?

Returns a dotted pair (cons cell)

New cards
95

TF

A dotted pair is a list

F

New cards
96

car and cdr

Take a list apart
Inverse of cons

New cards
97

car

Retrieves the first element of a list or pair.

New cards
98

cdr

Retrieves the rest of the elements of a list or pair after the first element.

New cards
99

append

Used to concatenate lists together. It takes one or more lists as arguments and returns a new list containing all the elements of the input lists concatenated together.

New cards
100

map

New cards

Explore top notes

note Note
studied byStudied by 5 people
... ago
5.0(1)
note Note
studied byStudied by 16 people
... ago
4.0(1)
note Note
studied byStudied by 10 people
... ago
5.0(1)
note Note
studied byStudied by 9 people
... ago
5.0(1)
note Note
studied byStudied by 69 people
... ago
5.0(3)
note Note
studied byStudied by 18 people
... ago
4.5(2)

Explore top flashcards

flashcards Flashcard (80)
studied byStudied by 13 people
... ago
4.0(1)
flashcards Flashcard (73)
studied byStudied by 15 people
... ago
4.5(2)
flashcards Flashcard (65)
studied byStudied by 2 people
... ago
5.0(1)
flashcards Flashcard (32)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (28)
studied byStudied by 242 people
... ago
5.0(5)
flashcards Flashcard (79)
studied byStudied by 12 people
... ago
5.0(1)
flashcards Flashcard (80)
studied byStudied by 2 people
... ago
5.0(1)
flashcards Flashcard (81)
studied byStudied by 228 people
... ago
5.0(4)
robot