Azure KeyVault Certificate with non-exportable key can still export the key through KeyVault Secret

For digital signature of files, I have a PKCS12 in hand with all necessary key material (e.g. private key + signature certificate + certificate chain).

The PKCS12 is built with something that looks like :

openssl pkcs12 -in cert_chain.pem -inkey private.key -passin "pass:xx" -export -passout "pass:yy" -out signature.pfx

My intent is to import this material into Azure KeyVault to have it perform the actual signature computation, without my own software having actual access to the private key.

(This is not, of course, a real HSM signature, but the intent is more or less the same : my software would only have access to Azure KeyVault’s signing API)

But I can’t seem to achieve this.

Event marking the key as not exportable, I always find a way to access the private key, one way or another, through azure APIs.

Long story short, the question : how to isolate the private key, so that an application with access to the keyvault (policy permissions: Certificate Get, Sign, Secret Get), can not access it ?

Let’s see what I have so far:

As far as I understand, this is possible with KeyVault’s Certificate policy, marking the key as exportable: false

I use azure-cli for the import operation :

az keyvault certificate import 
  --vault-name "someKv" 
  --name "someName" 
  -f signature.pfx 
  --password yy 
  --policy "@cert_policy.json"

With the policy being :

{
  "keyProperties": {"exportable": false},
  "secretProperties": {"contentType": "application/x-pkcs12"}
}

At this point I have something strange, which is my policy is not actively taken into account (e.g. in the output I still see the key marked as exportable: true).

I know my JSON file is taken into account by the call because if I change it, I have JSON parsing errors from the CLI.

This may be the core of my issue… But I’m stubborn. So I use a raw REST API call to force the setting :

curl -XPATCH 
  -H 'Content-Type: application/json' 
  -H "Authorization: Bearer someToken" 
  "https://someKv.vault.azure.net/certificates/myCertName/policy?api-version=7.4" 
  -d '{"key_props": {"exportable": false}}'

Which succeeds (HTTP 200/OK), and following this call I can see :

> az keyvault certificate show --vault-name "someKv" --name signature 
...
  "policy": {
    "attributes": { ... },
    ...
    "keyProperties": {
      ...
      "exportable": false,
      ...
    },

So I feel OK.

For example, I use the Java SDK in my app, and using azure-security-keyvault-jca facilities, when I try accessing the Key, I get not a RSAPrivateKey but a KeyVaultPrivateKey with its Keyvault access attributes, which (if you want to follow the source), clearly is what is expected for non-exportable keys.

I still feel OK.

Then, I implement my signature, and I need access to the certificate chain (indeed, my actual CA uses an intermediate certificate between my own cert and its root, so I have to embed it in the signature).

Looking around, I find no other way to access it in my setup, than to use Azure’s KeyVault Secret API (when importing a KeyVault Certificate, Azure creates a KeyVault Secret alongside). The secret’s content is a (base64-ed) PKCS12.

I open this PKCS12, it has a single entry (just like my original, imported one), and associated to this alias, the certificate, its chain… so what about the private key :

System.out.println(
  ks.getKey(aliases.get(0), "".toCharArray())
)
> SunRsaSign RSA private CRT key, 2048 bits
  params: null
  modulus: (a real value)
  private exponent: (a real value)

Oups… My software has access to the private key (incidentally, any Azure user with sufficient Keyvault privilege could also access the key, which is not absurd, but not particularly expected from exportable: false).
This is not what I intended.

Now I could remove the Get Secret permission to my app on the KeyVault’s policy, but then I could not access the secret at all, which prevents me from accessing the certificate chain (which I admittedly could ship with my app, but it feels duplicating information, which makes rolling and maintenance a more complex matter).

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật