Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

75%
+4 −0
Q&A How to detect if a Linux Docker host has had unwelcome guests?

You can't expect an attacker to abide by any particular rulebook. In fact, if they did, then the defenders' job would be so much easier. That's why attackers don't do it. Remember the adage: a de...

posted 3y ago by Canina‭  ·  edited 3y ago by Canina‭

Answer
#2: Post edited by user avatar Canina‭ · 2021-08-24T19:07:19Z (about 3 years ago)
  • You can't expect an attacker to abide by any particular rulebook.
  • In fact, if they did, then the defenders' job would be *so much easier*. That's why attackers don't do it.
  • Remember the adage: a defender has to defend against every possible attack everywhere, but an attacker only has to find one spot which is undefended from one attack in order to succeed.
  • Somewhere around 20 years ago, I had a Linux system compromised. I only realized that something was amiss when I saw an `..` entry in the output of `ls /dev` or something like that. Turned out that the attacker had dropped their stuff into a directory `/dev/.. /` (that's dot-dot-space). None of what you discuss would have caught that.
  • Modern attacks are *far* more sophisticated than that.
  • More generally, **you can't rely on a compromised system to tell you that it has been compromised.** An attacker that is in a position to tamper with files in `/bin`, or drop stuff into `/dev`, could just as well be poking around in `/lib` or modify `/sbin/init` in whatever manner they choose. And if they can cause changes to, say, anything in `/etc/systemd/system` or `/etc/ld.so.conf.d`, then really, *all* bets are off: they own the system and you are just along for the ride.
  • This leads to two main conclusions:
  • * Don't have a(n even potentially) vulnerable system push backups elsewhere. Any attacker who has penetrated that system can then directly affect the backups as well. Always *pull* backups onto a secured system, in the most restricted manner possible, *and* set up the backed-up host such that the backup server can't push files onto it. (The latter is often overlooked in suggestions online. With rsync over SSH, for example, you might want to restrict to `rsync --server --sender` on the backed-up host.)
  • * Don't try to guess what an attacker might do. Instead, assume that they will think of something that you haven't thought of, and monitor everything for changes *except* things that you *know* are legitimate changes. This is the approach taken by venerable tools such as logcheck and tripwire: instead of looking for specific hostile activity, assume that everything is at least potentially hostile unless you know that it's friendly.
  • Also, as somewhat of a corollary to the second point:
  • * Don't try to analyze on a system whether *that* system has been somehow compromised. While there might be clues that *something isn't quite right*, any moderately competently performed attack will make actual determination that an attack has occurred anywhere from difficult to impossible. You *have* to do such analysis on a system that you can *know* is not tampered with.
  • And, again an old adage:
  • * If you realize that the system has been compromised, *nuke it from orbit and reinstall from scratch from known good installation media*. It's the only way to be sure. If you restore from backups, then you absolutely must do so *selectively* and only after *careful analysis of what you are restoring* to ensure that you aren't reintroducing a backdoor for the attacker.
  • You can't expect an attacker to abide by any particular rulebook.
  • In fact, if they did, then the defenders' job would be *so much easier*. That's why attackers don't do it.
  • Remember the adage: a defender has to defend against every possible attack everywhere, but an attacker only has to find one spot which is undefended from one attack in order to succeed.
  • Somewhere around 20 years ago, I had a Linux system compromised. I only realized that something was amiss when I saw a `..` entry in the output of `ls /dev` or something like that. Turned out that the attacker had dropped their stuff into a directory `/dev/.. /` (that's dot-dot-space). None of what you discuss would have caught that.
  • Modern attacks are *far* more sophisticated than that.
  • More generally, **you can't rely on a compromised system to tell you that it has been compromised, precisely because it has been compromised.** An attacker that is in a position to tamper with files in `/bin`, or drop stuff into `/dev`, could just as well be poking around in `/lib` or modify `/sbin/init` in whatever manner they choose. And if they can cause changes to, say, anything in `/etc/systemd/system` or `/etc/ld.so.conf.d`, then really, *all* bets are off: they own the system and you are just along for the ride.
  • This leads to two main conclusions:
  • * Don't have a(n even potentially) vulnerable system push backups elsewhere. Any attacker who has penetrated that system can then directly affect the backups as well. Always *pull* backups onto a secured system, in the most restricted manner possible, *and* set up the backed-up host such that the backup server can't push files onto it. (The latter is often overlooked in suggestions online. With rsync over SSH, for example, you might want to restrict to `rsync --server --sender` on the backed-up host.)
  • * Don't try to guess what an attacker might do. Instead, assume that they will think of something that you haven't thought of, and monitor everything for changes *except* things that you *know* are legitimate changes. This is the approach taken by venerable tools such as logcheck and tripwire: instead of looking for specific hostile activity, assume that everything is at least potentially hostile unless you know that it's friendly.
  • Also, as somewhat of a corollary to the second point:
  • * Don't try to analyze on a system whether *that* system has been somehow compromised. While there might be clues that *something isn't quite right*, any moderately competently performed attack will make actual determination that an attack has occurred anywhere from difficult to impossible. You *have* to do such analysis on a system that you can *know* is not tampered with.
  • And, again an old adage:
  • * If you realize that the system has been compromised, *nuke it from orbit and reinstall from scratch from known good installation media*. It's the only way to be sure. If you restore from backups, then you absolutely must do so *selectively* and only after *careful analysis of what you are restoring* to ensure that you aren't reintroducing a backdoor for the attacker.
#1: Initial revision by user avatar Canina‭ · 2021-08-24T08:34:35Z (about 3 years ago)
You can't expect an attacker to abide by any particular rulebook.

In fact, if they did, then the defenders' job would be *so much easier*. That's why attackers don't do it.

Remember the adage: a defender has to defend against every possible attack everywhere, but an attacker only has to find one spot which is undefended from one attack in order to succeed.

Somewhere around 20 years ago, I had a Linux system compromised. I only realized that something was amiss when I saw an `..` entry in the output of `ls /dev` or something like that. Turned out that the attacker had dropped their stuff into a directory `/dev/.. /` (that's dot-dot-space). None of what you discuss would have caught that.

Modern attacks are *far* more sophisticated than that.

More generally, **you can't rely on a compromised system to tell you that it has been compromised.** An attacker that is in a position to tamper with files in `/bin`, or drop stuff into `/dev`, could just as well be poking around in `/lib` or modify `/sbin/init` in whatever manner they choose. And if they can cause changes to, say, anything in `/etc/systemd/system` or `/etc/ld.so.conf.d`, then really, *all* bets are off: they own the system and you are just along for the ride.

This leads to two main conclusions:

 * Don't have a(n even potentially) vulnerable system push backups elsewhere. Any attacker who has penetrated that system can then directly affect the backups as well. Always *pull* backups onto a secured system, in the most restricted manner possible, *and* set up the backed-up host such that the backup server can't push files onto it. (The latter is often overlooked in suggestions online. With rsync over SSH, for example, you might want to restrict to `rsync --server --sender` on the backed-up host.)

 * Don't try to guess what an attacker might do. Instead, assume that they will think of something that you haven't thought of, and monitor everything for changes *except* things that you *know* are legitimate changes. This is the approach taken by venerable tools such as logcheck and tripwire: instead of looking for specific hostile activity, assume that everything is at least potentially hostile unless you know that it's friendly.

Also, as somewhat of a corollary to the second point:

 * Don't try to analyze on a system whether *that* system has been somehow compromised. While there might be clues that *something isn't quite right*, any moderately competently performed attack will make actual determination that an attack has occurred anywhere from difficult to impossible. You *have* to do such analysis on a system that you can *know* is not tampered with.

And, again an old adage:

 * If you realize that the system has been compromised, *nuke it from orbit and reinstall from scratch from known good installation media*. It's the only way to be sure. If you restore from backups, then you absolutely must do so *selectively* and only after *careful analysis of what you are restoring* to ensure that you aren't reintroducing a backdoor for the attacker.