Summary
pam_usb's deny_remote check can fail to recognize an active remote tmux session when Linux reports a link-local IPv6 address with a zone index. If the check misses the session, access may be granted despite the configured remote-session restriction.
Affected context
The issue affects pam_usb deployments in which deny_remote is enabled and the tmux check parses output from /usr/bin/w -i. On systems where that output includes a scope identifier on a link-local IPv6 address, the address can fail to match the expected pattern. The check may then report no remote clients even when a remote tmux session is active.
Exploit preconditions
- Attack surface: A PAM authentication flow using pam_usb with the
deny_remotefeature enabled - Required access: The ability to reach the relevant authentication point; other configured authentication requirements may still apply
- Trigger point: The tmux remote-client check while processing
/usr/bin/w -ioutput - Why exploitation is possible: A zone index appended to a link-local IPv6 address can cause the detection pattern to miss an active remote session, allowing the check to fail open
Why this happens
The remote-session protection relies on pattern matching command output, but the pattern does not account for IPv6 scope identifiers. When the expected address is followed by a zone index before whitespace, the match fails and the function treats the session as absent. This is a failure of a security protection mechanism (CWE-693) that can result in an access-control check being bypassed (CWE-285).
Potential impact
- A user may be allowed to authenticate despite an active remote tmux session when
deny_remoteis intended to block access - The configured restriction on remote-session access could be weakened or ineffective on affected systems
- Additional access may be possible if the user also satisfies the other authentication requirements
General mitigation guidance
Defensive patterns include making security checks robust to documented variations in system command output and treating parsing errors or unexpected formats as indeterminate rather than as proof that a session is absent. Prefer structured interfaces over parsing human-oriented command output, and apply strict validation to any parsed fields. Keep authentication decisions fail-closed where appropriate, and limit the privileges available to authentication components.
How teams detect issues like this
- Review code that parses
/usr/bin/w -ioutput for assumptions about IPv6 address formatting and whitespace boundaries. - Use static analysis or code review to identify security checks that treat failed matches as evidence that a risky condition is absent.
- Test the detection logic with link-local IPv6 addresses both with and without scope identifiers, including on multi-homed systems.
- Apply policy checks that flag authentication decisions based on fragile parsing of command output; automated code review tools may help surface these patterns.

