diff --git a/CHANGELOG.md b/CHANGELOG.md index 89d741c..0248aae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ What changed in OpenBGA Interface Engine, grouped by release with unreleased changes on top, then by impact. Types follow [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). -## Unreleased (2026-11-12 to 2026-11-23) +## Unreleased (2026-11-12 to 2026-11-24) ### High impact @@ -173,6 +173,18 @@ top, then by impact. Types follow [Keep a Changelog](https://keepachangelog.com/ ### Medium impact +- **Fixed:** SFTP endpoints connect to servers with RSA host keys (2026-11-24) + + SFTP endpoints now connect to servers that identify themselves with an RSA host key, including + older 1024-bit keys, and sign in with RSA private keys. Before, such a server failed at connect + with "Wrong server signature". Pin the server's `SHA256:` fingerprint as for any other key. + + Technical notes: + + The engine's SSH library is built with RSA support: `russh` 0.65.1 → 0.65.4 with its `rsa` + feature, which adds `rsa` 0.10.0, `pkcs1` 0.8.0 and `crypto-primes` 0.7.2 (MIT or Apache-2.0) + and takes `ssh-key` 0.7.0-rc.12. `rsa` 0.10.0 is the release that fixes RUSTSEC-2023-0071. + - **Fixed:** Files are received when the engine takes them (2026-11-20) A message read from a file (a delimited file or a PDF report) was recorded as received at the diff --git a/Cargo.lock b/Cargo.lock index 0959b56..dcd31a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -378,7 +378,7 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.7", + "generic-array", ] [[package]] @@ -694,9 +694,9 @@ checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" [[package]] name = "crypto-bigint" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c035cb64cba03dad2fb921f3e218785e8cf9a41790da5eb3a1400f62fa2be11" +checksum = "914c195c4d7fbc5ed7f88d14cbf85914d5c664967658d43404b263913a477e82" dependencies = [ "cpubits", "ctutils", @@ -715,7 +715,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ - "generic-array 0.14.7", + "generic-array", "typenum", ] @@ -730,6 +730,16 @@ dependencies = [ "rand_core 0.10.1", ] +[[package]] +name = "crypto-primes" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3633a51a39c69ebbaa4feaa694bd83d241e4093901c84a0963b19d9bb3f0cf8f" +dependencies = [ + "crypto-bigint", + "rand_core 0.10.1", +] + [[package]] name = "csv" version = "1.4.0" @@ -906,6 +916,7 @@ dependencies = [ "const-oid", "crypto-common 0.2.2", "ctutils", + "zeroize", ] [[package]] @@ -1301,16 +1312,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "generic-array" -version = "1.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "337d46834ee672ab3e48caca2cb0c78cc174fb12b3a68d0d88f99a0519a5e36e" -dependencies = [ - "rustversion", - "typenum", -] - [[package]] name = "getrandom" version = "0.2.17" @@ -2597,6 +2598,7 @@ dependencies = [ "notify", "packie-config", "packie-core", + "rand 0.10.3", "russh", "russh-sftp", "serde_json", @@ -2710,6 +2712,16 @@ dependencies = [ "futures-io", ] +[[package]] +name = "pkcs1" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6250dd7321adbe93d12b750aee0ced159fd13e77f625edcdf1cb6f83cd99f650" +dependencies = [ + "der", + "spki", +] + [[package]] name = "pkcs5" version = "0.8.1" @@ -3089,6 +3101,27 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "rsa" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e77fd77e0dea28b3011fd62d15445b7de7959333b0276d930e03be0f755699" +dependencies = [ + "const-oid", + "crypto-bigint", + "crypto-common 0.2.2", + "crypto-primes", + "digest 0.11.3", + "hmac", + "pkcs1", + "pkcs8", + "rand_core 0.10.1", + "sha2 0.11.1", + "signature", + "spki", + "zeroize", +] + [[package]] name = "rsqlite-vfs" version = "0.2.0" @@ -3125,9 +3158,9 @@ dependencies = [ [[package]] name = "russh" -version = "0.65.1" +version = "0.65.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94be3d86c71b9ed220a675c405e35c7a02565a009bf8da2e9cc13a700320a5c5" +checksum = "569d8c45e20c123af2fc5ecb4803fde0a98572449ba4c24ed97741d7b02fedf7" dependencies = [ "aes", "bitflags 2.13.2", @@ -3148,7 +3181,6 @@ dependencies = [ "elliptic-curve", "enum_dispatch", "futures", - "generic-array 1.4.5", "getrandom 0.4.3", "ghash", "hex-literal", @@ -3165,12 +3197,14 @@ dependencies = [ "p521", "pageant", "pbkdf2", + "pkcs1", "pkcs5", "pkcs8", "polyval", "rand 0.10.3", "rand_core 0.10.1", "ring", + "rsa", "russh-cryptovec", "russh-util", "salsa20", @@ -3717,6 +3751,7 @@ checksum = "7b54d0ed0498daf3f78d82e00e28c8eec9d75a067c4cfbcc7a0f7d0f4077749e" dependencies = [ "base64ct", "bytes", + "crypto-bigint", "ctutils", "digest 0.11.3", "pem-rfc7468", @@ -3725,9 +3760,9 @@ dependencies = [ [[package]] name = "ssh-key" -version = "0.7.0-rc.11" +version = "0.7.0-rc.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a32fae177b74a22aa9c5b01bf7e68b33545be32d9e381e248058d2adc15ce3" +checksum = "0701b552e6bd8f13a6e07bde25307c32d7daad80a79b65832d110c0416e7b638" dependencies = [ "argon2", "bcrypt-pbkdf", @@ -3739,6 +3774,7 @@ dependencies = [ "p384", "p521", "rand_core 0.10.1", + "rsa", "sec1", "sha1", "sha2 0.11.1", diff --git a/Cargo.toml b/Cargo.toml index b332a4c..9d1370e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ nix = { version = "0.31.3", default-features = false, features = ["user"] } # Reads secret values from the terminal without echo (`packie secrets set`). rpassword = "7.5.4" rusqlite = { version = "0.41.1", features = ["bundled"] } -russh = { version = "0.65.1", default-features = false, features = ["ring"] } +russh = { version = "0.65.4", default-features = false, features = ["ring", "rsa"] } russh-sftp = "3.0.1" rust_decimal = { version = "1.43.0", default-features = false, features = ["std", "serde"] } serde = { version = "1.0.229", features = ["derive"] } @@ -66,6 +66,8 @@ uuid = { version = "1.29.0", features = ["v7", "serde"] } # Dev-only crates insta = "1.49.0" proptest = "1.12.0" +# Random RSA keys for the SFTP tests (the version ssh-key generates keys with). +rand = "0.10.3" tempfile = "3.27.0" [workspace.lints.rust] diff --git a/changelog.d/2026-11-24-sftp-rsa-host-keys.md b/changelog.d/2026-11-24-sftp-rsa-host-keys.md new file mode 100644 index 0000000..593b215 --- /dev/null +++ b/changelog.d/2026-11-24-sftp-rsa-host-keys.md @@ -0,0 +1,17 @@ +--- +date: 2026-11-24 +type: fixed +impact: medium +title: SFTP endpoints connect to servers with RSA host keys +area: Endpoints +link: /endpoints +--- +SFTP endpoints now connect to servers that identify themselves with an RSA host key, including +older 1024-bit keys, and sign in with RSA private keys. Before, such a server failed at connect +with "Wrong server signature". Pin the server's `SHA256:` fingerprint as for any other key. + +## Technical notes + +The engine's SSH library is built with RSA support: `russh` 0.65.1 → 0.65.4 with its `rsa` +feature, which adds `rsa` 0.10.0, `pkcs1` 0.8.0 and `crypto-primes` 0.7.2 (MIT or Apache-2.0) +and takes `ssh-key` 0.7.0-rc.12. `rsa` 0.10.0 is the release that fixes RUSTSEC-2023-0071. diff --git a/crates/packie-transport/Cargo.toml b/crates/packie-transport/Cargo.toml index 23a70c2..36d9daa 100644 --- a/crates/packie-transport/Cargo.toml +++ b/crates/packie-transport/Cargo.toml @@ -27,6 +27,7 @@ packie-core = { workspace = true } nix = { workspace = true, features = ["fs"] } [dev-dependencies] +rand = { workspace = true } tracing-subscriber = { workspace = true } [lints] diff --git a/crates/packie-transport/tests/sftp/main.rs b/crates/packie-transport/tests/sftp/main.rs index 93b7269..adb0b2a 100644 --- a/crates/packie-transport/tests/sftp/main.rs +++ b/crates/packie-transport/tests/sftp/main.rs @@ -21,7 +21,7 @@ use russh::keys::ssh_key::LineEnding; use serde_json::json; use tokio::net::TcpListener; -use server::{PASSWORD, Server, fingerprint, key, transports}; +use server::{PASSWORD, Server, fingerprint, key, rsa_key, transports}; fn read(path: impl AsRef) -> Vec { fs::read(path).unwrap() @@ -233,6 +233,30 @@ async fn key_authentication_uses_the_secret_store() { assert_eq!(error.cause, "authentication rejected by the server"); } +#[tokio::test] +async fn rsa_host_and_user_keys_sign_in() { + // A server identified only by a 1024-bit RSA key, as some still are, and an RSA user key. + let client = rsa_key(2048); + let server = Server::start_with_host_key(&client, rsa_key(1024)).await; + let report = probe(&server, &json!({})).await; + assert!(report.ok, "{report:?}"); + + let pem = client.to_openssh(LineEnding::LF).unwrap(); + let secrets = MapSecrets::new(HashMap::from([( + "sftp-key".to_owned(), + pem.as_str().to_owned(), + )])); + let auth = json!({"auth": {"method": "key", "private_key": {"secret": "sftp-key"}, "passphrase": null}}); + let sink = SystemTransports::new(Arc::new(secrets)) + .file_sink(&server.endpoint("/outbound", &auth)) + .unwrap(); + assert_eq!( + write(&*sink, "r.csv", b"rsa", OnExists::Fail).await, + "r.csv" + ); + assert_eq!(read(server.dir("outbound").join("r.csv")), b"rsa"); +} + #[tokio::test] async fn a_complete_file_is_returned_and_consumed_into_processed() { let server = Server::start(&key(9)).await; diff --git a/crates/packie-transport/tests/sftp/server.rs b/crates/packie-transport/tests/sftp/server.rs index 55641da..07340da 100644 --- a/crates/packie-transport/tests/sftp/server.rs +++ b/crates/packie-transport/tests/sftp/server.rs @@ -11,7 +11,7 @@ use std::time::Duration; use packie_config::EndpointConfig; use packie_transport::{FileSink, FileSource, MapSecrets, SystemTransports, Transports}; -use russh::keys::ssh_key::private::Ed25519Keypair; +use russh::keys::ssh_key::private::{Ed25519Keypair, RsaKeypair}; use russh::keys::{HashAlg, PrivateKey, PublicKey}; use russh::server::{Auth, ChannelOpenHandle, Msg, Session, VerifiedPublicKey}; use russh::{Channel, ChannelId}; @@ -32,6 +32,11 @@ pub fn key(seed: u8) -> PrivateKey { PrivateKey::from(Ed25519Keypair::from_seed(&[seed; 32])) } +/// A random RSA key of `bits`, for servers and users that still use RSA. +pub fn rsa_key(bits: usize) -> PrivateKey { + PrivateKey::from(RsaKeypair::random(&mut rand::rng(), bits).unwrap()) +} + pub fn fingerprint(key: &PrivateKey) -> String { key.public_key().fingerprint(HashAlg::Sha256).to_string() } @@ -47,10 +52,14 @@ impl Server { /// Starts a server with `/inbound` and `/outbound`, accepting the synthetic password /// and the public key of `client`. pub async fn start(client: &PrivateKey) -> Self { + Self::start_with_host_key(client, key(7)).await + } + + /// As [`Server::start`], identified by `host_key`. + pub async fn start_with_host_key(client: &PrivateKey, host_key: PrivateKey) -> Self { let files = TempDir::new().unwrap(); fs::create_dir(files.path().join("inbound")).unwrap(); fs::create_dir(files.path().join("outbound")).unwrap(); - let host_key = key(7); let fingerprint = fingerprint(&host_key); let config = Arc::new(russh::server::Config { keys: vec![host_key], diff --git a/docs/operations/configuration-reference.md b/docs/operations/configuration-reference.md index 2a1da5e..f0bec70 100644 --- a/docs/operations/configuration-reference.md +++ b/docs/operations/configuration-reference.md @@ -163,9 +163,9 @@ OS timing and log a warning; see the [TCP settings specification](../spec/config | `username` | `sftp` | Required | String, 1–255 characters. | | `auth.method` | `sftp` | Required | `password` or `key`. | | `auth.password` | `sftp` | Required for password auth | Secret reference. | -| `auth.private_key` | `sftp` | Required for key auth | Secret reference. | +| `auth.private_key` | `sftp` | Required for key auth | Secret reference to an Ed25519, ECDSA or RSA private key. | | `auth.passphrase` | `sftp` | Optional for key auth | Secret reference or `null`. | -| `host_key_fingerprint` | `sftp` | Required | `SHA256:` plus base64; pinned server key. | +| `host_key_fingerprint` | `sftp` | Required | `SHA256:` plus base64; pinned server key (Ed25519, ECDSA or RSA). | | `remote_directory` | `sftp` | Required | Absolute remote path. | | `connect_timeout_ms` | `sftp` | `10000` | Integer, 1–120,000. | | `operation_timeout_ms` | `sftp` | `30000` | Integer, 1–600,000 per list/read/write operation. | diff --git a/docs/spec/configuration.md b/docs/spec/configuration.md index 439aad5..a86f9b8 100644 --- a/docs/spec/configuration.md +++ b/docs/spec/configuration.md @@ -204,8 +204,8 @@ one directory; use two endpoints for separate in and out directories. | `host` | sftp | string | none | As `tcp_client.host`. | | `port` | sftp | integer | `22` | 1–65535. | | `username` | sftp | string | none | 1–255 characters. | -| `auth` | sftp | object | none | `{"method":"password","password":}` or `{"method":"key","private_key":,"passphrase":}`. Secrets by reference only. | -| `host_key_fingerprint` | sftp | string | none | Required server-key pin, normally `SHA256:` followed by base64. Configuration validation checks only the `SHA256:` prefix and a minimum total length of 10 bytes. A mismatch with the server's fingerprint puts the endpoint in `error` (`host_key_mismatch`). | +| `auth` | sftp | object | none | `{"method":"password","password":}` or `{"method":"key","private_key":,"passphrase":}`. Secrets by reference only. A private key is Ed25519, ECDSA or RSA. | +| `host_key_fingerprint` | sftp | string | none | Required server-key pin, normally `SHA256:` followed by base64. The host key may be Ed25519, ECDSA or RSA (1024 bits or more). Configuration validation checks only the `SHA256:` prefix and a minimum total length of 10 bytes. A mismatch with the server's fingerprint puts the endpoint in `error` (`host_key_mismatch`). | | `remote_directory` | sftp | string | none | Absolute remote path. | | `connect_timeout_ms` | sftp | integer | `10000` | 1–120,000. | | `operation_timeout_ms` | sftp | integer | `30000` | 1–600,000. One list, read or write operation. |