Keldagrim
Source-aware referenceA client-controlled role unlocks a report generator. A report query becomes template code. A permissive sudo rule then turns a low-privilege foothold into container root.
- 1. Forge the role
YWRtaW4= → adminThe application treats an unsigned cookie as authorization. - 2. Inject the report
search → template sourceBase64-decoded input is concatenated into Jinja syntax. - 3. Reach the process
Flask → keldagrimThe intended SSTI payload accesses Python and the OS. - 4. Cross the sudo boundary
LD_PRELOAD + sudo zipA user-selected shared object initializes with root privileges.
The scenario
The supplied project is a containerized training recreation of the TryHackMe Keldagrim attack path, not a record of a live TryHackMe machine. Its mining company website has public company pages and an unlinked /admin reporting panel.
The admin gate decodes a role cookie and compares it with the literal string admin. Once that gate is passed, a POSTed report query is decoded and inserted into a template compiled by Flask. The author walkthrough uses that template injection to execute commands as keldagrim, then abuses the installed sudo policy.
Read-only review, not a recorded exploitation
The Python application, all nine HTML templates, Docker configuration, startup script, sudoers fragment, README, and Markdown walkthrough were read as text. No container was built or started; no application, payload, compiler, scanner, shell, or supplied script was run. Expected behavior is identified as source-derived or author-reported. The generated HTML was not launched for testing.
What a complete solve means
- Distinguish host ports
8080/2222from container ports80/22. - Explain why base64 does not authenticate the role or sanitize the query.
- Trace the exact point where report data becomes template source.
- Keep web-admin access, process command execution, and OS-root access separate.
- Explain both the sudo rule and the dynamic-loader conditions behind the intended escalation.
- Read the flags actually generated for that deployment, rather than assume the walkthrough's flag strings.
The central idea
Follow who controls each value and what authority it gains at the next boundary.
The central correction
The guest page says “403,” but the source returns HTTP 200. Page appearance is not protocol behavior.
Reveal local training credentials
These are intentionally supplied in the README and Dockerfile, not recovered by this review. They belong to this local recreation only.
User: keldagrim
Password: keld4grim_d0rf
Host SSH port: 2222Using the supplied SSH credential skips the web foothold. It is useful for studying the sudo stage, but does not demonstrate the cookie or SSTI stages.
Reveal the author-reported flags
The Markdown walkthrough gives the following examples. Neither was read from a running lab, and neither is the current Compose default.
THM{k3ld4gr1m_us3r_fl4g_2d8f}THM{k3ld4gr1m_r00t_pr1v3sc_9a1c}The startup script splits a single FLAG string at its midpoint. See flag generation and its length caveat before treating any string here as a deployment answer.