Pentesting Cisco SD-WAN Part 2: Breaking Routers
A command injection flaw in the SSH wrapper script allowed an authenticated user to execute arbitrary commands as the binos user. A second flaw in a SUID binary allowed privilege escalation to root by manipulating the PATH environment variable.
Published on synacktiv.com
Written by Julien Legras, Thomas Etrillard - 07/05/2020 - in Pentest - Download
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The wrapper script used eval on the user-supplied SSH command when it started with 'scp', and a SUID binary called 'cat' without an absolute path, allowing PATH manipulation.
What the attacker needed
Valid SSH credentials for the router; access to the SSH service on port 830
The fix
The vulnerability was fixed in Cisco IOS XE SD-WAN Software version 17.2.1r.
How it was found
- Connect to the router's SSH service on port 830 with valid credentials.
- Send an SSH command that starts with 'scp' followed by shell metacharacters to inject a command.
- Use the injected command to obtain an interactive shell as the binos user.
- Find SUID binaries and identify /tmp/etc/bexecute, which runs scripts as root.
- Create a malicious 'cat' script in a writable directory and prepend that directory to PATH.
- Execute bexecute with a whitelisted script that calls 'cat' to run the malicious script and gain 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 write-up has not been written yet. The Original tab links to the source.
The router's SSH service had a script that ran user-supplied commands without proper checks, letting an attacker run their own commands. Then a special program that runs with high privileges could be tricked into running a fake 'cat' command, giving full control of the router.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.