Skip to content

Commit 7f8179a

Browse files
committed
_utils: document the security properties of sha256_streaming
Signed-off-by: William Woodruff <[email protected]>
1 parent 80639bc commit 7f8179a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sigstore/_utils.py

+12
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ def sha256_streaming(io: IO[bytes]) -> bytes:
114114
should be supplied for optimal performance.
115115
"""
116116

117+
# NOTE: This function performs a SHA256 digest over a stream.
118+
# The stream's size is not checked, meaning that the stream's source
119+
# is implicitly trusted: if an attacker is able to truncate the stream's
120+
# source prematurely, then they could conceivably produce a digest
121+
# for a partial stream. This in turn could conceivably result
122+
# in a valid signature for an unintended (truncated) input.
123+
#
124+
# This is currently outside of sigstore-python's threat model: we
125+
# assume that the stream is trusted.
126+
#
127+
# See: https://github.com/sigstore/sigstore-python/pull/329#discussion_r1041215972
128+
117129
sha256 = hashlib.sha256()
118130
# Per coreutils' ioblksize.h: 128KB performs optimally across a range
119131
# of systems in terms of minimizing syscall overhead.

0 commit comments

Comments
 (0)