docs(cors): Security section on wildcard origin + credentials (#277)#418
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #277 (which tracked upstream echo#2400).
Background
echo#2400 reported that a wildcard origin +
AllowCredentials: truereflects any request'sOriginback inAccess-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:
*+AllowCredentials: truereflects anyOrigin, allowing credentialed cross-origin requests from any site (links to the PortSwigger write-up).CORSandCORSWithConfigpanic, andCORSConfig.ToMiddleware()returns an error, instead of building the insecure middleware (verified against echo v5middleware/cors.go).UnsafeAllowOriginFuncfor dynamic validation, with a caution about hostile subdomains.Applied across all 5 locales (translated prose, identical code block).
Verification
toMiddlewareOrPanicand the"* as allowed origin and AllowCredentials=true is insecure and not allowed"error.Closes #277
🤖 Generated with Claude Code