Checkmk: Remote Code Execution by Chaining Multiple Bugs (3/3)
An authenticated arbitrary file read in NagVis allowed reading the plaintext automation secret, and a code injection in Checkmk's watolib allowed escaping a single-quoted PHP string to inject code. Chained with earlier bugs, an unauthenticated attacker could achieve remote code execution.
Published on sonarsource.com
This is the third and last article in the Checkmk - Remote Code Execution by Chaining Multiple Bugs series (first article, second article). Within the series of articles, we take a detailed look at multiple vulnerabilities we identified in Checkmk and its NagVis integration, which can be chained together by an…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The file read lacked URL scheme validation, and the PHP code generator escaped single quotes without accounting for a preceding backslash, allowing string context escape.
Impact
An unauthenticated remote attacker could fully take over the server running a vulnerable version of Checkmk.
What the attacker needed
Network access to Checkmk; earlier chain steps completed; default automation user present
The fix
The file read was fixed by limiting the requested scheme to http and https, and the code injection was fixed by escaping both single-quote and backslash characters.
How it was found
- Gain access to NagVis via earlier vulnerabilities in the chain.
- Use the getHoverUrl action with a file:/// URL to read the automation.secret file.
- Delete the automation.secret file using the Nagios PROCESS_FILE command from the second article.
- Log in to the Checkmk GUI with the automation user credentials, which are now treated as a normal user.
- Change profile settings to inject PHP code into the auth.php file via the escaping flaw.
- Access the NagVis component, which includes auth.php and executes the injected code.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
This is the final part of a series showing how several small flaws can be combined into a full server takeover. One flaw let a logged-in user read any file on the server, including a file holding a secret password for an automation account. Another flaw let that user slip PHP code into a generated configuration file, which the server then ran.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.