The vulnerability is a missing authorization flaw where the system processes task results from authenticated agents without verifying if the agent is authorized to report for the specified task. This allows a low-privilege attacker with a valid agent to forge results for services and cron jobs belonging to other users, leading to data integrity violations and potentially incorrect alert notifications.
The analysis of the patch identified two key functions where this vulnerability was present:
-
singleton.ServiceSentinel.worker: This function is responsible for processing service monitor results. The patch shows that the original code only checked for the existence of the service ID from the incoming report. The fix introduces a call to canReportServiceResult, which performs the necessary authorization checks, verifying that the reporting agent is covered by the service's monitoring configuration and belongs to the correct user.
-
rpc.NezhaHandler.RequestTask: This function is the main gRPC endpoint for receiving all task results. While the patch for this specific file was not provided in the commit details, the addition of the CanReportCronResult function and a new security test file (request_task_security_test.go) strongly indicate that this function was also vulnerable. It improperly handled cron job results, and the patch added authorization checks by calling the new CanReportCronResult function before processing them. The tests explicitly validate that forged cron results are now rejected.
Both functions are critical runtime indicators for this vulnerability. During an exploit, RequestTask would be the initial function in the stack trace to receive the malicious data, and for service monitoring, the exploit's effects would be processed by the worker function in a separate goroutine.