Security
- Proxy middleware: after routing, a
.or..path segment (also encoded as%2e) was resolved byRewrite/RegexRewriteor by the upstream into a path the router never matched.GET /api/x/../admin/usersmatched an unprotected/api/*proxy group but reached the upstream as/admin/users, skipping middleware such as authentication on/api/admin. After routing, Proxy now returns400 Bad Requestfor such paths, and rewrite targets in Proxy and the Rewrite middleware are applied literally instead of being resolved; a target with a dot segment or a leading//is rejected. Fixes GHSA-w5j2-g3fc-pwr6. Reported by AndyAnh174. - Static files:
Static,StaticFS,Group.StaticandGroup.StaticFSwith a prefix without a trailing slash registeredprefix*, so/assetsadmin/private.txtwas served from<root>/admin/private.txtfore.Static("/assets", root), bypassing a guard on/assets/admin. They now registerprefix/*, plusprefixfor the redirect toprefix/. Fixes GHSA-76qj-xf66-r429. Reported by AndyAnh174. - Static middleware on a group: documented that
middleware.Staticattached withGroup#Useis not protected by guards on routes inside the group or on nested groups, and thatGroup#Staticshould be used for files behind such guards. See GHSA-5hp7-4fcm-57f9. Reported by AndyAnh174.
Fixes
- Map binding: binding path, query, header or form data into a map whose value type is not
string,[]stringoranyreturns an error instead of skipping the values, and named string types no longer panic. Fixes #3235 in #3238. - Gzip middleware:
Accept-Encodingquality values are honored (gzip;q=0refuses gzip,x-gzipis accepted, substrings such asnotgzipno longer match), and responses that already have aContent-Encoding, for example from a reverse proxy, are passed through instead of compressed twice. Also fixesWritereporting more bytes than given at theMinLengththreshold, a truncated stream when a handler only flushes, and staleContent-LengthandContent-Encodingheaders. Fixes #3232 and #2788 in #3239. - Response:
Flushcommits an uncommitted response,WriteHeaderpasses 1xx informational codes (such as103 Early Hints) through without committing, and the built-in error handlers removeContent-Encoding,Content-LengthandContent-Dispositionbefore writing the error body. Fixes #3240, #3241 and #3242 in #3243.
Behavior changes
- After routing, Proxy rejects paths with
./..segments, and a Rewrite middleware attached after routing (onEcho#Use, a group or a route) applies its targets literally: relative targets and absolute URLs are rejected.Echo#Preis unchanged. StaticandStaticFSreturn theRouteInfoofprefix/*instead ofprefix*, and file names that only start with the prefix (for example/img-logo.pngfore.Static("/img-", dir)) are no longer served.- Binding into an unsupported map type returns
400 Bad Request. - A handler that sets
Content-Encodingitself is assumed to have encoded the body; the Gzip middleware no longer compresses it. - Custom
HTTPErrorHandlers still need to clear staleContent-Encoding,Content-LengthandContent-Dispositionthemselves.
No dependency or minimum Go-version changes.