Repository navigation
fix(bfe_http): avoid panic when https backend omits RSInsecureSkipVerify - #1467
Open
NopeCharon wants to merge 2 commits into
Open
NopeCharon wants to merge 2 commits into
NopeCharon wants to merge 2 commits into
Conversation
When a cluster's HTTPSConf sets a non-empty RSCAList and leaves RSInsecureSkipVerify unset, dialConn() dereferenced the nil RSInsecureSkipVerify pointer while building the certificate verification hooks. dialConn() runs in its own goroutine without a recover, so the first request forwarded to such a cluster crashed the whole bfe process. RSInsecureSkipVerify is optional and the rest of the code (the outer check in dialConn and the https health check) treats nil as false. This branch is only reached when RSInsecureSkipVerify is nil or false, so pass false to NewVerifyPeerCertHooks() directly: the backend certificate is verified against RSCAList and RSHost, as documented for an unset RSInsecureSkipVerify. Add a transport unit test that loads such an HTTPSConf through BackendHTTPSCheck() and checks a trusted CA succeeds while an untrusted CA or a mismatched RSHost is rejected. Drop the SC38 integration test workaround that always wrote RSInsecureSkipVerify=false, so the cases with a non-empty RSCAList now cover the unset field end to end, and mark the defect recorded in the SC38 design docs as fixed. Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
This branch has not been deployed
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.
What does this PR do
Fixes #1464
When a cluster's
HTTPSConfsets a non-emptyRSCAListand leavesRSInsecureSkipVerifyunset,Transport.dialConn()dereferenced the nil pointer while building the certificate verification hooks.dialConn()runs in its own goroutine without arecover, so the first request forwarded to such a cluster crashed the whole BFE process.That branch is only reached when
RSInsecureSkipVerifyis nil or false, so the fix passesfalsetoNewVerifyPeerCertHooks()directly. The backend certificate is then verified againstRSCAListandRSHost. This matches how the outer check indialConn()and the https health check already treat an unsetRSInsecureSkipVerify.Additional context
HTTPSConfthroughBackendHTTPSCheck(). It checks that a trusted CA succeeds while an untrusted CA or a mismatchedRSHostis rejected. Without the fix, the test binary panics at the dereference.RSInsecureSkipVerify: false. TC-01/02/05/06/07, which use a non-emptyRSCAList, now cover the unset field end to end. They crash the BFE process without this fix and pass with it.go test ./bfe_http/... ./bfe_server/... ./bfe_balance/backend/...,go test ./tests/integration/implementation/scenario-SC38-https-backend-tls/, andgo vet ./bfe_http/.