Toni Sanmateu
09/19/2025, 4:30 PMSELECT
CASE
WHEN EXISTS (
-- Check MDM-managed screensaver timeout
SELECT 1 FROM managed_policies
WHERE domain = 'com.apple.screensaver'
AND name = 'idleTime'
AND CAST(value AS INTEGER) > 0
) THEN 1
-- Can't detect user-configured screen lock from root
ELSE NULL -- Return NULL instead of 0 to indicate "unknown"
END AS screenlock_status;
2. Tried querying screenlock table, but seems like osqueryi can run it with user permission, but osqueryd cannot run it from a schedule with root permissions.
I need the query to detect the screenlock setting when ran by osqueryd when it fetches the configured schedule.
Loosing hope a bit. Any idea is welcome! Thank you šToni Sanmateu
09/19/2025, 4:33 PMkeychain_items,keychain_acls,mdfind,curl,user_ssh_keys,browser_plugins,safari_extensions,chrome_extensions,firefox_addons,user_interaction_events,process_envs,es_process_events,authorization_mechanisms,authorizations,wifi_networks,location_services,certificates,logged_in_users,users,ssh_configsToni Sanmateu
09/19/2025, 4:45 PMThere's no osquery flag that can fix this. The issue is at the macOS OS level, not osquery configuration.
I've checked all relevant flags:
- --allow_unsafe=true - Only affects executable permissions
- --disable_audit=false - For audit subsystem
- --force=true - For forcing operations
- --enable_file_events=true - For file monitoring
- No flag exists to "read user preferences as root"
The screenlock table's inability to read user preferences when running as root is hardcoded behavior in macOS, not configurable via osquery flags.
Your only options are:
1. Use MDM to enforce screen lock settings (readable by root)
2. Modify the query to return NULL instead of 0 for unknown status:
SELECT CASE
WHEN EXISTS (SELECT 1 FROM managed_policies WHERE domain = 'com.apple.screensaver')
THEN (SELECT enabled FROM screenlock)
ELSE NULL
END AS screenlock_status;
3. Document the limitation that Fleet can only verify MDM-enforced screen locks
There's simply no flag to bypass macOS's security model that prevents root from reading user security preferences.But I'm not convinced...
allister
09/22/2025, 11:17 AMToni Sanmateu
09/22/2025, 4:09 PMfritz
09/22/2025, 7:14 PMfritz
09/22/2025, 7:16 PMkolide_screenlock
osquery> SELECT * FROM kolide_screenlock WHERE user = 'fritz';
+---------+--------------+-------+
| enabled | grace_period | user |
+---------+--------------+-------+
| 1 | 0 | fritz |
+---------+--------------+-------+Toni Sanmateu
09/23/2025, 8:48 AMToni Sanmateu
09/23/2025, 8:49 AMToni Sanmateu
09/23/2025, 8:55 AMfritz
09/23/2025, 1:29 PMlaunchctl asuser command in order to retrieve user context while running the agent as root.fritz
09/23/2025, 1:31 PMBtw @fritz is this only an issue on macOS?The methods for determining screenlock status are different on Windows and Linux and have their own difficulties to navigate. We also use extended (non vanilla osquery) tables to evaluate screenlock on those platforms.
fritz
09/23/2025, 1:39 PMToni Sanmateu
09/23/2025, 1:46 PMfritz
09/23/2025, 1:50 PMToni Sanmateu
09/23/2025, 1:56 PMToni Sanmateu
09/23/2025, 1:57 PMToni Sanmateu
09/23/2025, 2:12 PMfritz
09/23/2025, 2:19 PMToni Sanmateu
09/23/2025, 2:25 PMToni Sanmateu
09/23/2025, 2:26 PMfritz
09/23/2025, 2:26 PMfritz
09/23/2025, 2:52 PMkolide_screenlock).
You could look at figuring out the launchctl asuser instantiation of osquery yourself using something like osquery-go, but I apologize, I wouldn't be able to help you much further.Toni Sanmateu
09/23/2025, 2:58 PMseph
Toni Sanmateu
10/07/2025, 8:27 AMseph
Toni Sanmateu
10/07/2025, 7:58 PMseph
Toni Sanmateu
10/07/2025, 7:59 PMDo note that much of the launcher code base has an enterprise license attached to it.You brought this comment into a context, which seems to imply you said it because that feature is not free. So I ask you to clarify, otherwise I don't get the comment.
seph
seph
Toni Sanmateu
10/07/2025, 8:01 PMToni Sanmateu
10/07/2025, 8:03 PMseph
Toni Sanmateu
10/07/2025, 8:03 PMToni Sanmateu
10/07/2025, 8:03 PM