0001-fix-logic-error-in-disableforwarding-option.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. From fc86875e6acb36401dfc1dfb6b628a9d1460f367 Mon Sep 17 00:00:00 2001
  2. From: "djm@openbsd.org" <djm@openbsd.org>
  3. Date: Wed, 9 Apr 2025 07:00:03 +0000
  4. Subject: [PATCH] upstream: Fix logic error in DisableForwarding option.
  5. This option was documented as disabling X11 and agent forwarding but it failed to do so.
  6. Spotted by Tim Rice.
  7. OpenBSD-Commit-ID: fffc89195968f7eedd2fc57f0b1f1ef3193f5ed1
  8. Upstream: https://github.com/openssh/openssh-portable/commit/fc86875e6acb36401dfc1dfb6b628a9d1460f367
  9. Fixes the following CVE:
  10. - CVE-2025-32728: In sshd in OpenSSH before 10.0, the DisableForwarding
  11. directive does not adhere to the documentation stating
  12. that it disables X11 and agent forwarding.
  13. [Titouan:
  14. - Remove diff on OpenBSD comment at the top of the file that does not apply
  15. cleanly on openssh 9.9
  16. ]
  17. Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
  18. ---
  19. session.c | 7 ++++---
  20. 1 file changed, 4 insertions(+), 3 deletions(-)
  21. diff --git a/session.c b/session.c
  22. index 52a4a3446e6..6444c77f31c 100644
  23. --- a/session.c
  24. +++ b/session.c
  25. @@ -2171,7 +2171,8 @@ session_auth_agent_req(struct ssh *ssh, Session *s)
  26. if ((r = sshpkt_get_end(ssh)) != 0)
  27. sshpkt_fatal(ssh, r, "%s: parse packet", __func__);
  28. if (!auth_opts->permit_agent_forwarding_flag ||
  29. - !options.allow_agent_forwarding) {
  30. + !options.allow_agent_forwarding ||
  31. + options.disable_forwarding) {
  32. debug_f("agent forwarding disabled");
  33. return 0;
  34. }
  35. @@ -2566,7 +2567,7 @@ session_setup_x11fwd(struct ssh *ssh, Session *s)
  36. ssh_packet_send_debug(ssh, "X11 forwarding disabled by key options.");
  37. return 0;
  38. }
  39. - if (!options.x11_forwarding) {
  40. + if (!options.x11_forwarding || options.disable_forwarding) {
  41. debug("X11 forwarding disabled in server configuration file.");
  42. return 0;
  43. }