RetroFed Forum
Your home away from modern life.
A sneaky demonstration of the dangers of curl bash
Post Reply
AuthorMessage
axx slrpnk.net axx@slrpnk.net
Joined: 2024-09-19
#52 · Quote Reply

Anytime I see a project that had this in their install instructions, I don't use that project. It shows how dumb the devs are

Yes, this is the correct approach from a security perspective.

2
axx slrpnk.net axx@slrpnk.net
Joined: 2024-09-19
#53 · Quote Reply

Curl bash is no different than running an sh script you dont know manually…

No, it is different, as it adds an entire layer of indirection and unknown to the mix, increasing the risk in the process.

1
axx slrpnk.net axx@slrpnk.net
Joined: 2024-09-19
#54 · Quote Reply

Is it different from running a bash script you downloaded without checking it? E.g. the installer that you get with GOG games? Genuine question, I'm no expert.

It is, see https://github.com/m4tx/curl-bash-attack

2
deadbeef79000 lemmy.nz deadbeef79000@lemmy.nz
Joined: 2023-06-17
#55 · Quote Reply

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. Operation that takes a long time. Like a sleep, or if you want it less obvious. A download, an unzip operation, apt update, etc. Fill the buffer with more bash commands. Measure on the server if at some point curl stops downloading the script. Se...

Oh that is clever.

3
xylogx lemmy.world xylogx@lemmy.world
Joined: 2023-06-26
#56 · Quote Reply

No you cannot, the pub key either needs to be present on the updater or uses infrastructure that is not owned by you. Usually how most software suppliers are doing it the public key is supplied within the updater.

Not sure how else to explain this. Look at the CISA bulletin on Shai-Hulud the attacker published valid and signed binaries that were installed by hundreds of users.

"CISA is releasing this Alert to provide guidance in response to a widespread software supply chain compromise involving the world’s largest JavaScript registry, npmjs.com. A self-replicating worm—publicly known as “Shai-Hulud”—has compromised over 500 packages.[i]

After gaining initial access, the malicious cyber actor deployed malware that scanned the environment for sensitive credentials. The cyber actor then targeted GitHub Personal Access Tokens (PATs) and application programming interface (API) keys for cloud services, including Amazon Web Services (AWS), Google Cloud Platform (GCP), and Microsoft Azure.[ii]

The malware then:

  • Exfiltrated the harvested credentials to an endpoint controlled by the actor.
  • Uploaded the credentials to a public repository named Shai-Hulud via the GitHub/user/repos API.
  • Leveraged an automated process to rapidly spread by authenticating to the npm registry as the compromised developer, injecting code into other packages, and publishing compromised versions to the registry.[iii]"
1
Dave lemmy.nz Dave@lemmy.nz
Joined: 2023-06-02
#57 · Quote Reply

It is, see https://github.com/m4tx/curl-bash-attack

That's an interesting proof of concept, but I don't think it shows it's different. That's a server side attack, whoever has control of the server could just have the script download a malicious binary instead and you wouldn't be able to tell from the script.

1
ShortN0te lemmy.ml ShortN0te@lemmy.ml
Joined: 2023-06-09
#58 · Quote Reply

Not sure how else to explain this. Look at the CISA bulletin on Shai-Hulud the attacker published valid and signed binaries that were installed by hundreds of users. "CISA is releasing this Alert to provide guidance in response to a widespread software supply chain compromise involving the world’s largest JavaScript registry, npmjs.com. A self-replicating worm—publicly known as “Shai-Hulud”—has...

After gaining initial access, the malicious cyber actor deployed malware that scanned the environment for sensitive credentials.

So as I said, the keys got compromised. Thats what i said in the second post.

1
aeiou_ckr lemmy.world aeiou_ckr@lemmy.world
Joined: 2024-09-24
#59 · Quote Reply

This helped a lot. I had no clue I could post the curl string in the URL bar of a browser to view the script. Thanks for the education!

-2
MehBlah lemmy.world MehBlah@lemmy.world
Joined: 2024-04-16
#60 · Quote Reply

Never have I ever piped curl to bash.

7
It_Is1-24PM lemmy.world It_Is1_24PM@lemmy.world
Joined: 2023-07-31
#61 · Quote Reply

I never thought about opening it in a browser. I always used curl to download such a script and view it where it was supposed to be run.

2
xylogx lemmy.world xylogx@lemmy.world
Joined: 2023-06-26
#62 · Quote Reply

After gaining initial access, the malicious cyber actor deployed malware that scanned the environment for sensitive credentials. So as I said, the keys got compromised. Thats what i said in the second post.

What you said is the key infra needs to get compromise. I do not need to own the PKI that issued the certs, I just need the private key of the signer. And again, this is something that happens. A lot. A software publisher gets owned, then their account is used to distribute malware.

1
Nibodhika lemmy.world Nibodhika@lemmy.world
Joined: 2023-06-10
#63 · Quote Reply

This helped a lot. I had no clue I could post the curl string in the URL bar of a browser to view the script. Thanks for the education!

You didn't knew that the tool to handle URLs written in C (very creatively named C-Url) was handling URLs? It's also written in C if you didn't knew.

1
Nibodhika lemmy.world Nibodhika@lemmy.world
Joined: 2023-06-10
#64 · Quote Reply

Yes this has risks. At the same time anytime you run any piece of software you are facing the same risks, especially if that software is updated from the internet. Take a look at the NIST docs in software supply chain risks.

But those are two very different things, I can very easily give you a one liner using curl|bash that will compromise your system, to get the same level of compromise through a proper authenticated channel such as apt/pacman/etc you would need to compromise either their private keys and attack before they notice and change them or stick malicious code in an official package, either of those is orders of magnitude more difficult than writing a simple bash script.

3
ShortN0te lemmy.ml ShortN0te@lemmy.ml
Joined: 2023-06-09
#65 · Quote Reply

What you said is the key infra needs to get compromise. I do not need to own the PKI that issued the certs, I just need the private key of the signer. And again, this is something that happens. A lot. A software publisher gets owned, then their account is used to distribute malware.

To achieve a compromised update you either need to compromise the update infrastructure AND the key or the infratstructure AND exploit the local updater to accept the invalid or forged signature.

As i said, to compromise a signature checked update over the internet you need to compromise both, the distributing infrastructure AND the key. With just either one its not possible. (Ignoring flaws in the code ofc)

1
smeenz lemmy.nz smeenz@lemmy.nz
Joined: 2023-07-11
#66 · Quote Reply

This helped a lot. I had no clue I could post the curl string in the URL bar of a browser to view the script. Thanks for the education!

You had no idea you could paste a url into a browser's location bar ?

3
xylogx lemmy.world xylogx@lemmy.world
Joined: 2023-06-26
#67 · Quote Reply

But those are two very different things, I can very easily give you a one liner using curl|bash that will compromise your system, to get the same level of compromise through a proper authenticated channel such as apt/pacman/etc you would need to compromise either their private keys and attack before they notice and change them or stick malicious code in an official package, either of those is o...

I would feel more comfortable running curl bash from a trusted provider than doing apt get from an unknown software repo. What you are trying to do is establish trust in your supply chain, the delivery vehicle is less important.

1
xylogx lemmy.world xylogx@lemmy.world
Joined: 2023-06-26
#68 · Quote Reply

To achieve a compromised update you either need to compromise the update infrastructure AND the key or the infratstructure AND exploit the local updater to accept the invalid or forged signature. As i said, to compromise a signature checked update over the internet you need to compromise both, the distributing infrastructure AND the key. With just either one its not possible. (Ignoring flaws in...

Take a look at Shai Hulud. All the attacker had was the key.

1
floquant lemmy.dbzer0.com floquant@lemmy.dbzer0.com
Joined: 2024-05-31
#69 · Quote Reply

This helped a lot. I had no clue I could post the curl string in the URL bar of a browser to view the script. Thanks for the education!

Shit are URLs esoteric knowledge now?

1
BluescreenOfDeath lemmy.world BluescreenOfDeath@lemmy.world
Joined: 2024-06-16
#70 · Quote Reply

The reality is a lot of newcomers to Linux won't even understand the risks involved, it's run because that's what they're told or shown to do. That's what I did for pihole many years ago too, I'll admit

Users are blameless, I find the fault with the developers.

Asking users to pipe curl to bash because it's easier for the developer is just the developer being lazy, IMO.

Developers wouldn't get a free pass for taking lazy, insecure shortcuts in programming, I don't know why they should get a free pass on this.

2
Buddahriffic lemmy.world Buddahriffic@lemmy.world
Joined: 2023-06-30
#71 · Quote Reply

An alternative that will avoid the user agent trick is to curl | cat, which just prints the result of the first command to the console. curl >> filename.sh will write it to a script file that you can review and then mark executable and run if you deem it safe, which is safer than doing a curl | cat followed by a curl | bash (because it's still possible for the 2nd curl to return a different set of commands).

You can control the user agent with curl and spoof a browser's user agent for one fetch, then a second fetch using the normal curl user agent and compare the results to detect malicious urls in an automated way.

A command line analyzer tool would be nice for people who aren't as familiar with the commands (and to defeat obfuscation) and arguments, though I believe the problem is NP, so it won't likely ever be completely foolproof. Though maybe it can be if it is run in a sandbox to see what it does instead of just analyzed.

3
ShortN0te lemmy.ml ShortN0te@lemmy.ml
Joined: 2023-06-09
#72 · Quote Reply

Take a look at Shai Hulud. All the attacker had was the key.

Yes, the secrets to submit to the distribution system got compromised and therefore the system got compromised.

1
neidu3 sh.itjust.works neidu3@sh.itjust.works
Joined: 2024-11-03
#73 · (edited) Quote Reply

Running arbitrary text from the internet through an interpreter.. what could possibly go wrong.

I need to set up a website with

fork while 1

...Just so I can (try to) convince people to

curl | perl

it

...rhyme intended.

1
Nibodhika lemmy.world Nibodhika@lemmy.world
Joined: 2023-06-10
#74 · Quote Reply

I would feel more comfortable running curl bash from a trusted provider than doing apt get from an unknown software repo. What you are trying to do is establish trust in your supply chain, the delivery vehicle is less important.

But what is a trusted provider? How can you trust it? How sure are you that you're not being MitM? Have you fully manually verified that there's no funky flags in curl like -k, that the url is using SSL, that it's a correct url and not pointing at something malicious, etc, etc, etc. There are a lot of manual steps you must verify using this approach, whereas using a package manager all of them get checked automatically, plus some extra checks like hundreds of people validating the content is secure.

To do apt get from an unknown repo, you first need to convince the person to execute root commands they don't understand on their machine to add that unknown repo, if you can convice someone to run an unsafe command with root credentials then the machine is already compromised.

I get your point, random internet scripts are dangerous but random internet packages can also dangerous. But that's a false equivalence because there are lots of safeguards to the packages in the usual way people install them, but less than 0 safeguards to the curl|bash. In a similar manner, if this was a post talking about the dangers of fireworks and how you can blow yourself up using them your answer is "but someone can plant a bomb in the mall I go to, or steal the codes for a nuclear missile and blow me up anyways".

1
mlg lemmy.world mlg@lemmy.world
Joined: 2023-07-29
#75 · Quote Reply

Use our easy bash oneliner to install our software!

Looks inside script

if [ $(command -v apt-get) ]; then apt-get install app; else echo "Unsupported OS"

Still less annoying than trying to build something from source in which the dev claims has like 3 dependencies but in reality requires 500mb of random packages you've never even heard of, all while their build system doesn't do any pre comp checking so the build fails after a solid hours of compilation.

8
ssfckdt lemmy.blahaj.zone ssfckdt@lemmy.blahaj.zone
Joined: 2024-03-19
#76 · Quote Reply

I'm a bit lost with

a more cautious user might first paste the url into the address bar of their web browser to see what the script looks like before running it. In the

You... You just.... You just dump the curl output to file and examine that and then run it if its good

Just a weird imagined sequence to me.

2
martini1992 lemmy.ml martini1992@lemmy.ml
Joined: 2020-11-26
#77 · Quote Reply

I'm a bit lost with a more cautious user might first paste the url into the address bar of their web browser to see what the script looks like before running it. In the You... You just.... You just dump the curl output to file and examine that and then run it if its good Just a weird imagined sequence to me.

Worse than that, the server can change it's response based on user agent so you need to curl it to a file first, a browser could be served a completely different response.

2
K3CAN lemmy.radio K3can@lemmy.radio
Joined: 2023-06-21
#78 · Quote Reply

Worse than that, the server can change it's response based on user agent so you need to curl it to a file first, a browser could be served a completely different response.

Which is exactly what is demonstrated in the post. 🙃

3
aeiou_ckr lemmy.world aeiou_ckr@lemmy.world
Joined: 2024-09-24
#79 · Quote Reply

You had no idea you could paste a url into a browser's location bar ?

I wasn't looking to get roasted for not knowing something. Guess that teaches me something else. Fuck people and thanking them for Shar something I didn't know.

0
Mister_Hangman lemmy.world Mister_Hangman@lemmy.world
Joined: 2023-07-06
#80 · Quote Reply

Thanks! I like to keep things simple. The colors are based on Counter Strike 1.6. 😁 And if you're into the classic styling, my homepage is a direct homage to my old 2000s sites.

Hahahaha noticed this too. 1.5 was where it was at tho

1
smeenz lemmy.nz smeenz@lemmy.nz
Joined: 2023-07-11
#81 · Quote Reply

I wasn't looking to get roasted for not knowing something. Guess that teaches me something else. Fuck people and thanking them for Shar something I didn't know.

I think the general response is from confusion over what you could possibly have been using the url bar for in your browser if you didn't know you could put urls there.

1
Post Reply Page 2 of 2   Goto page « First 1, 2
Back to top