Skip to content

docs(cors): Security section on wildcard origin + credentials (#277)#418

Merged
vishr merged 1 commit into
masterfrom
docs-cors-security
Jun 16, 2026
Merged

docs(cors): Security section on wildcard origin + credentials (#277)#418
vishr merged 1 commit into
masterfrom
docs-cors-security

Conversation

@vishr

@vishr vishr commented Jun 16, 2026

Copy link
Copy Markdown
Member

Closes #277 (which tracked upstream echo#2400).

Background

echo#2400 reported that a wildcard origin + AllowCredentials: true reflects any request's Origin back in Access-Control-Allow-Origin — a cross-origin attack vector. The maintainer's resolution note: "we need to add a security block to echo.labstack.com." The CORS page only had a terse one-line caution.

Change

Replaces that caution with a proper Security section that explains:

  • The danger — wildcard * + AllowCredentials: true reflects any Origin, allowing credentialed cross-origin requests from any site (links to the PortSwigger write-up).
  • v5's enforcementCORS and CORSWithConfig panic, and CORSConfig.ToMiddleware() returns an error, instead of building the insecure middleware (verified against echo v5 middleware/cors.go).
  • The safe pattern — enumerate trusted origins explicitly; use UnsafeAllowOriginFunc for dynamic validation, with a caution about hostile subdomains.

Applied across all 5 locales (translated prose, identical code block).

Verification

  • Build passes (301 pages).
  • Behavior statements checked against echo v5 source: toMiddlewareOrPanic and the "* as allowed origin and AllowCredentials=true is insecure and not allowed" error.

Closes #277

🤖 Generated with Claude Code

Upstream echo#2400 asked for the docs to explain the danger of combining a
wildcard origin with AllowCredentials, and the maintainer asked for a security
block on echo.labstack.com. The page only had a one-line caution that didn't
explain the behaviour or v5's enforcement.

Expand it into a "Security" section that explains:
- the danger: wildcard origin + AllowCredentials:true reflects any Origin back,
  enabling credentialed cross-origin attacks;
- v5's enforcement: CORS / CORSWithConfig panic and ToMiddleware() returns an
  error rather than building an insecure middleware;
- the safe pattern (explicit origins) and UnsafeAllowOriginFunc for dynamic
  validation.

Applied across all five locales (translated prose, identical code block).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vishr vishr merged commit c28aa7d into master Jun 16, 2026
2 checks passed
@vishr vishr deleted the docs-cors-security branch June 16, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve CORS middleware page

1 participant