os_sudo_timeout_configure adjust check for possible spaces #258

Closed
opened 2026-01-19 18:29:50 +00:00 by michael · 2 comments
Owner

Originally created by @gsprague on GitHub.

Summary

os_sudo_timeout_configure.yaml is giving a zero “0” result if there are spaces in the setting, i.e. Defaults timestamp_timeout = 5

Steps to reproduce

Add:
Defaults timestamp_timeout = 5
To:
/etc/sudoers.d/your-file

Run command:
/usr/bin/find /etc/sudoers* -type f -exec /usr/bin/grep -E "^Defaults\s+timestamp_timeout=0" '{}' \; | /usr/bin/wc -l | /usr/bin/xargs
command result = 0

Test:
open new terminal window
run a sudo command
run another sudo command, it will not prompt for pass until timeout is met

Operating System version

macOS v12.2.1

What is the current bug behavior?

The result is 0, it should be 1

What is the expected correct behavior?

The result should be 1 because the timeout is set greater than zero.

Relevant logs and/or screenshots

(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's tough to read otherwise.)

Output of checks

/usr/bin/find /etc/sudoers* -type f -exec /usr/bin/grep -E "^Defaults\s+timestamp_timeout=0" '{}' \; | /usr/bin/wc -l | /usr/bin/xargs
Result = 0

Possible fixes

Replace the regex \s+ after "Defaults" with \s*
Add \s* before and after the "="
/usr/bin/find /etc/sudoers* -type f -exec /usr/bin/grep -E "^Defaults\s*timestamp_timeout\s*=\s*0" '{}' \; | /usr/bin/wc -l | /usr/bin/xargs

Please also check other scripts with similar configuration like this:
os_sudoers_timestamp_type_configure.yaml
/usr/bin/find /etc/sudoers* -type f -exec /usr/bin/grep -E '(^Defaults\s+timestamp_type=global|^Defaults\s+timestamp_type=ppid)' '{}' \; | /usr/bin/wc -l | /usr/bin/xargs

Originally created by @gsprague on GitHub. <!--- Please read this! Before opening a new issue, make sure to search for keywords in the issues filtered by the "regression" or "bug" label and verify the issue you're about to submit isn't a duplicate. ---> ### Summary os_sudo_timeout_configure.yaml is giving a zero “0” result if there are spaces in the setting, i.e. Defaults timestamp_timeout = 5 ### Steps to reproduce Add: Defaults timestamp_timeout = 5 To: /etc/sudoers.d/your-file Run command: `/usr/bin/find /etc/sudoers* -type f -exec /usr/bin/grep -E "^Defaults\s+timestamp_timeout=0" '{}' \; | /usr/bin/wc -l | /usr/bin/xargs` command result = 0 Test: open new terminal window run a sudo command run another sudo command, it will not prompt for pass until timeout is met ### Operating System version macOS v12.2.1 ### What is the current *bug* behavior? The result is 0, it should be 1 ### What is the expected *correct* behavior? The result should be 1 because the timeout is set greater than zero. ### Relevant logs and/or screenshots (Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's tough to read otherwise.) ### Output of checks `/usr/bin/find /etc/sudoers* -type f -exec /usr/bin/grep -E "^Defaults\s+timestamp_timeout=0" '{}' \; | /usr/bin/wc -l | /usr/bin/xargs` Result = 0 ### Possible fixes Replace the regex \s+ after "Defaults" with \s* Add \s* before and after the "=" `/usr/bin/find /etc/sudoers* -type f -exec /usr/bin/grep -E "^Defaults\s*timestamp_timeout\s*=\s*0" '{}' \; | /usr/bin/wc -l | /usr/bin/xargs` Please also check other scripts with similar configuration like this: os_sudoers_timestamp_type_configure.yaml `/usr/bin/find /etc/sudoers* -type f -exec /usr/bin/grep -E '(^Defaults\s+timestamp_type=global|^Defaults\s+timestamp_type=ppid)' '{}' \; | /usr/bin/wc -l | /usr/bin/xargs`
Author
Owner

@gsprague commented on GitHub:

This also doesn't work when the timeout is set in a list or array like so:
Defaults env_reset,timestamp_timeout=2

@gsprague commented on GitHub: This also doesn't work when the timeout is set in a list or array like so: Defaults env_reset,timestamp_timeout=2
Author
Owner

@robertgendler commented on GitHub:

This should all be fixed and changed in the OS branches with the new sudo checks. Please check it out and make sure.

@robertgendler commented on GitHub: This should all be fixed and changed in the OS branches with the new sudo checks. Please check it out and make sure.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: usnistgov/macos_security#258