CVE-2021-23727

7.5 HIGH

📋 TL;DR

CVE-2021-23727 is a command injection vulnerability in Celery task queue software. Attackers who can access or manipulate metadata in Celery backends can execute arbitrary commands on affected systems. This affects all users running vulnerable Celery versions with default configurations.

💻 Affected Systems

Products:
  • Celery
Versions: All versions before 5.2.2
Operating Systems: All operating systems running Python
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerable in default configuration when using result backends. Redis, RabbitMQ, and other backends are affected.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full system compromise through remote code execution, allowing attackers to install malware, exfiltrate data, or pivot to other systems.

🟠

Likely Case

Limited command execution within the Celery process context, potentially leading to data theft or service disruption.

🟢

If Mitigated

No impact if proper network segmentation and access controls prevent attackers from reaching Celery backends.

🌐 Internet-Facing: MEDIUM - Requires access to backend storage, which may be exposed in cloud configurations or misconfigured deployments.
🏢 Internal Only: HIGH - Internal attackers or compromised internal systems can exploit this if they gain access to Celery backends.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires access to manipulate or inject data into Celery backend storage. Proof-of-concept code exists in security advisories.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 5.2.2 and later

Vendor Advisory: https://github.com/celery/celery/blob/master/Changelog.rst#522

Restart Required: Yes

Instructions:

1. Update Celery using pip: 'pip install celery>=5.2.2' 2. Restart all Celery workers and related services 3. Verify the update with 'celery --version'

🔧 Temporary Workarounds

Disable result backend

all

If task results are not needed, disable the result backend entirely

Set CELERY_RESULT_BACKEND = None in Celery configuration

Use secure serializer

all

Configure Celery to use a secure serializer for task metadata

Set CELERY_RESULT_SERIALIZER = 'json' in configuration

🧯 If You Can't Patch

  • Implement strict network access controls to Celery backend storage (Redis, RabbitMQ, etc.)
  • Monitor backend storage for suspicious metadata modifications or unexpected data

🔍 How to Verify

Check if Vulnerable:

Check Celery version with 'celery --version' or 'pip show celery' and verify it's below 5.2.2

Check Version:

celery --version

Verify Fix Applied:

Confirm version is 5.2.2 or higher with 'celery --version' and test that task metadata deserialization works without errors

📡 Detection & Monitoring

Log Indicators:

  • Unexpected command execution in Celery worker logs
  • Errors in task deserialization
  • Suspicious metadata in backend storage

Network Indicators:

  • Unusual connections to Celery backend storage
  • Unexpected data patterns in Redis/RabbitMQ traffic

SIEM Query:

source="celery.log" AND ("command injection" OR "deserialization error" OR "unexpected metadata")

🔗 References

📤 Share & Export