Files, processes and the shell
Transfer roots
Section titled “Transfer roots”Files move through two roots only: the session user’s home directory and /tmp. A path is written ~, ~/<path>, /tmp or /tmp/<path>. A path that leaves a root, including through a symlink, is refused.
| Route or method | Does |
|---|---|
PUT /v1/files/{home,tmp}/<path> |
Uploads a file. ?overwrite=true replaces an existing file; ?mode=0755 sets its mode. Without overwrite, an existing file gives 409 |
GET /v1/files/{home,tmp}/<path> |
Streams a file out, with a SHA-256 digest |
PUT /v1/dirs/{home,tmp}/<path> |
Uploads a zip and extracts it. The whole archive is checked before anything is written |
GET /v1/dirs/{home,tmp}/<path> |
Streams a directory as a zip |
file.get, directory.get |
The same reads as a method, returned inline as base64 up to 5 MiB |
Uploads are HTTP only. One upload, one extracted archive and one directory download each allow 1 GiB by default. At most four transfers run at once; a fifth gets 503. Transfers need the session token, and the report records each one’s path, size and digest, never its content. A file or zip over 5 MiB makes file.get or directory.get return an error that names the streaming route.
# Upload a file through Kasm's proxy, then use it from a page.# The headers go through curl's config on stdin, so the secrets stay out of the process list.curl -sS -X PUT -K - --data-binary @report.csv \ "https://<host>/desktop/<kasm_id>/runtime/v1/files/tmp/report.csv" <<EOFheader = "X-Kasm-Runtime-Session-Token: $RUNTIME_TOKEN"header = "Cookie: session_token=$KASM_COOKIE; username=$KASM_USERNAME"EOFdom.set_files can then choose that file in a page’s upload field; see Web pages.
Downloads
Section titled “Downloads”When a browser saves a file, downloads.wait returns it once it is finished. downloads.list returns the files in the browsers’ download folder (~/Downloads) and a cursor. The pattern matches windows.list and windows.wait: list, act, then wait from the cursor.
downloads.listreturns acursor.- Click the link with
dom.click, or open the file’s URL withdom.navigate. A navigation that becomes a download returnskind: "download"and leaves the page where it was. downloads.waitwithsinceset to that cursor returns the finished file with itspath,bytesandsha256. A download that finished between the action and the wait still matches.namenarrows the match with a glob such asreport*.csv, which also catches the browser’sreport (1).csv.file.getwith thepathreads it, orGET /v1/files/streams a larger one.
state is partial while a browser is still writing. A timeout is matched: false and lists the files still being written.
Chrome asks before a page starts a second download with no navigation in between. Nothing is written until someone answers, and downloads.wait times out. The prompt is in the accessibility tree, and a11y.action on its Allow button lets the download go ahead.
Processes
Section titled “Processes”| Method | Does |
|---|---|
proc.list |
Lists processes whose command line contains match ("" for all) |
proc.spawn |
Starts a command detached, as the session user |
proc.kill |
Signals processes whose command line matches a POSIX extended regular expression |
launch |
Starts a command like proc.spawn and records it as the session’s launched application |
wait_while |
Holds until a growing file or directory stops changing (kind: "growing", with path), or until no process matches (kind: "process", with match) |
launch and proc.spawn refuse a command whose program is an installed application’s own and name the apps.start call to use instead. This guides an agent and does not limit it, since shell runs anything.
The shell
Section titled “The shell”shell runs a command line with sh -c to completion and returns its combined output. A nonzero exit is a resolution error that carries the output; a shell that cannot start is an environment error. The command runs as the session user with the session’s display.
In a driven session shell has no timeout of its own. A command that never ends holds the call, and since calls run one at a time, it holds every other call too. Run long work with proc.spawn and follow it with wait_while.
Output is capped: the first 2,000 characters come back, followed by a marker that says how many bytes were dropped. The runtime removes only registered secret values from it, and a driven session usually registers none, so anything the command prints, including secrets, reaches the caller and the record. Secrets and evidence describes what the record holds.