---
id: "GHSA-h7wr-284f-5qvc"
kind: "vulnerability"
aliases: ["GHSA-h7wr-284f-5qvc"]
title: "Echo: Decompress permits unbounded gzip expansion in v4"
severity: "high"
cvss: null
epss: null
exploited: false
status: "open"
category: "package"
products: [{"name": "github.com/labstack/echo/v4", "fixed": ["4.16.1"], "affected": ">= 4.0.0, < 4.16.1", "ecosystem": "go"}]
ecosystems: ["go"]
tags: ["api-servers", "cwe-400", "cwe-409", "echo", "go", "package", "self-hosted"]
not_affected_if: ["body-limit-after-decompress", "default-config", "middleware-not-enabled"]
published_at: "2026-10-23T20:49:49+00:00"
first_seen_at: "2026-10-23T20:59:05+00:00"
updated_at: "2026-10-23T21:00:33+00:00"
sources: [{"source": "ghsa", "url": "https://github.com/advisories/GHSA-h7wr-284f-5qvc", "first_seen_at": "2026-10-23T20:59:05+00:00"}]
---

# Echo: Decompress permits unbounded gzip expansion in v4

The Echo v4 Decompress middleware does not limit how large a gzip request body can grow when decoded. A small compressed request can expand into a very large body that exhausts server memory or CPU, causing denial of service.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- go:github.com/labstack/echo/v4 affected >= 4.0.0, < 4.16.1 fixed 4.16.1

## How to check

Check go.mod for github.com/labstack/echo/v4 at a version below 4.16.1 (go list -m github.com/labstack/echo/v4).
Search the code for middleware.Decompress() or echo.DecompressConfig to see whether the middleware is enabled.

## Fix

Upgrade github.com/labstack/echo/v4 to v4.16.1 or later.
Alternatively, disable gzip request decompression on exposed routes, or place BodyLimit after Decompress so the limit applies to decoded bytes.

## Timeline

- 2026-10-23T20:59:05+00:00 ghsa https://github.com/advisories/GHSA-h7wr-284f-5qvc

## From the sources

## Impact

Echo v4's opt-in Decompress middleware exposed a gzip-decoded request stream without limiting its expanded size. A small compressed request could therefore produce a very large decoded body. Handlers that read or bind that body could consume excessive memory or CPU, and repeated or concurrent requests could cause denial of service.

The middleware is not enabled by default. A limit on the compressed request size alone does not bound the decompressed size. Applications that already apply an effective body limit after decompression have reduced exposure.

## Affected versions and patch

Echo v4 versions through v4.16.0 are affected. Upgrade to [v4.16.1](https://github.com/labstack/echo/releases/tag/v4.16.1).

The patch adds `DecompressConfig.MaxDecompressedSize`, defaulting to 100 MiB when zero. A value of `-1` explicitly disables the limit. Reading beyond the cap returns `ErrStatusRequestEntityTooLarge` (HTTP 413), including through JSON and XML binding. Bodies exactly at the configured limit remain valid. Streaming enforcement requires callers to handle body-read errors.

[Fix commit](https://github.com/labstack/echo/commit/3fb0ba7e17645bb65611e2a08875d0a2f65c421f).

## Workarounds

Disable gzip request decompression on exposed routes, or place BodyLimit after Decompress so the application limit applies to decoded bytes. Apply suitable request deadlines and concurrency limits as well.

## Credits

Reported by @q490107865. The exact-limit behavior incorporates @Shubham-Padkonde's work in [#3136](https://github.com/labstack/echo/pull/3136).

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
