fix: harden gateway slash command security#127
Merged
tjb-tech merged 2 commits intoHKUDS:mainfrom Apr 13, 2026
Merged
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.
Summary
This PR hardens the gateway/slash-command path against two verified security issues:
/memory showcould read files outside the project memory directory via path traversalSecurity issues covered
/memory showBefore this PR
/memory showaccepted attacker-controlled path input and could resolve reads outside the project memory directoryAfter this PR
/memory showresolves targets safely and enforces containment under the project memory directory before readingWhy this matters
These issues sit on trust boundaries that are reachable from remote chat/gateway usage:
In practice, one issue weakens a meaningful safety control and the other exposes arbitrary file-read behavior from the host running OpenHarness.
Attack flow
Affected code
ohmo/gateway/runtime.py,ohmo/gateway/models.py,ohmo/gateway/service.py,ohmo/cli.py,src/openharness/commands/registry.py/memory showsrc/openharness/commands/registry.py,src/openharness/memory/paths.pyRoot cause
Issue 1: remote slash-command permission-mode escalation
Issue 2: arbitrary file read via
/memory show/memory showjoined attacker-controlled input onto the memory directory pathCVSS assessment
AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H/memory showAV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:NRationale:
Safe reproduction steps
1. Remote slash-command permission-mode escalation
/permissions full_auto2. Arbitrary file read via
/memory show/memory show ../../../../../../etc/hostsExpected vulnerable behavior
/memory showshould not read files outside the project memory directoryChanges in this PR
remote_admin_opt_intoSlashCommand/permissionsand/planremote-denied by default while marking them eligible for explicit remote opt-inallow_remote_admin_commandsandallowed_remote_admin_commandsto gateway config/memory showtargets safely and enforce containment under the project memory directoryFiles changed
ohmo/gateway/runtime.pyohmo/gateway/models.py,ohmo/workspace.pyohmo/gateway/service.pyohmo/cli.pysrc/openharness/commands/registry.pyremote_admin_opt_in, marks sensitive commands as explicitly opt-in only, and hardens/memory showtests/test_commands/test_registry.py,tests/test_ohmo/test_gateway.pyMaintainer impact
Suggested fix rationale
Reference patterns from other software
These are not identical products, but they reflect the same secure-default pattern: privileged actions stay off by default for untrusted remote inputs, and trusted exceptions require explicit configuration.
Type of change
Test plan
tests/test_commands/test_registry.py::test_permissions_command_persiststests/test_commands/test_registry.py::test_permissions_command_is_marked_local_onlytests/test_commands/test_registry.py::test_permissions_command_supports_explicit_remote_admin_opt_intests/test_commands/test_registry.py::test_memory_show_rejects_path_traversaltests/test_commands/test_registry.py::test_memory_show_reads_normal_entries_with_md_fallbacktests/test_ohmo/test_gateway.py::test_runtime_pool_stream_message_emits_progress_and_tool_hinttests/test_ohmo/test_gateway.py::test_runtime_pool_blocks_local_only_commands_from_remote_messagestests/test_ohmo/test_gateway.py::test_runtime_pool_allows_opted_in_remote_admin_commandsuv run ruff check src tests ohmoExecuted with:
PYTHONPATH=src:. .venv/bin/python -m pytest tests/test_commands/test_registry.py::test_permissions_command_persists tests/test_commands/test_registry.py::test_permissions_command_is_marked_local_only tests/test_commands/test_registry.py::test_permissions_command_supports_explicit_remote_admin_opt_in tests/test_commands/test_registry.py::test_memory_show_rejects_path_traversal tests/test_commands/test_registry.py::test_memory_show_reads_normal_entries_with_md_fallback tests/test_ohmo/test_gateway.py::test_runtime_pool_stream_message_emits_progress_and_tool_hint tests/test_ohmo/test_gateway.py::test_runtime_pool_blocks_local_only_commands_from_remote_messages tests/test_ohmo/test_gateway.py::test_runtime_pool_allows_opted_in_remote_admin_commands -quv run ruff check src tests ohmoDisclosure notes