All ArticlesSecurity2026-11-18T19:11:18+08:00

Thinking Patched Credentials Mean the Breach Is Over? Check for Lateral Movement First

After resetting compromised credentials, teams often assume the incident is contained without checking if attackers already moved laterally to other systems. This article explains how to audit RDP logs, service accounts, and internal SSH keys to confirm no persistence remains beyond the initial access point.

A server gets compromised through a leaked credential. The team resets the password, patches the vulnerability, maybe rotates an API key or two, and closes the ticket. Incident contained, right? Not necessarily. A patch closes a software flaw. A password reset invalidates one credential. Neither action tells you whether the attacker already used that access to reach other systems on the network. If lateral movement happened before the reset, the attacker still has a foothold, and the "contained" incident is anything but.

This is one of the most common blind spots in incident response, especially in hosting and managed infrastructure environments where dozens of servers share internal networks, service accounts, and SSH trust relationships.

Why credential reset alone does not equal containment

The logic gap is straightforward. Between the moment an attacker gains access and the moment you discover and reset the compromised credential, time passes. Hours, days, sometimes weeks. During that window, a competent attacker does not sit idle on one machine. They enumerate the internal network, dump additional credentials from memory or config files, and pivot to other hosts.

As HKCERT noted in their analysis of internet-edge device compromises, patching alone cannot stop credential theft or persistent access. A patch fixes the door the attacker walked through. It does not evict the attacker from the rooms they already entered.

What typically gets overlooked after a credential reset:

  • SSH keys the attacker planted on other internal hosts
  • RDP sessions or cached credentials on Windows machines the attacker touched
  • Service account tokens or API keys harvested from config files, environment variables, or memory
  • New local user accounts created on adjacent systems
  • Modified authorized_keys files on servers that trust the compromised host

Until you check for these, you cannot call the incident contained.

Auditing SSH keys and trust relationships on Linux hosts

On Linux infrastructure, SSH key-based trust between servers is extremely common. Jump boxes, deployment pipelines, backup scripts, and monitoring agents all rely on key pairs. If an attacker lands on one host, the first thing they check is which other hosts this machine can reach without a password.

Start by identifying every authorized_keys file across your infrastructure. On each server:

# Find all authorized_keys files, including for service accounts
find / -name 'authorized_keys' -type f 2>/dev/null

Compare the keys listed in each file against your known inventory. Any key you do not recognize is a red flag. Pay special attention to:

  • Keys added to root's authorized_keys (/root/.ssh/authorized_keys)
  • Keys added to service accounts that normally do not accept interactive SSH (like www-data, mysql, backup)
  • Keys with unusual comments or no comment at all (legitimate keys typically have a user@host comment)

Also check the SSH daemon logs for authentication events from unexpected source IPs. On systems using journalctl:

# Review SSH authentication events from the past 7 days
journalctl -u sshd --since '7 days ago' | grep -i 'accepted\\|failed'

On older systems or those using traditional syslog, check /var/log/auth.log (Debian/Ubuntu) or /var/log/secure (CentOS/RHEL). Look for accepted logins from internal IPs that should not be initiating SSH connections to that host. A database server accepting SSH from a web server might be normal for your setup, or it might be lateral movement. You need your baseline to tell the difference.

Do not forget ~/.ssh/known_hosts on the compromised machine. This file reveals which hosts the attacker (or the attacker's tools) connected to from that machine. New entries added around the time of compromise deserve investigation.

Checking RDP logs and cached credentials on Windows

In mixed environments, Windows servers often sit alongside Linux hosts. RDP (Remote Desktop Protocol) is the primary lateral movement vector on Windows networks.

Windows Security Event Log records RDP logon events. The key Event IDs:

  • 4624 with Logon Type 10: successful RDP logon
  • 4625 with Logon Type 10: failed RDP logon attempt
  • 4648: logon attempted using explicit credentials (often indicates credential reuse or pass-the-hash)

On the compromised Windows host, open Event Viewer or use PowerShell:

# List successful RDP logons (Type 10) from the past 7 days
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4624; StartTime=(Get-Date).AddDays(-7)} |
  Where-Object { $_.Properties[8].Value -eq 10 } |
  Select-Object TimeCreated, @{N='SourceIP';E={_.Properties[18].Value}}, @{N='Account';E={_.Properties[5].Value}}

Look for logon events from the compromised account to other machines, and for logon events on the compromised machine from unexpected sources. Cross-reference timestamps with the estimated compromise window.

Cached credentials are another concern. Windows caches domain credentials locally by default (typically the last 10 logons, controlled by the CachedLogonsCount registry value). An attacker with local admin on one machine can extract these cached hashes and use them to authenticate to other systems. Resetting the originally compromised password does not invalidate cached hashes already sitting on other machines the attacker visited.

If your environment uses Active Directory, also check for:

  • New computer accounts or user accounts created during the compromise window
  • Group membership changes (especially additions to Domain Admins, Enterprise Admins, or local Administrators groups)
  • Kerberos ticket-granting ticket (TGT) requests from unusual hosts

Service accounts and API keys: the forgotten credentials

Service accounts are lateral movement gold. They typically have broad access, rarely get their passwords rotated, and often store credentials in plaintext config files. An attacker who reads a database connection string from a web app's config file now has credentials for the database server. Resetting the web app's compromised user password does nothing about that.

After a breach, audit every credential the compromised host had access to:

  • Database connection strings in application config files (.env, wp-config.php, settings.py, appsettings.json)
  • API keys and tokens stored in environment variables or config management
  • SMTP credentials used by the application to send email
  • Backup system credentials (rsync keys, S3 access keys, FTP passwords)
  • Control panel API tokens (cPanel, Plesk, or cloud provider API keys)

Every one of these needs rotation, not just the credential that was originally compromised. If the attacker had root or admin access on the host, assume they read everything on that filesystem.

This connects directly to what was covered in tracing spam sources through Exim after a breach — compromised SMTP credentials often get harvested and used from entirely different infrastructure, so the spam continues even after the original server is cleaned.

Building a lateral movement checklist that fits your environment

No single checklist works for every infrastructure. The right audit depends on what protocols your servers use internally, what trust relationships exist, and what logging you had enabled before the incident. But the general pattern holds:

  1. Map the blast radius. From the compromised host, list every system it could reach: SSH keys, stored credentials, network access. This is your list of hosts to investigate.

  2. Check authentication logs on every host in the blast radius. Look for logons from the compromised host or using the compromised account during the compromise window. On Linux, check SSH logs. On Windows, check Security Event Log for RDP and explicit credential logons.

  3. Audit key material and stored credentials. Compare authorized_keys files against known good state. Check for new local accounts. Identify every credential stored on the compromised host and rotate all of them.

  4. Look for persistence mechanisms. New cron jobs, systemd services, scheduled tasks, startup scripts, modified shell profiles (.bashrc, .profile). An attacker who moved laterally typically plants persistence on the new host too.

  5. Verify the timeline. Correlate filesystem timestamps (stat on Linux, $MFT analysis on Windows) with log entries. If you find a new SSH key on a second server and the creation timestamp falls within the compromise window, that server was touched.

The uncomfortable truth is that if logging was not enabled before the incident, some of these checks will come back inconclusive. That is still valuable information — it tells you where to improve monitoring for next time, and it tells you which systems you cannot confidently clear.

The real end of an incident

An incident is not over when the initial credential is reset. It is over when you have confirmed, with evidence from logs and filesystem artifacts, that the attacker did not establish access to any other system. If you cannot confirm that — because logs are missing, because the blast radius is too large to audit, or because you found evidence of lateral movement — the scope of the incident just expanded, and the response needs to expand with it.

Patching closes the vulnerability. Credential rotation locks the front door. But neither tells you whether someone is already inside the house. Check for lateral movement before you call it done.