You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
security: remove pickle from forms and Celery serializer
Pickle deserialization on attacker-controllable bytes is arbitrary code
execution. Two sites used pickle:
- The survey choice-question form pickled/unpickled a list of strings
through MultiExampleField.compress / MultiWidgetBasic.decompress and
pickle.loads in survey/views.py. Switched to json — the data is just a
list of up to 6 strings.
- Celery defaulted to the pickle serializer with
CELERY_ACCEPT_CONTENT including pickle/yaml/msgpack so dispatch sites
could pass Django model instances and a Dojo_User on the wire. Made
every task argument JSON-serializable: async_delete_task takes
(model_label, pk) and refetches; SLA recompute takes
(sla_config_id, product_ids); per-channel notification sends run
inline inside the surrounding async_create_notification task instead
of dispatching an inner Celery task with model instances; user
context is injected as async_user_id and resolved in the worker.
Flipped DD_CELERY_TASK_SERIALIZER default to json, tightened
CELERY_ACCEPT_CONTENT to ["json"], and added
CELERY_RESULT_SERIALIZER = "json".
Added unittests/test_no_pickle.py as a regression net (asserts no
pickle imports in dojo/ and that the Celery serializer settings stay
JSON-only) and unittests/test_survey_forms.py for the widget round-trip.
Operator note: workers running this version reject in-flight pickled
messages with ContentDisallowed. Drain the broker
(\`celery -A dojo purge -f\`) or scale workers to zero before deploy.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
"expires": int(60*60*1*1.2), # If a task is not executed within 72 minutes, it should be dropped from the queue. Two more tasks should be scheduled in the meantime.
0 commit comments