mirror of
https://github.com/usnistgov/macos_security.git
synced 2026-02-03 14:03:24 +00:00
pwpolicy_minimum_length_enforce fails when min length > ODV #28
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @phaninder-scalefusion on GitHub.
Summary
The
pwpolicy_minimum_length_enforcescript fails if the configured minimum length is greater than the CIS ODV (e.g., policy requires 15, admin sets 20).Steps to reproduce
Operating System version
(macOS 13 / 14 / 15)
Intel or Apple Silicon
Both
Current behavior
Script only accepts exact match, fails if policy is stricter.
Expected behavior
Script should pass if configured value >= ODV.
Possible fix
Update script logic to:
/usr/bin/pwpolicy -getaccountpolicies 2>/dev/null | tail +2 | grep -oE "policyAttributePassword matches '.\{[0-9]+," | awk -F'[{,]' -v ODV=$ODV '{if ($2 > max) max=$2} END {print (max >= ODV) ? "true" : "false"}'Additional note
The same issue is noticed in
pwpolicy_max_lifetime_enforceandpwpolicy_history_enforce@brodjieski commented on GitHub:
Changes have been merged into primary branches.