# XSS via ACME implementations

**URL:** <https://community.letsencrypt.org/t/xss-via-acme-implementations/72295>\
**Category:** Issuance Tech\
**Created:** [September 15, 2018, 12:50pm UTC](https://community.letsencrypt.org/t/xss-via-acme-implementations/72295 "2018-09-15T12:50:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hannob](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/hannob/32/22157_2.png) [@hannob](https://community.letsencrypt.org/u/hannob)\
**Post date:** [September 15, 2018, 12:50pm UTC](https://community.letsencrypt.org/t/xss-via-acme-implementations/72295/1 "2018-09-15T12:50:37Z")

</div>

I wanted to point out a blog post by the company Detectify (same people that found a vuln in the SNI validation a while ago, but a different issue):  
[https://labs.detectify.com/2018/09/04/xss-using-quirky-implementations-of-acme-http-01/](https://labs.detectify.com/2018/09/04/xss-using-quirky-implementations-of-acme-http-01/)

They found that some implementations of ACME enable cross site scripting. In the http-01 domain validation method the CA server sends the requester a token and then the server should serve the token concatenated with an account public key hash in a file named after the token.

It turns out some implementations do this in a way that they don’t really care about the token, but always reflect whatever you request under the corresponding url (/.well-known/acme-challenge/token). In some setups this is combined with content sniffing, which enables cross site scripting (i.e. if you reflect html content it will be served as text/html).

I discussed this recently with Frans Rosén (one of the finders) and we wondered if there’s some ACME implementation out there that has this behavior or if those hosters all came up with this on their own.

There are a lot of ACME implementations, but maybe someone here is aware of an implementation that might have this behavior. Would be interesting, because then we could fix this at the source and stop it from proliferating.

---

<div class="post-metadata">

**Author:** ![felixf](https://avatars.discourse-cdn.com/v4/letter/f/fbc32d/32.png) [@felixf](https://community.letsencrypt.org/u/felixf)\
**Post date:** [September 15, 2018, 1:18pm UTC](https://community.letsencrypt.org/t/xss-via-acme-implementations/72295/2 "2018-09-15T13:18:49Z")

</div>

You might also be interested in this discussion: [Is .well-known/acme-challenge/ an XSS risk](https://community.letsencrypt.org/t/is-well-known-acme-challenge-an-xss-risk/68349)

---

<div class="post-metadata">

**Author:** ![JuergenAuer](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/juergenauer/32/26491_2.png) [@JuergenAuer](https://community.letsencrypt.org/u/JuergenAuer)\
**Post date:** [September 15, 2018, 1:21pm UTC](https://community.letsencrypt.org/t/xss-via-acme-implementations/72295/3 "2018-09-15T13:21:25Z")

</div>

Hi @hannob

> [@hannob](#):
>
> It turns out some implementations do this in a way that they don’t really care about the token, but always reflect whatever you request under the corresponding url (/.well-known/acme-challenge/token).

thanks. This is really not a good idea. My own client sends a 404, if the token is wrong.

But: There are sometimes curious questions:

> [@\[SOLVED\] The client lacks sufficient authorization :: The key authorization file from the server did not match this challenge](https://community.letsencrypt.org/t/solved-the-client-lacks-sufficient-authorization-the-key-authorization-file-from-the-server-did-not-match-this-challenge/71767):
>
> M…

> The key authorization file from the server did not match this challenge [U7Z05MbBan\_sQRbagOsMUOrbrefGfGsWiYZqTbXdz\_c.Mxd6puZz877ZrQ7u9cPPc2amincbkMvNFjbgIj9OlQU] != [U7Z05MbBan\_sQRbagOsMUOrbrefGfGsWiYZqTbXdz\_c.JQoYFoTtPDe2MIr4xFKqpRpt0eKti-HMnJ0BIl9eOjE]

The token is correct, the dot is correct. But the hash of the account key is wrong.

And: There were wrong ipv6 - settings, so ipv6 sends another content then ipv4.

Removing the ipv6 - AAAA record solved the problem.

So it looks that these hosters reflect /.well-known/acme-challenge/1234 with the content

1234.[Hash of the public account key]

With the consequence:

If Letsencrypt has this error validating a domain name, Letsencrypt could search all accounts to find the account with [Hash of the public account key] to find such a wrong reflection.

---

<div class="post-metadata">

**Author:** ![\_az](https://avatars.discourse-cdn.com/v4/letter/_/22d042/32.png) [@\_az](https://community.letsencrypt.org/u/_az)\
**Post date:** [September 15, 2018, 8:53pm UTC](https://community.letsencrypt.org/t/xss-via-acme-implementations/72295/4 "2018-09-15T20:53:07Z")

</div>

Being able to reflect the requested resource in the body is valuable when you are performing HTTP validation for a domain that is served by many web servers (and are not load-balanced through a single endpoint).

It saves having to deploy challenges to each server, rather each server just has to be preconfigured with the JWK Thumbprint.

acme.sh is one of the clients that documents such a solution: [https://github.com/Neilpang/acme.sh/wiki/Stateless-Mode](https://github.com/Neilpang/acme.sh/wiki/Stateless-Mode) (though it does restrict the character set of the reflected part to that of base64url so it’s probably not vulnerable in most cases).

FWIW, server-side content sniffing a security risk independently of ACME.

I am not sure if the sniffing middleware from the article responds to `x-content-type-options: nosniff` as browsers do, but maybe it’s a good implementation guideline for acme-challenges anyway.

---

<div class="post-metadata">

**Author:** ![schoen](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/schoen/32/79_2.png) [@schoen](https://community.letsencrypt.org/u/schoen)\
**Post date:** [September 16, 2018, 2:00am UTC](https://community.letsencrypt.org/t/xss-via-acme-implementations/72295/5 "2018-09-16T02:00:33Z")

</div>

I think other clients may also have implemented a “stateless mode” directly inspired by the one from acme.sh. But maybe not.

See

[https://community.letsencrypt.org/search?q=%22stateless%20mode%22](https://community.letsencrypt.org/search?q=%22stateless%20mode%22)

for discussions about this.

@Neilpang, I think @_az is right that your implementation will not create this risk at all, but could you please verify that? Also, are you aware of whether any other implementations were deployed that were inspired by yours?

---

<div class="post-metadata">

**Author:** ![Neilpang](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/neilpang/32/20232_2.png) [@Neilpang](https://community.letsencrypt.org/u/Neilpang)\
**Post date:** [September 16, 2018, 3:04pm UTC](https://community.letsencrypt.org/t/xss-via-acme-implementations/72295/6 "2018-09-16T15:04:17Z")

</div>

I agree with you too.  
And I will check more details about this issue soon, and restrict the regular expression more.

> > Also, are you aware of whether any other implementations were deployed that were inspired by yours?

Sorry, I can not remember.

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/letsencrypt/original/3X/c/a/ca6c06ea1ea201324bba7048c6841ce60236468d.png) [@system](https://community.letsencrypt.org/u/system)\
**Post date:** [October 16, 2018, 3:10pm UTC](https://community.letsencrypt.org/t/xss-via-acme-implementations/72295/7 "2018-10-16T15:10:48Z")

</div>

Closed on October 16, 2018, 3:10pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
