Bug/sysmon vm svc not starting #2496
No reviewers
Labels
No labels
1week
2weeks
Failed compliance check
IP cameras
NATS
Possible security concern
Review effort 1/5
Review effort 2/5
Review effort 3/5
Review effort 4/5
Review effort 5/5
UI
aardvark
accessibility
amd64
api
arm64
auth
back-end
bgp
blog
bug
build
checkers
ci-cd
cleanup
cnpg
codex
core
dependencies
device-management
documentation
duplicate
dusk
ebpf
enhancement
eta 1d
eta 1hr
eta 3d
eta 3hr
feature
fieldsurvey
github_actions
go
good first issue
help wanted
invalid
javascript
k8s
log-collector
mapper
mtr
needs-triage
netflow
network-sweep
observability
oracle
otel
plug-in
proton
python
question
reddit
redhat
research
rperf
rperf-checker
rust
sdk
security
serviceradar-agent
serviceradar-agent-gateway
serviceradar-web
serviceradar-web-ng
siem
snmp
sysmon
topology
ubiquiti
wasm
wontfix
zen-engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
carverauto/serviceradar!2496
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2496/head"
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?
Imported from GitHub pull request.
Original GitHub pull request: #2044
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2044
Original created: 2025-12-03T04:01:11Z
Original updated: 2025-12-03T05:16:04Z
Original head: carverauto/serviceradar:bug/sysmon-vm_svc_not_starting
Original base: main
Original merged: 2025-12-03T05:16:00Z by @mfreeman451
User description
IMPORTANT: Please sign the Developer Certificate of Origin
Thank you for your contribution to ServiceRadar. Please note, when contributing, the developer must include
a DCO sign-off statement indicating the DCO acceptance in one commit message. Here
is an example DCO Signed-off-by line in a commit message:
Describe your changes
Issue ticket number and link
Code checklist before requesting a review
PR Type
Bug fix, Enhancement
Description
Add macOS package installer scripts for automatic service startup
Auto-restart sysmon-vm service after mTLS bootstrap configuration
Update packaging build to include pre/postinstall scripts
Document implementation in openspec change proposal
Diagram Walkthrough
File Walkthrough
main.go
Add auto-restart after mTLS bootstrap on macOScmd/checkers/sysmon-vm/main.go
os/execandruntimeto support service restartlaunchdServiceTargetconstant for macOS launchd serviceidentifier
restartLaunchdService()function to restart service aftermTLS bootstrap
launchctl kickstart
--mtls-bootstrap-onlyconfiguration write
postinstall
New postinstall script for service bootstrappackaging/sysmonvm_host/scripts/postinstall
/var/log/serviceradardirectory with proper permissionslaunchctl bootoutlaunchctl bootstrap systemlaunchctl kickstart -kpreinstall
New preinstall script for clean upgradespackaging/sysmonvm_host/scripts/preinstall
launchctl bootoutto cleanly unload service before upgradepackage-host-macos.sh
Update packaging script to include installer hooksscripts/sysmonvm/package-host-macos.sh
PKG_SCRIPTS_DIRvariable pointing to packaging scripts directoryexist and are executable
pkgbuildcommand to include--scriptsparameter with scriptsdirectory
BUILD.bazel
Add build dependency for installer scriptspackaging/sysmonvm_host/BUILD.bazel
pkg_scriptsfilegroup to track preinstall/postinstallscripts
sysmonvm_host_pkggenrule srcs to depend on:pkg_scriptsproposal.md
Document sysmon-vm macOS service startup fixopenspec/changes/fix-sysmon-vm-macos-service-startup/proposal.md
bootstrap, missing log directory
control commands
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2044#issuecomment-3604995839
Original created: 2025-12-03T04:01:50Z
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
Command execution path hijack
Description: The
restartLaunchdServicefunction executeslaunchctl kickstart -ksystem/com.serviceradar.sysmonvmviaexec.Commandwithout specifying an absolute path tothe binary or sanitizing the environment, which can allow PATH hijacking if the process
runs with elevated privileges or a manipulated environment; mitigate by using an absolute
path (e.g.,
/bin/launchctlor/usr/bin/launchctl) and a controlled environment.main.go [254-266]
Referred Code
Script PATH hijacking
Description: The postinstall script runs
launchctl bootstrap/enable/kickstartusing unqualifiedlaunchctland does not set a minimal PATH, which can be exploited via PATH hijackingduring package installation; invoke
launchctlwith an absolute path (e.g.,/bin/launchctlor
/usr/bin/launchctl) and setPATHto a safe value.postinstall [68-78]
Referred Code
Sensitive information exposure
Description: The script creates
/var/log/serviceradarand sets permissions to755, but does not setownership explicitly; if ownership defaults are unexpected, logs could be readable to all
users and may leak sensitive information—ensure correct ownership (e.g., root:wheel) and
consider stricter file permissions for log files.
postinstall [33-40]
Referred Code
Script PATH hijacking
Description: The preinstall script invokes
launchctlwithout an absolute path and without exporting asafe PATH, enabling PATH hijacking if an attacker can influence environment during
install; use absolute path to
launchctland sanitize PATH.preinstall [30-34]
Referred Code
🎫 No ticket provided
Codebase context is not defined
Follow the guide to enable codebase context checks.
Generic: Meaningful Naming and Self-Documenting Code
Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting
Status: Passed
Generic: Secure Error Handling
Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.
Status: Passed
Generic: Secure Logging Practices
Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.
Status: Passed
Generic: Security-First Input Validation and Data Handling
Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities
Status: Passed
Generic: Comprehensive Audit Trails
Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.
Status:
Action logging: The new service restart path logs high-level messages but does not record structured audit
details (user ID, timestamp, action outcome) for the critical action of restarting a
system service.
Referred Code
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status:
Error fallback: On failure to restart the launchd service, the code logs a note and manual instruction but
does not expose an alternative automated fallback or retry strategy, which may be
acceptable yet warrants review.
Referred Code
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2044#issuecomment-3604997542
Original created: 2025-12-03T04:02:53Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Improve service startup verification logic
Replace the unreliable
sleepandlaunchctl printcheck with a robust pollingloop using
launchctl listto verify that the service has a running PID, avoidingrace conditions and false warnings.
packaging/sysmonvm_host/scripts/postinstall [80-86]
Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies a race condition in the service verification logic and proposes a more robust polling mechanism to check if the service is actually running, improving the reliability of the post-install script.
Decouple application from OS service manager
Instead of having the Go binary call macOS's
launchctlto restart the service,the application should be decoupled from the OS service manager. A better
approach is for the running daemon to monitor its configuration file for changes
and automatically reload itself.
Examples:
cmd/checkers/sysmon-vm/main.go [83-86]
cmd/checkers/sysmon-vm/main.go [242-268]
Solution Walkthrough:
Before:
After:
Suggestion importance[1-10]: 6
__
Why: The suggestion correctly identifies that calling
launchctlfrom Go creates undesirable coupling, but the impact is moderate as the logic is confined to a specific bootstrap flag (--mtls-bootstrap-only) and guarded by an OS check.✅
Add timeout to external commandSuggestion Impact:
The commit changed exec.Command to exec.CommandContext and threaded a context into restartLaunchdService. However, it did not add a timeout or capture output; it kept Stdout/Stderr redirection.code diff:
Replace
exec.Commandwithexec.CommandContextand add a timeout to prevent thelaunchctlcommand from hanging. Also, capture the command's output to include itin the error message for better diagnostics.
cmd/checkers/sysmon-vm/main.go [256-264]
[Suggestion processed]Suggestion importance[1-10]: 6
__
Why: The suggestion improves robustness by adding a timeout to an external command, preventing potential hangs, and enhances error diagnostics by capturing output, which is a good practice.