Skip to content

internal/stream: reject sizes below one tag in EncryptedChunkCount#696

Open
sweis wants to merge 1 commit intoFiloSottile:mainfrom
sweis:claude/fix-stream-negative-size-HXoHp
Open

internal/stream: reject sizes below one tag in EncryptedChunkCount#696
sweis wants to merge 1 commit intoFiloSottile:mainfrom
sweis:claude/fix-stream-negative-size-HXoHp

Conversation

@sweis
Copy link

@sweis sweis commented Mar 12, 2026

EncryptedChunkCount returned (0, nil) for negative or sub-tag-size inputs —
the consistency check rounds both sides to 0 and passes silently. This would
cascade into NewDecryptReaderAt computing finalChunkIndex = -1.

Fix: a valid payload always carries at least one Poly1305 tag, even for empty
plaintext. Reject anything smaller than chacha20poly1305.Overhead up front.

Test: go test ./internal/stream/ -run TestEncryptedChunkCountRejectsSmallSizes -v

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.

2 participants