[BUG] Azure KeyVault Secrets does not validate or sanitize user input #47353
Labels
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
issue-addressed
Workflow: The Azure SDK team believes it to be addressed and ready to close.
KeyVault
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Library name and version
Azure.Security.KeyVault.Secrets 4.7.0
Describe the bug
When doing a Get/Set secret operation the API will send the secret name unsanitized, and unvalidated.
The cause of this behavior is here:
https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/keyvault/Azure.Security.KeyVault.Shared/src/KeyVaultPipeline.cs#L86
Where it explicitly does not escape path strings. The Secret API's makes no attempt at either validating or sanitizing input.
The following code shows the issue:
I'm not sure in what capacity this is a security issue, because you would need a system where the user has control over the secrets, but at the very least it's an annoyance, because other Vault systems (like HashiCorp Vault) allows slashes in secret names. Azure Key Vault Client will just do the wrong thing instead of failing on bad input.
Expected behavior
ArgumentException or 400 Bad Request from Key Vault since the secret name is actually not valid.
Actual behavior
The provided reproduction returns "hunter2", i.e. a different secret.
Reproduction Steps
Create a key vault, and create a secret called "user-foo-secret" and fill it with "******". Create another secret called "user-bar-secret" and fill it with "hunter2".
Environment
The text was updated successfully, but these errors were encountered: