Skip to content

ONVIF PullPoint event subscriptions fail on TP-Link Tapo camera #976

Closed

Description

@origin2000

Hi there. I had been holding off on updating since 0.43.4, because the changes after that version broke something on my system. Now that I have some time, I looked into it more closely and ran into the following issue. Please note that this report is based only on logs and tcpdump captures. I have not yet checked the onvif sources in lightnvr, so my analysis is a hypothesis that I haven’t validated against the code.

Summary

ONVIF PullPoint event subscriptions fail on TP-Link Tapo cameras (tested on Tapo C545D, the initial dual-lens camera for LightNVR's dual-lens ONVIF event implementation) in v0.48.2.

While CreatePullPointSubscription succeeds against port 2020, the camera returns a SubscriptionReference (wsa5:Address) on a dynamically allocated ephemeral port on the exact same host IP (e.g., :1026). LightNVR's origin validation rejects this endpoint because the port does not match the configured ONVIF base URL port (2020), completely breaking ONVIF motion detection and dual-lens cross-triggering.


Environment

  • LightNVR Version: v0.48.2 (previously working in 0.43.4 before strict port origin validation)
  • Architecture / Host: ARM64 (aarch64, Radxa Rock 4C+, Debian Trixie / Docker)
  • Camera Model: TP-Link Tapo C545D (Dual-Lens PTZ, reference hardware for dual-lens ONVIF event setup)
  • Configured ONVIF URL: http://192.168.1.123:2020/

Evidence

1. LightNVR Log Output

LightNVR successfully authenticates and creates the subscription, then immediately drops the returned PullPoint endpoint:

[INFO] Successfully created ONVIF subscription (lease: 600 seconds)
[WARN] Rejected ONVIF subscription endpoint outside the configured camera origin
[ERROR] Failed to pull messages from subscription
[WARN] [c545d_wide] ONVIF thread: detect_motion_onvif error -1 – backing off 5 s before retry

2. Packet Capture (tcpdump) of CreatePullPointSubscriptionResponse

Capturing the SOAP exchange between LightNVR and 192.168.1.123:2020 confirms that the Tapo C545D accepts CreatePullPointSubscription on :2020/onvif/event_service, but binds the subscription listener to a dynamic port (1026) on the same IP:

<SOAP-ENV:Header>
  <wsa5:MessageID>urn:uuid:d9dfe7d4-b618-44c9-907e-b92785fbdcd0</wsa5:MessageID>
  <wsa5:To SOAP-ENV:mustUnderstand="true">[http://192.168.1.123:2020/onvif/event_service](http://192.168.1.123:2020/onvif/event_service)</wsa5:To>
  <wsa5:Action SOAP-ENV:mustUnderstand="true">[http://www.onvif.org/ver10/events/wsdl/EventPortType/CreatePullPointSubscriptionResponse](http://www.onvif.org/ver10/events/wsdl/EventPortType/CreatePullPointSubscriptionResponse)</wsa5:Action>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
  <tev:CreatePullPointSubscriptionResponse>
    <tev:SubscriptionReference>
      <wsa5:Address>[http://192.168.1.123:1026/event-1026_1026](http://192.168.1.123:1026/event-1026_1026)</wsa5:Address>
    </tev:SubscriptionReference>
    <wsnt:CurrentTime>2026-11-15T19:20:41Z</wsnt:CurrentTime>
    <wsnt:TerminationTime>2026-11-15T19:30:41Z</wsnt:TerminationTime>
  </tev:CreatePullPointSubscriptionResponse>
</SOAP-ENV:Body>

Root Cause Analysis

Origin Comparison Mismatch: The subscription endpoint validator enforces an exact match on (scheme, host, port) against the configured onvif_url (http://192.168.1.123:2020).

Device Behavior: TP-Link Tapo firmware assigns a dedicated dynamic port per PullPoint subscription (e.g., :1026, :1027, etc.) on the same device IP (192.168.1.123). Per the ONVIF Events / WS-BaseNotification specification, a SubscriptionReference endpoint is not required to share the same TCP port as the initial device/event service endpoint.

Proposed Fix

Keep strict SSRF protection on scheme (http/https) and host (exact IP/hostname match against the configured onvif_url), while allowing any valid TCP port (1..65535) on that same camera host (or making same-host port relaxation configurable).

Activity

  1. RMG112096 commented on Nov 16, 2026

    @RMG112096

    Another affected camera: Mercusys MC500 (TP-Link's sister brand), ONVIF configured on port 2020.

    I haven't upgraded past 0.45.3 yet precisely because of the origin check, so this is observed on 0.45.3 (which has no origin validation), not on 0.47+ / 0.48.x. What I saw with tcpdump and conntrack on the NVR host while the existing PullPoint subscription was being polled (every ~6 s):

    • TCP traffic from the camera comes from port 554 (RTSP) and from an ephemeral port (1024), never from 2020.
    • The connection tracking table only shows connections towards the camera's port 1024, none towards 2020.

    So it looks like this camera also hands out a dynamic port on the same host IP for the subscription endpoint, the same behavior reported here for the Tapo C545D. This is inferred from the traffic pattern; I did not capture the SOAP CreatePullPointSubscriptionResponse itself, so I can't quote its wsa5:Address.

    This supports the proposed fix: keep the scheme and host check, but allow any port on the same camera host (or make it configurable). Happy to test a fix on this camera if useful.

    Environment

    • LightNVR version: 0.45.3 (image ghcr.io/opensensor/lightnvr:0.45.3, non-root, behind Caddy). Not tested on 0.47+ / 0.48.x; I'm holding on 0.45.3 because of this issue.
    • Architecture / Host: x86_64 (Intel Celeron J1800, 8 GB RAM), Debian 13 (Trixie), Docker
    • Camera model: Mercusys MC500 (HW 1.0, firmware 1.2.2 Build 260526), 2.4 GHz Wi-Fi only, PTZ via ONVIF
    • Configured ONVIF URL: http://192.168.0.53:2020/
  2. origin2000 commented on Nov 19, 2026

    @origin2000
    ContributorAuthor

    @matteius Thanks for fixing this bug. I apologize that I have only posted the bug and not offered to fix it. I still was in research mode on ONVIF specs to understand whether this is a requirement of the standard and the proposal would break this requirement. Obviously the fix then would have become a "feature" that admins need to enable/disable and would have affected the code itself plus needed a GUI part. Any ways thanks for the effort and I'm looking forward to the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions