Skip to content

[Rule Tuning] Microsoft Entra ID Exccessive Account Lockouts Detected #4851

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

Merged
merged 8 commits into from
Jul 1, 2025

Conversation

terrancedejesus
Copy link
Contributor

@terrancedejesus terrancedejesus commented Jun 26, 2025

Summary - What I changed

Fixes date in Microsoft Entra ID Exccessive Account Lockouts Detected.

Checklist

  • Added a label for the type of pr: bug, enhancement, schema, maintenance, Rule: New, Rule: Deprecation, Rule: Tuning, Hunt: New, or Hunt: Tuning so guidelines can be generated
  • Added the meta:rapid-merge label if planning to merge within 24 hours
  • Secret and sensitive material has been managed correctly
  • Automated testing was updated or added to match the most common scenarios
  • Documentation and comments were added for features that require explanation

Contributor checklist

@terrancedejesus terrancedejesus self-assigned this Jun 26, 2025
@terrancedejesus terrancedejesus marked this pull request as ready for review June 26, 2025 14:11
@terrancedejesus terrancedejesus added Rule: Tuning tweaking or tuning an existing rule python Internal python for the repository labels Jun 26, 2025
Copy link
Contributor

Rule: Tuning - Guidelines

These guidelines serve as a reminder set of considerations when tuning an existing rule.

Documentation and Context

  • Detailed description of the suggested changes.
  • Provide example JSON data or screenshots.
  • Provide evidence of reducing benign events mistakenly identified as threats (False Positives).
  • Provide evidence of enhancing detection of true threats that were previously missed (False Negatives).
  • Provide evidence of optimizing resource consumption and execution time of detection rules (Performance).
  • Provide evidence of specific environment factors influencing customized rule tuning (Contextual Tuning).
  • Provide evidence of improvements made by modifying sensitivity by changing alert triggering thresholds (Threshold Adjustments).
  • Provide evidence of refining rules to better detect deviations from typical behavior (Behavioral Tuning).
  • Provide evidence of improvements of adjusting rules based on time-based patterns (Temporal Tuning).
  • Provide reasoning of adjusting priority or severity levels of alerts (Severity Tuning).
  • Provide evidence of improving quality integrity of our data used by detection rules (Data Quality).
  • Ensure the tuning includes necessary updates to the release documentation and versioning.

Rule Metadata Checks

  • updated_date matches the date of tuning PR merged.
  • min_stack_version should support the widest stack versions.
  • name and description should be descriptive and not include typos.
  • query should be inclusive, not overly exclusive. Review to ensure the original intent of the rule is maintained.

Testing and Validation

  • Validate that the tuned rule's performance is satisfactory and does not negatively impact the stack.
  • Ensure that the tuned rule has a low false positive rate.

Copy link

@approksiu approksiu left a comment

Choose a reason for hiding this comment

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

LGTM!

created_str = rule.contents.metadata.creation_date
updated_str = rule.contents.metadata.updated_date

created = datetime.strptime(created_str, "%Y/%m/%d").date()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a good approach at the moment. In the future we may want to prefer using an approach using dateutil to parse the date as a more robust method.

def test_dates_not_in_future(self):
"""Ensure creation and updated dates are not in the future."""
invalid = []
today = datetime.now(timezone.utc).date()
Copy link
Contributor

Choose a reason for hiding this comment

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

This may not be a major concern, but for positive UTC offset timezones it is possible for this unit test to erroneously fail. For instance, we have team members in UTC+5. There will be certain times where the day will be head of UTC time for them.
E.g.

  • UTC Time: January 1, 2023, 21:30 (9:30 PM)
  • Local Time in UTC+5: January 2, 2023, 02:30 (2:30 AM)
  • Local Time in UTC-4: January 1, 2023, 17:30 (5:30 PM)

One way to address this is to start today as defined at UTC+14, but there are other ways too.

Suggested change
today = datetime.now(timezone.utc).date()
# Define UTC+14 timezone
utc_plus_14 = timezone(timedelta(hours=14))
# Get the current date in UTC+14
today = datetime.now(utc_plus_14).date()

@Mikaayenson
Copy link
Contributor

IMO I'd probably rewrite this using git commit timestamp. I suspect it would be more reliable. @terrancedejesus if you can just remove the code changes and fix the rule and open an issue, we can try to tackle this similar to how we do in other repos.

@eric-forte-elastic
Copy link
Contributor

eric-forte-elastic commented Jun 27, 2025

IMO I'd probably rewrite this using git commit timestamp. I suspect it would be more reliable. @terrancedejesus if you can just remove the code changes and fix the rule and open an issue, we can try to tackle this similar to how we do in other repos.

I think this makes sense as well 👍 Using this method, the localized date for the commit timestamp can be converted as needed. Also, the future check component of this PR is somewhat fungible. We are really looking for typos, with the obvious typo case being the created date in the future. A git commit timestamp approach also can check for typos on the date looking for if the rule file is new, does the creation/updated date match the commit date. If not, it is likely a typo, etc.

@terrancedejesus terrancedejesus merged commit 10d95ba into main Jul 1, 2025
11 checks passed
@terrancedejesus terrancedejesus deleted the rule-tuning-entra-id-account-lockout branch July 1, 2025 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport: auto Domain: Cloud Domain: Identity Integration: Azure azure related rules python Internal python for the repository Rule: Tuning tweaking or tuning an existing rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants