Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic config to control allowed Host headers #6750

Merged
merged 5 commits into from
Nov 14, 2024

Conversation

bergundy
Copy link
Member

@bergundy bergundy commented Nov 5, 2024

What changed?

Add a dynamic config to restrict which HTTP Host header values are allowed in HTTP API requests.

Why?

Prevent DNS rebinding attacks.

How did you test it?

Added a functional test.

@bergundy bergundy requested a review from a team as a code owner November 5, 2024 00:15
@bergundy bergundy requested a review from dnr November 5, 2024 00:15
common/dynamicconfig/cachedvalue.go Outdated Show resolved Hide resolved
common/dynamicconfig/cachedvalue.go Outdated Show resolved Hide resolved
common/dynamicconfig/cachedvalue.go Outdated Show resolved Hide resolved
@bergundy bergundy requested a review from dnr November 6, 2024 00:30
@bergundy bergundy force-pushed the http-allowed-hosts branch 2 times, most recently from 9b985f0 to c169e01 Compare November 6, 2024 17:25
common/dynamicconfig/cachedvalue.go Show resolved Hide resolved

FrontendHTTPAllowedHosts = NewGlobalTypedSetting(
"frontend.httpAllowedHosts",
[]string{"*"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can't use a non-nil reference for the default value because of how the default converter works (it does a shallow copy and then asks mapstructure to fill it in). this has to be []string(nil) and then handle the nil in application code (or in your second level converter)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate why this is a problem? I'm not sure I'm following. Are you saying that mapstructure will append to this default?

Seems like a usability issue. You can't expect to be the gatekeeper for all DC changing PRs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know :( It should be commented somewhere but I'm not sure where, there's no obvious place for the "api" for defining settings.

I was planning to add a linter or a runtime check using reflection at static init time.

common/dynamicconfig/cachedvalue.go Show resolved Hide resolved
common/wildcard.go Outdated Show resolved Hide resolved
service/frontend/http_api_server.go Show resolved Hide resolved
common/wildcard.go Outdated Show resolved Hide resolved
@bergundy bergundy requested a review from dnr November 12, 2024 22:49
@bergundy bergundy enabled auto-merge (squash) November 13, 2024 19:59
@bergundy bergundy merged commit 55270e4 into temporalio:main Nov 14, 2024
49 checks passed
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.

2 participants