{"id":"GHSA-c279-989m-238f","aliases":["GO-2026-4899"],"status":"published","title":"Sliver: Nil Pointer Dereference in tunnelCloseHandler causes panic when a reverse tunnel (rportfwd) close is attempted","description":"### Summary\nA nil pointer dereference in `tunnelCloseHandler` causes the handler goroutine to panic whenever a reverse tunnel (rportfwd) close is attempted. Both the legitimate close path AND the unauthorized close path dereference `tunnel.SessionID` where `tunnel` is guaranteed nil. This means rportfwd tunnels can never be cleanly closed, and any authenticated implant can trigger repeated goroutine panics.\n\n### Details\nFile: `server/handlers/sessions.go` lines 172 and 175\n\nThe function enters an `else` block precisely because `core.Tunnels.Get(tunnelData.TunnelID)` returned `nil`. Both conditions inside that else block then dereference `tunnel.SessionID` instead of `rtunnel.SessionID`:\n```go\n} else {\n    rtunnel := rtunnels.GetRTunnel(tunnelData.TunnelID)\n\n    if rtunnel != nil \u0026\u0026 session.ID == tunnel.SessionID {      // LINE 172 — nil deref\n        rtunnel.Close()\n        rtunnels.RemoveRTunnel(rtunnel.ID)\n    } else if rtunnel != nil \u0026\u0026 session.ID != tunnel.SessionID { // LINE 175 — nil deref\n        sessionHandlerLog.Warnf(\"...\")\n    }\n}\n```\n\nNote: The identical bug was already fixed in `tunnelDataHandler` at lines 124/126 (correctly uses `rtunnel.SessionID`), but the fix was \nnot applied to `tunnelCloseHandler`.\n\n### PoC\n```go\ntunnel := GetTunnel(999)   // returns nil — no normal tunnel with this ID\n// tunnel is nil here\n\nrtunnel := GetRTunnel(999) // returns valid rtunnel owned by session-AAAA\n\n// Both lines below panic with:\n// runtime error: invalid memory address or nil pointer dereference\nif rtunnel != nil \u0026\u0026 sessionID == tunnel.SessionID { ... }      // line 172\n} else if rtunnel != nil \u0026\u0026 sessionID != tunnel.SessionID { ... } // line 175\n```\n\nConfirmed on master commit `7ac4db3fa` with standalone reproducer.\nOutput:\n```\nPANIC on line 172 (legitimate close): runtime error: invalid memory address or nil pointer dereference\nPANIC on line 175 (unauthorized close): runtime error: invalid memory address or nil pointer dereference\n```\n\n![1](https://github.com/user-attachments/assets/93b24286-3282-454f-80a4-b01abe4f1d63)\n![2](https://github.com/user-attachments/assets/d4219aea-eb18-474c-b69a-a5e20e97161f)\n![3](https://github.com/user-attachments/assets/5a76b0d7-ae5b-4d91-bfe9-730d3e5c322c)\n\n### Impact\n- rportfwd tunnels **cannot be closed** — functional regression\n- Any authenticated implant can trigger repeated handler goroutine panics\n- rtunnel map entries leak (never cleaned up on close failure)\n- `recoverAndLogPanic()` prevents full server crash but silently drops the close operation\n\n### Fix\nReplace `tunnel.SessionID` with `rtunnel.SessionID` on both lines:\n```diff\n-  if rtunnel != nil \u0026\u0026 session.ID == tunnel.SessionID {\n+  if rtunnel != nil \u0026\u0026 session.ID == rtunnel.SessionID {\n       rtunnel.Close()\n       rtunnels.RemoveRTunnel(rtunnel.ID)\n-  } else if rtunnel != nil \u0026\u0026 session.ID != tunnel.SessionID {\n+  } else if rtunnel != nil \u0026\u0026 session.ID != rtunnel.SessionID {\n```","severity":{"version":"4.0","score":7.1,"vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","level":"high","from":"ghsa"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":false},"cwes":["CWE-476"],"published":"2026-03-29T15:25:42Z","modified":"2026-04-02T21:26:25Z","affected":[{"source":"ghsa","ecosystem":"Go","package":"github.com/bishopfox/sliver","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"last_affected":"1.7.3"}]}]},{"source":"osv","ecosystem":"Go","package":"github.com/bishopfox/sliver","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"last_affected":"1.7.3"}]}]},{"source":"osv","ecosystem":"Go","package":"github.com/bishopfox/sliver","ranges":[{"type":"SEMVER","events":[{"introduced":"0"}]}]}],"references":[{"url":"https://github.com/BishopFox/sliver/security/advisories/GHSA-c279-989m-238f","tags":["web","advisory"]},{"url":"https://github.com/advisories/GHSA-c279-989m-238f"},{"url":"https://github.com/BishopFox/sliver","tags":["package"]}],"sources":{"ghsa":[{"id":"GHSA-c279-989m-238f","title":"Sliver: Nil Pointer Dereference in tunnelCloseHandler causes panic when a reverse tunnel (rportfwd) close is attempted","description":"### Summary\nA nil pointer dereference in `tunnelCloseHandler` causes the handler goroutine to panic whenever a reverse tunnel (rportfwd) close is attempted. Both the legitimate close path AND the unauthorized close path dereference `tunnel.SessionID` where `tunnel` is guaranteed nil. This means rportfwd tunnels can never be cleanly closed, and any authenticated implant can trigger repeated goroutine panics.\n\n### Details\nFile: `server/handlers/sessions.go` lines 172 and 175\n\nThe function enters an `else` block precisely because `core.Tunnels.Get(tunnelData.TunnelID)` returned `nil`. Both conditions inside that else block then dereference `tunnel.SessionID` instead of `rtunnel.SessionID`:\n```go\n} else {\n    rtunnel := rtunnels.GetRTunnel(tunnelData.TunnelID)\n\n    if rtunnel != nil \u0026\u0026 session.ID == tunnel.SessionID {      // LINE 172 — nil deref\n        rtunnel.Close()\n        rtunnels.RemoveRTunnel(rtunnel.ID)\n    } else if rtunnel != nil \u0026\u0026 session.ID != tunnel.SessionID { // LINE 175 — nil deref\n        sessionHandlerLog.Warnf(\"...\")\n    }\n}\n```\n\nNote: The identical bug was already fixed in `tunnelDataHandler` at lines 124/126 (correctly uses `rtunnel.SessionID`), but the fix was \nnot applied to `tunnelCloseHandler`.\n\n### PoC\n```go\ntunnel := GetTunnel(999)   // returns nil — no normal tunnel with this ID\n// tunnel is nil here\n\nrtunnel := GetRTunnel(999) // returns valid rtunnel owned by session-AAAA\n\n// Both lines below panic with:\n// runtime error: invalid memory address or nil pointer dereference\nif rtunnel != nil \u0026\u0026 sessionID == tunnel.SessionID { ... }      // line 172\n} else if rtunnel != nil \u0026\u0026 sessionID != tunnel.SessionID { ... } // line 175\n```\n\nConfirmed on master commit `7ac4db3fa` with standalone reproducer.\nOutput:\n```\nPANIC on line 172 (legitimate close): runtime error: invalid memory address or nil pointer dereference\nPANIC on line 175 (unauthorized close): runtime error: invalid memory address or nil pointer dereference\n```\n\n![1](https://github.com/user-attachments/assets/93b24286-3282-454f-80a4-b01abe4f1d63)\n![2](https://github.com/user-attachments/assets/d4219aea-eb18-474c-b69a-a5e20e97161f)\n![3](https://github.com/user-attachments/assets/5a76b0d7-ae5b-4d91-bfe9-730d3e5c322c)\n\n### Impact\n- rportfwd tunnels **cannot be closed** — functional regression\n- Any authenticated implant can trigger repeated handler goroutine panics\n- rtunnel map entries leak (never cleaned up on close failure)\n- `recoverAndLogPanic()` prevents full server crash but silently drops the close operation\n\n### Fix\nReplace `tunnel.SessionID` with `rtunnel.SessionID` on both lines:\n```diff\n-  if rtunnel != nil \u0026\u0026 session.ID == tunnel.SessionID {\n+  if rtunnel != nil \u0026\u0026 session.ID == rtunnel.SessionID {\n       rtunnel.Close()\n       rtunnels.RemoveRTunnel(rtunnel.ID)\n-  } else if rtunnel != nil \u0026\u0026 session.ID != tunnel.SessionID {\n+  } else if rtunnel != nil \u0026\u0026 session.ID != rtunnel.SessionID {\n```","status":"published","published":"2026-03-29T15:25:42Z","modified":"2026-03-29T15:25:42Z","cvss":[{"version":"4.0","score":7.1,"vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","level":"high"}],"cwes":["CWE-476"],"updated_at":"2026-11-02T14:39:44.97342Z"}],"osv":[{"id":"GHSA-c279-989m-238f","title":"Sliver: Nil Pointer Dereference in tunnelCloseHandler causes panic when a reverse tunnel (rportfwd) close is attempted","description":"### Summary\nA nil pointer dereference in `tunnelCloseHandler` causes the handler goroutine to panic whenever a reverse tunnel (rportfwd) close is attempted. Both the legitimate close path AND the unauthorized close path dereference `tunnel.SessionID` where `tunnel` is guaranteed nil. This means rportfwd tunnels can never be cleanly closed, and any authenticated implant can trigger repeated goroutine panics.\n\n### Details\nFile: `server/handlers/sessions.go` lines 172 and 175\n\nThe function enters an `else` block precisely because `core.Tunnels.Get(tunnelData.TunnelID)` returned `nil`. Both conditions inside that else block then dereference `tunnel.SessionID` instead of `rtunnel.SessionID`:\n```go\n} else {\n    rtunnel := rtunnels.GetRTunnel(tunnelData.TunnelID)\n\n    if rtunnel != nil \u0026\u0026 session.ID == tunnel.SessionID {      // LINE 172 — nil deref\n        rtunnel.Close()\n        rtunnels.RemoveRTunnel(rtunnel.ID)\n    } else if rtunnel != nil \u0026\u0026 session.ID != tunnel.SessionID { // LINE 175 — nil deref\n        sessionHandlerLog.Warnf(\"...\")\n    }\n}\n```\n\nNote: The identical bug was already fixed in `tunnelDataHandler` at lines 124/126 (correctly uses `rtunnel.SessionID`), but the fix was \nnot applied to `tunnelCloseHandler`.\n\n### PoC\n```go\ntunnel := GetTunnel(999)   // returns nil — no normal tunnel with this ID\n// tunnel is nil here\n\nrtunnel := GetRTunnel(999) // returns valid rtunnel owned by session-AAAA\n\n// Both lines below panic with:\n// runtime error: invalid memory address or nil pointer dereference\nif rtunnel != nil \u0026\u0026 sessionID == tunnel.SessionID { ... }      // line 172\n} else if rtunnel != nil \u0026\u0026 sessionID != tunnel.SessionID { ... } // line 175\n```\n\nConfirmed on master commit `7ac4db3fa` with standalone reproducer.\nOutput:\n```\nPANIC on line 172 (legitimate close): runtime error: invalid memory address or nil pointer dereference\nPANIC on line 175 (unauthorized close): runtime error: invalid memory address or nil pointer dereference\n```\n\n![1](https://github.com/user-attachments/assets/93b24286-3282-454f-80a4-b01abe4f1d63)\n![2](https://github.com/user-attachments/assets/d4219aea-eb18-474c-b69a-a5e20e97161f)\n![3](https://github.com/user-attachments/assets/5a76b0d7-ae5b-4d91-bfe9-730d3e5c322c)\n\n### Impact\n- rportfwd tunnels **cannot be closed** — functional regression\n- Any authenticated implant can trigger repeated handler goroutine panics\n- rtunnel map entries leak (never cleaned up on close failure)\n- `recoverAndLogPanic()` prevents full server crash but silently drops the close operation\n\n### Fix\nReplace `tunnel.SessionID` with `rtunnel.SessionID` on both lines:\n```diff\n-  if rtunnel != nil \u0026\u0026 session.ID == tunnel.SessionID {\n+  if rtunnel != nil \u0026\u0026 session.ID == rtunnel.SessionID {\n       rtunnel.Close()\n       rtunnels.RemoveRTunnel(rtunnel.ID)\n-  } else if rtunnel != nil \u0026\u0026 session.ID != tunnel.SessionID {\n+  } else if rtunnel != nil \u0026\u0026 session.ID != rtunnel.SessionID {\n```","status":"published","published":"2026-03-29T15:25:42Z","modified":"2026-04-02T21:26:25.815310466Z","cvss":[{"version":"4.0","score":7.1,"vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","level":"high"}],"cwes":["CWE-476"],"updated_at":"2026-11-02T15:46:44.225359Z"},{"id":"GO-2026-4899","title":"Sliver: Nil Pointer Dereference in tunnelCloseHandler causes panic when a reverse tunnel (rportfwd) close is attempted in github.com/bishopfox/sliver","description":"Sliver: Nil Pointer Dereference in tunnelCloseHandler causes panic when a reverse tunnel (rportfwd) close is attempted in github.com/bishopfox/sliver","status":"published","published":"2026-04-02T18:42:30Z","modified":"2026-04-02T21:20:04.172581Z","updated_at":"2026-11-02T15:47:02.280725Z"}]}}
