-
Notifications
You must be signed in to change notification settings - Fork 65
Feat: ConfigMap-driven workflow HTTP denylist and SSRF hardening #235
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
Open
roguepikachu
wants to merge
9
commits into
kubevela:main
Choose a base branch
from
roguepikachu:fix/ssrf-http-guard
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
03f2857
Fix: harden workflow HTTP against SSRF by default.
roguepikachu a7ec9b2
Feat: add ConfigMap-driven workflow HTTP denylist.
roguepikachu 2a62a25
Fix: load HTTP deny ConfigMap via APIReader at startup.
roguepikachu e289a63
Fix: harden httpguard against review findings.
roguepikachu 367fdd0
Fix: resolve lint failure and raise httpguard patch coverage.
roguepikachu d90b69c
Test: raise patch coverage for HTTP deny wiring.
roguepikachu 839576e
Fix: close cubic review SSRF gaps in httpguard.
roguepikachu c78bf1c
Fix: include http_deny.go in Docker image builds.
roguepikachu b2ce418
Feat: add validated workflow HTTP deny config template.
roguepikachu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Workflow HTTP denylist config | ||
|
|
||
| Apply the system config template, then create a denylist ConfigMap in the | ||
| workflow controller namespace: | ||
|
|
||
| ```bash | ||
| vela config-template apply \ | ||
| -f charts/vela-workflow/config-templates/workflow-http-deny.cue | ||
|
|
||
| vela config create workflow-http-deny \ | ||
| --template workflow-http-deny \ | ||
| --namespace vela-system \ | ||
| 'denyHosts={metadata.google.internal,*.example.com}' \ | ||
| 'denyCIDRs={10.0.0.0/8,169.254.169.254}' | ||
| ``` | ||
|
|
||
| Configure the controller to load that ConfigMap: | ||
|
|
||
| ```bash | ||
| helm upgrade workflow kubevela/vela-workflow \ | ||
| --namespace vela-system \ | ||
| --reuse-values \ | ||
| --set workflow.httpDeny.configMapName=workflow-http-deny | ||
| ``` | ||
|
|
||
| The Helm chart does not install this config template or ConfigMap | ||
| automatically. Creating a raw ConfigMap with the `denyHosts` and `denyCIDRs` | ||
| data keys remains supported. | ||
41 changes: 41 additions & 0 deletions
41
charts/vela-workflow/config-templates/workflow-http-deny.cue
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import ( | ||
| "net" | ||
| "strings" | ||
| ) | ||
|
|
||
| metadata: { | ||
| name: "workflow-http-deny" | ||
| alias: "Workflow HTTP Denylist" | ||
| description: "Additional host, IP, and CIDR destinations denied for workflow HTTP requests." | ||
| scope: "system" | ||
| sensitive: false | ||
| } | ||
|
|
||
| #IPAddress: string & net.IP | ||
| #IPCIDR: string & net.IPCIDR | ||
|
|
||
| #Hostname: string & =~"^([A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)(\\.([A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?))*\\.?$" | ||
| #WildcardHostname: string & =~"^\\*\\.([A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)(\\.([A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?))*\\.?$" | ||
| #DenyHost: #IPAddress | #Hostname | #WildcardHostname | ||
| #DenyCIDR: #IPAddress | #IPCIDR | ||
|
|
||
| template: { | ||
| outputs: configMap: { | ||
| apiVersion: "v1" | ||
| kind: "ConfigMap" | ||
| metadata: { | ||
| name: context.name | ||
| namespace: context.namespace | ||
| } | ||
| data: { | ||
| denyHosts: strings.Join(parameter.denyHosts, "\n") | ||
| denyCIDRs: strings.Join(parameter.denyCIDRs, "\n") | ||
| } | ||
| } | ||
| parameter: { | ||
| // +usage=Exact hostnames, IP addresses, or leading wildcard hostnames to deny. | ||
| denyHosts: [...#DenyHost] | ||
| // +usage=IP addresses or CIDR ranges to deny. | ||
| denyCIDRs: [...#DenyCIDR] | ||
| } | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /* | ||
| Copyright 2026 The KubeVela Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
|
|
||
| "github.com/kubevela/workflow/pkg/utils/httpguard" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
| "sigs.k8s.io/controller-runtime/pkg/manager" | ||
| ) | ||
|
|
||
| func configureWorkflowHTTPDeny(ctx context.Context, reader client.Reader, mgr manager.Manager, configMapName, namespace string, blockPrivate bool) error { | ||
| httpguard.SetEnhancer(func(p httpguard.Policy) httpguard.Policy { | ||
| if blockPrivate { | ||
| p.BlockPrivate = true | ||
| } | ||
| return p | ||
| }) | ||
| if err := httpguard.LoadConfigMap(ctx, reader, configMapName, namespace); err != nil { | ||
| return fmt.Errorf("initialize workflow HTTP deny ConfigMap: %w", err) | ||
| } | ||
| if err := httpguard.SetupWatcher(mgr, configMapName, namespace); err != nil { | ||
| return fmt.Errorf("watch workflow HTTP deny ConfigMap: %w", err) | ||
| } | ||
| return nil | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| /* | ||
| Copyright 2026 The KubeVela Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "os" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| "sigs.k8s.io/controller-runtime/pkg/client/fake" | ||
|
|
||
| "github.com/kubevela/workflow/pkg/utils/httpguard" | ||
| ) | ||
|
|
||
| func TestResolveControllerNamespace(t *testing.T) { | ||
| t.Setenv("POD_NAMESPACE", "") | ||
| require.Equal(t, "vela-system", resolveControllerNamespace()) | ||
|
|
||
| t.Setenv("POD_NAMESPACE", " my-ns ") | ||
| require.Equal(t, "my-ns", resolveControllerNamespace()) | ||
|
|
||
| t.Setenv("POD_NAMESPACE", " ") | ||
| require.Equal(t, "vela-system", resolveControllerNamespace()) | ||
| } | ||
|
|
||
| func TestResolveControllerNamespace_unset(t *testing.T) { | ||
| require.NoError(t, os.Unsetenv("POD_NAMESPACE")) | ||
| require.Equal(t, "vela-system", resolveControllerNamespace()) | ||
| } | ||
|
|
||
| func TestConfigureWorkflowHTTPDeny_emptyConfigMap(t *testing.T) { | ||
| t.Cleanup(func() { | ||
| httpguard.SetDenyFragment(httpguard.Policy{ExactHosts: map[string]struct{}{}}) | ||
| httpguard.SetEnhancer(nil) | ||
| }) | ||
| scheme := runtime.NewScheme() | ||
| require.NoError(t, corev1.AddToScheme(scheme)) | ||
| cli := fake.NewClientBuilder().WithScheme(scheme).Build() | ||
|
|
||
| require.NoError(t, configureWorkflowHTTPDeny(context.Background(), cli, nil, "", "vela-system", false)) | ||
| require.True(t, httpguard.Current().BlockLinkLocal) | ||
| } | ||
|
|
||
| func TestConfigureWorkflowHTTPDeny_blockPrivateEnhancer(t *testing.T) { | ||
| t.Cleanup(func() { | ||
| httpguard.SetDenyFragment(httpguard.Policy{ExactHosts: map[string]struct{}{}}) | ||
| httpguard.SetEnhancer(nil) | ||
| }) | ||
| scheme := runtime.NewScheme() | ||
| require.NoError(t, corev1.AddToScheme(scheme)) | ||
| cli := fake.NewClientBuilder().WithScheme(scheme).Build() | ||
|
|
||
| require.NoError(t, configureWorkflowHTTPDeny(context.Background(), cli, nil, "", "vela-system", true)) | ||
| require.True(t, httpguard.Current().BlockPrivate) | ||
| } | ||
|
|
||
| func TestConfigureWorkflowHTTPDeny_loadsConfigMap(t *testing.T) { | ||
| t.Cleanup(func() { | ||
| httpguard.SetDenyFragment(httpguard.Policy{ExactHosts: map[string]struct{}{}}) | ||
| httpguard.SetEnhancer(nil) | ||
| }) | ||
| scheme := runtime.NewScheme() | ||
| require.NoError(t, corev1.AddToScheme(scheme)) | ||
| cm := &corev1.ConfigMap{ | ||
| ObjectMeta: metav1.ObjectMeta{Name: "workflow-http-deny", Namespace: "vela-system"}, | ||
| Data: map[string]string{httpguard.ConfigMapKeyDenyHosts: "denied.example"}, | ||
| } | ||
| cli := fake.NewClientBuilder().WithScheme(scheme).WithObjects(cm).Build() | ||
|
|
||
| require.NoError(t, httpguard.LoadConfigMap(context.Background(), cli, "workflow-http-deny", "vela-system")) | ||
| require.Error(t, httpguard.Current().BlockedHost("denied.example")) | ||
| } | ||
|
|
||
| func TestConfigureWorkflowHTTPDeny_missingConfigMap(t *testing.T) { | ||
| scheme := runtime.NewScheme() | ||
| require.NoError(t, corev1.AddToScheme(scheme)) | ||
| cli := fake.NewClientBuilder().WithScheme(scheme).Build() | ||
|
|
||
| err := configureWorkflowHTTPDeny(context.Background(), cli, nil, "missing", "vela-system", false) | ||
| require.Error(t, err) | ||
| require.Contains(t, err.Error(), "initialize workflow HTTP deny ConfigMap") | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.