Skip to content

Disable cache backend using pickle#1

Open
soapy1 wants to merge 4 commits into
masterfrom
disable-pickle
Open

Disable cache backend using pickle#1
soapy1 wants to merge 4 commits into
masterfrom
disable-pickle

Conversation

@soapy1
Copy link
Copy Markdown
Owner

@soapy1 soapy1 commented Apr 24, 2026

This aims to mitigate GHSA-w8v5-vhqr-4h9v by:

soapy1 added 2 commits April 24, 2026 10:25
- create cache dirs only accessible by owner
- set default cache to JSONCache

refs:
- grantjenks#359
- src.fedoraproject.org/rpms/python-diskcache/pull-request/1#
Comment thread diskcache/core.py
:param int pickle_protocol: pickle protocol for serialization

"""
raise RuntimeError("Disk has been disabled as a mitigation for CVE-2025-69872. Please use JSONDisk instead.")
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Also considered raising other errors - TypeError, NotImplementedError but these seemed not as accurate.

Comment thread diskcache/core.py
"""
self.compress_level = compress_level
super().__init__(directory, **kwargs)
self._directory = directory
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This still keeps the relationship between JSONDisk and Disk but tries to avoid raising the error when Disk is instantiated.
It might be worth it to try to separate these two a bit more.

@soapy1 soapy1 changed the title Disable cache backend uing pickle Disable cache backend using pickle Apr 24, 2026
Comment thread diskcache/__init__.py
EVICTION_POLICY,
UNKNOWN,
Cache,
Disk,
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

This makes diskcache.Disk not importable. For example:

$ python
>>> import diskcache
>>> from diskcache import JSONDisk
>>> from diskcache import Disk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'Disk' from 'diskcache' (/home/sophia/projects/python-diskcache/diskcache/__init__.py)
>>> 

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