News for hackers. Stuff that matters.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by ghotli on Friday September 08, 2023 @05:40PM (#37439753)
Worth mentioning that statically linked binaries prevent this attack vector. I won't weigh in on dynamic vs static in general but if you're shipping something you don't want fiddled with then maybe dynamic linking isn't what you're looking for.

My favorite nasty hack along these lines was to inject a new implementation of gethostname via LD_PRELOAD as the simplest path to prevent a CI server from surfacing a hostname in a place it shouldn't be.

Re:Using LD_PRELOAD to cheat, inject features and investigat... by klysm on Friday September 08, 2023 @05:47PM (#37439802)
I think this is a great entrypoint into the static/dynamic argument and I'd love to argue with some people about it. I believe dynamic used to make sense but no longer does in the vast majority of cases. Static binaries have their costs, but are so much easier to reason about.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by kreetx on Friday September 08, 2023 @06:01PM (#37439913)
If dynamic libraries are compatible to what they did (when you developed the program) then why waste disk and RAM?
Re:Using LD_PRELOAD to cheat, inject features and investigat... by aidenn0 on Friday September 08, 2023 @06:05PM (#37439943)
Because disk and RAM are cheap and that's a huge "If"
Re:Using LD_PRELOAD to cheat, inject features and investigat... by jonhohle on Friday September 08, 2023 @08:29PM (#37440986)
There’s also other security considerations. As an operator or builder, do you want to patch a library (say OpenSSL) to keep your system up to date or patch every binary. If changing a dependency requires rebuilding all consumers recursively, the there’s not a huge benefit.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by aidenn0 on Friday September 08, 2023 @10:55PM (#37441789)
I think in the specific case of security issues, more bugs have been fixed by upgrading dynamic dependencies than introduced. That's just my gut feeling though, and I'd like to see data.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by rewmie on Saturday September 09, 2023 @06:56AM (#37443988)
> I think in the specific case of security issues, more bugs have been fixed by upgrading dynamic dependencies than introduced.

That's just your personal assertion, which is entirely baseless and unsubstantiated. It's ok to have beliefs, but instead of pushing them as truths you should at least start by doing some cursory research to see if they are even plausible. And yours isn't.

Re:Using LD_PRELOAD to cheat, inject features and investigat... by klysm on Saturday September 09, 2023 @08:33AM (#37444584)
He qualified it saying it was a hunch… I don’t see where he pushed it as a truth
Re:Using LD_PRELOAD to cheat, inject features and investigat... by aidenn0 on Saturday September 09, 2023 @07:17PM (#37451258)
It's not entirely unsubstantiated, as my experience is that the former is very common. The latter is much harder to observe though, so it's just an impression.

I'm very interested in your assertion that my impression is implausible though. What evidence do you have?

Re:Using LD_PRELOAD to cheat, inject features and investigat... by selfhoster11 on Saturday September 09, 2023 @03:51AM (#37443174)
Only cheap if you're running on huge servers. End user machines and edge compute are more constrained, so one needs to be more polite with resource use there.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by kreetx on Saturday September 09, 2023 @08:12AM (#37444424)
It seems to me that deploying a static binary is for situations where one doesn't have control over the underlying system, or where shipping dependencies hasn't been solved, i.e, you just want to ship one binary.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by klysm on Saturday September 09, 2023 @08:32AM (#37444575)
Shipping one binary is much easier and I don’t even want to solve the problem of shipping deps as separate artifacts
Re:Using LD_PRELOAD to cheat, inject features and investigat... by o11c on Friday September 08, 2023 @07:41PM (#37440651)
This is a really silly entrypoint into the static/dynamic argument. Static linking does not protect anything here, only makes it harder for developers.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by semi on Saturday September 09, 2023 @09:22AM (#37445061)
They each have tradeoffs even only considering security.

Consider a situation in which there is a new vulnerability in openssl. you can treat this as a hypothetical question or just.. remember any of your past experiences of any of the many openssl vulns.

How many binaries on your server use the vulnerable version? If all binaries are dynamically linked you can answer this fairly trivially with a shell script to enumerate binaries, pass them to ldd, and a little grepping. If all of your binaries are statically linked what do you do? Ideally pull the build info from your build server that shows you every version of everything that went into the binary.. which is data that just doesn't exist for most people

Maybe you scan the binaries to do some kind of signature analysis... but I would not be confident in the results not having false positives and false negatives.

Now let's patch it. How quickly can you recompile every static binary on your server? Can you even easily cut new builds of these existing versions but with a small patch increment or will your dev teams just rush a new release of any changes they're working on?

or with dynamically libraries, you update the library on your server and be done with it

... or so you thought. you didn't check what processed were running with the old library still open in memory and restart them so you're still vulnerable :)

Re:Using LD_PRELOAD to cheat, inject features and investigat... by rewmie on Saturday September 09, 2023 @06:53AM (#37443965)
> I think this is a great entrypoint into the static/dynamic argument and I'd love to argue with some people about it.

I don't think it is. You start from an irrational and unsubstantiated belief that ignores any of the basic usecases of shared libraries.

> I believe dynamic used to make sense but no longer does in the vast majority of cases.

It's your personal belief, and one that's unsubstantiated and os based on ignorance.

> Static binaries have their costs, but are so much easier to reason about.

That assertion is completely irrelevant, as it fails to address any of the usecases for shared libraries. Being able to run code, and other dubious claims of simplicity, don't even qualify as questioning the purpose of shared libraries.

Re:Using LD_PRELOAD to cheat, inject features and investigat... by klysm on Saturday September 09, 2023 @08:17AM (#37444453)
Static binaries are easier to reason about. You’ve provided no evidence to the contrary.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by vhcr on Friday September 08, 2023 @06:45PM (#37440252)
If you're shipping something you don't want fiddled with, don't ship it, because it's an impossible task.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by ghotli on Friday September 08, 2023 @07:07PM (#37440405)
Sure. We agree. Cat and mouse. Can you help me understand what value you're adding to the discussion though? Low hanging fruit arguments based on semantics might be best suited elsewhere
Re:Using LD_PRELOAD to cheat, inject features and investigat... by ed_mercer on Friday September 08, 2023 @07:53PM (#37440768)
He/she is mentioning that an obtained client can always be hacked, no matter what, and the reader of the original comment may not realize that.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by sosodev on Friday September 08, 2023 @07:57PM (#37440794)
I think the vast majority of HN users would realize that. Is it important for the few that don’t? Perhaps
Re:Using LD_PRELOAD to cheat, inject features and investigat... by GreymanTheGrey on Friday September 08, 2023 @10:43PM (#37441709)
The original commenter clearly didn't understand it, since they asserted that "statically linked libraries prevent this attack vector".

Which is unambiguously not the case, they merely slow it down by a small margin.

Re:Using LD_PRELOAD to cheat, inject features and investigat... by LoganDark on Friday September 08, 2023 @11:05PM (#37441849)
LD_PRELOAD is the specific attack vector that is prevented by static linking. They made no claim that static linking prevents all forms of tampering.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by arp242 on Friday September 08, 2023 @11:43PM (#37442067)
It's a true statement; LD_PRELOAD cannot be used with statically linked binaries. You can "fiddle" in other ways, but not by using the LD_PRELOAD attack vector (although personally I wouldn't call it an "attack vector", although in some cases it could be where you can upload a malicious file and control the environment of another program somehow, or something along those lines).
Re:Using LD_PRELOAD to cheat, inject features and investigat... by alex_smart on Saturday September 09, 2023 @03:02AM (#37442925)
>Which is unambiguously not the case, they merely slow it down by a small margin.

When you are using shared libaries, it is fairly trivial to hook into the library calls and replace them with whatever you want. When you are using static libraries, the linker and optimizer could for example inline the machine code directly in the application code. What tools do you have to do similar tricks with statically compiled binaries?

Re:Using LD_PRELOAD to cheat, inject features and investigat... by KeplerBoy on Saturday September 09, 2023 @04:56AM (#37443458)
messing with executable binaries is undoubtedly harder but not impossible.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by rewmie on Saturday September 09, 2023 @06:27AM (#37443853)
> He/she is mentioning that an obtained client can always be hacked, no matter what, and the reader of the original comment may not realize that.

That pointless remark misses the whole point. Even though ideally an attack vector would be eliminated, it's already good enough if it becomes unexploitable by the vast majority of potential attackers. That's why there is a whole field called "app hardening" as in a sliding scale instead of "perfect app protection".

Re:Using LD_PRELOAD to cheat, inject features and investigat... by SkyPuncher on Saturday September 09, 2023 @01:25AM (#37442534)
I guess the entire world of online multiplayer games becomes hacker haven.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by themoonisachees on Saturday September 09, 2023 @04:45AM (#37443410)
Well, it is. Most popular online games have a large amount of cheaters.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by KeplerBoy on Saturday September 09, 2023 @04:54AM (#37443452)
That's a big selling point of cloud gaming.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by praash on Saturday September 09, 2023 @07:15AM (#37444084)
Even that can't prevent computer vision with a robot mouse.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by josephcsible on Friday September 08, 2023 @09:25PM (#37441270)
This is not an attack vector and not something programs should try to protect against. If attackers have control to the point that they can run a program with LD_PRELOAD, they've already won.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by ghotli on Friday September 08, 2023 @09:32PM (#37441303)
Won on that node, agreed. I suppose I meant the 'investigate programs' part of the title and if that aids in garnering info for attacking something it interacts with.

But of course it's all splitting hairs. A sufficiently dedicated / motivated / funded person can investigate even the most hardened static position independent binary. Dynamic linking with LD_PRELOAD is like propping the front door open in comparison.

Re:Using LD_PRELOAD to cheat, inject features and investigat... by yonatan8070 on Saturday September 09, 2023 @12:37AM (#37442340)
There are cases where developers need to protect software from a local user with root access, like DRM related software, games that want to defend against pirates, etc.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by ronsor on Saturday September 09, 2023 @12:51AM (#37442398)
That's more of a want than a need.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by josephcsible on Saturday September 09, 2023 @01:16AM (#37442500)
Those use cases are inherently evil, and the rest of us should go out of our way to make them impossible, or at least as difficult as possible. A local user with root access should always have full control over everything, regardless of the wishes of any hardware manufacturers or software developers.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by saagarjha on Saturday September 09, 2023 @05:12PM (#37450335)
This would not help with that goal.
Re:Using LD_PRELOAD to cheat, inject features and investigat... by userbinator on Friday September 08, 2023 @10:18PM (#37441565)
to prevent a CI server from surfacing a hostname in a place it shouldn't be

I had to deal with the same problem a few years ago, and used the exact same solution.