Server security guide · Romania

What should I do if my server has been compromised?

The first reflex on spotting an unknown process is to power the server off and clean it up. Both are mistakes: shutting down destroys evidence held in memory, and cleaning almost always leaves a door open. Handle an incident in order, not in a hurry.

Updated:

Short answer

  1. Isolate the server first with firewall rules that block outbound traffic and leave only your own access, and do not power it off, so memory stays intact.
  2. Preserve evidence on storage outside the machine: a disk copy, process and connection lists and logs, each with checksums.
  3. Rotate every secret that ever touched that server: passwords, SSH and API keys, certificates and deploy tokens.
  4. Restore the application on a fresh server from a backup taken before the compromise, and analyse then reinstall the old one instead of cleaning it.
  5. Notify on time: DNSC within 24 hours if you are an entity under OUG 155/2024, ANSPDCP within 72 hours if personal data is affected, and file a criminal complaint with the police.
First action
isolate with the firewall, do not shut down
DNSC early warning (NIS2 entities)
24 hours from detection
ANSPDCP notification (data breach)
72 hours, GDPR Article 33
Where the app goes back
onto a new machine, from a verified backup

How to recognise a compromise, and why you do not power off

Typical signs: an innocuously named process eating CPU, outbound connections to unknown addresses, a new entry in crontab or authorized_keys, recently modified system files, a user account you did not create, missing logs. Do not power the server off, because memory holds the running processes, the connections and sometimes the intruder's keys. Isolate it instead: default deny on inbound and outbound traffic, with one exception for the address you investigate from.

Evidence, secrets and a clean rebuild

Copy the disk and compute a checksum; save the output of ps, ss and last along with copies of the logs. Only then rotate every secret, not just the one you think the intruder used: database passwords, API keys, CI tokens, certificates. Put the application back on a freshly installed server from a backup taken before the first trace of compromise, after patching the flaw that was used. Analyse the old server, then reinstall it.

  • A separate communication channel, not email hosted on the affected server
  • A written timeline from the first minute: time, action, who did it
  • A post-incident report within two weeks: cause, impact, measures

What Romanian law requires

If your company is an essential or important entity under OUG 155/2024 (the NIS2 transposition approved by Law 124/2025), report a significant incident to DNSC with an early warning in 24 hours, a notification in 72 hours and a final report a month later. If personal data is affected and individuals are at risk, notify ANSPDCP within 72 hours of becoming aware (GDPR Article 33) and tell the individuals when the risk is high (Article 34). File the criminal complaint with the police or prosecutor: illegal access, Article 360 of the Criminal Code, goes to the ordinary prosecutor, while DIICOT takes only Articles 361–365 or organised groups.

Notification deadlines after an incident in Romania
Who notifiesWhomDeadlineLegal basis
Essential or important entityDNSC, early warning24 hours from detectionOUG 155/2024 (NIS2)
Essential or important entityDNSC, incident notification72 hoursOUG 155/2024 (NIS2)
Essential or important entityDNSC, final reportone month after the 72-hour notification (or after the incident is handled)OUG 155/2024, Article 15(7)
Any personal-data controllerANSPDCP72 hours from becoming awareGDPR Article 33
Any controller, when the risk is highAffected individualswithout undue delayGDPR Article 34
Any injured partyPolice / prosecutor (DIICOT for Articles 361–365)as soon as possible, to preserve evidenceCriminal Code, Articles 360–366

Commands and configuration

Isolate the server, keeping only the address you investigate from
sudo ufw default deny incoming
sudo ufw default deny outgoing
sudo ufw allow from 203.0.113.10 to any port 22 proto tcp
sudo ufw enable
Collect the state before any change, onto storage outside the machine
# Evidence is NOT written to the compromised machine: mount an external volume
# (mount /dev/sdb1 /mnt/evidence) or run the commands from your investigation host,
# for example: ssh root@server 'ps auxf --sort=-%cpu' > ps.txt
mount /dev/sdb1 /mnt/evidence && cd /mnt/evidence
ps auxf --sort=-%cpu > ps.txt
ss -tunap > connections.txt
last -aF > logins.txt
for u in $(cut -d: -f1 /etc/passwd); do echo "== $u"; crontab -l -u "$u" 2>/dev/null; done > cron.txt
find / -xdev -type f -newermt "$(date -d '-14 days' +%F)" > modified.txt
find / -xdev -name authorized_keys -print -exec cat {} \; > keys.txt
sha256sum * > SUMS.sha256

Practical examples

E-commerce team in Cluj-Napoca spots odd outbound traffic

A monitoring dashboard showed a web server sending traffic to an unknown address. The team blocked outbound traffic, snapshotted the disk, rotated the database and payment credentials, then relaunched the shop on a clean VPS from the last backup that predated the first suspicious log line.

Transport company in Constanta, classed as an important entity

Ransomware encrypted the invoicing server. The early warning reached DNSC the same day, the full notification within 72 hours and the final report three weeks later. Restoring from the offline backup took one day.

Common mistakes

  • Powering the server off straight away and losing all the evidence in memory.
  • Killing the suspicious process, changing one password and declaring the incident closed without learning how the intruder got in.
  • Restoring the backup onto the same compromised server, on top of the backdoor left behind.
  • Delaying notification 'until we understand what happened', although the 24-hour and 72-hour clocks start when you become aware of the incident.

How 4hosting helps

  • SIEM & Incident Response brings a response plan, analysis of centralised logs and a post-incident report. You request it from the DevOps Services section of the client panel, within your included hours: 1–8 h a month on VPS, 5–10 h on dedicated servers (depending on plan), 10 h on GPU servers.
  • Hours are not carried over, and extra hours are accepted and billed separately. Before any intervention, keep a copy of the disk; the 4hosting team will tell you which options your plan offers.
  • Hardening & Compliance includes anti-ransomware backup, meaning a copy that the compromised server has no right to write to.

Related questions

  • Can I clean the server instead of reinstalling it?

    In practice, no. An attacker with root can replace binaries, kernel modules or systemd services with versions that look legitimate, and you cannot know what is left behind. Reinstalling from scratch and restoring the data is faster and the only real guarantee.

  • How do I find out since when the server has been compromised?

    From centralised logs, if you have them: the first abnormal login, the first suspicious request in nginx, the first file change. On the affected server, file dates and cron entries give a hint, but they can be forged. The backup you restore must predate that date.

  • Do I have to tell my customers?

    If their personal data was accessed and the risk to them is high, GDPR requires you to inform them directly and without delay. Even when it is not mandatory, a short and honest message costs less than the rumour, and you can leave out details that would help other attackers.

Request a security review

A production server starts getting attacked within minutes of receiving a public IP address, however small the project is. This guide ranks the controls by impact, from SSH access to incident response, with the Romanian rules that apply along the way. Every topic has its own page with a short answer, examples and ready-to-use configuration.