security: strip OPEN_TERMINAL_* from subprocess env#128
Open
mazzz1y wants to merge 1 commit into
Open
Conversation
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.
User-spawned shells and commands inherited the full parent environment, including
OPEN_TERMINAL_API_KEY. A user runningenv | grep OPEN_TERMINAL_inside an/executecommand or/api/terminalssession could read internal configuration meant only for the server process.This is the minimal, conservative fix:
OPEN_TERMINAL_*keys are stripped. Other variables such asPATH,HOME,USER,SHELL,TERM,LANG, etc pass through unchanged, so user shells continue to feel normal.envinPOST /executestill wins on collision — authenticated callers can explicitly re-add any variable.Tested in my environment — REST API with OpenWebUI
Another option was introducing a prefix convention to fully separate server variables from sandbox variables — e.g.
SANDBOX_API_KEYon the server side becomesAPI_KEYinside the user's shell. This would give stronger isolation but is likely a breaking change: operators currently set env vars in their Dockerfile / compose / launch scripts and expect them to pass through to user commands. For that reason I did not choose this approach.