## ADDED Requirements ### Requirement: Console HTML pages SHALL be rendered through a template engine with automatic HTML escaping enabled The Host Agent local console SHALL render every HTML page through a single, process-wide template engine configured so that values interpolated into templates whose names end in `.html` are HTML-escaped by the engine before being written into the response, independent of whether the calling code remembers to escape them. The template engine and its autoescape configuration SHALL be constructed once at module import time of `host_agent/web/app.py` and reused by every page handler; pages SHALL NOT bypass the engine by constructing HTML through string concatenation, f-string interpolation, or any other path that skips autoescape. #### Scenario: All current pages go through the autoescaping engine - **WHEN** the Host Agent renders any of its login, status dashboard, devices, account, or history pages - **THEN** the rendered HTML is produced by the shared template engine with autoescape enabled for `.html` templates, and the page handler does not construct any HTML fragment via f-string, string concatenation, or `str.format` #### Scenario: A new page added later inherits autoescape without extra wiring - **WHEN** a future change adds a new `.html` template under the Host Agent console's templates directory and a route handler renders it through the shared template engine - **THEN** that new page's interpolated values are HTML-escaped by the engine without the new change having to reconfigure autoescape or wrap any value in an escaping helper #### Scenario: Handler code returns a plain HTMLResponse built from the engine's output - **WHEN** a console route handler produces its response - **THEN** the response is an `HTMLResponse` whose `content` is the string returned by the template engine's `render(...)` call, and the handler does not post-process that string in a way that could re-introduce unescaped markup ### Requirement: Operator- and externally-influenced values rendered into console pages SHALL be HTML-escaped Any value that originates from operator input (e.g. device name, driver type, connection info JSON, account username), from the control plane (e.g. host policy fields, assignment summaries), or from task execution (e.g. step summaries, scene/element descriptions) SHALL be HTML-escaped by the template engine when interpolated into a console page, so that the rendered output contains no executable `` and the operator subsequently loads the devices page or the status dashboard - **THEN** the rendered HTML contains the literal text `<script>alert(1)</script>` (or an equivalent escaped form) in the position where the device name is interpolated, and contains no `` - **THEN** the test receives the rendered HTML as a string and can assert that the XSS probe has been HTML-escaped in the output