site serve, site view and patch: show a VM's output without letting it control the terminal #254
Labels
No labels
blocked
bug
decision
duplicate
enhancement
help wanted
invalid
landed?
question
ready-to-merge
stale
wontfix
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
allod/tools#254
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Show what a VM prints on the hypervisor's terminal as text only, so a compromised VM cannot use its output to control or rewrite the owner's terminal.
Primary goals:
ssherror from the VM is still shown, line for line.allod site view,allod site serve --vmandallod patchall pass through the same filter.Current state
Commands run on the hypervisor start
sshto a VM and connect its output straight to the terminal. Whatever the VM writes arrives byte for byte, terminal control sequences included. A terminal acts on those: they can move the cursor, clear or overwrite what is on screen, and change the window title, so a VM can make the terminal show text the hypervisor never printed. The VM is the less trusted side: a VM never gains authority over the host.This has not been run against a real hypervisor and VM. It is read from the code, at
ef380c8:allod site viewcmd/allod/site_serve.go:14, reached fromcmd/allod/site_view.go:48allod site serve --vmcmd/allod/site_serve.go:14andcmd/allod/site_serve.go:91allod patch, reading from a VMcmd/allod/patch.go:204allod patch, transferring from a VMcmd/allod/patch.go:212runCommand(cmd/allod/exec.go:46) assigns the writer it is given to the child's output, and each caller above gives it the process's own standard error or standard output.What a VM writes includes text it does not author itself:
allod site serveprints the last lines of the preview unit's journal on failure, and those lines come from whatever the site's app logged.allod site viewalready discards the VM's standard output (cmd/allod/site_view.go:48), so nothing on the hypervisor reads a value from it. That is unchanged by this issue.Default
The output of an
sshto a VM goes through one writer before it reaches the terminal. The writer passes printable text, newline and tab, and replaces every other control byte, the escape character among them, with a visible form. It works on bytes as they arrive, holds no more than it needs to finish a multi-byte character, and never fails the write, so a VM that prints without end costs no memory and does not stallssh.Alternative, only if the default proves awkward: capture the VM's output and show it only when the remote command fails. It hides progress messages from a long start and needs a bound on what is kept.
Validation
Scope
In: the three commands in the table, the shared writer, its tests. Out: what
allod patchdoes with the bytes it captures from a VM; the pages a preview serves to the browser; the finalssh -Lofallod site view.viewbecomes thatssh(cmd/allod/site_view.go:53), so nothing ofallodis left to filter it; it runs no command in the VM, but anything the VM's ssh server sends the client, such as a banner, still reaches the terminal. Whetherviewshould keep a process of its own around thatsshis a separate decision.