CVE-2023-41338: Vulnerability in Ctx.IsFromLocal() in gofiber
Impact This vulnerability can be categorized as a security misconfiguration. It impacts users of our project who rely on the ctx.IsFromLocal() method to restrict access to localhost requests. If exploited, it could allow unauthorized access to resources intended only for localhost.
In it's implementation it uses c.IPs():
go // IPs returns a string slice of IP addresses specified in the X-Forwarded-For request header. // When IP validation is enabled, only valid IPs are returned. func (c Ctx) IPs() []string { return c.extractIPsFromHeader(HeaderXForwardedFor) }
Thereby, setting X-Forwarded-For: 127.0.0.1 in a request from a foreign host, will result in true for ctx.IsFromLocal()
Patches This issue has been patched in v2.49.2 with commit b8c9ede6efa231116c4bd8bb9d5e03eac1cb76dc
Workarounds Currently, there are no known workarounds to remediate this vulnerability without upgrading to the patched version. We strongly advise users to apply the patch as soon as it is released.
References For further information and context regarding this security issue, please refer to the following resources:
- Mozilla Developer Network - X-Forwarded-For
Other sources
Fiber is an Express inspired web framework built in the go language. Versions of gofiber prior to 2.49.2 did not properly restrict access to localhost. This issue impacts users of our project who rely on the ctx.IsFromLocal method to restrict access to localhost requests. If exploited, it could allow unauthorized access to resources intended only for localhost. Setting X-Forwarded-For: 127.0.0.1 in a request from a foreign host, will result in true for ctx.IsFromLocal. Access is limited to the scope of the affected process. This issue has been patched in version 2.49.2 with commit b8c9ede6. Users are advised to upgrade. There are no known workarounds to remediate this vulnerability without upgrading to the patched version.
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the vulnerability ID of this security advisory?
The vulnerability ID is CVE-2023-41338.
What is the impact of this vulnerability?
This vulnerability can allow unauthorized access to restricted resources.
What software versions are affected by this vulnerability?
Versions of Gofiber Fiber up to 2.49.2 and github.com/gofiber/fiber/v2 up to version 2.49.2 are affected.
How can I fix this vulnerability?
Update to a version of Gofiber Fiber and github.com/gofiber/fiber/v2 that is later than 2.49.2.
Where can I find more information about this vulnerability?
More information about this vulnerability can be found in the [security advisory](https://github.com/gofiber/fiber/security/advisories/GHSA-3q5p-3558-364f).