Repository navigation
fix(network): ask before trusting an SFTP host key (#223) - #281
Merged
Merged
Conversation
The SFTP trust prompt has to show the server's key type next to its SHA-256 fingerprint so the user can compare both with `ssh-keygen -lf` on the server. The confirmation error now reads `HOST_KEY_CONFIRM:<fp> type=<algorithm> needs confirmation: <fp>`, with the algorithm from `PublicKey::algorithm()` (ssh-key 0.7.0-rc.11). The fingerprint stays the first token, so `probe_server_fingerprint` keeps parsing it unchanged. Refs #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DKhrqRd1enKzdZs6PNpWco
Test connection retried with whatever fingerprint the server presented, and Save pinned the key from `nativeSftpProbeHostKey` without asking, so a man-in-the-middle on the first connection became the trusted key. Both paths now stop on HOST_KEY_CONFIRM and show a confirmation with the fingerprint and key type; the key is pinned only after "Trust and connect", and Cancel stores nothing. Browsing a saved server that has no pinned key asks the same way. HOST_KEY_CHANGED shows a translated "identity changed" message and logs the expected/presented fingerprints only. Editing a saved SFTP server can forget its pinned key, so the next connection asks again. The HOST_KEY_* parsing lives in the pure-Kotlin SftpHostKeyStatus, covered on the JVM with strings captured from the sftp-test container. Closes #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DKhrqRd1enKzdZs6PNpWco
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.
Description
The first SFTP connection trusted the server's host key without asking: Test connection retried with whatever fingerprint the server presented, and Save pinned the key returned by
nativeSftpProbeHostKey. A man-in-the-middle on that first connection became the trusted key.NetworkSftpScreen.kt): Test connection, Save, and browsing a saved server with no pinned key now stop onHOST_KEY_CONFIRMand open a confirmation modal (reusingConfirmDeleteModal, which gained anonCancelcallback) with the SHA-256 fingerprint and the key type. The key is pinned only after Trust and connect; Cancel stores nothing. The screen no longer callsnativeSftpProbeHostKey(the debug broadcast inVRActivitystill does).HOST_KEY_CHANGEDshows a translated "server identity changed" message; the expected and presented fingerprints go to the log only.SftpCredentialStore.setHostKeyFingerprint), so the next connection asks again.rust/protocols/src/sftp/): the confirmation now readsHOST_KEY_CONFIRM:<fp> type=<algorithm> needs confirmation: <fp>, the algorithm coming fromPublicKey::algorithm()(ssh-key 0.7.0-rc.11). The fingerprint stays the first token, soprobe_server_fingerprintparses it unchanged.SftpHostKeyStatus.kt): theHOST_KEY_*parsing lives in a pure-Kotlin class covered on the JVM with the exact strings captured from thesftp-testcontainer.values,values-pt-rBR, andvalues-es, in mirrored order with positional placeholders.Behavior kept on purpose: if the server is unreachable on Save, the server is saved without a pinned key (as before), and the trust prompt appears on the first browse.
Design note: Figma 04c shows the confirmation as an inline card in the form; this PR uses the modal in both the form and the browser, so the browse path can ask too.
Closes #223
Type of change
Affected layers
app/) — app shell, UI panels, credentials, history, i18nnative/) — OpenXR session, Vulkan/GLES render loop, controller inputrust/) — demux, decode, audio, network protocolsHow has this been tested?
cargo test)Ran locally:
./gradlew ktlintCheck testDebugUnitTest -PrustBuildMode=skip: 582 tests, 0 failures (SftpHostKeyStatusTest6/6,I18nParityTest,UiSourceGuardsTest)../gradlew :app:lintDebug -PrustBuildMode=skip: passed.cargo fmt --all --check,cargo clippy -p protocols -p media-logic --all-targets --all-features -- -D warnings,cargo test -p protocols -p media-logic: passed.sftp-testcontainer (docker/network-tests/): the SFTP TOFU integration tests (tofu_first_connection_without_fingerprint_returns_needs_confirmation,different_fingerprint_fails_with_identity_changed) pass; a first connection returnsHOST_KEY_CONFIRM:<fp> type=ssh-ed25519 …, a connection with the pinned key lists the directory, and after recreating the container the same pin returnsHOST_KEY_CHANGED.Not verified:
./scripts/test-network-protocols.sh.Checklist:
clippy -D warnings).If applicable
SCREEN_MODEinrust/bridge/src/lib.rs,enum class ScreenModeinnative/include/screen_mode.h, the catalog inScreenFormatCatalog.kt, andFormat3D::to_screen_mode_indexinrust/media-logic/src/format3d.rs.values/strings.xmland allvalues-*/strings.xml), keeping the key order mirrored and using positional placeholders (%1$s).media-logic(host-testable) rather than incore, where it could not be tested.Screenshots / Videos (if applicable)
None: the UI has not been run on a device yet.
Follow-ups
🤖 Generated with Claude Code
https://claude.ai/code/session_01DKhrqRd1enKzdZs6PNpWco