P1:L2 Software Security Flashcards

1
Q

Buffer (or memory) Overflow

A

A common and persistent vulnerability

In information security and programming, a buffer overflow, or buffer overrun, is an anomaly where a program, while writing data to a buffer, overruns the buffer’s boundary and overwrites adjacent memory locations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Stack buffer overflows

A

In software, a stack buffer overflow or stack buffer overrun occurs when a program writes to a memory address on the program’s call stack outside of the intended data structure, which is usually a fixed-length buffer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

stacks are used

A
  • In function/procedure calls
  • for allocation of memory for
    • local variables
    • parameters
    • control information (return address)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Vulnerable password checking program

A

Not good to hardcode password in code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Push and pop

A
Push = Stack grows
Pop = Stack shrinks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Password check code quiz

A
Too much data gets stored in the variable for int
Remember memory (or buffer) overflow

So… variable could possible be different from 0

Bad input caused a manipulation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which vulnerability applied to the code in example quiz?

A

The code did not check the input and reject password strings longer than 12 bytes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Creates a shell which allows it to execute any code the attacker wants

A

Shell Code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

ShellCode

A

Has to be stored in memory… instructions… assembler language.. translated into machine code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Whose privileges are used when attacker code is executed?

A
  • The host program’s
  • System service or OS root privileges

“Keys to the kingdom”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How many CVE vulnerabilities does NVD have?
NVD = National Vulnerability Database
CVE = Common Vulnerability and Exposure)

A

Close to 70,000

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How many buffer overflow vulnerabilities reported in the last 3 months

A

Close to one hundred

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How many buffer overflow vulnerabilities in last 3 years?

A

Over a thousand

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The return address is overwritten to point to a standard library function

A

Return-to-libc (write type)

This is a type of Buffer Overflow (a variation of)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Data stored in the heap is overwritten. Data can be tables of function pointers.

A
Heap Overflows (write type)
(another variation of Buffer Overflow)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Read much more of the buffer than just the data, which may include sensitive data

A

OpenSSL Heartbleed Vulnerability - a read-only overflow vulnerability which is dangerous if sensitive data is exposed.
(once again, another type of Buffer Overflow)

17
Q

Good defenses against Buffer Overflow Attacks

A
*Programming language is crucial
The language should be....
     *strongly typed
     *automatic bound checks
     *Automatic memory management
18
Q

Examples of “Safe languages”

A

Java, C++

OO languages make the problems above go away

19
Q

Why are some languages safe?

A

Buffer overflow becomes impossible due to runtime system checks

20
Q

What are drawbacks of secure languages?

A

Possible performance degradation

21
Q

What if you are stuck with language that does not auto check? Usage language that does not prevent buffer overflows?

A
  • Check input (ALL input is EVIL!)
  • Use safer functions that do “bounds checking”
  • Use automatic tools to analyze code for potential unsafe functions.
22
Q

Strongly or Weakly typed?

Any attempt to pass data of incompatible type is caught at compile time or generates an error at runtime.

A

Strongly

23
Q

Strongly or Weakly typed?

An array index operation b[k] may be allowed even though k is outside the range of the array.

A

Weakly

24
Q

Strongly or Weakly typed?

It is impossible to do “pointer arithmetic” to access arbitrary area of memory.

A

Strongly

25
Q

Analysis tools…

A
  • Can flag potential unsafe functions/constructs

* Can help mitigate security lapses, but it is really hard to eliminate all buffer overflows

26
Q

Stack canaries

A

When a return address is stored in a stack frame, a canary value is written just before it. Any attempt to rewrite the address using buffer overflow will result in the canary being rewritten and an overflow will be detected.

27
Q

ASLR

Address Space Layout Randomization

A

Randomizes stack, heap, libc, etc… This makes it harder for the attacker to find important locations (e.g. libc function address)

28
Q

Non-executable stack

A

Can be used with ASLR - This solution uses OS/harwdare support.

29
Q

Do stack canaries prevent return-to-libc buffer overflow attacks

A

Yes

Relies on re-writing return address… the canary will detect to see if the return-stack is modified

30
Q

Does ASLR protect against read-only buffer overflow attacks

A

No

Makes it harder to guess where certain variables are… but does not prevent 100%

31
Q

Can the OpenSSL geartbleed vulnerability be avoided with non-executable stack?

A

No

A read-only overflow: Doesn’t need to execute… only needs to read.