Skip to content

fix: keep servers from reading gate's environment on Linux - #8

Closed
vrmiguel wants to merge 2 commits into
mainfrom
tembo/hide-environment
Closed

vrmiguel wants to merge 2 commits into
mainfrom
tembo/hide-environment

Conversation

@vrmiguel

@vrmiguel vrmiguel commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

hookEnv keeps hook tokens out of servers' environments, but stdio servers run as the same user as gate, so any of them could still read every token from /proc/<gate's pid>/environ.

On Linux, gate now makes itself non-dumpable (prctl(PR_SET_DUMPABLE, 0)) at startup. That makes its /proc files, environ included, belong to root. Gate's children are unaffected: a process becomes dumpable again when it execs. If the call fails, gate logs a warning and keeps running.

This doesn't help when gate and its servers run as root, and macOS has no equivalent, since same-user processes can read each other's environment there too.

Tested by servers_cannot_read_gates_environment (Linux only), which fails without the change: the server read gate's environment, hook token included.


Want tembo to make any changes? Add a comment with @tembo and i'll get back to work!

View on Tembo  Review in Tembo  View Agent Settings

Co-authored-by: tembo[bot] <208362400+tembo-io[bot]@users.noreply.github.com>
@tembo tembo Bot added the tembo Pull request created by Tembo label Nov 9, 2026
Co-authored-by: Vinícius <36349314+vrmiguel@users.noreply.github.com>
@tembo

tembo Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Closing: this hides gate's own environment, but in Tembo's sandbox the same tokens are readable elsewhere by any same-user process (the agent's and shells' environments, and the gateway credential token in a world-readable config file), so it doesn't keep tokens from a hostile server. Real isolation needs servers to run as another user or in a separate sandbox.

@tembo tembo Bot closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tembo Pull request created by Tembo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant