-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d56e7f9
commit 4b198d4
Showing
9 changed files
with
102 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This has been safeguarded directly in the code | ||
CVE-2024-35515 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import io | ||
import pickle | ||
from base64 import b64decode | ||
from sqlitedict import SqliteDict | ||
|
||
|
||
class RestrictedUnpickler(pickle.Unpickler): | ||
def find_class(self, module, name): | ||
"""Override pickle.Unpickler.find_class() to prevent deserialization of class instances.""" | ||
raise pickle.UnpicklingError("Class deserialization is disabled") | ||
|
||
|
||
def restricted_loads(s): | ||
"""Helper function analogous to pickle.loads().""" | ||
return RestrictedUnpickler(io.BytesIO(s)).load() | ||
|
||
def restricted_decode(obj): | ||
"""Overwrite sqlitedict.decode() to prevent code injection.""" | ||
return restricted_loads(bytes(obj)) | ||
|
||
def restricted_decode_key(key): | ||
"""Overwrite sqlitedict.decode_key() to prevent code injection.""" | ||
return restricted_loads(b64decode(key.encode("ascii"))) | ||
|
||
|
||
class RestrictedSqliteDict(SqliteDict): | ||
def __init__(self, *args, **kwargs): | ||
super(RestrictedSqliteDict, self).__init__(*args, decode=restricted_decode, decode_key=restricted_decode_key, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters