Skip to content

[Security] Local RCE via Unsafe pickle.load() in Multiprocess Mode #221

Description

@Dhurgesh-mj

Overview

A security review of httpdbg 2.2.0 identified a local remote-code-execution vulnerability in the multiprocess recording mechanism.

The parent process deserializes .httpdbgrecords files using pickle.load() without integrity verification or validation. A malicious pickle can execute arbitrary Python code when the watcher processes the file.


1. Local RCE via Unsafe Deserialization — hooks/external.py — HIGH

The watcher loads .httpdbgrecords files using:

newrecords: HTTPRecords = pickle.load(dumpfile)

Affected line: hooks/external.py L83

Because Python pickle allows arbitrary callable execution during deserialization, a malicious .httpdbgrecords file can execute commands with the privileges of the httpdbg process.

Exploitation

An attacker who can write a malicious .httpdbgrecords file into the httpdbg multiprocess directory can trigger code execution when the background watcher processes it.

The multiprocess directory is created at:

Affected lines: hooks/external.py L35–38

self.directory = tempfile.TemporaryDirectory(prefix="httpdbg_")
os.environ["HTTPDBG_MULTIPROCESS_DIR"] = self.directory.name

The watcher continuously checks the directory and processes matching files.

Affected line: hooks/external.py L91

time.sleep(1.0)

A malicious pickle can use a __reduce__ gadget such as:

class RCE:
    def __reduce__(self):
        return (os.system, ("id",))

payload = pickle.dumps(RCE())

Writing the resulting payload as:

pwn.httpdbgrecords

into the monitored directory causes pickle.load() to execute the command.

Attack Chain

Attacker-controlled .httpdbgrecords
        ↓
httpdbg multiprocess directory
        ↓
Watcher detects file
        ↓
external.py:83 → pickle.load()
        ↓
Pickle gadget executes
        ↓
Arbitrary command execution
        ↓
httpdbg process privileges

Impact

Successful exploitation provides arbitrary code execution with the privileges of the process running httpdbg.

This could allow access to files, environment variables, credentials, network resources, and other data available to the httpdbg process.

Fix

Avoid deserializing untrusted data with pickle. Replace the IPC format with a safe serialization format such as JSON and reconstruct the expected record objects explicitly.

If pickle must be retained, authenticate the serialized data before deserialization and ensure the IPC directory cannot be modified by unauthorized processes.


Environment

  • httpdbg: 2.2.0
  • Python: 3.14.0
  • OS: Windows 11
  • Windows build: 10.0.26200

The vulnerability was reproduced successfully and arbitrary command execution was confirmed.

Request

Please treat this as a security issue. I can provide the complete reproduction/PoC privately if required.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions