Skip to content

harden localedata loading with restricted unpickler#1272

Open
uwezkhan wants to merge 1 commit into
python-babel:masterfrom
uwezkhan:safe-localedata-unpickler
Open

harden localedata loading with restricted unpickler#1272
uwezkhan wants to merge 1 commit into
python-babel:masterfrom
uwezkhan:safe-localedata-unpickler

Conversation

@uwezkhan
Copy link
Copy Markdown

this replaces the direct pickle.load() usage in babel.localedata with a restricted unpickler.

right now locale data files are loaded using pickle without restricting what objects can be created during deserialization. this change adds a _SafeUnpickler which only allows the small set of classes and builtin types that babel actually needs for locale data loading.

also added security tests to make sure:

normal locale data still loads correctly
malicious pickle payloads are rejected
unsafe globals cannot be loaded during deserialization

the existing .dat files continue to work and no changes are needed for the locale generation process.

this is mainly a defense in depth hardening change to make locale data loading safer against malicious or corrupted pickle data.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant