Main navigation | Main content
This lab will cover two kinds of vulnerabilities in OS interaction we've discussed in lecture, and their corresponding attack techniques. First will be controlling one program's use of another program, while second is a time-of-check to time-of-use race condition. These are the kinds of vulnerabilities that one might attack in a program that was privileged such as by running setuid, though for simplicity in what can be done in the CSE Labs context, you'll just attack unprivileged programs running as yourself. (If you're doing the lab with a partner you trust, you could try making the vulnerable programs setuid; though some of the attacks will be blocked in that setting.)
In the online lab we'll randomly split you into breakout groups of 2-3 students: please work together, discuss, and learn from the other student(s) in you group. Use the "Ask for Help" button to ask questions or show off what you've done. We also recommend working in groups in the in-person lab, but there you can choose your own groups and physically raise your hand to ask a question. You may still find it useful to use Zoom or tmate for screen sharing in person while respecting social distancing.
The program uses-system doesn't do anything interesting besides calling the system program uname, which when called without other arguments just prints Linux. As a sample attacker goal, suppose you want to make running uses-system trigger a different program, say the calculator program xcalc. The two modes of the uses-system program demonstrate two ways of calling an external program that could be hijacked.
cp /web/classes/Fall-2020/csci4271/labs/05/uses-system.c . gcc -Wall -g uses-system.c -o uses-system
The program read-five-chars attempts to read a file that should contain 5 characters followed by a newline, and then prints the contents of the file. However, there is a race between the checks on the file and the process of opening and printing it that can be used to trick the program into printing more than a 5-character string. Can you get the program to instead print:
My favorite five-character string is Calculator!
Here again the first argument to the program, named mode, switches between a few different versions of the vulnerability that can be attacked in different ways.
cp /web/classes/Fall-2020/csci4271/labs/05/read-five-chars.c . gcc -Wall -g read-five-chars.c -o read-five-chars
(a; b) & (c; d)can be used to run two sequences of commands at once. For instance can you predict what the following command will print?
(echo a; sleep 0.25; echo b) & (echo c; sleep 0.5; echo d)