Skip to content

fix(security): 2 improvements across 2 files#1109

Open
tomaioo wants to merge 7 commits into
Akkudoktor-EOS:mainfrom
tomaioo:fix/security/unsafe-pickle-load-in-selfconsumptionpro
Open

fix(security): 2 improvements across 2 files#1109
tomaioo wants to merge 7 commits into
Akkudoktor-EOS:mainfrom
tomaioo:fix/security/unsafe-pickle-load-in-selfconsumptionpro

Conversation

@tomaioo

@tomaioo tomaioo commented Jun 16, 2026

Copy link
Copy Markdown

Summary

fix(security): 2 improvements across 2 files

Problem

Severity: Critical | File: src/akkudoktoreos/prediction/interpolator.py:L20

The SelfConsumptionProbabilityInterpolator class uses pickle.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 .pkl file (regular_grid_interpolator.pkl) can achieve remote code execution when the application loads this file. The code even includes a # noqa: S301 comment 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)

tomaioo added 2 commits June 16, 2026 05:13
- 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>
@b0661

b0661 commented Jun 16, 2026

Copy link
Copy Markdown
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.

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.

3 participants