this post was submitted on 23 Feb 2026
169 points (98.3% liked)

Selfhosted

60861 readers
520 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

Detailed Rules Post

  1. Be civil.

  2. No spam.

  3. Posts are to be related to self-hosting.

  4. Don't duplicate the full text of your blog or readme if you're providing a link.

  5. Submission headline should match the article title.

  6. No trolling.

  7. Promotion posts require active participation, with an account that is at least 30 days old. F/LOSS without a paywall has exceptions, with requirements. See the rules link for details. Tags [CBH] or [AIP] are required, see the links in Rule 8 for details.

  8. AI-related discussions and AI-involved promotional posts have additional requirements for tagging, as noted in Rule 7 and the AI & Promotional Post Expanded Rules post, and find example disclosures here.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 3 years ago
MODERATORS
 

I set up a quick demonstration to show risks of curl|bash and how a bad-actor could potentially hide a malicious script that appears safe.

It's nothing new or groundbreaking, but I figure it never hurts to have another reminder.

you are viewing a single comment's thread
view the rest of the comments
[–] wildbus8979@sh.itjust.works 30 points 4 months ago (3 children)

And you better inspect and execute a downloaded copy, because a malicious actor can serve a different file for curl/wget than to your browser

[–] Flipper@feddit.org 20 points 4 months ago (2 children)

They can even serve a different file for curl vs curl|bash

[–] wildbus8979@sh.itjust.works 8 points 4 months ago

Yeah that do, I remember that the demo was pretty impressive ten fifteen years ago!

[–] deadbeef79000@lemmy.nz 7 points 4 months ago (2 children)

Does curl send a different useragent when it's piped?

Searching for those words just vomits 'hOW to SeT cUrL's UseRaGenT' blog spam.

[–] Flipper@feddit.org 20 points 4 months ago* (last edited 4 months ago) (1 children)

Its timing based. When piped a script, bash executes each line completly before taking the next line from the input. Curl has a limited output buffer.

  1. Operation that takes a long time. Like a sleep, or if you want it less obvious. A download, an unzip operation, apt update, etc.
  2. Fill the buffer with more bash commands.
  3. Measure on the server if at some point curl stops downloading the script.
  4. Serve a malicious payload.
[–] deadbeef79000@lemmy.nz 3 points 4 months ago

Oh that is clever.

[–] qupada@fedia.io 5 points 4 months ago

Not that I know of, which means I can only assume it'll be a timing-based attack.

With strategic use of sleep statements in the script you should stand a pretty good chance of detecting the HTTP download blocking while the script execution is paused.

If you were already shipping the kind of script that unpacks a binary payload from the tail end of the file and executes it, it's well within the realm of possibility to swap it for a different one.

[–] K3can@lemmy.radio 9 points 4 months ago* (last edited 4 months ago)

Yep! That's what the post shows.

I created a live demo file, too, so that you can actually see the difference based on how you request the file.

[–] csm10495@sh.itjust.works 1 points 4 months ago

Hit the nail on the head. Download the file, inspect, then run that local copy.