Sometimes the vulnerability is not in your target’s code - it is in their supply chain. Knife is a good example of what happens when a poisoned release slips through.
Machine info
| Name | Knife |
| Platform | HackTheBox |
| OS | Linux |
| Difficulty | Easy |
TL;DR
- A web server running PHP 8.1.0-dev - a version that shipped with a backdoor - allows arbitrary command execution via a custom HTTP header
- Initial shell as
james,sudo -lreveals theknifeCLI can be run as root without a password sudo knife exec -E "exec('/bin/bash')"drops a root shell immediately
Recon
Nmap
| |

Ports 22 (SSH) and 80 (HTTP) open. Apache 2.4.41 on Ubuntu. The scan already leaks PHP/8.1.0-dev in the response headers - that is the thread to pull.
Enumeration
Technology fingerprint
Vhost and directory enumeration returned nothing interesting - the site is mostly a static medical page with no obvious entry points. Running whatweb confirms the PHP version:

PHP 8.1.0-dev. This specific version was released in March 2021 with a backdoor injected by an attacker who compromised the PHP Git server. If a server runs this build, any request carrying the User-Agentt header (note the double t) with a value starting with zerodiumsystem( will execute arbitrary PHP.
Reference: Exploit-DB #49933
Foothold
PHP 8.1.0-dev backdoor RCE
Set up a listener and send the exploit payload:

| |
The callback arrives on the listener:

Shell as james. user.txt is in the home directory.
Privilege Escalation
GTFOBins: knife exec

james can run /usr/bin/knife as root without a password. Knife is a command-line tool for interacting with Chef, a configuration management platform. It is not unusual to find it on infrastructure boxes. What matters here is that knife exec evaluates arbitrary Ruby - and GTFOBins documents exactly how to abuse it:

| |
Root shell, root.txt in /root.
Takeaways (for OSCP)
- Supply chain compromises are real attack vectors. The PHP 8.1.0-dev backdoor is a textbook example - always fingerprint the exact software version, not just the product name.
whatweband response headers are your best friends during enumeration. When directory brute-force returns nothing, look at what the server is telling you about itself.- Check GTFOBins for every binary in
sudo -l. Knife is not an obvious escalation tool, but GTFOBins documents it. The pattern - CLI tools that evaluate scripts - repeats often on OSCP-style machines.
References
- HackTheBox - Knife
- Exploit-DB #49933 - PHP 8.1.0-dev Backdoor RCE
- GTFOBins - knife
- Lain Kusanagi list (OSCP prep)
