Skip to content

Comments

Trusted Publisher Checks for Azure Trusted Signing#25824

Open
jborean93 wants to merge 4 commits intoPowerShell:masterfrom
jborean93:trusted-publisher-az-ts
Open

Trusted Publisher Checks for Azure Trusted Signing#25824
jborean93 wants to merge 4 commits intoPowerShell:masterfrom
jborean93:trusted-publisher-az-ts

Conversation

@jborean93
Copy link
Collaborator

@jborean93 jborean93 commented Aug 6, 2025

PR Summary

Add support for checking the Azure Trusted Signing publisher identifier alongside the thumbprint. This check will verify whether the unique Azure TS OID present in the EKU is in any certificate in the TrustedPublishers store. It will also check whether the OID is present in the untrusted store making it possible to distrust all certificates for that Azure identity.

PR Context

Fixes: #21550

I need to spend some time to figure out how I could potentially add tests for this. It should be theoretically possible to generate certs with the same ID or at least have some test hook that changes what ID to check for but I'll think about it.

The behaviour of the untrusted check might need to be adjusted to only check the thumbprint only. Currently if any cert with the Azure identity OID is present in the untrusted store then all certs with that same OID will be untrusted. If the PowerShell team only wants to reject specific certs then that logic will have to be adjusted.

Edit: Tests added and untrusted check moved back to only untrusting by thumbprint. It is not easy to get the root CA thumbprint for an untrusted cert because Windows treats it as rejected and won't work with the X509Chain class. Upon reflection I think this behaviour is nicer as it allows you to reject specific timeframes/certs rather than the whole identity at once. Maybe an extra location could be used to reject identities entirely if desired.

PR Checklist

Add support for checking the Azure Trusted Signing publisher identifier
alongside the thumbprint. This check will verify whether the unique
Azure TS OID present in the EKU is in any certificate in the
TrustedPublishers store. It will also check whether the OID is present
in the untrusted store making it possible to distrust all certificates
for that Azure identity.
@ianjmcm
Copy link

ianjmcm commented Aug 11, 2025

This looks really good.

@SteveL-MSFT SteveL-MSFT requested a review from Copilot August 11, 2025 18:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for trusted publisher checks when using Azure Trusted Signing certificates in PowerShell's execution policy validation. The implementation allows PowerShell to trust Azure Trusted Signing certificates based on their unique publisher identifier (extracted from EKU OIDs) rather than only by certificate thumbprint.

  • Introduces Azure Trusted Signing publisher identifier checking alongside existing thumbprint validation
  • Adds comprehensive test coverage for the new trusted publisher functionality
  • Enhances security by validating certificates against both trusted and disallowed certificate stores

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
SecurityManager.cs Implements Azure Trusted Signing publisher ID extraction and validation logic in certificate trust checking
ExecutionPolicy.Tests.ps1 Adds comprehensive test suite covering various Azure Trusted Signing certificate trust scenarios

azurePublisherId == trustedIdentifier)
{
isTrusted = true;
break;
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The break statement exits the loop early when an Azure publisher ID match is found, but the thumbprint check continues through all certificates. For consistency and performance, consider adding a break after setting isTrusted = true for the thumbprint match as well.

Copilot uses AI. Check for mistakes.
Copy link
Member

@SteveL-MSFT SteveL-MSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is coming in late for 7.6, can you make this an Experimental Feature?

@microsoft-github-policy-service microsoft-github-policy-service bot added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Aug 11, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Aug 11, 2025
@jborean93
Copy link
Collaborator Author

@SteveL-MSFT can do. Do you see any problems with this method or do you prefer the registry route mentioned in the issue? Any concerns about the EKU + thumbprint method for the unique identifier and whether the root or immediate issuer should be used?

@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Aug 19, 2025
@TravisEz13 TravisEz13 added CL-Experimental Indicates that a PR should be marked as an Experimental Feature in the Change Log WG-Security security related areas such as JEA Needs-Triage The issue is new and needs to be triaged by a work group. labels Sep 23, 2025
@SteveL-MSFT
Copy link
Member

SteveL-MSFT commented Nov 24, 2025

@SteveL-MSFT can do. Do you see any problems with this method or do you prefer the registry route mentioned in the issue? Any concerns about the EKU + thumbprint method for the unique identifier and whether the root or immediate issuer should be used?

Was discussed in Security-WG, seems fine to us. Thanks!

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Review - Needed The PR is being reviewed label Nov 24, 2025

// Do a final check to verify that the certificate has not been
// explicitly added to the "Disallowed" store.
if (isTrusted && !IsUntrustedPublisher(signerCertificate))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect IsUntrustedPublisher() on top of the method - it makes no sense to check trust if certificate is blocked.
Also it would be nice to add the check in trace too.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Review - Needed The PR is being reviewed label Dec 2, 2025
@microsoft-github-policy-service
Copy link
Contributor

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Experimental Indicates that a PR should be marked as an Experimental Feature in the Change Log Needs-Triage The issue is new and needs to be triaged by a work group. Review - Needed The PR is being reviewed WG-Security security related areas such as JEA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Enterprise signed scripts

5 participants