Skip to content

fix(bfe_http): avoid panic when https backend omits RSInsecureSkipVerify - #1467

Open
NopeCharon wants to merge 2 commits into
bfenetworks:developfrom
NopeCharon:fix-https-backend-nil-insecure-skip-verify
Open

NopeCharon wants to merge 2 commits into
bfenetworks:developfrom
NopeCharon:fix-https-backend-nil-insecure-skip-verify

Conversation

@NopeCharon

Copy link
Copy Markdown

What does this PR do

Fixes #1464

When a cluster's HTTPSConf sets a non-empty RSCAList and leaves RSInsecureSkipVerify unset, Transport.dialConn() dereferenced the nil 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.

That branch is only reached when RSInsecureSkipVerify is nil or false, so the fix passes false to NewVerifyPeerCertHooks() directly. The backend certificate is then verified against RSCAList and RSHost. This matches how the outer check in dialConn() and the https health check already treat an unset RSInsecureSkipVerify.

Additional context

  • Adds a transport unit test that loads such an HTTPSConf through BackendHTTPSCheck(). It checks that a trusted CA succeeds while an untrusted CA or a mismatched RSHost is rejected. Without the fix, the test binary panics at the dereference.
  • Removes the SC38 integration test workaround that always wrote RSInsecureSkipVerify: false. TC-01/02/05/06/07, which use a non-empty RSCAList, now cover the unset field end to end. They crash the BFE process without this fix and pass with it.
  • Marks the defect recorded in the SC38 design docs as fixed.
  • Passing: go test ./bfe_http/... ./bfe_server/... ./bfe_balance/backend/..., go test ./tests/integration/implementation/scenario-SC38-https-backend-tls/, and go vet ./bfe_http/.

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

No deployments
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.

BFE panics when an https backend sets RSCAList without RSInsecureSkipVerify

1 participant