Skip to content

fix: remove unsafe pickle deserialization in txt_to_obj (CVE CWE-502)#677

Merged
dushyantbehl merged 1 commit into
foundation-model-stack:mainfrom
YashasviChaurasia:fix/remove-pickle-deserialization
Jul 21, 2026
Merged

fix: remove unsafe pickle deserialization in txt_to_obj (CVE CWE-502)#677
dushyantbehl merged 1 commit into
foundation-model-stack:mainfrom
YashasviChaurasia:fix/remove-pickle-deserialization

Conversation

@YashasviChaurasia

Copy link
Copy Markdown
Contributor

Description of the change

Remove the pickle.loads fallback in txt_to_obj() which allowed arbitrary code execution via crafted base64 payloads in the SFT_TRAINER_CONFIG_JSON_ENV_VAR environment variable (CWE-502). The function now only accepts JSON. The corresponding serialize_args() in build/utils.py is updated to use json.dumps instead of pickle.dumps.

Related issue number

Closes CVE report: Deserialization of Untrusted Data (CWE-502, CVSS 9.9 Critical)

How to verify the PR

  1. Confirm pickle is no longer imported or used in tuning/utils/config_utils.py or build/utils.py
  2. Run: PYTHONPATH=. pytest tests/utils/test_config_utils.py::test_get_json_config_can_load_from_envvar -v
  3. Verify the previous exploit payload (base64-encoded pickle opcodes) now raises a json.JSONDecodeError instead of executing

Was the PR tested

  • I have added >=1 unit test(s) for every new method I have added.
  • I have ensured all unit tests pass

@github-actions

Copy link
Copy Markdown

Thanks for making a pull request! 😃
One of the maintainers will review and advise on the next steps.

@github-actions github-actions Bot added the fix label Jul 20, 2026
@YashasviChaurasia
YashasviChaurasia force-pushed the fix/remove-pickle-deserialization branch 3 times, most recently from 1173cd3 to 51470f9 Compare July 20, 2026 08:37

@dushyantbehl dushyantbehl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YashasviChaurasia do we know why some tests are failing here?
if its only mlflow tests then can you disable them in the workflow as part of the PR.

@dushyantbehl dushyantbehl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM apart from minor request

@YashasviChaurasia
YashasviChaurasia force-pushed the fix/remove-pickle-deserialization branch from 51470f9 to 877c69c Compare July 20, 2026 20:06
@dushyantbehl
dushyantbehl merged commit b837608 into foundation-model-stack:main Jul 21, 2026
8 checks passed
@dushyantbehl

Copy link
Copy Markdown
Collaborator

@YashasviChaurasia I have merged this PR...please see if any test case run needs fixing. We can merge it separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants