Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

box: fix panic when decoding corrupted PEM from JWT file

Nick Craig-Woodf6efaf2a63f8
diff --git a/backend/box/box.go b/backend/box/box.go
index 6f73441cc..8c5903578 100644
--- a/backend/box/box.go
+++ b/backend/box/box.go
@@ -255,6 +255,9 @@ func getQueryParams(boxConfig *api.ConfigJSON) map[string]string {
func getDecryptedPrivateKey(boxConfig *api.ConfigJSON) (key *rsa.PrivateKey, err error) {
block, rest := pem.Decode([]byte(boxConfig.BoxAppSettings.AppAuth.PrivateKey))
+ if block == nil {
+ return nil, errors.New("box: failed to PEM decode private key")
+ }
if len(rest) > 0 {
return nil, fmt.Errorf("box: extra data included in private key: %w", err)
}