Skip to content

fix: use incremental hashing in Preset.get_hash() - #3905

Open
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/presets-chunked-hash
Open

fix: use incremental hashing in Preset.get_hash()#3905
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/presets-chunked-hash

Conversation

@Quratulain-bilal

Copy link
Copy Markdown
Contributor

Problem

Preset.get_hash() called f.read() which loads the entire file into memory before hashing. A maliciously sized preset file could cause unbounded memory allocation.

Fix

Use incremental hashlib.sha256().update() with 64 KiB chunks.

Testing

  • Verified hash output matches the previous implementation for the same file

…tire file into memory

Preset.get_hash() called f.read() which loads the entire file into
memory before hashing. Use incremental hashlib.sha256().update()
with 64 KiB chunks to prevent unbounded memory allocation on large
or maliciously sized preset files.
@Quratulain-bilal
Quratulain-bilal requested a review from mnriem as a code owner July 31, 2026 12:13
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