Summary
Nezha Monitoring contains a flaw where a RoleMember user can schedule cron tasks that execute arbitrary commands across all registered servers, not just their own.
Under specific configuration values, the scheduler broadcasts attacker-controlled commands to other tenants' agents, which then run the commands and exfiltrate results to an attacker-controlled webhook.
Affected context
The vulnerability affects multi-tenant Nezha Monitoring deployments where RoleMember-level users can create scheduled cron tasks through the dashboard.
When the cron task is configured with a global coverage option and no explicit server list, the scheduler uses a shared in-memory server map as the target set.
In such environments, servers belonging to administrators and other members are inadvertently included, meaning a tenant's cron task can reach servers outside its intended scope.
Exploit preconditions
- Attack surface: Nezha Monitoring web dashboard (cron task creation feature)
- Required access: Valid RoleMember account with permission to define scheduled tasks
- Trigger point: Scheduler ticks that process cron tasks configured with
Cover=CronCoverAllandServers=[] - Why exploitation is possible: The system reuses a global
ServerSharedmap for target selection and does not constrain cron task execution to the requesting tenant's servers, effectively bypassing authorization boundaries and enabling arbitrary command execution on other tenants' agents.
Why this happens
The core issue combines improper authorization with command execution capabilities.
The scheduler logic relies on a global ServerShared map and an overly broad coverage mode to select execution targets, but it does not enforce per-tenant or per-user ownership checks before dispatching commands.
Those commands, defined as free-form strings in the cron configuration, are executed by agents without adequate scoping or isolation.
This maps primarily to CWE-78: Improper Neutralization of Special Elements used in an OS Command due to untrusted commands being executed, and secondarily to CWE-269: Improper Privilege Management and CWE-862: Missing Authorization because a low-privilege user can affect higher-privilege and cross-tenant resources.
Potential impact
- Remote execution of arbitrary OS commands on administrators' servers
- Cross-tenant compromise of other members' servers within the same Nezha deployment
- Theft or exfiltration of sensitive data via attacker-controlled notification webhooks
- Installation of backdoors, cryptominers, or additional malware on affected hosts
- Lateral movement inside the monitored infrastructure and escalation of operational control
General mitigation guidance
Effective mitigation focuses on tightening authorization boundaries and restricting command execution capabilities:
- Enforce strict tenant isolation in scheduler and task-selection logic so that users can only target servers they own or are explicitly granted.
- Treat scheduled command strings as highly privileged operations; consider limiting them to predefined actions or templates instead of arbitrary shell commands.
- Apply least-privilege principles to RoleMember and similar roles, removing the ability to execute arbitrary commands across broad server sets.
- Introduce configuration-level guards that prevent "all servers" coverage modes from being used by non-administrative roles.
- Consider sandboxing or lowering the privilege of the agent processes that execute commands so that any abuse has reduced impact.
How teams detect issues like this
Detection typically involves correlating dashboard activity with scheduler behavior and agent responses:
- Use log analysis or SIEM rules to flag cron tasks created by non-admin users with global coverage or empty server lists.
- Monitor for unusual patterns of command execution originating from a single low-privilege account targeting many unrelated servers.
- Review webhook or notification configurations for destinations controlled by untrusted or external parties, especially when linked to high-volume task output.
- Apply static or configuration analysis checks in CI/CD pipelines or policy engines to prevent deployment of configurations that allow cross-tenant task execution.
- Periodically review role definitions and access control policies to ensure that only trusted roles can define powerful or wide-scope scheduled tasks.

