fix: cherry pick security issue fixes (#1432)

* fix: potential "Potentially unsafe external link" of TOS and EMail Links

* fix: "Size computation for allocation may overflow" by limiting aes encrypt to 64MB
This commit is contained in:
Livio Amstutz
2021-03-19 09:10:50 +01:00
committed by GitHub
parent bc7e650089
commit b01f277e4b
5 changed files with 8 additions and 4 deletions

View File

@@ -92,6 +92,10 @@ func EncryptAES(plainText []byte, key string) ([]byte, error) {
return nil, err
}
maxSize := 64 * 1024 * 1024
if len(plainText) > maxSize {
return nil, errors.ThrowPreconditionFailedf(nil, "CRYPT-AGg4t3", "data too large, max bytes: %v", maxSize)
}
cipherText := make([]byte, aes.BlockSize+len(plainText))
iv := cipherText[:aes.BlockSize]
if _, err = io.ReadFull(rand.Reader, iv); err != nil {