Explorar el Código

add back signature prefix and length check

Alexander Belanger hace 4 años
padre
commit
b0c4023a5c
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      ee/billing/ironplans.go

+ 4 - 0
ee/billing/ironplans.go

@@ -212,6 +212,10 @@ func (c *Client) GetIDToken(projectID uint, user *cemodels.User) (token string,
 // VerifySignature verifies a webhook signature based on hmac protocal
 // VerifySignature verifies a webhook signature based on hmac protocal
 // https://docs.ironplans.com/webhook-events/webhook-events
 // https://docs.ironplans.com/webhook-events/webhook-events
 func (c *Client) VerifySignature(signature string, body []byte) bool {
 func (c *Client) VerifySignature(signature string, body []byte) bool {
+	if len(signature) != 71 || !strings.HasPrefix(signature, "sha256=") {
+		return false
+	}
+
 	actual := make([]byte, 32)
 	actual := make([]byte, 32)
 	_, err := hex.Decode(actual, []byte(signature))
 	_, err := hex.Decode(actual, []byte(signature))