IBM HMC Exploit CVE-2021-29707
A restricted shell on IBM HMC could be escaped using sed's execute command, and then a setuid binary that called a script without sanitising the environment allowed privilege escalation to root by overriding the cut command with a bash function.
Published on tomcope.com
During some security research I discovered a method in which the local user account restricted in the HMC shell could be uses to escalate privilege to root access. The post will go through my thought process while researching the vulnerability.
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
Likely the restricted shell allowed sed's execute command, and a setuid wrapper script did not sanitise the PATH or environment before calling external commands.
Impact
A local user with restricted HMC shell access could escalate to root, gaining full control of the appliance.
What the attacker needed
Local user account on HMC; restricted shell access
The fix
IBM confirmed a fix and published a security bulletin.
How it was found
- Connect to the HMC via SSH and observe the restricted bash shell.
- Use sed's execute command to run /bin/bash with a full PATH and redirect input/output to the current TTY, escaping the restricted shell.
- Identify setuid binaries in /usr/hmcrbin, including asmmenu.
- Create a bash function named cut that spawns a shell and export it.
- Run asmmenu with the crafted environment to execute the function as root.
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 IBM Hardware Management Console (HMC) is a management appliance. A low-privileged user could break out of a restricted command shell and then trick a special root-owned program into running their own code, giving them full control of the system.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.