CSRF Vulnerability in Komari Management Interface
The Komari management interface lacks CSRF protections and secure cookie attributes, allowing an attacker to perform unauthorized administrative actions including arbitrary code execution.
The Komari management interface (version < 0.0.0-20260609084633-98122fa4d110) contains a significant security flaw regarding session and administrative request validation. The session_token cookie is generated without Secure or SameSite attributes, and all administrative API endpoints under /api/admin/ lack CSRF token verification or Origin-based access controls.
While modern browsers implement SameSite=Lax by default - which hinders cross-site POST requests - the application remains susceptible in same-origin contexts, when accessed via legacy browsers, or during Man-in-the-Middle (MitM) attacks due to the missing Secure flag. Successful exploitation enables unauthorized actors to perform high-impact operations, including executing shell commands via /api/admin/task/exec, disabling 2FA, and modifying system configurations. This vulnerability stems from inadequate middleware configuration in the underlying Gin framework implementation.
Attack Chain
- Attacker identifies the target instance of the Komari management console.
- Attacker crafts a malicious payload (e.g., HTML form or JavaScript fetch request) targeting a sensitive endpoint such as
/api/admin/task/exec. - Attacker lures an authenticated administrative user to a malicious site or injects the payload via existing XSS vulnerabilities in the target's environment.
- The victim's browser initiates the unauthorized request to the Komari API.
- The server receives the request, including the non-secure
session_tokencookie, which is automatically included by the browser if the environment does not strictly enforceSameSite=Laxor if it is a same-origin request. - The server application, lacking CSRF middleware, processes the request as legitimate, assuming it originated from the administrative interface.
- The intended administrative operation (e.g., code execution or configuration change) is performed on the server or managed nodes.
Impact
Successful exploitation allows attackers to bypass administrative authentication. Impacted operations include the execution of arbitrary shell commands on managed nodes, complete disabling of administrator 2FA, deletion of monitoring records, and modification of system settings. This could lead to a total compromise of the managed infrastructure and the Komari monitoring server itself.
Recommendation
Prioritize updating the Komari package to version 0.0.0-20260609084633-98122fa4d110 or later. Ensure that webserver-level headers are configured to prevent cross-site request forgery and that the application is served exclusively over HTTPS with cookies flagged as Secure and SameSite=Strict. For detection engineering, monitor webserver access logs for anomalous POST requests to /api/admin/ paths that do not originate from the expected internal management source IPs or authorized referrers.
Immediate actions
Upgrade Komari package to version 0.0.0-20260609084633-98122fa4d110 or later
Threat Hunt
Search webserver logs for POST requests to /api/admin/ paths from unusual IP addresses
Data: webserver_access_logs
Mitigations
Upgrade to the specified patched version
komari < 0.0.0-20260609084633-98122fa4d110
Detection coverage 1
Detect Suspicious Administrative API Access
highDetects potentially unauthorized POST requests to sensitive Komari administrative endpoints, which may indicate a CSRF attempt if the source is not a trusted management host.
Detection queries are available on the platform. Get full rules →