diff --git a/pkg/blob/blob.go b/pkg/blob/blob.go index 80c4aa913..906dea1b5 100644 --- a/pkg/blob/blob.go +++ b/pkg/blob/blob.go @@ -29,6 +29,7 @@ import ( "strings" "sync" "time" + "unicode" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" azstorage "github.com/Azure/azure-sdk-for-go/storage" @@ -178,6 +179,113 @@ var ( defaultAzureOAuthTokenDir = "/var/lib/kubelet/plugins/" + DefaultDriverName subscriptionIDRegex = regexp.MustCompile(`^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$`) + + // containerNameRegex enforces Azure Blob Storage container naming rules. + // Names containing spaces or special characters cannot match and are + // rejected before reaching the blobfuse2 args string. + containerNameRegex = regexp.MustCompile(`^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$`) + + // allowedEphemeralMountOptions is the allowlist of blobfuse2 CLI flags that + // may appear in volumeAttributes.mountOptions for an ephemeral inline volume. + // Any flag NOT in this map is rejected by SanitizeMountOptions. + // + // Verified against: blobfuse2 mount --help (v2.x) + // + // Intentionally absent (must remain driver-controlled): + // --tmp-path — redirects file-cache root to arbitrary host path + // --block-cache-path — same primitive for block-cache mode + // --config-file — loads arbitrary blobfuse2 config from host + // --log-file-path — root-owned log writes to arbitrary host path + // --container-name — driver sets this from the validated containerName + // volumeAttribute; allowing it in mountOptions would + // override that validation entirely + // --passphrase — decrypts --secure-config files; enables config-file + // attack path indirectly + // --secure-config — enables encrypted config loading; combined with + // --passphrase reinstates the --config-file attack + // + // Note: FUSE passthrough tokens "-o