question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

identity: ClientCertificateCredential with secret key in TPM?

See original GitHub issue

Is your feature request related to a problem? Please describe.

The ClientCertificateCredential implementation requires that the application itself handle secret keying material, either as a string directly or indirectly as a file name that is, ultimately, opened and turned into a string internally. This, in turn, implies that the system on which the application is running has cleartext access to the secret material, at least while running, even if it’s stored under encryption at rest. This creates low-hanging risks for the secret key: it could be disclosed due to system misconfiguration (such as being accessible to a co-located service or user account) or due to bugs in the application (and/or its runtime).

Describe the solution you’d like

For (virtual) machines with (v)TPMs, HSMs, or other PKCS#11 providers, it would be a significant improvement to have the application not handle secret key material at all, only exchanging key identifiers and messages to be signed with the secure hardware. FWIW, Azure VMs generally support vTPMs (https://docs.microsoft.com/en-us/azure/virtual-machines/trusted-launch), as does HyperV (under which my motivating application is running).

Rather than implement this functionality directly in JS or linked native code, as identity authentication is performed only rarely, it may be simplest to offer a new Credential type that spawns an external program, writes the JWT to be signed to (and then closes) its stdin, and reads the signed response from its stdout. If spawning a program is too much overhead, then instead making a socket connection (to a SOCK_STREAM UNIX domain socket, especially) and using write(); shutdown(); read(); close() similarly, would also work fine.

This will probably require cooperation with msal, which looks like it ultimately outsources JWT work to the jsonwebtoken package?

I am unsure where, exactly, in this stack is the right intercept. In node-jsonwebtoken itself might be ideal, for broadest impact, but it looks like several places have their own ideas about the well-formedness of PEM-encoded keys, which will necessitate rework.

Describe alternatives you’ve considered

At the moment, because the secret keys are stored in files, they are roughly equivalent to client secrets for most threat models (nobody is realistically MITMing or decrypting our TLS session with Azure), and so we are using a ClientSecretCredential instead, with the secret held in a file available only to the application (and the root user), but this is less than ideal.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
KarishmaGhiyacommented, Jun 13, 2022

Hi @nwf-msr I will add code samples for using client assertion credential. We are planning to release it in July.

0reactions
nwf-msrcommented, Dec 8, 2022

With apologies, I haven’t had time to investigate. It seems like it should, but I haven’t jumped back into trying to make the TPM and nodejs play nicely together.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TPM 2.0 Keys for Device Identity and Attestation
When used in this document, a credential is a combination of a private key, accessible for the required purpose (e.g. creating a signature)...
Read more >
Trusted Platform Module (TPM) fundamentals (Windows)
A Trusted Platform Module (TPM) is a microchip designed to provide basic security-related functions, primarily involving encryption keys.
Read more >
Implement Azure AD Client credentials flow using Client ...
Secrets. Create a client certificate in Azure Key Vault ... The Key Vault needs to be configured for the identities in the access...
Read more >
Have you considered TPM key attestation? - nicolonsky tech
Key attestation uses a trusted platform module to protect your private keys and can be enabled on active directory certificate services CAs ...
Read more >
Azure Identity 101 - DefaultAzureCredential - Jon Gallant
"Key Vault Secrets User Role". Get your Azure account ID. Use the Azure CLI to find your Azure account ID: az ad signed-in-user...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found