Clean the session files upon unpackling Error in FileSession clean up #2012
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've seen clean failures in my production error log files due to
UnpicklingError: invalid load key, '\x00'
. I suspect the session file was created by attackers. This would 1) break the cleansing thread, leaving many expired sessions not cleaned up, also 2) I tend to think it's not good/safe to ignore and keep these "bad" session files. Below is the original traceback info in the error log.What kind of change does this PR introduce?
What is the related issue number (starting with
#
)What is the current behavior? (You can also link to an open issue here)
UnpicklingError: invalid load key, '\x00'
would break the cleansing thread, leaving many expired sessions not cleaned up, also I tend to think it's not good/safe to ignore and keep these "bad" session files.What is the new behavior (if this is a feature change)?
If pickling a session file is throwing pickling error, then just delete that file.
Other information:
Checklist:
and description in grammatically correct, complete sentences