Summary
A security vulnerability has been identified in GitHub CLI where gh codespace ports forward binds the local forwarded port to all available network interfaces by default. While port forwarding is active, a service in a Codespace can therefore become reachable through the user's non-loopback local IP addresses by other hosts that can route to the user's machine.
This behavior does not change the GitHub-side visibility of the Codespaces port. Instead, it exposes the forwarded service through a wildcard-bound listener on the user's local machine, even when the source Codespaces port remains private.
Details
When a user runs:
gh codespace ports forward <remote-port>:<local-port>
GitHub CLI creates a local TCP listener for the requested local port. In affected versions, that listener binds to the wildcard address, which accepts connections through every available network interface.
For example, forwarding a private Codespaces service to local port 18000 can result in a listener equivalent to:
A host on the same LAN, VPN, or another network that can route to the user's machine may connect to that listener while the forwarding command is running. The attacker does not need shell access to the user's machine, access to locally stored credentials, or access to the Codespace.
The vulnerability was introduced in GitHub CLI v2.28.0.
In v2.98.0, gh codespace ports forward binds to the loopback interface by default. Users who intentionally need to expose a forwarded service through other local network interfaces can opt into the previous behavior with the new --all-interfaces flag.
The command also reports the actual local listener address so users can confirm whether forwarding is limited to loopback or exposed through all interfaces.
Impact
A network-adjacent attacker can access a service forwarded by gh codespace ports forward through the victim machine's non-loopback network interfaces while the forwarding process is active.
The precise impact depends on the forwarded service. At minimum, this creates unintended network exposure. If the service provides sensitive information or state-changing operations without additional authentication, an attacker may be able to read that information or invoke those operations.
Successful exploitation requires the victim to be actively forwarding a port and the attacker to be able to route traffic to the victim's machine.
Remediation and Mitigation
- Upgrade GitHub CLI to
v2.98.0 or later.
- On affected versions, avoid
gh codespace ports forward on untrusted or shared networks.
- Use host firewall rules to block inbound access to locally forwarded ports.
- Stop the forwarding process when it is no longer needed.
Summary
A security vulnerability has been identified in GitHub CLI where
gh codespace ports forwardbinds the local forwarded port to all available network interfaces by default. While port forwarding is active, a service in a Codespace can therefore become reachable through the user's non-loopback local IP addresses by other hosts that can route to the user's machine.This behavior does not change the GitHub-side visibility of the Codespaces port. Instead, it exposes the forwarded service through a wildcard-bound listener on the user's local machine, even when the source Codespaces port remains private.
Details
When a user runs:
GitHub CLI creates a local TCP listener for the requested local port. In affected versions, that listener binds to the wildcard address, which accepts connections through every available network interface.
For example, forwarding a private Codespaces service to local port
18000can result in a listener equivalent to:A host on the same LAN, VPN, or another network that can route to the user's machine may connect to that listener while the forwarding command is running. The attacker does not need shell access to the user's machine, access to locally stored credentials, or access to the Codespace.
The vulnerability was introduced in GitHub CLI
v2.28.0.In
v2.98.0,gh codespace ports forwardbinds to the loopback interface by default. Users who intentionally need to expose a forwarded service through other local network interfaces can opt into the previous behavior with the new--all-interfacesflag.The command also reports the actual local listener address so users can confirm whether forwarding is limited to loopback or exposed through all interfaces.
Impact
A network-adjacent attacker can access a service forwarded by
gh codespace ports forwardthrough the victim machine's non-loopback network interfaces while the forwarding process is active.The precise impact depends on the forwarded service. At minimum, this creates unintended network exposure. If the service provides sensitive information or state-changing operations without additional authentication, an attacker may be able to read that information or invoke those operations.
Successful exploitation requires the victim to be actively forwarding a port and the attacker to be able to route traffic to the victim's machine.
Remediation and Mitigation
v2.98.0or later.gh codespace ports forwardon untrusted or shared networks.