Skip to content

Conversation

glbrntt
Copy link
Collaborator

@glbrntt glbrntt commented Jun 2, 2025

Motivation:

The decompressor has a decompression limit to protect against zip bombs. This can either be absolute or ratio based. It's also possible in gRPC for a zero length message to be marked as compressed. gRPC attempts to decompress the zero length message and fails (because zlib wants a non-zero sized buffer and gRPC won't give it one as the limit is the buffer size is limited by the ratio * msg_size which in this case is zero).

Modifications:

  • If the input to decompress has no length, skip decompression altogether

Result:

Motivation:

The decompressor has a decompression limit to protect against zip bombs.
This can either be absolute or ratio based. It's also possible in gRPC
for a zero length message to be marked as compressed. gRPC attempts
to decompress the zero length message and fails (because zlib wants a
non-zero sized buffer and gRPC won't give it one as the limit is the
buffer size is limited by the `ratio * msg_size` which in this case is
zero).

Modifications:

- If the input to decompress has no length, skip decompression
  altogether

Result:

- Can decompress zero length payloads with the ratio limit
- Resolves grpc#2245
@glbrntt glbrntt added 🔨 semver/patch No public API change. version/v1 Relates to v1 labels Jun 2, 2025
@glbrntt glbrntt merged commit a56a157 into grpc:release/1.x Jun 3, 2025
11 checks passed
@glbrntt glbrntt deleted the v1/decompression branch June 3, 2025 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change. version/v1 Relates to v1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants