Skip to main content

One post tagged with "symlinks"

View All Tags

Your Symlinks Return 404 on v3.7.0: Root Confinement in the Static Middleware

ยท 20 min read
Fiber Team
Maintainers

A shop runs on a single VM. Every deploy unpacks the build into a new directory under /srv/shop/releases, flips the current link to it, and reloads the service. Product photos and avatars live in /srv/shop/shared/uploads so they survive releases, and the deploy script links that directory into each release as public/uploads. The Fiber app serves /srv/shop/current/public with the static middleware and has done so without trouble for a year.

Then the app moves to Fiber v3.7.0. The tests pass, the deploy goes out, and every avatar on the site turns into a broken image. The CSS still loads, the home page still loads, and the logs show nothing but a stream of 404s for /uploads/.... A few minutes later someone notices that the Apple touch icon and the web fonts are gone too.

The app's code did not change. Fiber v3.7.0 ships fasthttp v1.78.0, and since fasthttp v1.77.0 the file server behind the static middleware resolves every path with Go's os.Root. A file root on disk is now confined: a symbolic link that leads out of it is treated like a missing file. The same release added an opt-out, AllowSymlinksOutsideRoot (#4803). The static documentation states the rule in one paragraph; this post is about what it does to a real deployment. It shows exactly which links are refused, a startup check that lists them before users find them, how to fix each kind without the opt-out, and the paths that the new rule does not cover at all. Everything was built and tested against Fiber v3.7.0 with Go 1.26.11. The option needs Fiber v3.7.0 or later, which needs Go 1.26.