Cybersecurity senior with hands-on experience in cybersecurity, systems, and full-stack software development.
CSCI 496: Senior Portfolio
In partial fulfillment of the requirements for the degree of
Bachelor of Science in Cybersecurity (class of 2026)
View My Resume
View My LinkedIn Profile
This project demonstrates a Time-of-Check to Time-of-Use (TOCTOU) race condition attack in a Linux environment. The goal of the project is to show how improper handling of file access, specifically separating the “check” and “use” phases, can allow an attacker to manipulate a program’s behavior.
The project consists of a vulnerable C program (checker.c) and a Python attack script (TOCTOU_attack.py). The victim program checks whether a file (secret.txt) is writable, pauses briefly, and then writes to it. During this delay, the attacker script replaces the file with a malicious file (inject), causing the victim program to unknowingly operate on the attacker-controlled file.
This demonstrates a real-world class of vulnerabilities that can occur in operating systems and applications that rely on non-atomic file operations.
This project was originally executed on a Kali Linux Virtual Machine, but it also works in the Windows Command Prompt. The compiled executable for this project is available in the GitHub Releases section.
Ensure all files are in the same directory: checker.c TOCTOU_attack.py secret.txt inject
gcc checker.c -o checker
python3 TOCTOU_attack.py secret.txt stolen inject
This project does not include a traditional graphical user interface. Instead, it uses terminal-based output to demonstrate the interaction between the victim program and the attacker script.
The output logs clearly show:

Fig 1. The checker.c program simulates a vulnerable application. It performs a file permission check and introduces a delay before using the file, creating the opportunity for exploitation.

Fig 2. The Python script automates the attack by monitoring the victim process and swapping files at the correct moment during execution.

Fig 3. The output demonstrates that the attack was successful. Although the victim program reports normal operation, the contents of secret.txt are altered, showing “Hacked!”, proving that the attacker was able to exploit the race condition.
This project highlights the importance of secure coding practices when working with shared resources such as files. Developers should avoid separating security checks from usage and instead rely on atomic operations to prevent race conditions.
One challenge encountered during this project was ensuring proper timing for the attack to succeed consistently. Because race conditions depend on execution timing, multiple test runs and careful tuning were required.
Additionally, this project reinforced the importance of testing software in controlled environments, as exploiting such vulnerabilities on real systems could lead to serious security risks.