Skip to main content
Back to engineering notes

Engineering note

Preventing feedback loops in configurable gateways

Resolved endpoint validation for local loop prevention.

Networking / Endpoint validation

Local feedback risk

Configurable client and server roles allow the gateway to receive pushed streams or connect to remote feeds. They also permit an output connector to target a local input listener, creating a feedback path through message processing. Repeated circulation can exhaust resources and distort delivery telemetry.

The endpoint guard rejects conflicting local endpoints before connection establishment. Application routing policy separately determines which destinations may receive a processed message.

Endpoint comparison

A wildcard listener accepts traffic addressed to applicable local interfaces. Hostnames may resolve to those interfaces or to loopback. Validation therefore compares resolved addresses with listener bindings, rather than relying on configuration-string equality.

Destination approval

  1. Register listenersTrack the effective role, direction, transport, port and local binding.
  2. Resolve the destinationObtain candidate numeric addresses for this connection attempt.
  3. Check each candidateCompare the actual candidate with registered local listeners before opening its socket.
  4. Connect or rejectUse an approved numeric address; stop the attempt if the guard rejects it.
The local guard is separate from payload routing and release policy. A connection attempt also has a bounded deadline so a stalled address cannot consume an unlimited wait.

Synthetic loop configuration

In this synthetic example, an input listener binds to 0.0.0.0:42000. An output targets feed.example.test:42000, resolving to 127.0.0.1. The output can reach the local listener despite the different configured names, so the guard rejects the attempt.

Comparison includes effective direction, role, transport and port. Matching port numbers alone do not establish a feedback path. The addresses above are illustrative.

Resolution and connection lifecycle

DNS results can change after configuration validation. TCP destinations are approved immediately before socket creation, and reconnecting transports repeat resolution and validation. UDP senders pin the approved address for their active lifecycle.

TCP uses the approved numeric destination while retaining the configured hostname for TLS SNI and certificate name validation.

Listener registration and destination updates are synchronised to prevent concurrent activations validating against incomplete state. Registrations must be released during teardown and failed startup.

Protection scope

The guard covers local endpoint conflicts within one application instance. Remote relays, NAT mappings and other gateways require separate routing or network controls.

Changes to host interfaces require affected connections to be reopened so address validation reflects the current configuration.

Verification cases

  • Exercise loopback, local interface addresses and wildcard listeners.
  • Resolve a hostname to several candidates, including a local one.
  • Change the resolved destination between reconnect attempts.
  • Verify simultaneous activation and cleanup after failed startup.
  • Check that a legitimate remote endpoint remains usable.

Verification must cover both rejected feedback paths and permitted remote connections. Local endpoint validation does not establish the absence of loops elsewhere in the network.

Related reading: message direction and connection role and the networking rebuild.

Examples are generalised or synthetic and omit operational details and identifying information.

← All engineering notes