Repository navigation
fix(server): scope sessions to connections and harden server limits - #888
Merged
Merged
Conversation
Scope session.list/get/exec/destroy to the creating connection, cap connections, time out incomplete requests, free decoder buffers, make final_env opt-in and size-capped, and classify bad shell_variant and startup_options as INVALID_ARGUMENT. CLI: pin --readwrite-root to its startup inode, reject a missing --root, add --max-exec-timeout (default 10m), treat --rcfile as value-taking, and stop the server cleanly on SIGINT/SIGTERM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the server/CLI findings from the second review of main at 19ff56a.
Server
session.listshows only that connection's sessions, andget/exec/destroyfrom another connection returnSESSION_NOT_FOUND. A connection's sessions are destroyed when it closes.server.MaxConnections). A connection that leaves a request incomplete for 30s is closed; idle connections have no deadline. The decoder is replaced after each request so a large request's buffer is freed.final_envis returned only when the request setsinclude_final_env: true, and it is capped at 1 MiB (final_env_truncated). This also stops--inherit-envvalues from being echoed by default. It still includes non-exported shell variables, because the runtime's FinalEnv doesn't record export status; with opt-in plus the size cap, filtering would need a runtime API change.shell_variantor astartup_optionsentry thatset -orejects now returns-32602 INVALID_ARGUMENTinstead of INTERNAL. This adds a smallinterp.IsSetOptionhelper (cross-area, 9 lines).CLI
--readwrite-root: each new session re-checksos.SameFileagainst the directory validated at startup, before and after the mount opens. A rename-and-symlink swap now fails the session instead of mounting the target.--rootmust be an existing directory; the check runs at startup.--max-exec-timeoutflag (default 10m, must be positive) is wired toserver.Config.MaxExecTimeout.--rcfile FILEis value-taking, sogbash --rcfile /dev/null --root DIR -c pwdworks.signal.NotifyContextinserveServer, so interactive shells are unaffected).Breaking for clients: final_env is now opt-in, and sessions can no longer be shared across connections.
SPEC §5 CLI bullets and §6.2 are updated, along with website/content/api/server.mdx. Every item has a regression test.
go test -race ./server/... ./cli/...andmake lintpass.