Fiber: HSTS header never set in helmet middleware due to incorrect protocol check
gofiber fiber
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| github.com/gofiber/fiber Go |
|
|
| github.com/gofiber/fiber/v3 Go |
|
|
gofiber fiber
| Product | Affected | Fixed in |
|---|---|---|
| github.com/gofiber/fiber Go |
|
|
| github.com/gofiber/fiber/v3 Go |
|
|
Fiber is an Express inspired web framework written in Go. Prior to 3.4.0, the helmet middleware in middleware/helmet/helmet.go never sets the Strict-Transport-Security response header even when HSTSMaxAge is configured because it checks c.Protocol() for https instead of c.Scheme(). This issue is fixed in version 3.4.0.
From the CVE record · GitHub_M
Before 3.4.0, Fiber’s helmet middleware does not set the Strict-Transport-Security header even when HSTSMaxAge is configured, because it checks the wrong request property for HTTPS. This leaves clients without the configured HSTS protection; the input does not specify an authentication requirement or user interaction.
Teams running github.com/gofiber/fiber or github.com/gofiber/fiber/v3 versions earlier than 3.4.0 should check their deployments.