Skip to content

Serve ServerCommander through built-in web console#10

Merged
VectoDE merged 1 commit intomainfrom
codex/create-standalone-console-window-for-servercommander
Oct 21, 2025
Merged

Serve ServerCommander through built-in web console#10
VectoDE merged 1 commit intomainfrom
codex/create-standalone-console-window-for-servercommander

Conversation

@VectoDE
Copy link
Owner

@VectoDE VectoDE commented Oct 21, 2025

Summary

  • replace the dedicated terminal relaunch with a self-hosted web console that captures stdout/stderr and streams updates to the UI
  • launch the browser-based terminal at startup and route command execution and clear events through the new console server
  • fall back to OS-level clearing only when the web console is unavailable

Testing

  • go build ./...
  • go test ./...

https://chatgpt.com/codex/tasks/task_e_68f7b700f248832caaebf128532d6d5c

@VectoDE VectoDE merged commit 0cfb2b3 into main Oct 21, 2025
1 check passed
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +241 to +264
func (c *ConsoleServer) handleExecute(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
return
}

var payload struct {
Command string `json:"command"`
}

if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {
http.Error(w, "invalid payload", http.StatusBadRequest)
return
}

command := strings.TrimSpace(payload.Command)
if command == "" {
w.WriteHeader(http.StatusNoContent)
return
}

c.broadcastAppend(">> " + command + "\n")
go c.executeCommand(command)
w.WriteHeader(http.StatusAccepted)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Expose command execution endpoint without origin checks

The new web console accepts POSTs to /execute and directly forwards the payload to cmd.Execute with no CSRF token, authentication, or Origin/Referer validation. Because the server listens on 127.0.0.1 a malicious website opened in the user’s browser can issue a cross‑site fetch to this endpoint (it does not need to read the response) and execute arbitrary ServerCommander commands, which often map to shell actions. The random port does not prevent this because it can be brute‑forced. This is effectively a remote code execution vector for any user running the app with a browser open.

Useful? React with 👍 / 👎.

Comment on lines 10 to +12
func main() {
ui.ApplicationBanner()
reader := bufio.NewReader(os.Stdin)

for {
fmt.Print(utils.Yellow, "\n>> ", utils.Reset)
input, err := reader.ReadString('\n')
if err != nil {
fmt.Println(utils.Red, "Failed to read input:", err, utils.Reset)
continue
}

command := strings.TrimSpace(input)
if command == "" {
continue
}

if err := cmd.Execute(command); err != nil {
fmt.Println(utils.Red, err, utils.Reset)
}
if err := ui.RunStandaloneConsole(cmd.Execute); err != nil {
log.Fatal(err)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Browser console cannot satisfy interactive prompts

Replacing the CLI loop with RunStandaloneConsole executes each command via HTTP but only forwards the initial command string. Commands that call utils.Prompt/PromptPassword still read from the process’s original os.Stdin (initialised at startup), which is no longer connected to the browser input. When users trigger interactive commands such as session add from the web UI, the prompts are rendered in the browser but the process waits for input on the hidden terminal, effectively hanging the command. Consider plumbing user input back to os.Stdin or rewriting prompts to use the web channel so interactive commands remain usable.

Useful? React with 👍 / 👎.

@VectoDE VectoDE deleted the codex/create-standalone-console-window-for-servercommander branch October 21, 2025 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant