Annotations: Deny newlines. (#12640)
This commit is contained in:
parent
63d4d64fe4
commit
698c3c0df1
2 changed files with 11 additions and 0 deletions
|
|
@ -79,6 +79,8 @@ var (
|
|||
// URLWithNginxVariableRegex defines a url that can contain nginx variables.
|
||||
// It is a risky operation
|
||||
URLWithNginxVariableRegex = regexp.MustCompile("^[" + extendedAlphaNumeric + urlEnabledChars + "$]*$")
|
||||
// MaliciousRegex defines chars that are known to inject RCE
|
||||
MaliciousRegex = regexp.MustCompile(`\r|\n`)
|
||||
)
|
||||
|
||||
// ValidateArrayOfServerName validates if all fields on a Server name annotation are
|
||||
|
|
@ -113,6 +115,10 @@ func ValidateRegex(regex *regexp.Regexp, removeSpace bool) AnnotationValidator {
|
|||
if !regex.MatchString(s) {
|
||||
return fmt.Errorf("value %s is invalid", s)
|
||||
}
|
||||
if MaliciousRegex.MatchString(s) {
|
||||
return fmt.Errorf("value %s contains malicious string", s)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue