Skip to content

fix(security): stop logging runtime command contents - #4280

Merged
simonrosenberg merged 11 commits into
mainfrom
fix-sensitive-runtime-logs
Jul 29, 2026
Merged

simonrosenberg merged 11 commits into
mainfrom
fix-sensitive-runtime-logs

Conversation

@simonrosenberg

@simonrosenberg simonrosenberg commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

stop logging runtime command contents


AGENT:

Why

Production runtime paths logged complete shell commands and terminal output. Those fields can contain injected credentials. A seven-day production log review found 995 timeout records from the affected path with credential-bearing commands.

Summary

  • Replace raw command and terminal-content logs with command IDs, lengths, timeouts, and exception types.
  • Preserve command execution, timeout signaling, and returned command results.
  • Add regression coverage with fake token-shaped values and assert they never reach captured logs.

Issue Number

N/A

How to Test

  • uv run pytest tests/agent_server/test_bash_service.py tests/sdk/workspace/remote/test_remote_workspace_mixin.py tests/tools/terminal/test_ps1_corruption.py
    • 44 passed.
    • The agent-server test sends an HTTP request through the ASGI app, runs a real timed-out bash subprocess, confirms the SIGTERM cleanup trap ran, and confirms the fake credential is absent from logs.
  • uv run pre-commit run --files openhands-agent-server/openhands/agent_server/bash_service.py openhands-sdk/openhands/sdk/workspace/remote/remote_workspace_mixin.py openhands-tools/openhands/tools/terminal/terminal/terminal_session.py tests/agent_server/test_bash_service.py tests/sdk/workspace/remote/test_remote_workspace_mixin.py tests/tools/terminal/test_ps1_corruption.py
    • All hooks passed.

Video/Screenshots

N/A. This changes server-side logging only.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

No secret values or production log payloads are included in this PR.


Agent Server images for this PR

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python amd64, arm64 nikolaik/python-nodejs:python3.13-nodejs22-slim Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:95a1bb6-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-95a1bb6-python \
  ghcr.io/openhands/agent-server:95a1bb6-python

All tags pushed for this build

ghcr.io/openhands/agent-server:95a1bb6-golang-amd64
ghcr.io/openhands/agent-server:95a1bb6e8d4ab86818dd7ea1dc18c70d423026e6-golang-amd64
ghcr.io/openhands/agent-server:fix-sensitive-runtime-logs-golang-amd64
ghcr.io/openhands/agent-server:95a1bb6-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:95a1bb6-golang-arm64
ghcr.io/openhands/agent-server:95a1bb6e8d4ab86818dd7ea1dc18c70d423026e6-golang-arm64
ghcr.io/openhands/agent-server:fix-sensitive-runtime-logs-golang-arm64
ghcr.io/openhands/agent-server:95a1bb6-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:95a1bb6-java-amd64
ghcr.io/openhands/agent-server:95a1bb6e8d4ab86818dd7ea1dc18c70d423026e6-java-amd64
ghcr.io/openhands/agent-server:fix-sensitive-runtime-logs-java-amd64
ghcr.io/openhands/agent-server:95a1bb6-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:95a1bb6-java-arm64
ghcr.io/openhands/agent-server:95a1bb6e8d4ab86818dd7ea1dc18c70d423026e6-java-arm64
ghcr.io/openhands/agent-server:fix-sensitive-runtime-logs-java-arm64
ghcr.io/openhands/agent-server:95a1bb6-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:95a1bb6-python-amd64
ghcr.io/openhands/agent-server:95a1bb6e8d4ab86818dd7ea1dc18c70d423026e6-python-amd64
ghcr.io/openhands/agent-server:fix-sensitive-runtime-logs-python-amd64
ghcr.io/openhands/agent-server:95a1bb6-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-amd64
ghcr.io/openhands/agent-server:95a1bb6-python-arm64
ghcr.io/openhands/agent-server:95a1bb6e8d4ab86818dd7ea1dc18c70d423026e6-python-arm64
ghcr.io/openhands/agent-server:fix-sensitive-runtime-logs-python-arm64
ghcr.io/openhands/agent-server:95a1bb6-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-arm64
ghcr.io/openhands/agent-server:95a1bb6-golang
ghcr.io/openhands/agent-server:95a1bb6e8d4ab86818dd7ea1dc18c70d423026e6-golang
ghcr.io/openhands/agent-server:fix-sensitive-runtime-logs-golang
ghcr.io/openhands/agent-server:95a1bb6-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:95a1bb6-java
ghcr.io/openhands/agent-server:95a1bb6e8d4ab86818dd7ea1dc18c70d423026e6-java
ghcr.io/openhands/agent-server:fix-sensitive-runtime-logs-java
ghcr.io/openhands/agent-server:95a1bb6-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:95a1bb6-python
ghcr.io/openhands/agent-server:95a1bb6e8d4ab86818dd7ea1dc18c70d423026e6-python
ghcr.io/openhands/agent-server:fix-sensitive-runtime-logs-python
ghcr.io/openhands/agent-server:95a1bb6-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim

About Multi-Architecture Support

  • Each variant tag (e.g., 95a1bb6-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., 95a1bb6-python-amd64) are also available if needed

Co-authored-by: openhands <openhands@all-hands.dev>
@github-actions

github-actions Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Python API breakage checks — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-agent-server/openhands/agent_server
   bash_service.py2213086%74–76, 145–146, 148–149, 179–181, 193–196, 277, 282–283, 304–309, 377–378, 414–415, 419, 452–453
   sockets.py2422689%202, 205, 208, 286–287, 291, 293–295, 301–303, 306, 427–430, 435–436, 441–443, 513, 515, 534, 591
openhands-sdk/openhands/sdk/workspace/remote
   remote_workspace_mixin.py134795%348–351, 376–378
openhands-tools/openhands/tools/terminal/terminal
   subprocess_terminal.py28023018%16, 66–67, 93–96, 99–104, 110–111, 117–118, 120–122, 129–130, 134–135, 141–142, 145, 148–152, 154, 157, 159–161, 175–178, 180, 183–184, 187, 190–191, 194, 198–199, 201, 203, 207–208, 210–211, 213–219, 221–227, 230–235, 237–238, 240–241, 246, 248–256, 260–262, 264–265, 267–268, 271–273, 275–278, 280–281, 283–284, 286–291, 296–298, 300, 303, 306–307, 310–311, 317–319, 321–328, 330–333, 337–345, 380–381, 383–384, 387–388, 390, 392, 394–396, 399–402, 404–406, 408–409, 411–412, 421–424, 433–435, 438–439, 442, 444, 447–448, 450, 457–458, 462, 464–469, 473–474, 476–479, 481–487, 489–490, 492–496, 500–501, 503–509, 513–514, 517–518, 520–521, 523–525
   terminal_session.py2198561%51–57, 115–117, 122, 128, 132–134, 170–171, 176, 204, 209–210, 215, 221, 224–228, 243, 259–260, 301–303, 309, 312–313, 317, 323, 326, 341–343, 349, 352–353, 357, 363, 366, 386, 388, 391, 393, 411, 428, 442, 448, 457, 460, 497, 501, 504, 507–508, 514, 518, 524, 527, 534, 541, 544, 602–604, 608, 613, 618, 622–623, 626–629, 635, 638
TOTAL39909805180% 

@simonrosenberg
simonrosenberg marked this pull request as ready for review July 27, 2026 17:58

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⚠️ QA Report: PASS WITH ISSUES

The agent-server timeout and RemoteWorkspace client paths now avoid logging fake token-shaped command contents, but a real terminal execution path still emits command/output contents through lower-level DEBUG logs.

Does this PR achieve its stated goal?

Partially. I verified the main agent-server timeout path with a real local server and HTTP request: the base branch logged the full timed-out command with a fake token, while the PR logged only timeout metadata and command ID, and the cleanup trap still ran. I also verified RemoteWorkspace command execution against a local agent-server no longer logs the command on the client side. However, a real SubprocessTerminal command execution on the PR still captured the fake token in DEBUG logs from the terminal backend, so the broader goal of stopping runtime command/output logging is not fully achieved.

Phase Result
Environment Setup ✅ make build completed successfully.
CI Status ⏳ 21 successful, 2 skipped, 6 pending, 0 failing at the time checked.
Functional Verification ⚠️ Agent-server and RemoteWorkspace behavior fixed; terminal subprocess logging still leaks fake command/output contents.
Functional Verification

Test 1: agent-server timeout logging through the real HTTP API

Step 1 — Reproduce baseline without the fix:
Checked out 14876fc971807314240b6e74158baba8f25307dd, started uv run python -m openhands.agent_server --host 127.0.0.1 --port 8123, then POSTed a token-shaped command to /api/bash/start_bash_command with timeout: 1.

Observed:

[base] http_status=200 timed_out_log=yes marker_exists=yes log_contains_fake_token=yes
[base] relevant log lines:
"Command timed out after 1 seconds: LEAK_TEST=<FAKE_TOKEN>; trap 'touch /tmp/qa-base-cleanup-marker; exit 0' TERM; sleep 30"

This confirms the bug: the command timed out, cleanup still ran, and the timeout log included the fake token-bearing command.

Step 2 — Apply the PR changes:
Checked out 51d40fb6602785954c36056f06790ffd1cf17bb4.

Step 3 — Re-run with the fix in place:
Started uv run python -m openhands.agent_server --host 127.0.0.1 --port 8124 and sent the same kind of request.

Observed:

[pr] http_status=200 timed_out_log=yes marker_exists=yes log_contains_fake_token=no
[pr] relevant log lines:
"Command timed out after 1 seconds (command_id=02dde4ce-2ead-4b89-9d5f-6427b46c796e)"

This confirms the agent-server timeout path preserves behavior while removing the command contents from the log.

Test 2: RemoteWorkspace client command logging against a local server

Step 1 — Reproduce baseline without the fix:
Checked out the base commit, started a local agent-server, and ran:

RemoteWorkspace(host="http://127.0.0.1:8125", working_dir="/tmp").execute_command("printf '<FAKE_TOKEN>\n'", timeout=10.0)

Observed:

[base-remote] exit_code=0
[base-remote] result_contains_fake_token=True
[base-remote] client_log_contains_fake_token=True
[base-remote] relevant client log lines:
Executing remote command: printf '<FAKE_TOKEN>

This shows the result returned command output as expected, but the client DEBUG log exposed the command.

Step 2 — Apply the PR changes:
Checked out the PR commit.

Step 3 — Re-run with the fix in place:
Ran the same RemoteWorkspace command against a local agent-server on port 8126.

Observed:

[pr-remote] exit_code=0
[pr-remote] result_contains_fake_token=True
[pr-remote] client_log_contains_fake_token=False
[pr-remote] relevant client log lines:
Executing remote command

This confirms the RemoteWorkspace path still executes successfully and no longer logs the command contents on the client side.

Test 3: real SubprocessTerminal command logging

Step 1 — Reproduce baseline without the fix:
Checked out the base commit and executed a real shell command through TerminalSession(SubprocessTerminal(...)) with DEBUG log capture.

Observed:

[base-terminal] exit_code=0
[base-terminal] returned_observation_contains_fake_token=True
[base-terminal] captured_debug_logs_contain_fake_token=True
RECEIVED ACTION: command="printf '<FAKE_TOKEN>
'" ...
SENDING COMMAND: "printf '<FAKE_TOKEN>
'"
Wrote to subprocess PTY: b"printf '<FAKE_TOKEN>
'
"
Read from subprocess PTY: ... printf '<FAKE_TOKEN> ... <FAKE_TOKEN> ...
COMBINED OUTPUT: printf '<FAKE_TOKEN> ... <FAKE_TOKEN>

This confirms the old terminal path logged command and output contents.

Step 2 — Apply the PR changes:
Checked out the PR commit.

Step 3 — Re-run with the fix in place:
Ran the same real SubprocessTerminal execution with a different fake token.

Observed:

[pr-terminal] exit_code=0
[pr-terminal] returned_observation_contains_fake_token=True
[pr-terminal] captured_debug_logs_contain_fake_token=True
Received terminal action (is_input=False, command_length=48)
Initial terminal output (content_length=269)
Sending command (command_length=48)
Wrote to subprocess PTY: b"printf '<FAKE_TOKEN>
'
"
Read from subprocess PTY: ... printf '<FAKE_TOKEN> ... <FAKE_TOKEN> ...
Terminal content read (content_length=642)

This shows the TerminalSession log lines were redacted to lengths, but the same real execution still emits raw command/output through the lower-level subprocess terminal logs.

Issues Found

  • 🟠 Issue: Real SubprocessTerminal execution still logs command and terminal output contents at DEBUG level, so the terminal-runtime portion of the secret-log fix is incomplete.

This review was created by an AI agent (OpenHands) on behalf of the user.

@aivong-openhands

Copy link
Copy Markdown
Contributor

Mutation-testing the new suite

I ran mutation testing against the five test files this PR touches to see which of the scrubbed log sites are actually pinned down. Baseline: 64 passed.

The test pattern here is the right one — plant a known secret, exercise the code, then assert both that the log line still exists and that the secret doesn't appear in caplog.text. It works: every control mutant that re-introduces a leak on a covered path dies.

Control mutant (re-introduces a leak) Result
_logger.debug(f"Executing remote command: {command}") ❌ caught
logger.debug(f"Wrote to subprocess PTY: {data!r}") ❌ caught
Log terminal_content in the no-change-timeout warning ❌ caught
Log command.command in the bash timeout warning ❌ caught
Log terminal_content in _handle_completed_command ❌ caught
Stop skipping redundant auth frames in bash_events_socket ❌ caught

Four mutants survive with a fully green suite. Three of them share a shape: every covered log site is on a success or timeout path, and none of the exception handlers are exercised.

Surviving mutant Result
Restore f"Error executing bash command '{command.command}': {e}" ✅ 64 passed
Restore f"Remote command execution failed: {e}" ✅ 64 passed
Restore f"Failed to kill process for command: {command.command}" ✅ 64 passed
Drop the "command"/"role" narrowing in _is_auth_control_message ✅ 64 passed

1. The exception handlers are the least-tested and most leak-prone sites

bash_service._start_bash_command's except Exception and remote_workspace_mixin._execute_command_generator's except Exception can both go back to interpolating the full command with the suite green. Error paths are exactly where this class of bug originates — a handler reaches for every variable in scope when something goes wrong — so they're worth the same treatment the happy paths got.

test_execute_command_generator_exception_handling already exists and already forces the exception; it needs three lines:

def test_execute_command_generator_exception_handling(caplog):
    secret = "ghp_" + "e" * 36
    caplog.set_level(logging.DEBUG)
    # ... existing setup, with the command carrying the secret ...
    generator = mixin._execute_command_generator(
        f"curl -H 'Authorization: Bearer {secret}' example.test", None, 30.0
    )
    # ... existing assertions ...
    assert "Remote command execution failed" in caplog.text
    assert secret not in caplog.text

For bash_service, patching _pub_sub (or create_subprocess_exec) to raise once gets you into the handler with a secret-bearing command already in scope.

The SIGKILL-failed branch ("Failed to kill process") is the lowest-value of the three — reaching it means a process survived SIGKILL and two 1s waits — so covering it may not be worth the mock. Worth knowing it's uncovered rather than assuming it isn't.

2. The one behaviour change in the PR is untested

Narrowing _is_auth_control_message with and "command" not in data and "role" not in data is the only non-logging change here, and it can be deleted with a green suite. test_bash_socket_ignores_redundant_auth_before_command doesn't reach it: its second frame is {"command": "printf queued-command"} with no type, so data.get("type") == "auth" is already False and the new clauses never decide anything.

What the narrowing actually prevents is a bash payload that carries type: "auth" being silently swallowed by continue instead of executed. This test covers it — I confirmed it passes on this branch and fails with the narrowing removed:

@pytest.mark.asyncio
async def test_bash_socket_runs_command_payload_that_declares_auth_type():
    """A bash payload carrying type="auth" must still execute, not be skipped."""
    ws = _make_mock_websocket(headers={})
    ws.receive_json.side_effect = [
        {"type": "auth", "command": "printf hi"},
        WebSocketDisconnect(),
    ]
    mock_bash_service = MagicMock(spec=BashEventService)
    mock_bash_service.subscribe_to_events = AsyncMock(return_value=uuid4())
    mock_bash_service.unsubscribe_from_events = AsyncMock(return_value=True)
    mock_bash_service.start_bash_command = AsyncMock()

    with (
        patch("openhands.agent_server.sockets.bash_event_service", mock_bash_service),
        patch("openhands.agent_server.sockets.get_default_config") as mock_config,
    ):
        mock_config.return_value.session_api_keys = []
        await bash_events_socket(
            ws, session_api_key=None, resend_mode=None, resend_all=False
        )

    mock_bash_service.start_bash_command.assert_awaited_once()
    assert mock_bash_service.start_bash_command.await_args.args[0].command == "printf hi"

A matching negative — {"type": "auth", "role": "user"} on the events socket — would pin the other half.


Not a test gap: the strongest fix in this PR isn't a test

Dropping the command parameter from _signal_process_group entirely is the best change here. The value isn't in scope, so no future edit can leak it and no test is needed to defend it. That's worth applying more widely than it was: _execute_command_generator and _start_bash_command both still hold the full command in scope at their error-log sites, which is why those two mutants were easy to write.

On the lint angle — ruff's G004 (f-string in logging call) would flag re-introduction mechanically, but it's a blunt instrument here: select is currently ["E","F","I","UP","ARG"], and turning on G004 reports 30 violations in these five files alone and 672 across openhands-sdk + openhands-tools + openhands-agent-server. Most are harmless (f"Using shell: {resolved_shell_path}"). So I wouldn't propose it repo-wide off the back of this PR — but a per-file # ruff: noqa-inverse (enabling G004 for just the modules that handle command text) would lock in the win for ~30 mechanical fixes.

One last thing worth checking before merge: subprocess_terminal.py still has logger.error(f"Failed to write to PTY: {e}", exc_info=True) at line 255 and logger.debug(f"Error reading PTY output: {e}") at 288, both on the data path this PR was scrubbing. They log the exception rather than the buffer, so they're probably fine — but they're the two sites nearest the ones you fixed, and neither is covered.

This comment was generated by an AI assistant on behalf of the user.

@simonrosenberg
simonrosenberg marked this pull request as draft July 28, 2026 09:50
Co-authored-by: openhands <openhands@all-hands.dev>
@simonrosenberg

Copy link
Copy Markdown
Member Author

Addressed the review feedback in 844e73c5e:

  • Tightened redundant auth-frame detection to an exact protocol-field allowlist.
  • Added regression coverage for auth-looking application payloads.
  • Added exception-path tests proving secret-bearing bash commands and remote execution errors do not enter logs.

BashOutput persistence is unchanged because it is functional event state, distinct from centralized logging. The focused tests and all 32 hosted code checks pass.

@simonrosenberg
simonrosenberg marked this pull request as ready for review July 28, 2026 10:15

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

✅ QA Report: PASS

Runtime logging behavior was verified before/after with real terminal, agent-server HTTP, and RemoteWorkspace execution paths; the PR stops leaking token-shaped command/output contents to logs while preserving command execution.

Does this PR achieve its stated goal?

Yes. The stated goal was to stop logging runtime command contents without breaking command execution, timeout signaling, or returned results. On origin/main, the same real operations leaked fake token-shaped values into terminal, server timeout, and remote workspace logs; on PR commit 5f577c9, those operations still returned/produced the expected user output and timeout side effect, but the logs only included metadata such as command IDs, lengths, and markers.

Phase Result
Environment Setup ✅ uv run python -V created the project environment and installed editable packages successfully.
CI Status 🟡 Most checks are successful; Docker image builds and coverage were still in progress when checked; qa-changes is skipped.
Functional Verification ✅ Real runtime paths verified: terminal subprocess, agent-server bash HTTP timeout, and SDK RemoteWorkspace command execution.
Functional Verification

Test 1: Terminal subprocess logs no longer include command/output contents

Step 1 — Reproduce baseline without the fix:
Checked out origin/main (395b94b0) and ran a real subprocess terminal command through TerminalSession:

observation_contains_secret=True
log_contains_secret=True
wrote_marker=True
read_marker=True
observation_exit_code=0

This confirms the old behavior leaked the fake token-shaped command/output value to debug logs while the terminal command itself succeeded.

Step 2 — Apply the PR's changes:
Checked out fix-sensitive-runtime-logs at 5f577c9af074b0b5fcbbd70f4a2ae0cdc1fbbb56.

Step 3 — Re-run with the fix in place:
Ran the same terminal execution path:

observation_contains_secret=True
log_contains_secret=False
wrote_marker=True
read_marker=True
observation_exit_code=0

This shows user-visible command behavior is preserved, but terminal debug logs no longer contain the fake secret.

Test 2: Agent-server bash timeout logs no longer include command contents

Step 1 — Reproduce baseline without the fix:
Started agent-server from origin/main, made a real HTTP request to /api/bash/start_bash_command with a timeout command that installs a SIGTERM trap, and waited for timeout handling:

200
marker_exists=true
server_log_contains_bash_secret=true
Command timed out after 1 seconds: LEAK_TEST=ghp_BASEBASH...; trap 'touch /tmp/qa_marker_BASE; exit 0' TERM; sleep 30

This confirms the timeout path worked, the cleanup trap ran, and the old server warning log included raw command contents.

Step 2 — Apply the PR's changes:
Checked out the PR branch and started agent-server on a fresh port.

Step 3 — Re-run with the fix in place:
Sent the same HTTP timeout scenario:

200
marker_exists=true
server_log_contains_bash_secret=false
Command timed out after 1 seconds (command_id=f6e72669-8884-45ca-ac5b-1a4c084857cf)

This confirms timeout signaling and SIGTERM cleanup still work, while the timeout log now uses the command ID instead of raw command contents.

Test 3: RemoteWorkspace command logs no longer include command contents

Step 1 — Reproduce baseline without the fix:
With the base agent-server running, executed a real SDK RemoteWorkspace.execute_command(...) call against the server:

stdout_contains_secret=True
stderr_contains_timeout=False
exit_code=0
log_contains_secret=True
log_has_remote_marker=True

This confirms the old RemoteWorkspace client log included the fake token-shaped command content even though the remote command succeeded.

Step 2 — Apply the PR's changes:
Checked out the PR branch and ran the same SDK client against a fresh local server.

Step 3 — Re-run with the fix in place:
Executed the same RemoteWorkspace call:

stdout_contains_secret=True
stderr_contains_timeout=False
exit_code=0
log_contains_secret=False
log_has_remote_marker=True

This shows returned command output is preserved for the caller, but the RemoteWorkspace log no longer leaks the command contents.

Issues Found

None.

This review was created by an AI agent (OpenHands) on behalf of the user.

@VascoSch92
VascoSch92 requested a review from all-hands-bot July 28, 2026 11:06

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

✅ QA Report: PASS

Runtime QA confirms the PR preserves command execution results while stopping sensitive command/terminal content from appearing in the affected debug/warning logs.

Does this PR achieve its stated goal?

Yes. The PR set out to stop logging runtime command contents that may contain credentials; I reproduced the pre-fix leak on the baseline commit, then reran the same real runtime paths on the PR. The bash timeout path still returns 200 OK and times out, RemoteWorkspace and terminal commands still return the secret in user-facing command results, but the captured runtime logs no longer contain the secret-shaped values or raw command text.

Phase Result
Environment Setup ✅ uv sync --dev completed successfully; branch restored to fix-sensitive-runtime-logs with a clean worktree.
CI Status ⏳ 39 checks observed: 33 passing, 5 skipped, 1 pending (qa-changes, this workflow).
Functional Verification ✅ Verified bash API timeout logs, RemoteWorkspace logs, terminal subprocess logs, and bash websocket redundant auth handling with real runtime operations.
Functional Verification

Test 1: Bash API timeout logging no longer includes raw command contents

Step 1 — Reproduce baseline leak without the fix:
Checked out baseline commit 395b94b0c3c4994f6c530f1e3bf3196f71fab950, started the agent-server on port 8766, and sent a real timeout command containing a fake token-shaped value to POST /api/bash/start_bash_command.

Observed HTTP/1.1 200 OK; the baseline server log then included the raw command:

Command timed out after 1 seconds: LEAK_TEST=ghp_QABASEBASEBASEBASEBASEBASEBASEBASEBASEBA; trap 'echo cleanup-ran >&2; exit 0' TERM; sleep 20

This confirms the original bug: the timeout warning exposed the full command and fake credential-shaped value.

Step 2 — Apply the PR changes:
Checked out PR head 5f577c9af074b0b5fcbbd70f4a2ae0cdc1fbbb56 and started the agent-server on port 8767.

Step 3 — Re-run with the fix in place:
Sent the same kind of real timeout command to the PR server. Observed HTTP/1.1 200 OK; the PR server log only included metadata:

Command timed out after 1 seconds (command_id=88e66e5c-01ab-4e66-b298-388bf4fd4bb7)

This confirms the timeout path still works, but the runtime warning no longer logs command contents or the fake token.

Test 2: RemoteWorkspace preserves command output but omits command text from client logs

Step 1 — Reproduce baseline leak without the fix:
Against the baseline server on port 8766, I ran a real SDK RemoteWorkspace.execute_command() call with a fake token-shaped value.

Observed:

result_exit_code= 0
result_contains_secret= True
logs_contain_secret= True
DEBUG:openhands.sdk.workspace.remote.remote_workspace_mixin:Executing remote command: printf 'ghp_QAREMOTEBASEBASEBASEBASEBASEBASEBASE\n'

This confirms baseline RemoteWorkspace logging exposed the command text even though the command itself executed correctly.

Step 2 — Apply the PR changes:
Used the PR server on port 8767 and the same RemoteWorkspace API path.

Step 3 — Re-run with the fix in place:
Ran the equivalent command on PR code:

result_exit_code= 0
result_contains_secret= True
logs_contain_secret= False
DEBUG:openhands.sdk.workspace.remote.remote_workspace_mixin:Executing remote command

This shows user-facing command output is preserved, but the DEBUG log no longer includes the secret-bearing command.

Test 3: Subprocess terminal preserves output but omits command/output content from debug logs

Step 1 — Reproduce baseline leak without the fix:
On baseline, I created a real subprocess terminal session and executed printf with a fake token-shaped value. The command result contained the value, and DEBUG logs also contained it:

observation_contains_secret= True
logs_contain_secret= True
DEBUG:openhands.tools.terminal.terminal.terminal_session:SENDING COMMAND: "printf 'ghp_QATERMBASEBASEBASEBASEBASEBASEBASEBASE\n'"
DEBUG:openhands.tools.terminal.terminal.subprocess_terminal:Read from subprocess PTY: '... ghp_QATERMBASEBASEBASEBASEBASEBASEBASEBASE ...'

This confirms the baseline terminal path leaked both command and terminal content through debug logging.

Step 2 — Apply the PR changes:
Checked out PR head and reran the same subprocess terminal workflow.

Step 3 — Re-run with the fix in place:
Observed:

observation_contains_secret= True
logs_contain_secret= False
DEBUG:openhands.tools.terminal.terminal.subprocess_terminal:Wrote to subprocess PTY (byte_count=285)
DEBUG:openhands.tools.terminal.terminal.terminal_session:Sending command (command_length=50)
DEBUG:openhands.tools.terminal.terminal.subprocess_terminal:Read from subprocess PTY (content_length=747)

This confirms the terminal still returns the expected command output to the user, while debug logs now contain only lengths/counts.

Test 4: Bash websocket ignores redundant auth control frame and still executes commands

On PR code, I connected to the real /sockets/bash-events websocket, sent a redundant auth control frame containing a fake sk-oh-... value, then sent a bash command:

saw_command_event= True
saw_output_event= True

Server log grep for the fake auth value, validation errors, and command output showed only the normal request marker:

Received bash request

This confirms the changed websocket path accepts the real command after a redundant auth frame without logging the auth secret.

Issues Found

None.

This QA review was created by an AI agent (OpenHands) on behalf of the user.

Final verdict: PASS

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review verdict: material security finding

The primary timeout, execution-error, RemoteWorkspace, and terminal/subprocess paths are correctly changed to log metadata rather than command/output content, and the added regression coverage exercises those normal paths well. Current GitHub checks are green. I also ran the five changed test modules: 109 tests passed; the remaining 33 failures were all pre-existing tmux-parameterized cases because tmux is unavailable in this review environment.

Important finding

openhands-agent-server/openhands/agent_server/sockets.py:548-558 still logs the complete BashEventBase representation whenever a bash WebSocket event send is skipped or fails:

  • skip_sending_bash_event_socket_disconnected: %r
  • error_sending_bash_event_disconnected: %r (%s)
  • error_sending_bash_event: %r

BashCommand.__repr__ contains the raw command, while BashOutput.__repr__ contains raw stdout/stderr. I reproduced this on the checked-out head by making websocket.send_json() raise RuntimeError: a token-shaped value in BashOutput.stdout appeared verbatim in the DEBUG log. A disconnect/send failure is a realistic production condition, so the stated security goal remains incomplete even though the successful-send path is clean.

Please change these messages to log only safe metadata (for example event kind/id, command_id, order, exit code, and exception type), and add a regression test that injects token-shaped command/output content and forces _send_bash_event() through both the disconnected and unexpected-exception paths. This location is not part of a changed hunk, so I am reporting it in the review body rather than creating an invalid inline thread.

Risk assessment

High security risk until addressed. The leak requires a WebSocket disconnect/send exception, but when triggered it can disclose exactly the command and terminal output this PR intends to keep out of centralized logs. The functional behavior changes also touch terminal execution/stdin/stdout handling, so per repository policy a human maintainer should make the final merge decision after the lightweight eval assessment.

This review was created by an AI agent (OpenHands) on behalf of the repository reviewer.

@enyst enyst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Interesting, it looks like this comment is correct? #4280 (review)

Co-authored-by: openhands <openhands@all-hands.dev>
@simonrosenberg

Copy link
Copy Markdown
Member Author

Fixed the WebSocket send-failure leak in b54af3bbb.

_send_bash_event() now logs only a fixed allowlist of safe metadata (kind, event/command IDs, order, and exit code) plus the exception class name. It no longer logs the event representation, exception message, or exception traceback text on pre-disconnect, expected disconnect-race, or unexpected-exception paths.

Added regression coverage with token-shaped command, stdout/stderr, and exception-message values. All 92 relevant security tests and pre-commit checks pass.

@enyst enyst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👋 I'm an AI agent (Opus 5) reviewing this PR on behalf of Engel Nyst (@enyst).

🟢 Good taste

This removes command, input, output, event-repr, and exception-text leakage at the relevant runtime boundaries while retaining useful identifiers, lengths, timeout values, and exception types for diagnosis. The regression tests use sentinel secrets across bash service, websocket, remote workspace, subprocess terminal, and terminal session paths. I did not find a remaining leak introduced or missed within this PR's changed surfaces.

[RISK ASSESSMENT]

  • [Overall PR] ⚠️ Risk Assessment: 🔴 HIGH
    The patch is mechanically small but directly changes secrets-handling and production diagnostic behavior across several shared runtime layers. A missed sink would expose user commands or output; over-redaction could impair incident diagnosis.

Recommendation: Do not auto-merge. Request review from a human security/runtime maintainer to validate coverage of logging sinks and the diagnostic tradeoff.

VERDICT:
✅ Worth merging: The redaction strategy is consistent and backed by focused regression coverage.

KEY INSIGHT:
Structured metadata such as command IDs, byte counts, and exception types preserves operational value without serializing user-controlled content.

@all-hands-bot

Copy link
Copy Markdown
Collaborator

🤖 OpenHands is reviewing this PR.

Requested reviewer: @all-hands-bot
Review request event: 28649738283 at 2026-07-29T09:18:57Z
Head commit: b54af3bbba3a06afadb4c6ea01e07d0e83c7acc7
View the conversation: https://oss-agent-canvas.ngrok.dev/conversations/abe64b68-05f7-4553-9dd2-bf14a105d68a

This comment was posted by an AI agent (OpenHands).

@all-hands-bot all-hands-bot left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟡 Acceptable, but incomplete security fix

The metadata-only changes for bash execution, RemoteWorkspace, terminal sessions, subprocess PTY I/O, and bash-event delivery are consistent and preserve returned command results. The focused regression tests cover the primary success, timeout, and send-failure paths. I reviewed commit b54af3bbba3a06afadb4c6ea01e07d0e83c7acc7; its CI checks were green apart from the then-running QA job. Locally, 129 focused tests passed; 33 tmux-parameterized failures were environmental because tmux is unavailable.

[IMPORTANT FINDING]

  • openhands-agent-server/openhands/agent_server/sockets.py:468: the bash WebSocket exception handler still calls logger.exception("error_in_bash_event_subscription", stack_info=True). This serializes str(e) into centralized logs. For Pydantic validation failures, that string includes the rejected input value. I reproduced this through bash_events_socket with command={"credential": "token-SECRET123"}; the captured ERROR traceback contained token-SECRET123 verbatim. The same handler also catches exceptions from start_bash_command, whose messages may contain command text. This leaves a realistic authenticated runtime path that defeats the stated security goal. Please log safe metadata only, for example error_type and a command ID when one exists, rather than exception text or traceback on this path. Add a regression test that submits a malformed secret-bearing bash payload and asserts the sentinel is absent from caplog.text.

I am placing this in the review body because line 468 itself is not an added line in the PR diff.

[RISK ASSESSMENT]

  • [Overall PR] ⚠️ Risk Assessment: 🔴 HIGH
    This is a security-focused change across shared runtime command and terminal paths. Most known sinks are addressed, but the confirmed WebSocket validation/error sink can still disclose client-controlled credential material. The terminal execution changes can also plausibly affect evaluation behavior, so a human runtime/security maintainer should make the final merge decision after the lightweight eval assessment.

VERDICT:
❌ Needs follow-up: remove the remaining exception-text sink before merging.

KEY INSIGHT:
Exception tracebacks are payload logs when validation errors embed rejected user input.

Improve this review? If any feedback above seems incorrect or irrelevant to this repository, you can teach the reviewer to do better:

  1. Add or edit .agents/skills/custom-codereview-guide.md with the /codereview trigger and the missing repository context.
  2. Re-request a review so the reviewer reads the updated guidance from the PR branch.
  3. Let the guideline change go through normal maintainer review when merged.

Resolve with AI? Install the iterate skill and run /iterate to drive CI, review, and QA.

Was this review helpful? React with 👍 or 👎.

This review was created by an AI agent (OpenHands) on behalf of the repository reviewer.

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⚠️ QA Report: PASS WITH ISSUES

Runtime verification passed: the PR stops app/runtime debug logs from recording fake credential-bearing command contents while preserving command execution, timeout handling, terminal output, and bash websocket behavior.

Does this PR achieve its stated goal?

Yes. I reproduced the sensitive-log problem on the merge-base baseline (395b94b0) and re-ran the same runtime scenarios on the current PR head (069e30a2): bash timeout execution still returned normally and ran the SIGTERM cleanup trap, terminal execution still returned the fake secret to the caller, and the app/runtime logs no longer contained the fake secret. I also verified the remote workspace command generator no longer logs the full command, and a redundant bash websocket auth frame no longer blocks the following real command.

Phase Result
Environment Setup ✅ Used the repo's uv run environment to start a real local agent-server with DEBUG app logging and run SDK/tool clients.
CI Status ⚠️ Current PR checks show 32 passing, 1 failing (sdk-tests), and 5 skipped; I did not rerun tests per QA instructions.
Functional Verification ✅ Sensitive runtime log paths exercised before/after with fake token-shaped inputs; changed behavior works.
Functional Verification

Test 1: agent-server bash timeout log no longer includes command contents

Step 1 — Reproduce baseline without the fix:
Checked out 395b94b0, started a real local agent-server, and sent POST /api/bash/start_bash_command with a command shaped like:

LEAK_TEST=<FAKE_SECRET>; trap 'touch /tmp/qa_cleanup_BASE2; exit 0' TERM; sleep 30

Baseline summary:

{
  "http_status": 200,
  "http_kind": "BashCommand",
  "server_timeout_logged": true,
  "server_cleanup_marker_exists": true,
  "server_secret_in_logs": true,
  "server_log_excerpt": [
    "Command timed out after 1 seconds: LEAK_TEST=<FAKE_SECRET>; trap 'touch /tmp/qa_cleanup_BASE2; exit 0' TERM; sleep 30"
  ]
}

This confirms the original bug: the server logged the full timed-out command, including credential-shaped content, while still running the cleanup trap.

Step 2 — Apply the PR's changes:
Checked out current PR head 069e30a2 and reran the same scenario.

Step 3 — Re-run with the fix in place:
PR-head summary:

{
  "http_status": 200,
  "http_kind": "BashCommand",
  "server_timeout_logged": true,
  "server_cleanup_marker_exists": true,
  "server_secret_in_logs": false,
  "server_log_excerpt": [
    "Command timed out after 1 seconds (command_id=a9c54ee0-13ec-4d27-b6fe-47997b55d15d)"
  ]
}

This shows the timeout path still behaves correctly, but the log now contains metadata instead of the sensitive command.

Test 2: terminal debug logs no longer include typed commands or terminal output

Step 1 — Reproduce baseline without the fix:
On 395b94b0, created a real TerminalSession using the subprocess terminal and executed:

printf '<FAKE_SECRET>\n'

Baseline summary:

{
  "terminal_observation_has_secret": true,
  "terminal_secret_in_logs": true,
  "terminal_log_excerpt": [
    "SENDING COMMAND: \"printf '<FAKE_SECRET>\\n'\"",
    "Wrote to subprocess PTY: b\"printf '<FAKE_SECRET>\\n'\\n\"",
    "Read from subprocess PTY: ... <FAKE_SECRET> ..."
  ]
}

This confirms the old runtime logs captured both the command and terminal output.

Step 2 — Apply the PR's changes:
Checked out 069e30a2 and reran the same terminal operation.

Step 3 — Re-run with the fix in place:
PR-head summary:

{
  "terminal_observation_has_secret": true,
  "terminal_secret_in_logs": false,
  "terminal_log_excerpt": [
    "Received terminal action (is_input=False, command_length=51)",
    "Sending command (command_length=51)",
    "Wrote to subprocess PTY (byte_count=52)",
    "Read from subprocess PTY (content_length=749)"
  ]
}

This confirms user-visible terminal behavior is preserved while logs now expose only lengths/counts.

Test 3: remote workspace command generator no longer logs full commands

Step 1 — Reproduce baseline without the fix:
On 395b94b0, invoked RemoteWorkspace._execute_command_generator(...) with:

curl -H 'Authorization: Bearer <FAKE_SECRET>' https://example.invalid

Baseline log probe:

{'secret_in_log': True, 'excerpt': "DEBUG:openhands.sdk.workspace.remote.remote_workspace_mixin:Executing remote command: curl -H 'Authorization: Bearer <FAKE_SECRET>' https://example.invalid\n"}

This confirms the remote command path logged credential-bearing command text at DEBUG.

Step 2 — Apply the PR's changes:
Checked out 069e30a2 and reran the same generator probe.

Step 3 — Re-run with the fix in place:
PR-head log probe:

{'secret_in_log': False, 'excerpt': 'DEBUG:openhands.sdk.workspace.remote.remote_workspace_mixin:Executing remote command\n'}

This confirms the changed remote path no longer logs the command contents.

Test 4: redundant bash websocket auth frame no longer blocks a real command

Step 1 — Reproduce baseline without the fix:
On 395b94b0, connected to /sockets/bash-events, sent a redundant auth control frame, then sent a real bash command (printf ws-ok).

Baseline websocket summary:

{
  "event_count": 1,
  "saw_error": true,
  "saw_ws_ok": false,
  "excerpt": "BashError ... Field required ... input_value={'type': 'auth', ...}"
}

This shows the auth frame was treated as a bash request and prevented the real command from being accepted.

Step 2 — Apply the PR's changes:
Checked out 069e30a2 and repeated the websocket interaction.

Step 3 — Re-run with the fix in place:
PR-head websocket summary:

{
  "event_count": 1,
  "saw_error": false,
  "saw_ws_ok": true,
  "secret_in_ws_payloads": false,
  "excerpt": "{\"command\":\"printf ws-ok\", ... ,\"kind\":\"BashCommand\"}"
}

This confirms the changed websocket loop ignores the redundant auth frame and processes the next command.

Issues Found

  • 🟠 CI: Current GitHub checks show sdk-tests failing. I did not rerun or diagnose tests, but the PR is not fully green at the time of this QA review.
  • No functional issues found in the runtime scenarios I exercised.

Final verdict: PASS WITH ISSUES.

This review was created by an AI agent (OpenHands) on behalf of the user.

Co-authored-by: openhands <openhands@all-hands.dev>
@all-hands-bot

Copy link
Copy Markdown
Collaborator

🤖 OpenHands is reviewing this PR.

Requested reviewer: @all-hands-bot
Review request event: 28653327900 at 2026-07-29T10:28:13Z
Head commit: 712692cd616cba88f0124c55b2162ed808f0bca8
View the conversation: https://oss-agent-canvas.ngrok.dev/conversations/f5c616bf-cb58-4b11-aa90-5ca2db655074

This comment was posted by an AI agent (OpenHands).

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⚠️ QA Report: PASS WITH ISSUES

The changed runtime paths were exercised before/after with fake credential-bearing commands; the PR preserves command execution/results while removing those values from captured logs, but two CI checks are currently failing.

Does this PR achieve its stated goal?

Yes. I reproduced the original behavior on origin/main: live bash API timeout logs, RemoteWorkspace client logs, and subprocess terminal debug logs all exposed fake token-shaped command/output content. Re-running the same real user flows on fix-sensitive-runtime-logs showed the commands still executed and returned their output to the caller, while captured logs contained only command IDs/lengths/type metadata and LOG_SECRET_HITS=0.

Phase Result
Environment Setup ✅ make build completed successfully; no tests/linters/pre-commit hooks were run.
CI Status ⚠️ sdk-tests and windows-tests are failing; QA Changes by OpenHands is pending; most other checks pass.
Functional Verification ✅ Live bash API, SDK RemoteWorkspace, and subprocess terminal paths verified before/after.
Functional Verification

Test 1: Live bash API timeout logging

Step 1 — Reproduce / establish baseline (without the fix):
Checked out origin/main, started the real agent server with uv run python -m openhands.agent_server --host 127.0.0.1 --port 18765, then posted a real bash command with a fake credential-shaped value and a 1-second timeout:

curl -H 'Content-Type: application/json' \
  --data '{"command":"LEAK_TEST=<fake-ghp-token>; trap ... TERM; sleep 30","timeout":1}' \
  http://127.0.0.1:18765/api/bash/start_bash_command

Observed:

BRANCH=main
HTTP_CODE=200
MARKER=present
TIMEOUT_LOG_LINES=1
SECRET_LOG_HITS=1
RESPONSE={"command":"LEAK_TEST=<fake-ghp-token>; trap ... TERM; sleep 30", ...}
LOG: Command timed out after 1 seconds: LEAK_TEST=<fake-ghp-token>; trap ... TERM; sleep 30

This confirms the bug exists on main: the server executed the command and ran the SIGTERM cleanup trap, but the timeout warning logged the full command contents.

Step 2 — Apply the PR's changes:
Checked out fix-sensitive-runtime-logs at 712692cd616cba88f0124c55b2162ed808f0bca8.

Step 3 — Re-run with the fix in place:
Started the real agent server on port 18766 and posted the same kind of timeout command.

Observed:

BRANCH=pr
HTTP_CODE=200
MARKER=present
TIMEOUT_LOG_LINES=1
SECRET_LOG_HITS=0
RESPONSE={"command":"LEAK_TEST=<fake-ghp-token>; trap ... TERM; sleep 30", ...}
LOG: Command timed out after 1 seconds (command_id=f8d5c7e3-d4c5-43d3-9801-ede993e8dfec)

This shows the timeout behavior and returned command payload are preserved for the client, while the server log no longer includes the fake credential-bearing command.

Test 2: SDK RemoteWorkspace client logging against a live server

Step 1 — Reproduce / establish baseline (without the fix):
On origin/main, started a real agent server on port 18767 and used the public SDK client:

workspace = RemoteWorkspace(working_dir=os.getcwd(), host="http://127.0.0.1:18767")
result = workspace.execute_command("printf '<fake-ghp-token>\n'", timeout=10.0)

Observed:

BRANCH=main
RESULT_EXIT=0
STDOUT_HAS_SECRET=True
LOG_SECRET_HITS=1
LOG: Executing remote command: printf <fake-ghp-token>

This confirms the client returned the command output correctly, but also leaked the command contents at debug level.

Step 2 — Apply the PR's changes:
Checked out fix-sensitive-runtime-logs at 712692cd616cba88f0124c55b2162ed808f0bca8.

Step 3 — Re-run with the fix in place:
Started a real agent server on port 18768 and ran the same SDK RemoteWorkspace.execute_command(...) flow.

Observed:

BRANCH=pr
RESULT_EXIT=0
STDOUT_HAS_SECRET=True
LOG_SECRET_HITS=0
LOG: Executing remote command

This shows normal RemoteWorkspace command execution still works and returns stdout to the caller, but the debug log no longer contains the command/token value.

Test 3: Subprocess terminal command/output logging

Step 1 — Reproduce / establish baseline (without the fix):
On origin/main, used the public terminal API as a real caller would:

session = create_terminal_session(work_dir=os.getcwd(), terminal_type="subprocess")
session.initialize()
observation = session.execute(TerminalAction(command="printf '<fake-ghp-token>\n'"))
session.close()

Observed:

BRANCH=main
OBS_EXIT=0
OBS_HAS_SECRET=True
LOG_SECRET_HITS=11
LOG: RECEIVED ACTION: command='printf <fake-ghp-token>\\n' ...
LOG: SENDING COMMAND: 'printf <fake-ghp-token>'
LOG: Wrote to subprocess PTY: b'printf <fake-ghp-token>\\n'
LOG: COMBINED OUTPUT: printf <fake-ghp-token> ...

This confirms the old terminal path returned the command output but also logged command/output content in several debug messages.

Step 2 — Apply the PR's changes:
Checked out fix-sensitive-runtime-logs at 712692cd616cba88f0124c55b2162ed808f0bca8.

Step 3 — Re-run with the fix in place:
Ran the same subprocess terminal scenario.

Observed:

BRANCH=pr
OBS_EXIT=0
OBS_HAS_SECRET=True
LOG_SECRET_HITS=0
LOG: Read from subprocess PTY (content_length=328)
LOG: Read from subprocess PTY (content_length=748)

This shows the user-facing observation still contains the command output, while debug logs avoid the sensitive command/output content.

Issues Found

  • 🟠 Issue: CI is not fully green: sdk-tests and windows-tests are currently failing, and the QA check was still pending when reviewed. I did not rerun tests per QA instructions.

This review was created by an AI agent (OpenHands) on behalf of the user.

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🟢 Good taste — no material code findings

The change consistently replaces command, terminal-content, event-representation, and exception-text logging with bounded metadata while preserving command results and WebSocket error responses. The previously confirmed bash WebSocket validation-error leak is fixed at head 712692cd616cba88f0124c55b2162ed808f0bca8, and the new tests cover malformed payloads plus error-send failures without allowing token-shaped values into captured logs.

I also reviewed the PR discussion, existing reviews, all 11 changed files, and the surrounding runtime paths. The focused local run exercised 164 tests: 131 passed, including every changed security regression; the 33 failures were only the existing tmux parametrizations because tmux is unavailable in this environment. GitHub currently reports agent-server-tests, tools-tests, workspace-tests, cross-tests, stress tests, binary builds, and QA as successful. sdk-tests and windows-tests remain failed, so maintainers should require those checks to be green or explicitly classify them as unrelated before merging.

Because this touches terminal/stdin/stdout handling, repository policy requires a COMMENT rather than an approval without benchmark evidence. A human runtime maintainer should make the final merge decision after the lightweight eval assessment.

[RISK ASSESSMENT]

  • [Overall PR] ⚠️ Risk Assessment: 🟡 MEDIUM

This is a security-sensitive change across shared command execution and terminal paths. The implementation is narrowly scoped, preserves returned data, and has strong leak-regression coverage; residual risk comes from the breadth of runtime logging paths, the terminal-behavior eval category, and two currently failing CI jobs.

VERDICT:
✅ Worth merging once CI/eval validation is accepted by a human maintainer.

KEY INSIGHT:
Logging exception classes and stable identifiers retains operational diagnostics without turning validation errors or runtime events into secret-bearing payload logs.

This review was created by an AI agent (OpenHands) on behalf of the repository reviewer.

@simonrosenberg
simonrosenberg requested a review from enyst July 29, 2026 10:55
@simonrosenberg

Copy link
Copy Markdown
Member Author

@VascoSch92 can you kindly re-review? :) CI erros are unrelated

@VascoSch92

Copy link
Copy Markdown
Member

@simonrosenberg For me is good. But why the tests are not passing?

@simonrosenberg

Copy link
Copy Markdown
Member Author

@simonrosenberg For me is good. But why the tests are not passing?

unrelated CI issue I fixed independently :)

@simonrosenberg
simonrosenberg enabled auto-merge (squash) July 29, 2026 13:36
@simonrosenberg

Copy link
Copy Markdown
Member Author

@VascoSch92 thanks for the review!

@simonrosenberg
simonrosenberg merged commit 6387406 into main Jul 29, 2026
30 checks passed
@simonrosenberg
simonrosenberg deleted the fix-sensitive-runtime-logs branch July 29, 2026 13:44
neubig added a commit that referenced this pull request Aug 13, 2026
…ershell spawns

Use psutil.Process.wait/pid_exists for the child liveness wait rather than
spawning a fresh powershell.exe on every poll, which itself could exhaust the
old 20s watchdog on a slow hosted runner (second failure mode observed in PR
#4280). Raise the pytest timeout to 45s to cover the bounded slow path plus
finally cleanup. Note in the docstring that the assertion covers only the
directly spawned child, not the whole process tree.

Co-authored-by: openhands <openhands@all-hands.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants