anantbhandarkar/make-it-right/mir-backend-go-echo
Claude Code and agent skill by anantbhandarkar/make-it-right
- community
Checking that the SKILL.md file is still in the repository.
Make It Right (Echo module). Echo web framework reliability augmentation for Go backends, covering Echo v5 (current) and v4 (maintained). Chains: mir-backend (generic gates) -> mir-backend-go (Go runtime) -> this (Echo library mechanics). Adds the mechanical footguns the runtime-agnostic tiers omit: echo.Context comes from a sync.Pool and must never be retained past the handler or handed to a goroutine; the v4->v5 rewrite that AI mixes up (Context became a *echo.Context struct, Logger became *slog.Logger, HTTPErrorHandler's arguments swapped, e.Shutdown and e.Close removed in favour of StartConfig); Bind never validates, so a missing c.Validate ships unchecked input, and Bind merges path and query values into one struct, a mass-assignment path; middleware ordering and graceful shutdown; and Echo's insecure defaults - c.RealIP() trusts X-Forwarded-For unless IPExtractor is set, and middleware.Secure sends no HSTS or CSP. TRIGGER only when the Go backend uses the Echo framework - building, reviewing, or debugging an Echo handler, middleware, or router. SKIP for Gin (mir-backend-go-gin), Fiber (mir-backend-go-fiber), chi, stdlib net/http, or any non-Echo stack, and for every non-Go runtime.
Install
npx vskill@latest install anantbhandarkar/make-it-right/mir-backend-go-echoSKILL.md
The same SKILL.md was published earlier as anantbhandarkar/make-it-right/mir-backend-go-echo.
/mir-backend-go-echo · Make It Right (Echo)
Bottom tier of the chain: mir-backend (generic gates) → mir-backend-go (Go runtime model) → this (Echo library mechanics). Run the gates first; load the Go runtime tier for goroutine lifecycle, context propagation, and race discipline; reach for this at Gate 5 (design mechanics), Gate 6 (implementation), and Gate 7 review. Runtime-level concerns (goroutine leaks, data races, context propagation, typed-nil, slice aliasing, `os.Root`, module checksums) live in `mir-backend-go` — not here.
Stack state, verified 13 Aug 2026.
| Line | Current | Notes | |
|---|---|---|---|
v5 (github.com/labstack/echo/v5) | v5.3.1 (2026-07-21); v5.0.0 GA 2026-01-18 | Current major. go.mod requires Go 1.25 | |
v4 (github.com/labstack/echo/v4) | v4.15.4 (2026-06-15) | Still receiving security and bug fixes |
Establish the major before writing a line. Handler signatures, the logger, the error handler, and the whole server-startup API changed in v5 (footgun 2). Note also that echo-contrib ships separate release lines for v4 and v5 — importing the wrong one gives type errors that look like Echo's fault. Whichever major you are on, this module's earlier claim that "v5 is pre-release" is obsolete: v5 has been GA since January 2026.
The Echo footguns AI walks into most
1. echo.Context is pooled — do not retain it across the handler boundary
Echo keeps contexts in a sync.Pool and reuses them. Storing the context in a struct, or handing it to a goroutine that outlives the handler, means you are reading a context that now belongs to a different request.
c.Request().Context()is canceled the instant the handler returns. Passing it to background work makes every downstream call fail withcontext canceled— this is the more common bug than the pooling itself, because it fails loudly on the first request rather than silently under load.- Values stashed with
c.Set(key, value)live in the per-request store. Read them out before the handler returns if a goroutine needs them. - Copy the values you need into a plain struct. Do not build a helper that "clones the context" — there is no supported clone, and the pooled fields will still be reused.
2. v4 and v5 are different APIs — do not mix them
| Concern | v4 | v5 | |
|---|---|---|---|
| Handler signature | func(c echo.Context) error (interface) | func(c *echo.Context) error (struct pointer) | |
| Logger | custom echo.Logger interface; e.Logger.Error(...) | *slog.Logger; c.Logger() returns *slog.Logger | |
| Error handler | func(err error, c echo.Context) | func(c *echo.Context, err error) — arguments swapped | |
| Default error handler | e.DefaultHTTPErrorHandler | DefaultHTTPErrorHandler(exposeError bool) factory | |
| Binder interface | Bind(i any, c Context) error | Bind(c *Context, target any) error | |
| Standalone binders | — | BindBody, BindQueryParams, BindPathValues (was BindPathParams), BindHeaders | |
| Server startup | e.Start / e.StartTLS / e.Shutdown / e.Close; e.Server is an exported *http.Server | StartConfig{...}.Start(ctx, e); `e.Shutdown` and `e.Close` are gone; the http.Server is internal, reachable only via StartConfig.BeforeServeFunc | |
c.RealIP() default | trusts X-Forwarded-For / X-Real-IP | trusts them in v5.0.0; returns the socket peer address from v5.1.0 | |
| Removed | — | GetPath, the MethodNotAllowedHandler / NotFoundHandler package variables |
The swapped HTTPErrorHandler arguments are the nastiest: both parameters are single-word types, so a v4 handler pasted into a v5 project can compile in some shapes and log the wrong thing.
3. Bind does not validate — and Bind reads more sources than you think
c.Bind(&req) deserializes; it never runs validation tags. Two separate mistakes follow.
Forgetting `Validate` is the silent one. Registering no validator is loud — c.Validate(x) returns ErrValidatorNotRegistered. Never calling Validate at all produces no error anywhere, and your validate:"required,email" tags are decoration.
`Bind` merges sources. Echo's default binder fills the struct from path parameters and, for methods without a body (GET, DELETE, HEAD), from query parameters — as well as from the body. A field an attacker cannot reach through JSON may be settable through the URL. When you want exactly one source, use the explicit binders (echo.BindBody(c, &req), echo.BindQueryParams(c, &req) in v5; (&echo.DefaultBinder{}).BindBody(c, &req) in v4) instead of the catch-all Bind.
- Never bind to your DB/ORM model. Use a dedicated request struct per endpoint. See Security, mass assignment.
validate:"required"rejects the zero value, not just an absent key — use a pointer field when0or""is legitimate.
4. Middleware order — Recover() first, and know Pre from Use
Echo runs middleware in registration order. Your middleware registered before middleware.Recover() is not covered by it, and a panic there kills the process.
e.Pre(...)runs before the router matches, so it is the only place a middleware can change the path that routing sees.e.Use(...)runs after the match.- Anything in
Prethat rewrites or unescapes the path can desynchronise routing from later path handling — that is exactly the shape of CVE-2026-55677 (see Security). Add path-rewriting middleware deliberately, never by copy-paste. - Group middleware applies to routes registered on that group after the
Usecall. Register middleware first, routes second. Recover()covers panics on the request goroutine only. Goroutines you spawn need their ownrecover—mir-backend-gofootgun 5.
5. HTTPErrorHandler — one error shape, and do not expose the error
Returning raw Go errors from handlers produces a different response shape per endpoint and leaks internals. Echo's default (DefaultHTTPErrorHandler(false)) returns {"message": "<status text>"}; the factory's exposeError argument adds {"error": "<err.Error()>"} to the body — that is direct internal-error disclosure, and it must stay false outside development.
- Return
echo.NewHTTPError(code, message)from handlers and middleware; let the error handler shape the response. - The error handler does nothing if the response is already committed. A handler that writes a 200 and then returns an error sends a 200 with a success body — check errors before you write.
- The default handler does not log. If you replace it, logging is now your job; if you keep it, add a logging middleware or errors vanish.
6. Graceful shutdown — different in each major
v5: e.Start(":8080") already installs a SIGINT/SIGTERM handler and drains with a default GracefulTimeout of 10 seconds. e.Shutdown and e.Close no longer exist. To tune it, drive StartConfig yourself:
A negative GracefulTimeout disables draining entirely — do not set it to skip a slow shutdown; fix the slow request instead.
v4: wire it manually, and set the timeouts, because e.Server is a zero-value *http.Server with none:
In both majors, Shutdown does not wait for goroutines you spawned inside handlers — track them yourself. Close DB pools after the drain returns.
Security
Echo-specific mechanics. Runtime-level items (os.Root, SSRF dialer control, govulncheck, module checksums, secret redaction) are in mir-backend-go.
CVE-2026-55677 — encoded %2F bypassed route-level middleware
The router matched on the raw encoded path while StaticDirectoryHandler unescaped %2F to / before resolving the file. A request could therefore be routed as if it were a public path while the file handler read a protected one, bypassing auth middleware attached to a route prefix. High severity, CVSS 7.5.
| Affected | Fixed | |
|---|---|---|
| v4 ≤ 4.15.2 | 4.15.3 | |
| v5 ≤ 5.1.1 | 5.2.0 |
The fix disables path unescaping in static file serving by default. That means:
middleware.StaticConfig.EnablePathUnescaping = truere-opens the exact mismatch the fix closed. Turn it on only if you genuinely serve files whose names contain encoded characters, and only if no middleware makes authorization decisions from the path.DisablePathUnescapingis deprecated and now ignored.- The router's
RouterConfig.UnescapePathParamValuesis the same class of decision for path parameters. - The pattern to recognise:
e.StaticFS("/", os.DirFS("public"))next to route-prefix auth middleware. Authorize on the resource, not on the string in the URL.
GHSA-pgvm-wxw2-hrv9 (Feb 2026) is the sibling bug: Windows path traversal via backslash in middleware.Static's default filesystem. Serve from an explicit fs.FS (os.DirFS, embed.FS) rather than the default root-path filesystem, and keep Browse: false so directories are not listed.
c.RealIP() trusts client headers on v4 and on v5.0.0
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/mir-backend-go-echo/SKILL.md
Popularity
- Repository stars
- 15
- 7-day trend score
- 14
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/anantbhandarkar/make-it-right/mir-backend-go-echo)