Skip to main content

Live HTML Over SSE With app.Render and htmx

· 25 min read
René Werner
Fiber maintainer

A support team works from a shared queue page that polls the server every five seconds. The queue is never quite current, so two agents regularly claim the same ticket within those five seconds, and one of them finds out later that the work was wasted. Meanwhile thirty open tabs ask the server 360 times a minute whether anything happened. Nearly always, nothing did.

Server-Sent Events fix both, and pushing HTML instead of JSON keeps one rendering layer: the fragment comes from the same Go template as the page, and htmx swaps it in with no JavaScript of your own. But c.Render writes only into the response at hand, while one agent's claim has to reach thirty other streams. app.Render writes a template through the configured view engine into any io.Writer.

I built the live queue on it: each update rendered once, numbered, replayed after a reconnect. On the way, an htmx settle delay lost every claim in a headless browser and a later request overwrote a stored form value. app.Render wraps fragments in the page layout unless you pass "", and one reconnect path arrives without Last-Event-ID. Each comes with its fix.

Deny by Default: Route-Aware Authorization With c.Endpoint()

· 23 min read
René Werner
Fiber maintainer

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.

That is the most ordinary way into 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 a route inherits from its group, and that holds until a route lands in the wrong place.

c.Endpoint() lets a global middleware see the route that will handle a request before any handler runs. That is enough to keep every access rule in one table keyed by route name, deny any route the table does not mention, and refuse to start when the table and the routes disagree.

Localhost Is Not a Boundary: DNS Rebinding and Host Authorization

· 22 min read
René Werner
Fiber maintainer

Somebody on your team writes a small helper for the editor: a Fiber app on 127.0.0.1:7777 that lists and reads project files, so an editor plugin or a coding agent can ask it for context. It has no authentication, because "nothing outside this machine can reach it". That is half true. Nothing outside the machine can connect 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 is DNS rebinding, older than most of the tools it now hits.

CORS and Fiber's tokenless CSRF check both miss it. The Host header gives it away, and the hostauthorization middleware turns the rebound request into a 403, on a local tool and on a public server alike.