Summary
luci-app-tailscale-community contains a command injection flaw in the tailscale.do_login RPC endpoint that lets authenticated users run arbitrary shell commands as root.
The issue occurs when user-controlled loginserver and loginserver_authkey values are embedded in a double-quoted shell command without proper escaping, enabling shell substitutions such as $() to be evaluated.
Affected context
This vulnerability appears in environments using luci-app-tailscale-community to manage Tailscale through LuCI RPC calls.
It is relevant when:
- The tailscale.do_login RPC method is exposed to authenticated LuCI users or API clients
- User-supplied loginserver or loginserver_authkey values are passed directly into shell commands
- The underlying system executes these commands with elevated (root) privileges
Exploit preconditions
- Attack surface: LuCI RPC interface (tailscale.do_login method)
- Required access: Authenticated access to the LuCI interface or the corresponding RPC endpoint
- Trigger point: Submission of crafted loginserver or loginserver_authkey parameters that include shell substitution syntax (e.g., $() or backticks)
- Why exploitation is possible: User-controlled data is interpolated into a double-quoted shell command without proper quoting or sanitization, allowing the outer shell to interpret and execute embedded commands before argument parsing
Why this happens
The root cause is the construction of shell commands by concatenating untrusted input directly into a command string executed by a shell.
Within the tailscale.do_login implementation, user-controlled parameters (loginserver and loginserver_authkey) are placed inside double quotes but not escaped, which does not prevent command substitution or other shell expansions.
This aligns with CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where user input is treated as part of executable shell syntax instead of as opaque data.
Potential impact
- Authenticated users can execute arbitrary OS commands as root on the device
- Complete compromise of the affected system, including configuration and stored credentials
- Ability to install persistent malware or backdoors
- Lateral movement to other systems reachable from the compromised device
- Disruption of network services managed via Tailscale or LuCI
General mitigation guidance
Effective mitigation typically focuses on removing shell interpretation of untrusted data and reducing privilege of command execution.
Common defensive patterns include:
- Avoid building shell command strings from user input; instead, use parameterized process execution APIs that do not invoke a shell
- If shell usage is unavoidable, strictly escape or neutralize special characters and disallow command substitution syntax in user-supplied fields
- Validate loginserver and loginserver_authkey against expected formats (e.g., hostnames, URLs, key patterns) before use
- Run auxiliary command-executing components with least privilege and minimize the commands they are permitted to invoke
- Separate configuration handling from command execution so user input cannot directly affect shell syntax
How teams detect issues like this
Organizations can detect similar command injection risks by:
- Using static analysis rules that flag string concatenation or interpolation of user input into shell-executing APIs (e.g., system, popen, os.execute)
- Reviewing RPC and web handler code for patterns where parameters are passed directly into command lines, especially within quoted shell strings
- Enforcing coding guidelines that prohibit shell-based command construction with untrusted data and require safe process execution wrappers
- Applying automated security testing or fuzzing that injects command substitution patterns (like $() or
...) into parameters and monitors for unexpected behavior

