Skip to content

Commit

Permalink
Disable http/2 on the webhook server by default
Browse files Browse the repository at this point in the history
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
  • Loading branch information
maysunfaisal committed Oct 26, 2023
1 parent bceebc2 commit 3f459a9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ RUN chmod +x /usr/local/bin/entrypoint.sh
ARG ENABLE_WEBHOOKS=true
ENV ENABLE_WEBHOOKS=${ENABLE_WEBHOOKS}

# disable http/2 on the webhook server by default
ARG ENABLE_WEBHOOK_HTTP2=false
ENV ENABLE_WEBHOOK_HTTP2=${ENABLE_WEBHOOK_HTTP2}

# Set the Git config for the AppData bot
WORKDIR /
COPY --from=builder /workspace/manager .
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ DEVFILE_REGISTRY_URL ?= https://registry.devfile.io
# ENVIRONMENT is used for feature flagging. For testing, values should be development, staging, and production
ENVIRONMENT ?= ""
ENABLE_WEBHOOKS ?= true
ENABLE_WEBHOOK_HTTP2 ?=false

APPLICATION_API_CRD = https://raw.githubusercontent.com/redhat-appstudio/application-api/main/manifests/application-api-customresourcedefinitions.yaml

Expand Down Expand Up @@ -169,7 +170,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go

docker-build: test ## Build docker image with the manager.
docker build --build-arg ENABLE_WEBHOOKS=${ENABLE_WEBHOOKS} -t ${IMG} .
docker build --build-arg ENABLE_WEBHOOKS=${ENABLE_WEBHOOKS} --build-arg ENABLE_WEBHOOK_HTTP2=${ENABLE_WEBHOOK_HTTP2} -t ${IMG} .

docker-push: ## Push docker image with the manager.
docker push ${IMG}
Expand Down
6 changes: 6 additions & 0 deletions docs/build-test-and-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ For example:

`DEVFILE_REGISTRY_URL=https://myregistry make deploy` would deploy application-service configured to use https://myregistry.

#### Enabling HTTP/2 on the Webhook Server

By default, http/2 on the webhook server is disabled due to CVE-2023-44487.

If you want to enable http/2 for the webhook server, build with `ENABLE_WEBHOOK_HTTP2=true make docker-build`

### Deploying Locally

#### Disabling Webhooks for Local Development
Expand Down
16 changes: 16 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package main

import (
"crypto/tls"
"flag"
"fmt"
"log"
Expand Down Expand Up @@ -159,6 +160,12 @@ func main() {
}
}

// Retrieve the option to enable HTTP2 on the Webhook server
enableWebhookHTTP2 := os.Getenv("ENABLE_WEBHOOK_HTTP2")
if enableWebhookHTTP2 == "" {
enableWebhookHTTP2 = "false"
}

// Parse any passed in tokens and set up a client for handling the github tokens
err = github.ParseGitHubTokens()
if err != nil {
Expand Down Expand Up @@ -225,6 +232,15 @@ func main() {
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
setupLog.Info("setting up webhooks")
setUpWebhooks(mgr)
server := mgr.GetWebhookServer()
if enableWebhookHTTP2 == "false" {
setupLog.Info("disabling http/2 on the webhook server")
server.TLSOpts = append(server.TLSOpts,
func(c *tls.Config) {
c.NextProtos = []string{"http/1.1"}
},
)
}
}

if err = (&controllers.SnapshotEnvironmentBindingReconciler{
Expand Down

0 comments on commit 3f459a9

Please sign in to comment.