T09 · Insecure Skill Coding Practices
- Location
scripts/toolkit/stream.py:1157- Finding
Unauthenticated WebRTC bridge binds to all network interfaces
- Content
View full analysis
Vulnerability Details
File Location:
scripts/toolkit/stream.py:1157-1179
Vulnerability Type: Unauthenticated network exposure of camera streams and credentials
Risk Level: HighVulnerable Code
python rtsp_path = target.rtsp_sub_path if sub_stream else target.rtsp_path rtsp_url = dm._build_rtsp_url( target.ip, target.rtsp_port, rtsp_path, target.username, target.password, ) import yaml config_path = _os.path.join(_GO2RTC_SKILL_DIR, "go2rtc.yaml") stream_name = camera_name.replace(" ", "_") go2rtc_config = { "streams": {stream_name: rtsp_url}, "api": {"listen": f":{port}"}, } with open(config_path, "w") as f: yaml.dump(go2rtc_config, f, default_flow_style=False, allow_unicode=True) try: popen_kwargs = { "stdout": subprocess.PIPE, "stderr": subprocess.PIPE, } if _GO2RTC_IS_WIN: popen_kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW _go2rtc_process = subprocess.Popen( [binary, "-config", config_path], **popen_kwargs, )Technical Analysis
start_webrtc_stream()constructs an authenticated RTSP URL containing the camera username and password, writes it togo2rtc.yaml, and starts go2rtc with an API listener configured as:<port>.This listener syntax does not restrict the service to the loopback interface. Although the returned URL is described as
http://localhost:<port>, the underlying service may be reachable through every host network interface. No authentication or access-control configuration is supplied to go2rtc.The implementation therefore expands access from the user-local browser to other systems capable of reaching the host. It also leaves the credential-bearing RTSP URL in a plaintext configuration file under the Skill root.
Attack Path
- The user starts a browser preview through
start_webrtc_stream(). - The function builds an RTSP URL containing ...[truncated 947 chars]
- The user starts a browser preview through
- Remediation
View remediation
Remediation Suggestions
- Bind the go2rtc API explicitly to the loopback interface, such as
127.0.0.1:<port>. - If remote access is an intended feature, require explicit user authorization and configure strong authentication and transport protection.
- Create
go2rtc.yamlwith owner-only permissions rather than relying on process-default permissions. - Avoid persisting credential-bearing RTSP URLs where possible. Generate an ephemeral configuration or securely remove it when the stream stops.
- Validate that the selected port is not already exposed by firewall or port-forwarding rules.
- Return the actual bound address rather than presenting a localhost URL while listening on broader interfaces.
- Bind the go2rtc API explicitly to the loopback interface, such as
