mirror of
https://github.com/usnistgov/macos_security.git
synced 2026-02-03 05:53:24 +00:00
DISA customer pointed out potential issue with regex in pwpolicy_custom_regex_enforce #113
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 @akegerreis on GitHub.
Summary
APPL-14-003060 requires a password content policy that matches this regular expression:
.[A-Z]{1,}[a-z]{1,}.
The intent is to match passwords that contain “a minimum of one lowercase character and one uppercase character.”.
However, the DISA customer states the regular expression actually matches "uppercase characters immediately followed by lowercase characters". E.g. the current expression matches:
But not:
The customer is suggesting the following regular expressions:
taking into account the context (ICU regular expression as part of a NSPredicate “matches” operator):
.([a-z].[A-Z]|[A-Z].[a-z]).
Or, using lookahead assertions:
(?=.[a-z])(?=.[A-Z]).*
Operating System version
macOS 14 (Sonoma)
@georgalis commented on GitHub:
If this approach is more intelligible... the test could be fitted...
for a in AAABBB aaabbb aaaBBB AAAbbb AAA.BBB AAA.BBB aaa.BBB AAA.bbb ; do
printf "$a\t:"
echo "$a"
| grep '[a-z]'
| grep '[A-Z]' >/dev/null
&& echo okay
|| echo fail
done
AAABBB :fail
aaabbb :fail
aaaBBB :okay
AAAbbb :okay
AAA.BBB :fail
AAA.BBB :fail
aaa.BBB :okay
AAA.bbb :okay
cf
Apple macOS 14 (Sonoma) STIG: APPL-14-003060 (in version v1 r1)
https://app.xylok.io/reference/benchmark/apple_macos_14_stig/check/31e5ff2f-bdad-46ad-a315-875cbc567a9c/?version=c1bf4645-5306-4bd3-af7d-edfa35c63166
On Fri, Feb 23, 2024 at 12:40 PM bernstei @.***> wrote:
--
George Georgalis, (415) 894-2710, http://www.galis.org/
@ion-ize commented on GitHub:
@bernstei Yeah, I realized that issue two after some further testing when my PR #363 was pushed. I have now submitted a new PR (#368) which includes a positive lookahead like you suggested here. The only difference with mine is that yours does not match an empty string while mine does but you cannot have an empty password with the other policies in place so it should not matter.
Here is the regex in my PR:
@robertgendler this should finally resolve this in a full capacity once #368 is approved and merged.
@bernstei commented on GitHub:
The regex in #363 would match
AAA-bbb, but notbbbAAA, because it requires that the capital letter come first. If the regex syntax allows logical or, I think you could use.*([A-Z]{1,}.*[a-z]{1,}|[a-z]{1,}.*[A-Z]{1,}).*(some of those parens or pipe characters might need to be escaped), or perhaps two separate simple pwpolicy entries (similar to the ones implementing the numeric and the special character reqs).The password policy mobileconfig that's generated (guess it's the
<key>minComplexChars</key> <integer>1</integer>that causes it) leads to a pwpolicy prefs that includeI don't know if there's any problem adding those to the pwpolicy manually (and I also really don't understand why putting
customRegexin the mobileconfig requires that the profile be installed by an MDM, and fail to install manually).@bernstei commented on GitHub:
I've also discovered that the alphanumeric mobileconfig leads to the following regex in the xml returned by
pwpolicy -getaccountpoliciesThis definitely matches both
5aanda5, as I've verified by having it in place and going to the password changing System Pref, although I don't quite understand why.I also just checked the regex from #363. It accepts
AAaa, but notaaAA, which makes sense, but it also doesn't acceptAaorAAaoraaA(in the password change dialog box). It seems to require two of each, which I really don't understand.This regex, using zero-width lookahead, constructed by analogy to the mobileconfig-derived alphanumeric regex, works, requiring a single upper case and a single lower case, in either order
I think this is the correct way to implement the upper and lower case password complexity requirement, either as a
customRegexin the mobileconfig or explicitly in apwpolicy.xml@robertgendler commented on GitHub:
Please check out the sonoma branch. PR #363 took care of it.
@bernstei commented on GitHub:
Thanks. Just for my edification, does anyone understand why a
customRegexfield in the mobileconfig makes it MDM-only?@ion-ize commented on GitHub:
@bernstei It's especially weird because Jamf does not seem to even support the customRegex key. We have to re-upload the mobileconfig every time we want to change this.
@robertgendler commented on GitHub:
PR #368 has been merged. Check it out.
@robertgendler commented on GitHub:
No idea why. That's an Apple question.
In fact I'm not sure they know it's MDM only since no where in their documentation does it specify it must be sent via MDM server. We only found out due to it not installing and popping up with an error about that when manually installing it.
@robertgendler commented on GitHub:
I believe this is all fixed in the
sonomabranch. So closing the issue.@akegerreis commented on GitHub:
Here is what we are planning to put in our supplemental:
1.1.1 Smart Card Enforcement Exemption
Any and all use of exemptions to the smart card enforcement on Apple macOS
must be approved and documented with the site ISSM or AO.
1.1.1.1 Group Exemption
Starting in macOS 10.15, enforcement on a system can be granularly
configured by adding a field to /private/etc/SmartcardLogin.plist. The
NotEnforcedGroup can be added to the file to list a Directory group that
will not be included in smart card enforcement. To activate this feature,
enforceSmartCard and allowUnmappedUsers must be applied via a configuration
profile (com.apple.security.smartcard).
To configure the NotEnforcedGroup, the SmartcardLogin.plist should be
<?xml version="1.0" encoding="UTF-8"?>minimally configured as follows:
SHA256_HASH_OF_CERTDOMAIN_1,SHA256_HASH_OF_CERTDOMAIN_2
Once a system is configured for the NotEnforcedGroup, a user can be added to
the assigned group by running the following:
/usr/sbin/dseditgroup -o edit -a <exempt_user> -t user
1.1.1.2 User Exemption
Alternatively, if a single user needs to be exempt for a period of time,
kDSNativeAttrTypePrefix:SmartCardEnforcement can be set in the user's Open
Directory record. The following values can be set:
0 - The system default is respected.
1 - Smartcard enforcement is enabled.
2 - Smartcard enforcement is disabled.
In Active Directory environments, the value of the userAccountControl
attribute is respected.
Run the following command to set the exemption when booted from macOS:
/usr/bin/dscl . -append /Users/ SmartCardEnforcement 2
Run the following command to set the exemption when booted from Recovery:
/usr/bin/defaults write /Volumes/Macintosh
HD/var/db/dslocal/nodes/Default/users/ SmartCardEnforcement
-array-add 2
When booted to recovery on an Apple Silicon Mac, run the following after
setting the exemption.
/usr/sbin/diskutil apfs updatePreboot /Volumes/Macintosh\ HD
Regards,
Aaron Kegerreis | CISSP
DISA RE11 Cyber Standards Support
Chambersburg, PA 17201
@.*** (NIPR)
@.*** (SIPR)
From: Bob Gendler @.>
Sent: Wednesday, March 27, 2024 2:28 PM
To: usnistgov/macos_security @.>
Cc: Kegerreis, Aaron S CTR DISA (USA) @.>;
Author @.>
Subject: Re: [usnistgov/macos_security] DISA customer pointed out potential
issue with regex in pwpolicy_custom_regex_enforce (Issue #358)
I believe this is all fixed in the sonoma branch. So closing the issue.
Reply to this email directly, view it on GitHub
<https://usg01.safelinks.protection.office365.us/?url=https%3A%2F%2Fgithub.c
om%2Fusnistgov%2Fmacos_security%2Fissues%2F358%23issuecomment-2023574128&dat
a=05%7C02%7Caaron.s.kegerreis.ctr%40mail.mil%7C6e3b158c3a8e44140a1d08dc4e8ba
42b%7C102d0191eeae4761b1cb1a83e86ef445%7C0%7C0%7C638471608861865201%7CUnknow
n%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6
Mn0%3D%7C0%7C%7C%7C&sdata=%2FaiX1IueXD5vUBJqBQ3guYBbRtrlDX5RJDg3zbNnD%2Bs%3D
&reserved=0> , or unsubscribe.
You are receiving this because you authored the thread.
<https://github.com/notifications/beacon/BCWDEQEXAO5ACLREBFGRWB3Y2MFS3A5CNFS
M6AAAAABDK3R2O2WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTT
YTVFHA.gif> Message ID:
@.***
@.***> >
@akegerreis commented on GitHub:
Sounds good, thanks!
Aaron Kegerreis | CISSP
DISA RE11 Cyber Standards Support
Chambersburg, PA 17201
@.*** (NIPR)
@.*** (SIPR)
From: Bob Gendler @.>
Sent: Wednesday, March 27, 2024 2:28 PM
To: usnistgov/macos_security @.>
Cc: Kegerreis, Aaron S CTR DISA (USA) @.>;
Author @.>
Subject: Re: [usnistgov/macos_security] DISA customer pointed out potential
issue with regex in pwpolicy_custom_regex_enforce (Issue #358)
I believe this is all fixed in the sonoma branch. So closing the issue.
Reply to this email directly, view it on GitHub
<https://usg01.safelinks.protection.office365.us/?url=https%3A%2F%2Fgithub.c
om%2Fusnistgov%2Fmacos_security%2Fissues%2F358%23issuecomment-2023574128&dat
a=05%7C02%7Caaron.s.kegerreis.ctr%40mail.mil%7C6e3b158c3a8e44140a1d08dc4e8ba
42b%7C102d0191eeae4761b1cb1a83e86ef445%7C0%7C0%7C638471608861865201%7CUnknow
n%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6
Mn0%3D%7C0%7C%7C%7C&sdata=%2FaiX1IueXD5vUBJqBQ3guYBbRtrlDX5RJDg3zbNnD%2Bs%3D
&reserved=0> , or unsubscribe.
You are receiving this because you authored the thread.
<https://github.com/notifications/beacon/BCWDEQEXAO5ACLREBFGRWB3Y2MFS3A5CNFS
M6AAAAABDK3R2O2WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTT
YTVFHA.gif> Message ID:
@.***
@.***> >