Sliver: Nil Pointer Dereference in tunnelCloseHandler causes panic when a reverse tunnel (rportfwd) close is attempted

Description

Summary

A 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.

Details

File: server/handlers/sessions.go lines 172 and 175

The 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:

} else {
    rtunnel := rtunnels.GetRTunnel(tunnelData.TunnelID)

    if rtunnel != nil && session.ID == tunnel.SessionID {      // LINE 172 — nil deref
        rtunnel.Close()
        rtunnels.RemoveRTunnel(rtunnel.ID)
    } else if rtunnel != nil && session.ID != tunnel.SessionID { // LINE 175 — nil deref
        sessionHandlerLog.Warnf("...")
    }
}

Note: The identical bug was already fixed in tunnelDataHandler at lines 124/126 (correctly uses rtunnel.SessionID), but the fix was
not applied to tunnelCloseHandler.

PoC

tunnel := GetTunnel(999)   // returns nil — no normal tunnel with this ID
// tunnel is nil here

rtunnel := GetRTunnel(999) // returns valid rtunnel owned by session-AAAA

// Both lines below panic with:
// runtime error: invalid memory address or nil pointer dereference
if rtunnel != nil && sessionID == tunnel.SessionID { ... }      // line 172
} else if rtunnel != nil && sessionID != tunnel.SessionID { ... } // line 175

Confirmed on master commit 7ac4db3fa with standalone reproducer.
Output:

PANIC on line 172 (legitimate close): runtime error: invalid memory address or nil pointer dereference
PANIC on line 175 (unauthorized close): runtime error: invalid memory address or nil pointer dereference

1
2
3

Impact

  • rportfwd tunnels cannot be closed — functional regression
  • Any authenticated implant can trigger repeated handler goroutine panics
  • rtunnel map entries leak (never cleaned up on close failure)
  • recoverAndLogPanic() prevents full server crash but silently drops the close operation

Fix

Replace tunnel.SessionID with rtunnel.SessionID on both lines:

-  if rtunnel != nil && session.ID == tunnel.SessionID {
+  if rtunnel != nil && session.ID == rtunnel.SessionID {
       rtunnel.Close()
       rtunnels.RemoveRTunnel(rtunnel.ID)
-  } else if rtunnel != nil && session.ID != tunnel.SessionID {
+  } else if rtunnel != nil && session.ID != rtunnel.SessionID {

Basic information

Type
reviewed
Severity
high
Advisory on GitHub
Open advisory ↗
Repository advisory
Open repository advisory ↗
Source code
Browse source ↗
Published (advisory)
2026-03-29 15:25:42 UTC
Updated
2026-03-29 15:25:42 UTC
GitHub reviewed
2026-03-29 15:25:42 UTC

CVSS Scores

Base score Version Severity Vector
7.1 4.0
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 Click to expand
Attack vector (AV:N)
Could be attacked over the internet or any normal routed network.
Attack complexity (AC:L)
Exploitation conditions are straightforward and stable.
Attack requirements (AT:N)
No additional preconditions are required beyond normal reachability.
Privileges required (PR:L)
Low privileges are required.
User interaction (UI:N)
No user interaction is required.
Vulnerable system confidentiality impact (VC:N)
No confidentiality impact on the vulnerable system.
Vulnerable system integrity impact (VI:N)
No integrity impact on the vulnerable system.
Vulnerable system availability impact (VA:H)
High availability impact on the vulnerable system.
Subsequent system confidentiality impact (SC:N)
No confidentiality impact on subsequent systems.
Subsequent system integrity impact (SI:N)
No integrity impact on subsequent systems.
Subsequent system availability impact (SA:N)
No availability impact on subsequent systems.

Identifiers

Type Value
GHSA GHSA-c279-989m-238f ↗

CWEs

CWE id Name
CWE-476 NULL Pointer Dereference

Credits

  • VarshankNaik (reporter)

Affected packages (1)

Vulnerable version ranges and first patched releases as published by GitHub.

Ecosystem Package Vulnerable range First patched Vulnerable functions
go github.com/bishopfox/sliver <= 1.7.3

References

cvelogic Threat Intelligence