Skip to content

feat: implement enterprise privileged access and identity security rules (AZ-IDN-016-025) - #279

Open
TFT444 wants to merge 7 commits into
devfrom
feat/258-privileged-access-identity
Open

feat: implement enterprise privileged access and identity security rules (AZ-IDN-016-025)#279
TFT444 wants to merge 7 commits into
devfrom
feat/258-privileged-access-identity

Conversation

@TFT444

@TFT444 TFT444 commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implements GitHub issue #258 — 10 new Azure Identity security rules covering privileged access and identity protection for Microsoft Entra ID.

New Rules:

  • AZ-IDN-016 (CRITICAL) Privileged user missing phishing-resistant MFA
  • AZ-IDN-017 (HIGH) Global Administrator permanently assigned outside PIM
  • AZ-IDN-018 (HIGH) Privileged role assigned outside PIM
  • AZ-IDN-019 (HIGH) Stale privileged account retains active access (>90 days)
  • AZ-IDN-020 (HIGH) No emergency access / break-glass accounts detected
  • AZ-IDN-021 (HIGH) Legacy authentication protocols not blocked by Conditional Access
  • AZ-IDN-022 (HIGH) No MFA requirement enforced for Azure Management
  • AZ-IDN-023 (MEDIUM) Identity Protection risk policies disabled
  • AZ-IDN-024 (MEDIUM) Service principals broadly excluded from MFA enforcement
  • AZ-IDN-025 (MEDIUM) Privileged role-assignable group has no owner

Infrastructure Added:

  • 5 new Microsoft Graph API collectors in scanner/azure_client.py
  • Full MockAzureClient support for all 5 new collectors (fully offline testing)
  • 58 new tests in tests/test_rules_identity_priv.py all passing
  • 10 remediation playbooks (fix_az_idn_016.sh through fix_az_idn_025.sh)
  • Compliance mappings: CIS Azure Benchmark 2.0.0, NIST CSF, ISO 27001, SOC 2
  • docs/rules-reference.md entries for all 10 rules

Test Plan

  • ruff check all checks passed (0 errors)
  • ruff format --check 276 files already formatted
  • All 10 playbooks pass bash -n syntax validation
  • 58 new rule tests pass (pytest tests/test_rules_identity_priv.py)
  • Full test suite: 643 passed, 4 pre-existing failures (unrelated), 0 new failures
  • All collectors return None on permission failure (no false findings)

Closes #258

@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
pip/azure-mgmt-cosmosdb 10.0.0 UnknownUnknown
pip/azure-mgmt-redis 14.5.0 🟢 6.9
Details
CheckScoreReason
Maintained🟢 1030 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 10
Code-Review🟢 9Found 22/23 approved changesets -- score normalized to 9
CII-Best-Practices🟢 5badge detected: Passing
Security-Policy🟢 10security policy file detected
Packaging⚠️ -1packaging workflow not detected
License🟢 10license file detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Signed-Releases⚠️ -1no releases found
Branch-Protection🟢 5branch protection is not maximal on development and all release branches
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Binary-Artifacts🟢 8binaries present in source code
Pinned-Dependencies🟢 5dependency not pinned by hash detected -- score normalized to 5
Fuzzing🟢 10project is fuzzed

Scanned Files

  • requirements.txt

@TFT444
TFT444 requested review from m-khan-97 and removed request for SHAURYAKSHARMA24 and parthrohit22 August 17, 2026 02:01
@TFT444 TFT444 self-assigned this Aug 17, 2026
@Vishnu2707

Copy link
Copy Markdown
Member

@TFT444 - Resolve the conflicts, post which an initial review would be appreciated from @ritiksah141 @parthrohit22.

@TFT444
TFT444 requested a review from parthrohit22 August 17, 2026 23:32
@TFT444
TFT444 force-pushed the feat/258-privileged-access-identity branch from 11e460e to deab51b Compare August 17, 2026 23:40
@TFT444

TFT444 commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator Author

@TFT444 - Resolve the conflicts, post which an initial review would be appreciated from @ritiksah141 @parthrohit22.

conflict solved. @ritiksah141 @parthrohit22 have a look please i believe its mergable now. verify it please

@parthrohit22 parthrohit22 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The overall direction is useful, but this PR is not merge-ready. Several collectors and rules do not match the Microsoft Graph or Azure SDK contracts, which can cause incorrect findings and silent false negatives.

Blocking issues:

  1. PIM detection uses roleAssignmentSchedules but expects Eligible/Active assignment types. Microsoft Graph returns Assigned/Activated; eligible assignments must be collected from roleEligibilitySchedules. AZ-IDN-017 and AZ-IDN-018 will therefore misclassify valid PIM assignments.

  2. AZ-IDN-023 calls unsupported Identity Protection policy endpoints. The resulting exception is converted to None, so the rule silently returns no findings.

  3. AZ-IDN-024 checks for "All" in excludeServicePrincipals, but Graph represents exclusions as service-principal IDs. The workload identity coverage logic needs to use includeServicePrincipals and actual policy scope.

  4. Privileged role assignments can target users, groups, or service principals. The collector treats every principal as a user, causing incorrect MFA, stale-account, and break-glass findings.

  5. Cosmos DB and cache collection failures return empty lists. The rules interpret those empty lists as compliant inventories, creating silent false negatives.

  6. AZ-STOR-009 reads period_since_creation_in_days, but the Azure SDK property is immutability_period_since_creation_in_days.

  7. Several new rules compare Azure SDK enum objects using str(value) rather than normalizing .value. This affects TLS, encryption-source, audit-policy, and immutability-state checks.

  8. AZ-IDN-021 and AZ-IDN-022 do not validate included users, exclusions, report-only state, or application scope. A policy covering only a subset of users can incorrectly suppress a tenant-wide finding.

Please correct these issues and add regression tests using representative Microsoft Graph payloads and actual Azure SDK model objects before merging.

@TFT444
TFT444 force-pushed the feat/258-privileged-access-identity branch from 8f0c830 to fc98ddb Compare August 27, 2026 21:22
@TFT444

TFT444 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

@parthrohit22 all 8 blockers from your review have been addressed in the latest commit. Quick summary of what changed: PIM collector now queries both roleAssignmentSchedules and roleEligibilitySchedules; IDN-023 uses CA-policy inspection instead of the unsupported endpoints; IDN-024 uses includeServicePrincipals with proper exclude logic; all principals now carry principalType; Cosmos/cache failures return None with a warning instead of an empty list; STOR-009 uses immutability_period_since_creation_in_days; enum comparisons use enum_str(); and IDN-021/022 validate user scope. Tests updated to match. Would appreciate a re-review when you get a chance.

@m-khan-97

Copy link
Copy Markdown
Collaborator

@TFT444, I have noted the commit addressing the eight SDK/API blockers. Since this branch is now significantly behind dev, please rebase it first and rerun the complete suite. I will verify the collector contracts and rule behavior against that fresh head rather than reviewing code that will change during conflict resolution.

TFT444 added 7 commits August 29, 2026 01:55
Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
…les (AZ-IDN-016-025)

Add 10 new rules covering privileged identity security for Microsoft Entra ID:
- AZ-IDN-016: Privileged user missing phishing-resistant MFA (CRITICAL)
- AZ-IDN-017: Global Administrator permanently assigned outside PIM (HIGH)
- AZ-IDN-018: Privileged role assigned outside PIM (HIGH)
- AZ-IDN-019: Stale privileged account retains active access (HIGH)
- AZ-IDN-020: No emergency access accounts detected (HIGH)
- AZ-IDN-021: Legacy authentication protocols not blocked (HIGH)
- AZ-IDN-022: No MFA requirement for Azure Management (HIGH)
- AZ-IDN-023: Identity Protection risk policies disabled (MEDIUM)
- AZ-IDN-024: Service principals excluded from MFA enforcement (MEDIUM)
- AZ-IDN-025: Privileged role-assignable group has no owner (MEDIUM)

Add 5 new Graph API collectors to azure_client.py:
- get_privileged_role_members, get_privileged_users_mfa_methods,
  get_pim_role_assignments, get_identity_protection_policies,
  get_privileged_groups

Add MockAzureClient support for all new collectors (fully offline tests).
Add 58 tests in test_rules_identity_priv.py covering compliant, violating,
empty inventory, API failure (None), and edge cases.
Add 10 remediation playbooks (fix_az_idn_016.sh through fix_az_idn_025.sh).
Add compliance mappings for CIS Azure 2.0.0, NIST CSF, ISO 27001, SOC 2.
Add docs/rules-reference.md entries for all 10 rules.

Closes #258

Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
…ty rules

PIM detection (IDN-017, IDN-018):
- Collector now queries both roleAssignmentSchedules (Active) and
  roleEligibilitySchedules (Eligible) so eligible assignments are
  actually detected; previously only Active schedules were fetched
- principalId/principalType tracked for all principal types (users,
  groups, service principals), not only users

Identity Protection (IDN-023):
- Replace unreliable direct policy endpoints with CA-policy inspection:
  checks conditions.userRiskLevels / signInRiskLevels on enabled policies

CA policy user scope (IDN-021, IDN-022):
- _covers_all_users() helper added; policies that target a subset of
  users no longer suppress a tenant-wide finding

Workload identity exclusion (IDN-024):
- Fix excludeServicePrincipals check: the field holds SP IDs, not All;
  rewrite to use includeServicePrincipals presence and All-exclude logic

Collection failures (Cosmos DB, Redis cache):
- get_cosmos_accounts / get_managed_caches return None on failure instead
  of []; callers log a warning and skip rather than treating missing
  inventory as compliant

Enum normalization (AZ-STOR-009, AZ-DB-007):
- Replace raw str() calls with enum_str() for SDK enum fields
- Fix immutability retention property:
  period_since_creation_in_days -> immutability_period_since_creation_in_days

Test fixtures updated to match new API contracts (principalId, deep-merge
of CA policy conditions, correct immutability property name).

CI: add chromadb CVE-2026-45830 and CVE-2026-45833 to pip-audit ignore
list (no patched version; removal tracked in PR #317).

Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
The skip condition checked for the ai/vectorstore/ directory, which can
exist from a previous build without the BM25 index file. After PR #317
replaced chromadb with a JSON BM25 index, the test ran and raised
VectorStoreNotBuilt instead of skipping. Changed skipif to check for
the actual index file so the class is skipped correctly when the index
has not been built.

Signed-off-by: Tanvir Farhad <tamimtarafder12@gmail.com>
@TFT444
TFT444 force-pushed the feat/258-privileged-access-identity branch from fc98ddb to 2bb2694 Compare August 29, 2026 01:01
@TFT444
TFT444 requested a review from vogonPrayas as a code owner August 29, 2026 01:01
@TFT444

TFT444 commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator Author

@m-khan-97 @parthrohit22 the branch has been rebased onto current dev and all 870 tracked tests pass with 0 failures. The 8 SDK/API blockers from Parth's review were addressed in a prior commit (PIM collector queries both roleAssignmentSchedules and roleEligibilitySchedules, IDN-023 uses CA policy inspection, IDN-024 uses includeServicePrincipals, all principals carry principalType, Cosmos/cache failures return None, enum comparisons use .value, IDN-021/022 validate scope). Also fixed the BM25 skip guard in test_ai_hallucination_guard.py which was raising instead of skipping when the index hasn't been built. Ready for re-review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement enterprise privileged access and identity security rules

4 participants