Add option to sanitize annotation inputs (#7874)
* Add option to sanitize annotation inputs * Fix e2e tests after string sanitization * Add proxy_pass and serviceaccount as denied values
This commit is contained in:
parent
8333c8c127
commit
67e13bf692
11 changed files with 283 additions and 16 deletions
|
|
@ -18,6 +18,7 @@ package config
|
|||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
|
|
@ -97,6 +98,11 @@ type Configuration struct {
|
|||
// If disabled, only snippets added via ConfigMap are added to ingress.
|
||||
AllowSnippetAnnotations bool `json:"allow-snippet-annotations"`
|
||||
|
||||
// AnnotationValueWordBlocklist defines words that should not be part of an user annotation value
|
||||
// (can be used to run arbitrary code or configs, for example) and that should be dropped.
|
||||
// This list should be separated by "," character
|
||||
AnnotationValueWordBlocklist string `json:"annotation-value-word-blocklist"`
|
||||
|
||||
// Sets the name of the configmap that contains the headers to pass to the client
|
||||
AddHeaders string `json:"add-headers,omitempty"`
|
||||
|
||||
|
|
@ -762,6 +768,20 @@ func NewDefault() Configuration {
|
|||
defNginxStatusIpv6Whitelist := make([]string, 0)
|
||||
defResponseHeaders := make([]string, 0)
|
||||
|
||||
defAnnotationValueWordBlocklist := []string{
|
||||
"load_module",
|
||||
"lua_package",
|
||||
"_by_lua",
|
||||
"location",
|
||||
"root",
|
||||
"proxy_pass",
|
||||
"serviceaccount",
|
||||
"{",
|
||||
"}",
|
||||
"'",
|
||||
"\\",
|
||||
}
|
||||
|
||||
defIPCIDR = append(defIPCIDR, "0.0.0.0/0")
|
||||
defNginxStatusIpv4Whitelist = append(defNginxStatusIpv4Whitelist, "127.0.0.1")
|
||||
defNginxStatusIpv6Whitelist = append(defNginxStatusIpv6Whitelist, "::1")
|
||||
|
|
@ -772,6 +792,7 @@ func NewDefault() Configuration {
|
|||
|
||||
AllowSnippetAnnotations: true,
|
||||
AllowBackendServerHeader: false,
|
||||
AnnotationValueWordBlocklist: strings.Join(defAnnotationValueWordBlocklist, ","),
|
||||
AccessLogPath: "/var/log/nginx/access.log",
|
||||
AccessLogParams: "",
|
||||
EnableAccessLogForDefaultBackend: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue