Repository navigation
Backlog
Backlog
Copy link
Description
Goal
A server can no longer open channels towards the client that the client never asked for. The client never requests X11, agent or port forwarding, so every server-initiated channel open is refused, and a server cannot make the app hold an unbounded number of such channels.
Context
crates/ssh-transport/src/handler.rs:92-225:ClientHandlerimplements onlydisconnected,auth_banner,kex_doneandcheck_server_key. Allserver_channel_open_*callbacks use the russh defaults.- The vendored russh (
vendor/russh, 0.63.2) accepts these by default withreply.accept()(vendor/russh/src/client/mod.rs):server_channel_open_forwarded_tcpip(2472),server_channel_open_forwarded_streamlocal(2494),server_channel_open_agent_forward(2513),server_channel_open_session(2561),server_channel_open_direct_tcpip(2580),server_channel_open_direct_streamlocal(2602),server_channel_open_x11(2621). Only unknown channel types are rejected (should_accept_unknown_server_channelreturnsfalse, mod.rs:2530). - An accepted channel gets an entry in the session's channel maps and its own message buffer; the default handler drops the
Channelhandle without closing it. There is no limit on the number. - Nothing in
crates/orapps/requests forwarding (request_x11,agent_forward,tcpip_forward,streamlocal_forwardare never called). The client only opensdirect-tcpipitself for jump hosts (crates/ssh-transport/src/connect.rs:541), which is a client-initiated open and not affected. - Spec 0005 does not mention server-initiated channels.
Requirements
ClientHandleroverrides all sevenserver_channel_open_*callbacks listed above and refuses each open withChannelOpenFailure::AdministrativelyProhibited(reply.reject(...), or droppingreply, which sends the same failure —vendor/russh/src/lib_inner.rs:587-602).should_accept_unknown_server_channelkeeps returningfalse.- A refused open is logged at debug level with the channel type only (no addresses or data from the server at info level).
- The refusal does not close or disturb the session: shell, exec, SFTP and jump-host connections keep working.
- No change to the vendored russh sources.
- Spec 0005 states in its security section (§9) that the client requests no forwarding and refuses every channel the server opens on its own.
Acceptance Criteria
- Against the in-process test server (
crates/ssh-transport/tests/fixtures/test_server.rs), a server that opens an X11 channel, an agent-forward channel and a forwarded-tcpip channel towards the client after authentication receives an open failure for each (one test per type) - After the refused opens, an exec command on the same connection still succeeds
- A server opening 1000 channels in a row gets 1000 failures, and the same connection still runs an exec command afterwards
- A jump-host connection (client-initiated
direct-tcpip) still works (existing tests stay green) - Spec 0005 §9 describes the rule
- Relevant automated tests pass
Technical Notes
- Security-relevant module: SSH transport. No change to host key verification, authentication, the filter engine or credential handling.
- If the in-process test server cannot open server-initiated channels, extend the fixture; the tests go into a new file
crates/ssh-transport/tests/server_opened_channels.rs. - User-visible only as a security change: add a changelog fragment.
Files: crates/ssh-transport/src/handler.rs, crates/ssh-transport/tests/fixtures/test_server.rs, crates/ssh-transport/tests/ (new server_opened_channels.rs), docs/specs/0005-ssh-module.md, changelog.d/
Spec impact: update 0005
Open questions
- Reject with
reply.reject(AdministrativelyProhibited)explicitly or dropreply. Recommendation: the explicit call, so the intent is visible in the code.
Related Work
- SSH transport: refused or forced shell and exec requests fail fast instead of hanging #1665 (also edits Spec 0005)
Metadata
Metadata
Assignees
Type
Fields
Priority
P2 - Normal
Activity