Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Get-PublishedTemplates #161

Open
wants to merge 2 commits into
base: testing
Choose a base branch
from

Conversation

SamErde
Copy link
Collaborator

@SamErde SamErde commented Aug 30, 2024

Get-PublishedTemplates pulls a list of published templates with their name, OID, flags, enrollment flag, whenModified, revision, and minor revision. This should help us check if vulnerable templates are published and also ultimately check if the vulnerable version is in use by issued certificate requests.

Please review the bitwise checks for the template's flags and mspki-enrollment-flag properties to see if the logic is correct and returns all published templates in your test environments.

Contributes to #87.

Get-PublishedTemplates pulls a list of published templates with their name, OID, flags, enrollment flag, last modified date, revision, and minor revision. This should help us check if vulnerable templates are published and also ultimately check if the vulnerable version is in use by issued certificate requests.
@SamErde SamErde added the enhancement New feature or request label Aug 30, 2024
@SamErde SamErde self-assigned this Aug 30, 2024
Copy link
Owner

@TrimarcJake TrimarcJake left a comment

Choose a reason for hiding this comment

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

Big comment in code. Feel free to hit me up for more details.

Get-PublishedTemplates

.NOTES
If either of these flags are set, the template is considered published:
Copy link
Owner

Choose a reason for hiding this comment

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

Your logic doesn't seem consistent with what's actually published, but it's very possible I'm missing something.

Your code returns this from my lab CA:
image

But the Certificate Templates list on my lab CA looks like this:
image

Which matches CA's object's cetificateTemplates attribute expanded:
image

Note: The Certificate Templates pane shows the templates displayName attribute while the expanded certificateTemplates list shows the name attribute.

This function should be rewritten to see if the template name exists within the certificateTemplates attribute on any pKIEnrollmentService object. We already collect the required attribute in Get-ADCSObject, so I think you could:

  1. Collect all the published template names from all the CA objects
  2. De-duplicate the list and store it as $PublishedTemplates
  3. Loop through the templates to see if $PublishedTemplates -contains $TemplateName
  4. Return $true or $false to enrich the template object as a custom attribute.

Or whatever you want to do. You probably have a more elegant way of doing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants