fix(security): 2 improvements across 2 files#1109
Open
tomaioo wants to merge 7 commits into
Open
Conversation
- Security: Unsafe pickle.load in SelfConsumptionProbabilityInterpolator - Security: Unrestricted file path validation in import validators Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
- Security: Unsafe pickle.load in SelfConsumptionProbabilityInterpolator - Security: Unrestricted file path validation in import validators Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
Collaborator
|
Hello @tomaioo, please add a test that shows that your changes are working. Currently I doubt it because you did not convert the pickled file to a format that that can be loaded by your changed method. I would say your AI should do some extra rounds. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
fix(security): 2 improvements across 2 files
Problem
Severity:
Critical| File:src/akkudoktoreos/prediction/interpolator.py:L20The
SelfConsumptionProbabilityInterpolatorclass usespickle.load()to deserialize data from a file without any validation or sanitization. Pickle is a dangerous serialization format that can execute arbitrary code during deserialization. An attacker who can modify or replace the.pklfile (regular_grid_interpolator.pkl) can achieve remote code execution when the application loads this file. The code even includes a# noqa: S301comment acknowledging the security issue but suppresses it rather than fixing it.Solution
Replace pickle with a safer serialization format like JSON, or if binary format is required, use a format with schema validation like Protocol Buffers, FlatBuffers, or numpy's native save/load with explicit array shape/dtype validation. If pickle must be used, implement file integrity verification (e.g., cryptographic signature) and load from a read-only trusted location.
Changes
src/akkudoktoreos/prediction/interpolator.py(modified)src/akkudoktoreos/prediction/elecpriceimport.py(modified)