Live data from Hacker News

Acme.sh runs arbitrary commands from a remote server

github.com

41–50 of 71 posts

Re: Acme.sh runs arbitrary commands from a remote server

#41

Earlier quoted context omitted.

Shell is a bad fit for many uses (an ACME client is more ambitious than I would build in shell, personally), but the things it's good at, it's really good at. I have yet to find anything else that's even close to as good for glue code when I have a handful of tools and/or a bunch of files that I need to string together. Unless you're writing in Ada, I promise whatever language you think is better has its own sharp ed…

I usually replace shell scripts with python (using sh module: https://amoffat.github.io/sh/ for calling other scripts/programs).

Golang is better suited for this, for my needs at least.

Re: Acme.sh runs arbitrary commands from a remote server

#42

This means that acme.sh has an RCE. Once the patch is in I'm rotating all my certs, even though I use ZeroSSL. I do wonder if what HiCA did gave possibilities to post the private key somewhere else?

If the executed script transmits the key, then yes. (But the script we observed does not.)

Re: Acme.sh runs arbitrary commands from a remote server

#43

Earlier quoted context omitted.

I usually replace shell scripts with python (using sh module: https://amoffat.github.io/sh/ for calling other scripts/programs).

Golang is better suited for this, for my needs at least.

Yeah, lego-acme is a solid alternative.

https://github.com/go-acme/lego

Re: Acme.sh runs arbitrary commands from a remote server

#44

Sounds about par for the course for folks that think shell is a productively sustainable way of writing secure or reliable software. Not even remotely sorry about that opinion. The gall to claim ACME compat, then force require a single client, all so you can remote execute arbitrary commands. Should be enough to ruin the CA, but we know how people handle things like this "oh, won't affect me " (until it does). Seemin…

There is almost never a good reason to use constructs like eval in any language (and it exists in many languages), just like there are barely any good reasons to use constructs like system() in C. It appears acme.sh was running eval. I haven't looked into it, but the most common reason I see eval in use is because people don't know that you do it much simpler/more directly by just geting the shell to run commands that are variables with no issue, e.g., `doit() { printf "running: %s\\n" "$*" ; "$@" ; } ; doit ls /` which works in POSIX sh, no bashisms. (Obviously you should only call it with at least the first argument being trusted)

But shell is really not hard if people stick to a few easy guidelines:

- quote all var expansion, e.g., "$var" not $var or ${var} (very rare to need otherwise, and never for untrusted data)

- use "$@" to perfectly forward arguments (not $@, not $*, not "$*" except when you want to turn many arguments into one)

- don't use eval

- use `set -eu` and explicitly handle functions/commands that may benignly return/exit non-zero, e.g., `diff -U10 ./a ./b || true`

- use printf on untrusted strings instead of echo (just use it generally, I say), e.g., printf %s\\n "$var" instead of echo "$var". One of the few times you want to use "$*" is with printf though, e.g., printf %s\\n "$*" instead of echo "$@". Try them out, easy to see why, as with one thing to format and multiple arguments, `printf %s\\n "$@"` is equivalent to `for i in "$@" ; do printf %s\\n "$i" ; done`

- when using xargs, use -0 if available, or at least -d\\n if available (busybox doesn't have it for example). also usually want to use -r

Re: Acme.sh runs arbitrary commands from a remote server

#45

Earlier quoted context omitted.

Golang is better suited for this, for my needs at least.

Yeah, lego-acme is a solid alternative. https://github.com/go-acme/lego

Er, are we comparing ACME clients or shell alternatives?

Re: Acme.sh runs arbitrary commands from a remote server

#46
post #40

Earlier quoted context omitted.

I usually replace shell scripts with python (using sh module: https://amoffat.github.io/sh/ for calling other scripts/programs).

yeah until your scripts stop running someday because python...

Can you elaborate?

Re: Acme.sh runs arbitrary commands from a remote server

#47
post #40

Earlier quoted context omitted.

yeah until your scripts stop running someday because python...

Can you elaborate?

Python scripts will often break with system upgrades, most acutely when Python2 went away, but under many other circumstances as well.

Re: Acme.sh runs arbitrary commands from a remote server

#48

Sounds about par for the course for folks that think shell is a productively sustainable way of writing secure or reliable software. Not even remotely sorry about that opinion. The gall to claim ACME compat, then force require a single client, all so you can remote execute arbitrary commands. Should be enough to ruin the CA, but we know how people handle things like this "oh, won't affect me " (until it does). Seemin…

How did we get here?

- The barrier to entry for shell scripting is tiny. You basically start with `ls` in an interactive shell and end up writing a frickin' 500-line monstrosity within a month.

- POSIX has fossilised scripting languages. I hoped we'd have something like PowerShell by now, but although we have some fine alternatives, none of them seem to be good enough to actually overcome the inertia of POSIX.

- Doing something that looks correct is easy, but doing the right thing is super effing hard. See looping through complex sets of files.

- People use statements like "It's just a script", as if scripts are somehow easy to write. Bullshit.

Re: Acme.sh runs arbitrary commands from a remote server

#49
post #47

Earlier quoted context omitted.

Can you elaborate?

Python scripts will often break with system upgrades, most acutely when Python2 went away, but under many other circumstances as well.

I would expect python2 to only have gone away across major versions of an OS, which is about as non-disruptive as it could have been, considering.

Of course, as I write this ansible is broken on one of my machines for reasons that appear to stem from a python 3.x->3.y update, so...

Re: Acme.sh runs arbitrary commands from a remote server

#50

Major props and thanks to the HiCA person for engaging on the thread even though they were getting hammered. Yes they made some really (damn clever but) bad implementation decisions to use an RCE in the client to basically hack around the entire system, and then compounded it with other bad decisions to redirect to the US White House website to stop a DDoS, but the fact that they engaged, admitted, and explained what…

But... HiCA just disappeared. Their site is gone now.
Post reply on HN