Docsity

CS 161 Final Exam Spring 2017, Exams of Computer Networks

Toggle sidebar
bg1
Paxson
Spring 2017
CS 161
Computer Security Final Exam
Print your name: ,
(last) (first)
I am aware of the Berkeley Campus Code of Student Conduct and acknowledge that any
academic misconduct on this exam will be reported to the Center for Student Conduct and
may lead to a “F”-grade for the course.
Sign your name:
Print your class account login: cs161- and SID:
Your TA’s name:
Number of exam of
person to your left:
Number of exam of
person to your right:
You may consult two sheets of notes (each double-sided). You may not consult other notes,
textbooks, etc. Calculators, computers, and other electronic devices are not permitted.
Please write your answers in the spaces provided in the test.
You have 180 minutes. There are 9 questions, of varying credit (600 points total). The
questions are of varying difficulty, so avoid spending too long on any one question. Parts of
the exam will be graded automatically by scanning the bubbles you fill in, so please do
your best to fill them in somewhat completely. Don’t worry—if something goes wrong with
the scanning, you’ll have a chance to correct it during the regrade period.
If you have a question, raise your hand, and when an instructor motions to you,
come to them to ask the question.
Do not turn this page until your instructor tells you to do so.
Question: 1 2 3 4 5 6 7 8 9 Total
Points: 80 74 48 72 64 54 96 56 56 600
Score:
Page 1 of 35
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Partial preview of the text

Download CS 161 Final Exam Spring 2017 and more Exams Computer Networks in PDF only on Docsity!

Paxson

Spring 2017

CS 161

Computer Security

Final Exam

Print your name: , (last) (first)

I am aware of the Berkeley Campus Code of Student Conduct and acknowledge that any academic misconduct on this exam will be reported to the Center for Student Conduct and may lead to a “F”-grade for the course.

Sign your name:

Print your class account login: cs161- and SID:

Your TA’s name:

Number of exam of person to your left:

Number of exam of person to your right:

You may consult two sheets of notes (each double-sided). You may not consult other notes, textbooks, etc. Calculators, computers, and other electronic devices are not permitted. Please write your answers in the spaces provided in the test.

You have 180 minutes. There are 9 questions, of varying credit (600 points total). The questions are of varying difficulty, so avoid spending too long on any one question. Parts of the exam will be graded automatically by scanning the bubbles you fill in, so please do your best to fill them in somewhat completely. Don’t worry—if something goes wrong with the scanning, you’ll have a chance to correct it during the regrade period.

If you have a question, raise your hand, and when an instructor motions to you, come to them to ask the question.

Do not turn this page until your instructor tells you to do so.

Question: 1 2 3 4 5 6 7 8 9 Total

Points: 80 74 48 72 64 54 96 56 56 600

Score:

Page 1 of 35

Problem 1 True/False (80 points) For each of the following, FILL IN THE BUBBLE next to True if the statement is correct, or next to False if it is not. Each correct answer is worth 4 points. Incorrect answers are worth 0 points. Answers left blank are worth 1 point.

(a) Thanks to strong cryptography, a TLS connection to your bank is secure even if their web server’s TCP/IP implementation has a buffer overflow vulnerability.

True False

(b) Thanks to strong cryptography, a TLS connection to your bank is secure even if your home router’s TCP/IP implementation has a buffer overflow vulnerability.

True False

Solution: A key property of TLS is how it provides end-to-end security: two systems can communicate using TLS without having to trust any of the inter- mediaries that forward their traffic. Thus, even if an attacker completely pwns your home router, the worst they can do to you is deny you service to your bank.

(c) To protect against Kaminsky blind spoofing attacks requires servers to implement a new version of the DNS protocol.

True False

(d) Using DNSSEC to resolve example.com guarantees authenticity and integrity on subsequent HTTP connections to example.com, but not confidentiality.

True False

Solution: DNSSEC provide authenticity and integrity for DNS results, but not for any subsequent use of those results. The subsequent connections will have to achieve security separately, such as by using TLS.

(e) A properly configured firewall can prevent any DDoS attack from disrupting the ability of remote users to access your network.

True False (f) Using a prepared statement to feed user input to an SQL query ensures that nothing the user enters will be treated as an SQL command. True False

(g) VPN can enable you to safely connect to your company when using an untrusted public WiFi network.

True False

True False

Solution: The certificate authority only knows example.com’s public key, not its private key, which it would need for passive decryption. A certificate binds a public key to an identity (in this case the domain name example.com).

(s) Consider a worm that spreads by each infected instance uniform randomly selecting a 32-bit IP address. We would expect the worm to initially spread exponentially fast, but then slow down its spread during the later part of its propagation.

True False

(t) The Slammer worm spread extra-fast because each infected instance of the worm kept increasing its scanning speed.

True False

Problem 2 Multiple Choice (74 points)

(a) (6 points) Suppose an attacker steals the private key of a website that uses TLS, and remains undetected. What can the attacker do using the private key? Mark ALL that apply.

Decrypt recorded past TLS sessions that used RSA key exchange.

Successfully perform a MITM attack on future TLS sessions.

Decrypt recorded past TLS sessions that used Diffie–Hellman key ex- change.

None of these.

(b) (6 points) DNSSEC provides which of the following security properties for DNS responses? Mark ALL that apply.

Confidentiality

Integrity

None of these

Authentication

Availability

(c) (8 points) “Mixing program control and user data” is a class of vulnerabilities where a program/application accidentally treats user input as code and executes it. Which of the following attacks exploit this class of vulnerabilities? Mark ALL that apply.

Buffer overflows

CSRF

SQL Injection

None of these

Stored XSS

Reflected XSS

Clickjacking

(d) (6 points) To verify that she is visiting the correct website, Alice is told to make sure to check that the URL in the browser’s address bar is the URL she actually wants to visit. Which of the following statements are true? Mark ALL of the following statements that apply.

Of relevance for this situation is the principle of Least Privilege

Of relevance for this situation is the principle of Consider Human Factors

This will help Alice defend herself against CSRF attacks

This will help Alice defend herself against some DNS spoofing attacks

This will help Alice defend herself against some phishing attacks

None of these

Gandalf’s machine can use the berkeley.edu KSK to encrypt the query it sends to the berkeley.edu DNS server.

berkeley.edu’s ZSK will be signed by the root’s KSK.

berkeley.edu’s ZSK will be signed by berkeley.edu’s KSK.

Gandalf’s machine will receive a final A record for gondor. berkeley.edu that is signed with berkeley.edu’s ZSK.

Gandalf’s machine will receive a fi- nal A record for gondor.berkeley. edu that is encrypted with a pub- lic key that Gandalf provides in his DNS query.

The final A record for gondor. berkeley.edu will have object secu- rity.

If zones correctly implement DNSSEC, then Gandalf is secure against a MITM attacker who at- tempts to modify content retrieved from the gondor.berkeley.edu web site.

(g) (6 points) A border firewall’s primary purpose is (Mark ONE):

Block incoming VPN connections.

Prevent CSRF attacks.

Detect buffer overflows.

Prevent XSS attacks.

Prevent a network intruder inside the network from spreading inter- nally.

None of these.

Solution: A border firewall’s primary purpose is to control which systems and which types of connections are allowed across the site’s border. It does not focus on attack detection; generally allows, rather than hinders, incoming VPN connections; and cannot contain a network intruder already inside the network from spreading internally, since that spread does not transit the site’s border.

(h) (8 points) Which of the following attacks might allow an attacker to steal one of your browser cookies (Mark ALL that apply):

Reflected XSS

Stored XSS

Clickjacking

None of these

Buffer overflow

TLS downgrade

DDoS

Solution: A common mistake was to select Clickjacking. While clickjacking can cause user input (clicks or keystrokes) to go where the user did not intend it to go, these misdirections still result in HTTP requests that follow the usual rules regarding whether and which cookies to send.

(i) (6 points) Alice and Bob want to communicate over an insecure channel using one of the following schemes, where M is the message in plaintext. Which scheme should they use in order to avoid padding oracle attacks? Assume that (1) all of the algorithms are secure, and (2) MAC and Sign do not leak anything about M. Mark ALL that apply.

Enc(M ), MAC(M )

Enc(M || MAC(M ))

None of these

Enc(M ), MAC(Enc(M ))

Enc(M ), Sign(M )

Solution: Recall from Project 2 that in padding oracle attacks, the attacker modifies the ciphertext in some cleverly chosen fashion, asks the client to decrypt it, and then observes whether the decryption process caused an invalid-padding error. If the attacker can observe whether such an error occurred, then this leaks partial information; after repeating this many times, an attacker can piece together all of these clues to deduce what the original message must have been.

To defend against padding oracle attacks, the recipient must be able to verify the integrity of the ciphertext before decrypting it. That is, the MAC / signature must be computed over the ciphertext, and not the plaintext. Hence, only the option on the top right is correct; in the others, the integrity of the message can only be verified after decrypting the ciphertext.

identity; Mallory can request her own key from the server and then forward the message to Alice. Using a nonce instead of a timestamp in S’s response (Options 4 and 5) only works if A sends the nonce to S in step 1.

A student pointed out on Piazza that the problem asks for defending against attacks applicable to the protocol in the previous question, and Option 3 does so, even though it’s flawed in a different way. We allowed full credit for answers that included Option 3 providing no other options (other than Option 12) were selected, and only the correct option was selected for the previous question.

Problem 3 Bypassing ASLR (48 points) Mallory is trying to perform a return-to-libc attack on a simple stack buffer overflow vulnerability. She wants to overwrite the return address of the vulnerable function with the address of the system function, and pass it an arbitrary command argument. But the system she wants to attack has ASLR enabled, so &system (the address of system) is different every time.

Wanting to explore this further, Mallory writes the simple program:

#include void main() { printf("system is at 0x%x\n", &system); }

She runs this five times, with ASLR enabled, and gets the following output: system is at 0xbf9d7f system is at 0xbf9d7f system is at 0xbf9d7f system is at 0xbf9d7f system is at 0xbf9d7f

(a) (16 points) She shouts “Eureka! It won’t work every time, but I can easily break this now!”. What did Mallory learn? How can she use it to successfully exploit the buffer overflow with a return-to-libc attack?

Solution: The implementation of ASLR has insufficient entropy — &system appears to have no more than one byte of randomness, so Mallory learned that just by repeatedly trying a manageable number of times, she can eventually luck upon the correct address of system.

Full credit required conveying the notion of exploiting repeated attempts to eventually make a correct guess.

(b) (8 points) What is the probability that Mallory will succeed if she has 1 chance to perform her return-to-libc attack?

Solution: If there is one byte of randomness, than the probability for a single attack to succeed is 2561. There might even be less randomness; in the output Mallory saw, the high bit in the bottom byte of the address never varied, so the probability might be as much as 1281.

If the probability is 2561 , then it will take Mallory an expected 128 tries to guess correctly if her failed guesses do not cause re-randomization due to crash-and- restart; or an expected 256 tries if it does.

Fill the 16 byte buffer. Note the shell comment character

at the end so that subsequent bytes are ignored

sudo rm -rf / ##

Overwrite SFP in order to get to RIP (next line). AAAA Guess at &system. (reversed to account for little endi- anness)

\x14\x7f\x9d\xbf

Dummy value in the stack position where a proper IA- call would have pushed $eip to become the stored $rip. The system function’s assembly code will ex- pect 4 bytes to proceed the arguments on the stack (by “proceed”, we mean appear in lower memory addresses). This is the address that system() will return to. For this attack, it doesn’t matter that the value is bogus since system() waits for the shell to finish executing, at which point Mallory has presumably completed her attack.

DUMM

Address of memory storing the attack string argument (argv[1]). This is what system() will read as its argu- ment.

\x07\x07\x07\x

Getting this answer fully correct was quite difficult. We awarded partial credit for specifying various parts.

Problem 4 Attacks on TLS (72 points) Recall the TLS protocol, depicted in the figure below. We use the following notation: {M }K denotes a message M encrypted using the key K. [M ]− K^1 denotes a message M along with a signature over M using the key K−^1.

Client Server

  1. Client sends a 256-bit random number Rb and supported cipher suites C
  2. Server sends a 256-bit random number Rs and chosen cipher suite Cser
  3. Server sends certificate
  4. DH: Server sends [g, p, ga^ mod p]K−server 1
  5. Server signals end of handshake
  6. DH: Client sends gb^ mod p RSA: Client sends {P S}Kserver Client and server derive cipher keys Cb, Cs and integrity keys Ib, Is from Rb, Rs, P S
  7. Client sends MAC(dialog, Ib)
  8. Server sends MAC(dialog, Is)
  9. Client data takes the form {M 1 , MAC(M 1 , Ib)}Cb
  10. Server data takes the form {M 2 , MAC(M 2 , Is)}Cs

(^1) ClientHello

2 ServerHello

3 Certificate

4 ServerKeyExchange

5 ServerHelloDone (^6) ClientKeyExchange

(^7) ChangeCipherSpec, Finished

8 ChangeCipherSpec, Finished (^9) Application Data

10 Application Data

Figure 1: TLS 1.2 Key Exchange

(a) (24 points) Suppose the client and server use RSA to exchange the premaster secret. Mallory intercepts the ClientKeyExchange message and replaces P S with a fake value P S′. Assume that Mallory can modify the messages after ClientKeyExchange as well, if required. Which of the following are true? Mark ALL that apply.

Mallory will be able to decrypt the application data sent by the client to the server. Mallory will be able to decrypt the application data sent by the server to the client. The server will detect the tampering when it receives ClientKeyExchange.

Mallory can avoid detection until the server receives Finished from the client, at which point she’ll be detected.

Mallory can avoid detection until the client receives Finished from the server, at which point she’ll be detected.

None of these

Solution: No. Mallory will still be unable to learn the master secret, and hence will not be able to forge the MAC over the dialog. She will thus get detected.

ii. (12 points) Suppose the client and server support a weak variant of Diffie- Hellman (DHweak). Mallory is aware of an attack on DHweak that allows her to learn the exchanged secret. She therefore wishes to force the client and server to use DHweak instead of standard Diffie-Hellman.

Solution: Yes. Mallory needs to modify ClientHello + both Finished mes- sages. Since she can extract the exchanged secret, she can derive the in- tegrity keys necessary to modify the MACs.

(c) (24 points) Recall that ClientHello contains a nonce Rb, along with C, the cipher suites supported by the client. ServerHello contains a nonce Rs along with Cser, the cipher suite chosen by the server. Which of the following modifications to the TLS protocol would prevent Mallory from conducting any downgrade attacks on the cipher suites? Mark ALL that apply.

ServerKeyExchange includes [Rb]Kserver− 1 , [C]Kserver− 1

ServerKeyExchange includes [Rb, C]Kserver− 1

ServerKeyExchange includes [C]Kserver− 1

ServerKeyExchange includes [Cser]K−server 1

ServerKeyExchange includes [C]Kserver− 1 , [Cser]K−server 1

ServerKeyExchange includes [C || Cser]K−server 1

ServerKeyExchange includes [Rb || C || Cser]Kserver− 1

None of these

Solution: The attack won’t work if the client can verify that the cipher suites C received by the server were altered by Mallory. To this end, the server can send the client a signature over C after binding it with Cser (as in Options 6 and 7). The client can then verify the signature, validate C, and be assured that the server chose Cser after receiving the correct cipher suites. (Including Rb as in Option 7 is unnecessary, but doesn’t cause any problems.) Options 1, 2 and 3 (lefthand column) don’t work because Mallory can obtain the necessary signature by launching her own separate TLS session with the server and sending C in the ClientHello message. Including Rb in the signature doesn’t help because Mallory can still MITM the connection as follows:

  1. Pause the client’s ClientHello message
  2. Launch a separate TLS session using the client’s Rb and C, obtaining a valid signature over these
  1. Resume the client’s ClientHello after downgrading C to C′
  2. Replace the server’s signature over C′^ and Rb using the one obtained in (2). Option 4 (lower left) doesn’t contain a signature over C, so the client can’t tell that the server never received the client’s original cipher suite offerings.

Option 5 (upper right) doesn’t work because it contains separate signatures over C and Cser, allowing Mallory to selectively replace the signature over C, as described above.

Problem 5 Software vulnerability (64 points) Here is a fragment of Python source code for a fictitious email-based spell-checker service:

def process_incoming_email(msg): return_addr = msg.get("From") search_term = msg.get("Subject") status = os.system("fgrep " + search_term + " /usr/share/dict/words") if status == 0: # exit code 0 means success response = "The word " + search_term + " is spelled right!" else: response = "Sorry, " + search_term + " is not a word." send_response(return_addr, response)

In this service, users submit a word to check as the Subject: header field of an email. For example:

To: [email protected] From: [email protected] Subject: phenommenon

The process incoming email function is responsible for checking the spelling of the word, generating an appropriate response message, and sending the response back to the original sender via email. The function works by extracting a search term from the Subject header field, then using the fgrep command to search for the term in /usr/share/dict/words, a file containing a list of English words. The fgrep command searches a file for a fixed text pattern; its syntax is ‘fgrep pattern filename ’. os.system is a Python function that accepts a single string and executes the string using the command shell. It works the same as the C system() library routine that we discussed in lecture.

(a) (16 points) The process incoming email function has a vulnerability. What email Subject: could you send that would cause the server to pause for 10 seconds before replying?

Subject:

Solution: Subject: dbadmin /etc/passwd #

The above search term will cause process incoming email to build this com- mand:

fgrep dbadmin /etc/passwd # /usr/share/dict/words

Instead of searching /usr/share/dict/words, fgrep will search /etc/passwd. The ‘#’ turns the /usr/share/dict/words at the end of the command into a comment. The exit code of fgrep will reflect whether the search term dbadmin was found in /etc/passwd. If dbadmin was found, the email reply will be

The word dbadmin /etc/passwd # is spelled right! If dbadmin was not found, the email reply will be

Sorry, dbadmin /etc/passwd # is not a word.

Some ideas that do not work completely: dbadmin /etc/passwd; cd This doesn’t work because the return value of os.system is the return value of the last command. Putting a cd (or other command) at the end will cause the return value of os.system to reflect that command, not fgrep dbadmin /etc/passwd.

dbadmin /etc/passwd; This doesn’t work because the /usr/share/dict/words that gets ap- pended will be interpreted as a command name by the shell. Because the file is not executable, trying to execute it will always result in a nonzero exit status. The slight variant dbadmin /etc/passwd (no semicolon at the end) actu- ally does work, because the /usr/share/dict/words that gets appended will be interpreted as an additional filename argument to fgrep, not a separate command. The search will work correctly as long as dbadmin is not present in /usr/share/dict/words.

(c) (32 points) State one way that you could fix the vulnerability? (If you name more than one, we will only grade the first.)

Solution: Possible solutions:

  • Use subprocess.Popen in place of os.system. (Or some other API that allows you to specify a vector of command arguments, rather than a shell string.)
  • Carefully escape search term to remove shell metacharacters. (This is tricky because it requires detailed knowledge of how the shell will interpret each character.)
  • Implement the search in Python rather than using a fgrep subprocess.

Problem 6 Coffee Shop Worries (54 points) Alice and Bob just arrived at Brewed Awakening, the local coffee shop. Eve is already there, enjoying a cup of tea.

(a) (6 points) Alice wants to connect to Brewed Awakening’s WiFi network. Under which protocols would her connections be safe from sniffing attacks by other coffee shop visitors, such as Eve? Mark all that apply.

WEP

WPA2 - Personal mode

WPA2 - Enterprise mode

None of these

Solution: Only “WPA2 - Enterprise mode” provides per-connection secret keys with the WiFi access point to secure each connection separately.

(b) (24 points) Turns out that Brewed Awakening’s network has no encryption. Al- ice warns Bob that its not safe to use this connection, but Bob disagrees. Bob connects to the WiFi, and tests that he has Internet connectivity by going to https://kewlsocialnet.com. It loads without issues. Bob says the Alice: “See, no problem! That access was totally safe!”

If Bob is correct and the access to kewlsocialnet.com was safe, explain why he is correct. If he is not correct, provide a network attack against Bob.

Answer:

Solution: Bob is correct.

Bob is visiting an HTTPS website, which uses TLS to provide an end-to-end secure channel. As Bob’s browser did not encounter any certificate warnings, then unless there’s been a CA breach or some other CA issue, the network connection has confidentiality, authentication, and integrity.

We allowed full credit for solutions that specified that Bob was incorrect and provided a valid approach for undermining his HTTPS connection to the site, including the threat of obtaining fraudulent certs from misbehaving CAs. We allowed only partial credit for solutions that framed attacks that would work in the situation if TLS did not provide all of the strong security properties that it