Skip to main content

10 posts tagged with "security"

View All Tags

Filters Nobody Planned For: Binding attr[color]=red Into Go Maps in Fiber v3.7

ยท 23 min read
Fiber Team
Maintainers

A shop sells jackets. The product list has filters for color and size, and the handler binds them into a struct with a Color field and a Size field. Then the merchandising team adds "material" to the product data, and a week later "hood" and "waterproof rating". Every new attribute is a new struct field, a new WHERE clause, a code review and a deploy, for something that is really just another row in the attributes table. The frontend team would rather send whatever the data has: ?attr[color]=red&attr[material]=down.

Plenty of APIs already speak this shape. PHP turns it into nested arrays and Rails into nested hashes, Stripe takes metadata[...] this way, JSON:API sets aside the filter parameter family for it, and Express parsed it into objects by default until version 5 switched its default query parser to a simpler one. In Fiber, a struct field of type map[string]string used to be skipped by the binder without a word. A request for exactly this has been open since 2023, and Fiber v3.7.0 closes it: map fields of a struct now bind from query strings and form bodies. This post builds a facet filter on top of it, backed by SQLite, and spends most of its time on what a map hands you: keys chosen by whoever sends the request. Everything was built and tested against Fiber v3.7.0 with modernc.org/sqlite v1.62.0. Map fields need Fiber v3.7.0 or later, which needs Go 1.26 like every release since v3.6.0.

Deny by Default: Route-Aware Authorization With c.Endpoint() in Fiber v3.6

ยท 23 min read
Fiber Team
Maintainers

A pull request adds GET /api/admin/export, a CSV download of every customer record. The handler is fine, the test for the CSV format is fine, and the reviewer approves it. Two weeks later somebody notices that the route was registered on the api group instead of the admin group, so the only thing it checked was a valid login. Every customer with an account could download every other customer. Nobody wrote a wrong access rule. The route simply never had one, and nothing in the app noticed.

This is the most ordinary way to end up in A01 of the OWASP Top 10 2025, broken access control, whose first piece of advice is to deny by default. In a Fiber app, "default" usually means "whatever middleware the route happens to inherit from its group". That works until the day a route lands in the wrong place. Fiber v3.6.0 added c.Endpoint(), which lets global middleware see the route that will handle a request before any handler runs. This post uses it to build a single policy table keyed by route name, a middleware that rejects every route the table does not mention, and a startup check that refuses to boot when the table and the routes disagree. Everything was built and tested against Fiber v3.6.1. c.Endpoint(), c.Bearer() and c.SetLocal() need v3.6.0 or later, which requires Go 1.26.

Localhost Is Not a Boundary: DNS Rebinding and Host Authorization in Fiber v3

ยท 22 min read
Fiber Team
Maintainers

Somebody on your team writes a small helper for the editor. It is a Fiber app on 127.0.0.1:7777 that lists and reads files from the current project, so an editor plugin or a coding agent can ask it for context. It has no authentication, because it only listens on loopback and "nothing outside this machine can reach it". That sentence is half true. Nothing outside the machine can open a connection to it. But the browser on the same machine can, and the browser runs code from every website its user visits.

Over the past months, several Model Context Protocol servers received advisories for exactly this setup, among them genieacs-mcp, whose Streamable HTTP transport listened on 127.0.0.1:8080 without checking Host or Origin. The attack behind them is called DNS rebinding, and it is older than most of the tools it now hits. This post shows how it works, why the usual browser defenses do not notice it, and how the hostauthorization middleware that shipped in Fiber v3.3.0 closes the hole, for local tools and for public servers. Everything was built and tested against Fiber v3.6.1, which needs Go 1.26. The example also uses c.Origin(), which arrived in v3.6.0.