Harden CORS, handshake origin handling and polling input validation - #218
Open
devin-ai-integration[bot] wants to merge 5 commits into
Open
Harden CORS, handshake origin handling and polling input validation#218devin-ai-integration[bot] wants to merge 5 commits into
devin-ai-integration[bot] wants to merge 5 commits into
Conversation
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Author
Runtime verification — CORS / handshake origin / polling input hardeningTested by starting three real CORS / origin enforcementPolling input validationNit: the Session-id reuse, log redaction, regression |
sanjomo
requested review from
NeatGuyCoding and
sanjomo
and removed request for
NeatGuyCoding
July 25, 2026 17:37
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.
Description
Security hardening found during a scan of the codebase. The main issue:
EncoderHandler.addOriginHeadersreflected any requestOriginback inAccess-Control-Allow-Origintogether withAccess-Control-Allow-Credentials: true(defaultenableCors=true), so any website could read a victim's authenticated polling responses cross-origin. Credentials are now only granted to explicitly configured origins, and a newallowedOriginsallow list is also enforced at handshake time (covering websocket, which is not subject to CORS at all).allowedOriginsentries are matched against the full origin and may contain*wildcards:Type of Change
Related Issue
N/A
Changes Made
BasicConfiguration: newallowedOriginsset +isOriginAllowed()with*wildcard patterns (a wildcard never spans/, so it cannot escape the authority), copied in the copy constructor (so the Spring Boot / Micronaut property binding getsallowed-originsfor free)EncoderHandler: credentials only for configured/allow-listed origins, no CORS headers for disallowed origins,Vary: OriginaddedAuthorizeHandler: reject handshakes from origins outside a non-empty allow list with 403; regenerate the session id when a client supplies (via theioheader/cookie) one already in use, preventing takeover of a live session; redactCookie/Authorization/Proxy-Authorization/X-Api-Keyfrom handshake debug logsPollingTransport: validatej,b64andsidquery params (previouslyNumberFormatException/IllegalArgumentExceptionescaped to the pipeline) and null-check the client on?disconnect(previously an NPE for an unknown sid)Also scanned for, and did not find: hardcoded credentials in main sources, SQL/command injection (no SQL or process execution), unsafe Jackson polymorphic typing (Kafka/NATS codecs use a restrictive
PolymorphicTypeValidator), or outdated dependencies with known CVEs.Testing
AllowedOriginsTest, CORS cases inEncoderHandlerTest)mvn test(netty-socketio-core: 711 tests, 0 failures; 4 pre-existing flaky distributed tests passed on retry)SocketIOServerinstances — see the test results commentChecklist
Additional Notes
Behaviour change to be aware of: cookie-authenticated cross-origin clients (
withCredentials) will stop working until their origin is added tooriginor the newallowedOrigins— that is the point of the fix, since the previous default granted credentials to every origin. Clients that don't send anOriginheader (server-to-server, mobile, CLI) are never rejected. OneEncoderHandlerTestassertion was updated because it asserted the vulnerable behaviour.Link to Devin session: https://app.devin.ai/sessions/8e4e71040eda4df18038140a44f22f06
Requested by: @sanjomo