fix: harden default request timeout, GraphQL error leakage, and LSP exit halt - #102
Merged
Merged
Conversation
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.
A default
ServerApplicationserver had no request timeout, leaving it exposed to Slowloris-style slow-request attacks;HttpTransportandHttpTransport.httpsare now constructed withRequestTimeout.DEFAULT(60 seconds) andMaxRequestSize.DEFAULTinstead of leaving both unset.RequestTimeout.DEFAULTis a new constant; callers that genuinely want no timeout can still passRequestTimeout.NONEexplicitly.GraphQlSchemapreviously forwarded a data fetcher's raw exception message straight into the client-facing GraphQL error, which could leak internal details like stack state, SQL, or file paths.GraphQlSchema.executenow distinguishesExceptionWhileDataFetchingerrors from the GraphQL spec's normal client-facing errors (validation, syntax): the former are logged server-side via a newTelemetryRecorder(settable throughGraphQlSchema.Builder.recorder, defaulting to aSystem.out/System.errrecorder) and replaced with a generic"Internal Server Error"message, while the latter continue to pass through with control-character sanitization only.TaskGraphQlHandlernow takes aTelemetryRecorderand wires it through fromServerApplication, which exposes its recorder via a new protectedrecorder()accessor.LspTransport.tcpbinds loopback-only by convention because theexitnotification unconditionally callsRuntime.halt, and LSP has no authentication of its own. This adds a second layer:exitnow only triggersRuntime.haltwhen the bound address is actually loopback, determined byInetAddress.isLoopbackAddress(); on any other bind address,exitjust closes that connection instead of killing the whole process.