Skip to content

ADCS enhancement #221

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

Open
wants to merge 4 commits into
base: v4
Choose a base branch
from
Open

ADCS enhancement #221

wants to merge 4 commits into from

Conversation

JonasBK
Copy link
Contributor

@JonasBK JonasBK commented Jul 8, 2025

Description

Collection of two new ACL permissions:

  • WriteAltSecurityIdentities
  • WritePublicInformation

Collection of CA registry key values:

  • DisabledExtensions
  • RPCEncryptionEnforced

Motivation and Context

Tickets: BED-6155, BED-6176

How Has This Been Tested?

Locally in lab environment.

Types of changes

  • Chore (a change that does not modify the application functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • Documentation updates are needed, and have been made accordingly.
  • I have added and/or updated tests to cover my changes.
  • All new and existing tests passed.
  • [] My changes include a database migration.

Summary by CodeRabbit

  • New Features

    • Added support for two new permissions: WriteAltSecurityIdentities and WritePublicInformation in access control processing.
    • Introduced new data fields to display RPC encryption enforcement status and a list of disabled extensions in certificate authority registry data.
  • Bug Fixes

    • Improved detection of user-specified SAN policy by dynamically identifying the active policy module.
  • Tests

    • Added new unit tests to cover scenarios for the newly supported permissions.
    • Improved formatting consistency in existing test files.

Copy link

coderabbitai bot commented Jul 8, 2025

Warning

Rate limit exceeded

@JonasBK has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 14 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between ad53ce0 and 8658fb9.

📒 Files selected for processing (1)
  • src/CommonLib/Processors/CertAbuseProcessor.cs (3 hunks)

Walkthrough

The changes introduce new constants and GUIDs for "WriteAltSecurityIdentities" and "WritePublicInformation" in several utility classes. ACL processing logic is extended to handle these new rights for user and computer objects. The certificate abuse processor gains methods to check RPC encryption enforcement and disabled extensions. Related data models and tests are updated accordingly.

Changes

File(s) Summary
src/CommonLib/Enums/EdgeNames.cs
src/CommonLib/Processors/ACEGuids.cs
Added new constant strings for "WriteAltSecurityIdentities" and "WritePublicInformation" edge names and GUIDs.
src/CommonLib/OutputTypes/APIResults/StringArrayRegistryAPIResult.cs Introduced StringArrayRegistryAPIResult class with a string array property for registry API results.
src/CommonLib/OutputTypes/CARegistryData.cs Added properties for RPCEncryptionEnforced and DisabledExtensions to CARegistryData.
src/CommonLib/Processors/ACLProcessor.cs Extended ACL processing logic to handle new rights for user and computer objects.
src/CommonLib/Processors/CertAbuseProcessor.cs Modified method to dynamically determine policy subkey; added methods for RPC encryption enforcement and disabled extensions.
test/unit/ACLProcessorTest.cs Added braces for formatting; introduced new test cases for the additional ACL rights and object types.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant CertAbuseProcessor
    participant Registry

    Caller->>CertAbuseProcessor: RPCEncryptionEnforced(target, caName)
    CertAbuseProcessor->>Registry: Read InterfaceFlags from CA config key
    Registry-->>CertAbuseProcessor: Return InterfaceFlags value
    CertAbuseProcessor-->>Caller: Return BoolRegistryAPIResult

    Caller->>CertAbuseProcessor: DisabledExtensions(target, caName)
    CertAbuseProcessor->>Registry: Read Active policy module from PolicyModules
    Registry-->>CertAbuseProcessor: Return Active policy module name
    CertAbuseProcessor->>Registry: Read DisableExtensionList from active policy subkey
    Registry-->>CertAbuseProcessor: Return DisableExtensionList array
    CertAbuseProcessor-->>Caller: Return StringArrayRegistryAPIResult
Loading

Poem

In the warren where code bunnies dwell,
New rights and GUIDs ring a bell!
Extensions disabled, encryption enforced,
Registry secrets carefully sourced.
With tests that hop and never fail,
This update’s a bright, bushy-tailed tale.
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@JonasBK JonasBK self-assigned this Jul 8, 2025
@JonasBK JonasBK added the enhancement New feature or request label Jul 8, 2025
@JonasBK JonasBK changed the title Adcs update ADCS enhancement Jul 8, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/CommonLib/Processors/CertAbuseProcessor.cs (1)

254-293: Critical logic errors in IsUserSpecifiesSanEnabled method.

The method has several critical issues:

  1. Incorrect registry value name: The first registry call uses subValue = "EditFlags" but should be subValue = "Active" to read the active policy name.

  2. Null reference logic error: Lines 268-270 attempt to cast data.Value to string when it's null, which will cause a null reference exception.

  3. Wrong variable reference: Line 289 uses (int)data.Value but should use (int)data2.Value since we're processing the second registry call.

Apply this diff to fix the issues:

        public BoolRegistryAPIResult IsUserSpecifiesSanEnabled(string target, string caName)
        {
            var ret = new BoolRegistryAPIResult();
            var activePolicy = "CertificateAuthority_MicrosoftDefault.Policy";
            var subKey =
                $"SYSTEM\\CurrentControlSet\\Services\\CertSvc\\Configuration\\{caName}\\PolicyModules";
-           const string subValue = "EditFlags";
+           const string subValue = "Active";
            var data = Helpers.GetRegistryKeyData(target, subKey, subValue, _log);

            ret.Collected = data.Collected;
            if (!data.Collected)
            {
                ret.FailureReason = data.FailureReason;
                return ret;
            }

-           if (data.Value == null)
+           if (data.Value != null)
            {
                activePolicy = (string)data.Value;
            }

            var subKey2 =
                $"SYSTEM\\CurrentControlSet\\Services\\CertSvc\\Configuration\\{caName}\\PolicyModules\\{activePolicy}";
            const string subValue2 = "EditFlags";
            var data2 = Helpers.GetRegistryKeyData(target, subKey2, subValue2, _log);

            ret.Collected = data2.Collected;
            if (!data2.Collected)
            {
                ret.FailureReason = data2.FailureReason;
                return ret;
            }

            if (data2.Value == null)
            {
                return ret;
            }

-           var editFlags = (int)data.Value;
+           var editFlags = (int)data2.Value;
            ret.Value = (editFlags & 0x00040000) == 0x00040000;

            return ret;
        }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ad304b and ad53ce0.

📒 Files selected for processing (7)
  • src/CommonLib/Enums/EdgeNames.cs (1 hunks)
  • src/CommonLib/OutputTypes/APIResults/StringArrayRegistryAPIResult.cs (1 hunks)
  • src/CommonLib/OutputTypes/CARegistryData.cs (1 hunks)
  • src/CommonLib/Processors/ACEGuids.cs (1 hunks)
  • src/CommonLib/Processors/ACLProcessor.cs (1 hunks)
  • src/CommonLib/Processors/CertAbuseProcessor.cs (3 hunks)
  • test/unit/ACLProcessorTest.cs (59 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/CommonLib/OutputTypes/CARegistryData.cs (2)
src/CommonLib/OutputTypes/APIResults/BoolRegistryAPIResult.cs (1)
  • BoolRegistryAPIResult (3-6)
src/CommonLib/OutputTypes/APIResults/StringArrayRegistryAPIResult.cs (1)
  • StringArrayRegistryAPIResult (5-8)
src/CommonLib/Processors/CertAbuseProcessor.cs (3)
src/CommonLib/Helpers.cs (1)
  • Helpers (16-313)
src/CommonLib/OutputTypes/APIResults/BoolRegistryAPIResult.cs (1)
  • BoolRegistryAPIResult (3-6)
src/CommonLib/OutputTypes/APIResults/StringArrayRegistryAPIResult.cs (1)
  • StringArrayRegistryAPIResult (5-8)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (12)
src/CommonLib/OutputTypes/APIResults/StringArrayRegistryAPIResult.cs (1)

5-8: Well-structured registry API result class following established patterns.

The implementation correctly inherits from APIResult and provides a Data property with sensible initialization. The pattern matches other registry result classes in the codebase.

src/CommonLib/OutputTypes/CARegistryData.cs (1)

11-12: Consistent addition of new CA registry properties.

The new properties RPCEncryptionEnforced and DisabledExtensions follow the established pattern and use appropriate types that match the new registry API result classes.

src/CommonLib/Processors/CertAbuseProcessor.cs (2)

296-320: Well-implemented RPCEncryptionEnforced method.

The method correctly reads the InterfaceFlags registry value and checks for the RPC encryption bit (0x00000200). The implementation follows the established pattern for registry access and error handling.


323-365: Correctly implemented DisabledExtensions method.

The method properly implements the two-step registry access pattern:

  1. First reads the active policy name from the PolicyModules registry key
  2. Then reads the DisableExtensionList from the specific active policy subkey

The logic for handling null values and error cases is correct, following the established patterns in the codebase.

src/CommonLib/Enums/EdgeNames.cs (1)

25-26: LGTM! New edge name constants properly implemented.

The new constants follow the established naming convention and are correctly positioned within the existing constant definitions. The names align with the corresponding GUIDs and processing logic in the other files.

src/CommonLib/Processors/ACLProcessor.cs (2)

621-629: LGTM! WriteAltSecurityIdentities processing correctly implemented.

The conditional logic follows the established pattern and correctly handles User and Computer object types. The ACE object creation includes all required properties and uses the appropriate constants.


630-638: LGTM! WritePublicInformation processing correctly implemented.

The conditional logic is consistent with the existing pattern and properly handles the new ACE type. The implementation maintains the same structure and property assignments as other ACE processing logic.

test/unit/ACLProcessorTest.cs (5)

21-22: LGTM: Consistent formatting improvements

The addition of braces to class and method declarations improves code consistency and follows C# best practices.

Also applies to: 40-45, 47-49, 52-55


2095-2132: Excellent test coverage for new WriteAltSecurityIdentities ACE type

This test method properly covers the new WriteAltSecurityIdentities permission for User objects. It follows the established testing patterns, uses appropriate mocking, and verifies all expected assertions.


2134-2171: Comprehensive coverage for WriteAltSecurityIdentities on Computer objects

This test ensures the new WriteAltSecurityIdentities permission works correctly for Computer objects, providing complete coverage alongside the User test.


2173-2210: Well-implemented test for WritePublicInformation ACE type

This test method thoroughly covers the new WritePublicInformation permission for User objects, following established patterns and ensuring proper functionality verification.


2212-2249: Complete test coverage for WritePublicInformation on Computer objects

This test rounds out the comprehensive coverage for the new ACE types, ensuring WritePublicInformation works correctly for Computer objects. The implementation follows established patterns and completes the test matrix for the new functionality.

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.

1 participant