CS4630 Spring 2021 exam



final exam

Answer each of the following questions. This exam is open-book and open-notes, but you may use only resources that were created before this exam was released (at 9pm eastern time on 12 May 2021). You may not collaborate with other students.

Please show your work for questions in the comments field were applicable so we are able to give you partial credit.

If you think a question is ambiguous or unclear, please make your best guess about what was meant and explain what you did in the comments field for the question. We are unlikely to be able to answer your inquiries during the exam time.

Some viruses infect executables by compressing the original executable and creating a wrapper that that runs the virus code, then decompresses and runs the executable.

Question 1 (4 pt) (see above)

Which of the following antivirus techniques likely motivated this virus design? Select all that apply.

  1. likely that wrapper has a signature that can be found in the beginning of the new executable

  2. common metadata to check would include file sizes

Regrade request

One potential technique for viruses to infect executable files is to scan for the machine code that corresponds to a call instruction and replace it with a call to inserted virus code.

In x86-64, one encoding of the call instruction consists of the opcode byte E8 (hexadecimal) followed by a 32-bit signed offset from the address of the first byte of the instruction following the call. So one way a virus could apply this scheme would be to search the executable for an E8 byte followed by a 32-bit signed number that would make the destination address remain within the executable. It would then replace that instruction with a call to virus code.

Question 2 (4 pt) (see above)

Which of the following are true about the scheme proposed above for finding and replacing x86-64 call instructions? Select all that apply.

  1. could change a call that is very rarely run or some E8 that's not call

  2. while a pattern could match the modified call instruction, it would also match just about any executable, since there aren't fixed aspects of the modified call instrction that don't appear in normal call instructions. The virus code might still be detectable for other reasons, but that's not what this question is asking about (it reads "**this scheme*** allows the virus to be deteced" NOT "the virus may be detected").

Regrade request
Question 3 (4 pt) (see above)

Suppose a virus replaced a call instruction located 0x1d59 bytes from the beginning of an executable that appears in objdump disassembly output like:

  401d59:       e8 d7 ff ff ff          callq  401d35

with a call to the virus code encoded that appears in objdump output as follows:

  401d59:       e8 40 41 00 00          callq  405e9e

What would be an appropriate instruction or instructions to add to the end the virus code to allow the executable to appear to run without minimal disruption?

Regrade request
Question 4 (4 pt)

Viruses that append their virus code to an executable can often be detected based on changes made to the list of segments in an executable's headers.

Consider the following executable headers:

a.out:    file format elf64-x86-64
a.out
architecture: i386:x86-64, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0000000000401c10

Program Header:
    LOAD off    0x0000000000000000 vaddr 0x0000000000400000 paddr 0x0000000000400000 align 2**12
         filesz 0x0000000000000518 memsz 0x0000000000000518 flags r--
    LOAD off    0x0000000000001000 vaddr 0x0000000000401000 paddr 0x0000000000401000 align 2**12
         filesz 0x000000000009375d memsz 0x000000000009375d flags r-x
    LOAD off    0x0000000000095000 vaddr 0x0000000000495000 paddr 0x0000000000495000 align 2**12
         filesz 0x0000000000026650 memsz 0x0000000000026650 flags r--
    LOAD off    0x00000000000bc0c0 vaddr 0x00000000004bd0c0 paddr 0x00000000004bd0c0 align 2**12
         filesz 0x0000000000005170 memsz 0x00000000000068c0 flags rw-
    NOTE off    0x0000000000000270 vaddr 0x0000000000400270 paddr 0x0000000000400270 align 2**3
         filesz 0x0000000000000020 memsz 0x0000000000000020 flags r--
    NOTE off    0x0000000000000290 vaddr 0x0000000000400290 paddr 0x0000000000400290 align 2**2
         filesz 0x0000000000000044 memsz 0x0000000000000044 flags r--
     TLS off    0x00000000000bc0c0 vaddr 0x00000000004bd0c0 paddr 0x00000000004bd0c0 align 2**3
         filesz 0x0000000000000020 memsz 0x0000000000000060 flags r--
0x6474e553 off    0x0000000000000270 vaddr 0x0000000000400270 paddr 0x0000000000400270 align 2**3
         filesz 0x0000000000000020 memsz 0x0000000000000020 flags r--
   STACK off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**4
         filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw-
   RELRO off    0x00000000000bc0c0 vaddr 0x00000000004bd0c0 paddr 0x00000000004bd0c0 align 2**0
         filesz 0x0000000000002f40 memsz 0x0000000000002f40 flags r--

Briefly describe what would likely be changed in the headers shown above if a virus appended its code to this end of this executable. Assume that the appended viruses code is larger than 1 page (4096 bytes) in size.

Answer:

several solutions, accepted any one:

Some students had solutions that would require changing where parts of the executable would be loaded relative to each other, by adjusting a the vaddrs/paddrs of a bunch of segments. We didn't give these full credit since this seems to require the virus to do complicated rewriting of the existing executable's machine code.

Regrade request
Question 5 (4 pt)

To evade pattern-based detection and analysis, malware frequently "encrypts" most of its code and includes a randomized decryption routine that decrypts and runs the code.

A frequently proposed solution for antimalware software or analysts to obtain the decrypted code is to run the malware in an emulator, and stop when the malware starts runnning machine code that it wrote while running. Then, one would examine the memory managed by the emulator for the decrypted code. Briefly explain a way that malware could defeat this automated scheme.

Answer:

could decrypt code in multiple segments, so the detection triggers early

We also accepted solutions that proposed detecting the emulator and refusing to run the virus code (but you needed to suggest a method that would be likely to do this for full credit).

Regrade request

Some self-replicating malware tries to evade signature based detection by performing a machine code to machine code transformation as part of its replication process. One possible transformation is to introduce additional operations that have no useful effects in between instructions as part of this transformation.

Question 6 (4 pt) (see above)

One idea to detect this transformation is to ignore nop instructions and instructions that do not change any values in memory or registers (e.g. add $0, %rax, jmp foo; foo:) when doing pattern matching. Give an example of how malware could use this strategy of inserting additional useless instructions between its instructions but evade this countermeasure.

Answer:

add to register not used by malware's normal machine code; add and substract from a register; push and pop a value from the stack; ...

Regrade request
Question 7 (4 pt) (see above)

To implement this transformation, the malware must make some adjustments to deal with jumps and calls within the malware code. Suppose a jump instruction is encoded using a relative offset. Which of the following information would alone be sufficient to the malware to produce a correct jump instruction in the new machine code? Select all that apply.

  1. intended all these to be interpreted as also including the original jump (and its original offset), but not clear

Regrade request
Question 8 (5 pt)

Which of the following techniques are likely to make it more difficult to set breakpoints and, when those breakpoints are reached, get a useful call stack trace of some malware in a debugger? Select all that apply.

  1. doesn't affect what functions are called and when, also the strings/values are likely to be decrypted at runtime and so visible in a call trace that shows arguments

  2. doesn't change what function calls happen or make those function calls not use the stack as usual; also doesn't do anything that affects operation of breakpoints

  3. likely to hide function calls so call stack is not useful; also operations won't have a single location where a breakpoint can be set with a conventional debugger

Regrade request
Question 9 (5 pt)

Consider a dynamic taint tracking scheme that executes a program by annotating each value in a running program with a flag about whether it is "tainted". When a tainted value is used in arithmetic to compute another another value, the other value is marked as tainted. Which of the following techniques are likely make this kind of dynamic taint tracking scheme ineffective? Select all that apply.

  1. if we implement this taint tracking scheme with an emulator the original machine code will be unchanged (we'll just have an implementation of each machine code instruction that does more state tracking than a normal processor); if we do a machine code to machine code transformation, the original machine code will likely be preserved to make the translation correct when a program reads constants out of its code segment.

  2. this taint tracking scheme doesn't rely on analyzing control flow (regardless of whether it's control flow based on ifs or witches), so there won't be a difference in what's tainted before/after this transformation (except tha tht eh new variable may or may not be tainted)

  3. should perform the same calculations/arithmetic with the same values, so have roughly the same taint information

Regrade request
Question 10 (4 pt)

What is the difference between a sandbox and a virtual machine?

Regrade request

Suppose we wanted to use sandboxing to protect against vulnerabilities in a video calling application.

Question 11 (4 pt) (see above)

What would be true about attempting to do this by confining the entire application using chroot? Select all that apply.

  1. need to identify config files in order to ensure that they're included in the chroot environment

  2. would need to include files a user might want to upload in the chroot environment, which would seem to defeat a lot of the security benefit of the chroot environment

  3. other windows likely not accessed through filesystem (e.g. via a windowing server or the display driver or similar instead)

Regrade request
Question 12 (4 pt) (see above)

If one wanted to use privilege separation for this task, what is a part of the video calling application that would be a good candidate for performing privilege separation?

Answer:

video decoding, network decoding, chat message rendering; generally we want to run the parts of the video calling application that deal with data controlled by a potential attacker with less privileges

We preferred answers that made it clear what would go in the less privileged part of the application, but also accepted answers which identified what functionality would be outside the sandbox (and accessed from the sandbox via a limited API): e.g. choosing files for file sharing or windows for screensharing

Regrade request
Question 13 (4 pt)

How does AFL-tmin know its minimized test case triggers the same bug as the original test case?

Regrade request
Question 14 (4 pt)

Which of the following are allowed under Rust's ownership rules? Assume only built-in references are used, not special reference classes that implement different policies like Rc or RefCell. Select all that apply.

  1. function will borrow the reference to the hashmap

  2. Node can't "own" its parent that also owns the Node

  3. for safety, need to have some mechanism to ensure that other core stops using reference before search function completes. Because of this concern Rust doesn't allow this without using some special reference class that implements a multithreading-safe policy

Regrade request
Question 15 (5 pt)

Some bounds-checking schemes use a lookup table that allows code to use the address of any byte of an object to determine the beginning and end and size of an object. Which of the following are true about these schemes? Select all that apply.

  1. the lookup table needs to be able to tell us both about where the beginning/end of the struct (or maybe an array of structs) is AND where the beginning/end of objects in the struct are, and it seems like one with the structure proposed won't do that

  2. "red zone" usually refers to space that should not be modified/will cause errors if modified. Baggy Bound checking, the scheme which worked most like this, did sometimes adding padding to make sizes a power of two, but didn't need padding if the size was already a power of two; and in general, padding is not required if you're willing to have higher overhead for the bounds check

  3. the lookup table allows us to reconstruct the information that would be in "fat" pointers

Regrade request
Question 16 (4 pt)

Which of the following patterns would match the machine code for an x86-64 return? Select all that apply.

Regrade request
Question 17 (4 pt)

Which of the following statements are true about using static analysis to find potential security bugs (such as use-after-free or a buffer overflow) in a function F()?

Regrade request
Return to course pageReturn to index