Writing

Remote-session auditing: why an IP address needs a timestamp

How I connected RDP, SSH, and VPN context without turning a network address into identity

7 min read
Infrastructure Technical article
rdpsshvpnauditingtemporal correlationobservabilityincident responseidentitypythonpowershell

A record containing an account, server, and timestamp is useful. During an investigation, however, it often leaves the harder question unanswered: where did the access actually originate?

The obvious next step is to inspect the source IP. But in networks with DHCP, VPNs, NAT, and address reuse, asking who owns that address now does not establish who used it at the time of the event. Confusing those questions can turn a plausible-looking audit result into a false attribution.

That constraint shaped the evolution of an RDP session monitor into a common remote-access domain with RDP and SSH collectors, central persistence, temporal origin resolution, and a later VPN-monitor integration. The production backend and infrastructure are private; this article describes the engineering model without corporate identifiers or proprietary code.

Four entities that should remain separate

Before building an audit trail, I separated the questions each evidence source can answer:

EntityWhat it establishesWhat it does not establish alone
RDP or SSH sessionAccount activity on a host during an intervalWho physically operated the source
Observed source IPAddress seen by the destination hostPermanent identity of a device
DeviceAsset associated with network and inventory evidenceWhether its owner was the session user
VPN sessionNetwork context assigned to VPN credentials during an intervalWhether the VPN account equals the Windows/Linux account

This matters especially for third-party access: tunnel credentials and destination-system credentials may intentionally differ. Correlation connects events and intervals, not arbitrary user identities.

Capture the session fact first

The Windows collector uses complementary sources. Event Log records transitions such as LOGON, DISCONNECT, RECONNECT, and LOGOFF. The WTS API exposes currently observed sessions and helps reconcile missed events. Neither source, by itself, is an infallible complete history.

Linux poses a different challenge: OpenSSH and journald provide authentication evidence, while systemd-logind represents persistent sessions. An Accepted log line is not necessarily a unique logical session, and very short-lived sessions may open and close between state polls.

The collectors therefore retain checkpoints and a durable local spool. The conceptual sequence is:

Reliable event delivery and ACK checkpoint
01 ObserveCollect the remote-session event.
02 Persist locallySave durable evidence before network transmission.
03 TransmitSend the stored event to the receiver.
04 Receive ACKAcknowledge accepted delivery explicitly.
05 Advance checkpointMove the collection cursor only after the ACK.

Retries are expected. The central API must be idempotent and reconcile snapshots rather than counting a retransmission as a separate access. The order matters: establish the session fact first, then resolve its context.

The collectors have public implementations: RDP Session Agent and SSH Session Agent. The Remote Session API has a sanitized public project page, but its production repository is private.

Network identity includes time

A conceptual resolver lookup should not use source_ip alone. It needs:

(source_ip, observed_at)

Consider a fictional example. At 09:10, device A holds a network address. That lease ends later, and device B receives the same address. A session observed at 09:12 cannot be attributed to device B using an end-of-day inventory snapshot.

Resolution requires evidence whose validity interval covers the observed instant. With one sufficient eligible association, the result can be MATCHED. With multiple plausible overlapping candidates, it is AMBIGUOUS. With insufficient evidence, it is UNRESOLVED.

OutcomeOperational meaningSafe behavior
MATCHEDAvailable evidence supports an associationDisplay the link with provenance
AMBIGUOUSMultiple candidates are plausibleDo not choose arbitrarily
UNRESOLVEDNo sufficient temporal evidence existsPreserve the session without attribution
Resolver failureThe lookup could not be completedRecord the failure and retry when appropriate

The final row is not another identity outcome. It is a processing state. A timeout may justify bounded retries; a completed inconclusive response should not trigger endless retries in search of a preferred answer.

VPN is network context, not another remote-session protocol

Adding VPN introduced a second temporal authority. A VPN connection may exist without RDP or SSH, and a remote session may occur without a VPN.

The architecture preserves the domains:

Temporal attribution with independent VPN and device paths
01 RDP / SSH AgentCollects a remote-session observation.
02 Persisted session eventStores event time and source evidence.
03 Asynchronous correlation jobChecks an evidence window instead of current IP ownership.
04 Source contextClassifies which resolver applies.
05A · VPN VPN temporal resolverMatches sessions active during the observation interval.
05B · Other Device temporal resolverCorrelates non-VPN sources with historical device evidence.
06 Session historyStores matched, ambiguous, or unresolved attribution with source evidence.

Addresses belonging to the VPN context are resolved by that authority. If no valid session is found, the system does not consult an unrelated source to manufacture a device association. Avoiding that fallback keeps two different authorities from being treated as interchangeable.

A VPN session may relate to zero, one, or several RDP/SSH sessions. The UI can navigate in both directions, but it must not claim that the tunnel account equals the operating-system account.

Correlate after ingestion

Looking up the origin before accepting each event may seem convenient, but it creates a critical dependency: a VPN or inventory outage would interrupt the session-audit pipeline itself.

I separated two paths:

  1. Critical ingestion: authenticated, durable, idempotent, and able to acknowledge a collector.
  2. Eventual enrichment: an independent worker queries the temporal authority, attaches supported evidence, or records an unavailable lookup.

This preserves session facts even when correlation is delayed. It also gives operators useful health measures: queue age, pending jobs, resolver latency, and outcome distribution.

Historical evidence must survive DHCP changes

Another decision was to preserve the evidence that supported each completed correlation. Without that snapshot, a historical report could silently change weeks later as DHCP leases, VPN assignments, or inventory records evolved.

Freezing evidence does not make it perfect. Clock skew, missing observations, and source reliability still matter. Its value is explainability: an analyst can inspect what was known when the association was produced without depending solely on today’s network state.

Later corrections should be explicit and auditable, not invisible replacements of the earlier conclusion.

Validation without manufactured events

The RDP/SSH foundation was tested with real collectors and queries, including session capture and state reconciliation. Device resolution was validated against address changes over time, specifically to avoid static IP-to-device matching.

The VPN integration progressed through technical phases covering temporal resolution, provider routing, credential separation, session relationships, cross-navigation, and metrics. Those checkpoints were completed, but the latest execution report reviewed still required a controlled pilot with representative real-world activity: a VPN session without remote access, another with RDP/SSH, and disconnect/reconnect scenarios. I am not presenting that remaining evidence gate as completed acceptance.

A useful practice is to test failure paths without inserting fabricated production audit events. Controlled resolver lookups can validate authority routing while keeping the event history restricted to observed facts.

Security, privacy, and limits

Remote-access monitoring should be explicit about its collection boundary. Here the scope is session metadata, observable origin, lifecycle, and correlation provenance. It is not screen recording, terminal content, executed commands, clipboard capture, or password collection.

Collectors send data to an authenticated service; consumers receive read permissions separated from ingestion credentials. History access control, proportionate retention, secret-free logs, and synchronized clocks remain operational requirements.

The principal epistemic limit is that network correlation is not definitive personal attribution. NAT, shared accounts, reused sessions, incomplete sources, and clock drift are still hypotheses an investigation must consider.

Lessons for defensive engineering

The most valuable outcome was not another dashboard column. It was a system designed to explain what it knows, why it knows it, and what it cannot infer.

  • Persisting facts before enrichment keeps the audit trail available through outages.
  • Separating VPN and device authorities prevents guess-based identity.
  • Accepting ambiguity as a valid outcome reduces false positives.
  • Preserving temporal evidence makes history auditable even as the network evolves.
  • Validating each phase without exaggerating coverage is more useful than claiming universal attribution.

The same principles apply to incident response, endpoint telemetry, and any system that combines logs from multiple sources: a relationship is reliable only when its time, provenance, and degree of certainty are explicit.