Fall of Civilizations [en]

A while ago, the YouTube algorithm suggested an episode of the Fall of Civilizations podcast. Not exactly sure why, because I rarely watch history topics online. (I do sometimes read up on history topics on Wikipedia, so maybe that’s why? Although I cannot see any obvious 3rd-party tracking code on Wikipedia.) Even more rarely do I follow overly random YouTube suggestions, but this time I clicked the video and started watching. Here’s the trailer:

And somehow I got hooked. By now, I’ve watched all 12 episodes that are available today. Some of them are several hours long and more episodes are in the making. Here’s my top 5 so far:

  1. The Bronze Age Collapse
    Hell yeah, “sea peoples”. Also see this talk by some other guy.
  2. The Sumerians
    I like my history ancient and this is about as ancient as it gets.
  3. Byzantium
    A.k.a. the Eastern Roman Empire, definitely a big one – I wonder if there will be an episode about the collapse of the western part?
  4. The Aztecs
    And also The Inca and The Mayans. Sorry, for lumping them together. The non-European perspective is often marginalized where I live.
  5. Easter Island
    I’m fascinated by the history of Polynesia, maybe because I lived there for a while. Well, that was New Zealand, one of the other corners of that huge triangle.
    (This episode got featured on Fefe’s Blog recently, which is also very random.)

Not sure why I like that shit so much. Back in school I was never particularly keen on history. And frankly, a fair portion of my history knowledge comes from the first two Age of Empires games — Wololo! — not just the re-enacted battles, but also the background info for the campaigns. Well that, and Wikipedia, and having visited a fair amount of historic places.

XSS Demo [en]

Finally some good use for my new infrastructure. I’ve had this small Angular app lying around, which I wrote for a presentation/demo on XSS a couple of years ago. So far, I’ve run it locally to demonstrate XSS vulnerabilities and how to exploit them. Now I have a place to put it and share it with others. You can find it here:

The Docker image doesn’t do TLS termination itself. Instead I’m using an nginx reverse-proxy for that, same as with this blog. Just had to add another nginx config file. And add the dedicated subdomain to my Let’s Encrypt configuration. There, done.

The XSS demo app may not be very intuitive, because the original target audience was just myself. But it comes with a brief guide. Just play around from there. I may add more inline documentation later…

Right now the focus is on XSS vulnerabilities in plain HTML, via the DOM, and via Angular. Not saying the latter are vulnerable themselves. But they are all prone to XSS, if used carelessly. I’m thinking about extending the list to other web front-end libs/components/frameworks/technologies, e.g. a WYSIWYG editor or a Markdown processor.

The B in BYOK stands for Bullshit [en]

I’ve recently encountered a customer, who insisted on a Bring-Your-Own-Key (BYOK) setup for compliance reason. I’ve always been skeptical about that and I didn’t have to search long for confirmation. This is what the Wikipedia article on BYOK has to say:

[…] a cloud computing security marketing model […]

[…] gives the enterprise the perceived control of its own keys […]

Data owners may believe their data is secured […]

I’ve rarely seen anything that snarky on Wikipedia. Yet so accurate.

Let’s Revoke! [en]

Getting TLS certificates from Let’s Encrypt is easy, but that’s just part of the story. It may sound paranoid, but being able to revoke certs is almost equally important. The premise is that there’s always a chance that your private keys will leak. Maybe it will never happen to me, but it will eventually happen to someone. The risk is certainly higher for companies and organizations: team members come and go all the time, and some of them might gain knowledge of the keys. That’s why revoking certificates should be part of off-boarding procedures. Well, I’m running this blog alone, and there’s not much to protect here. Nevertheless I wanted to learn how to get this right and played through that whole revocation exercise.

Like everything else around Let’s Encrypt, certificate revocation is automated via the ACME protocol. Of course, you wouldn’t want anyone else to revoke your certs — that would effectively block all HTTPS traffic to your side. So before revoking a cert, Let’s Encrypt needs some proof that you are the legitimate owner. Generally there are 3 alternatives:

  • A: Prove control of the private key that belongs to the cert.
  • B: Prove control of the Let’s Encrypt account that has issued the cert, via the account private key.
  • C: Prove ownership of all the domains listed in the certificate.

Alternative A requires that I never lose any private key, at least not before the corresponding cert expires. (Btw, I’d recommend against reusing the same private key for consecutive certs. Luckily certbot generates a new private key when renewing a cert.) But my servers and discs are cattle, not pets. I intend to throw them away at anytime and recreate them from scratch or replace them with something better. So my private keys can go away any time, too. If I wanted to use them for certificate revocation, I’d have to back them up in some way. Ideally to some some key management solution like Hashicorp Vault or Ansible Vault (which I’m already using for other parts of my infrastructure). But each copy of the private key increases the risk that it will get leaked.

Alternative B is similar, although the account private key is somewhat more stable. It makes sense to use the same account for consecutive certs. But relying on the account for revocation would require rock solid backups of the key. (Writing these lines I realize that leaking the account private key itself would also be problematic. Let’s Encrypt associates the account with a list of authorized domains and might skip challenges for a certain period of time. I should research ACME specs and Let’s Encrypt policies on this…)

So I wanted to experiment with alternative C, which works even after I have lost all of my private keys. But when I lose the private keys, I’ll probably lose the certs themselves at the same time. So how do I even know which certs to revoke?

CT to the rescue

Wouldn’t it be nice, if Let’s Encrypt published a list of all certs that they ever issued? Actually, wouldn’t it be nice, if all CAs did that? Turns out they are already doing that. It’s what the Certificate Transparency (CT) standard (RFC 6962) is for. The main purpose of CT is, ensuring that CAs (and domain owners) can verify that other CAs are not issuing certificates fraudulently. CT defines an append-only data-structure (based on Merkle trees) which CAs can use to log all the certs that they issue.

Ideally browsers (and other TLS clients) should only trust certificates that have been published in a CT log. Chrome is already enforcing that, but Firefox seems to be lagging behind.

CT logs can be operated by CAs themselves (like Let’s Encrypt does) or by third parties (like Cloudflare or Google). Different CAs can submit their issued certs to different logs. TLS clients consume the CT log entries (a.k.a. Signed Certificate Timestamps a.k.a. SCT) via various channels (e.g. an X.509 extension or a TLS extension or OCSP) but none of those contain the URL of the CT log itself. Which is weird, because CT logs have a clearly defined REST API which is rooted at an HTTPS URL. Lack of URLs makes it harder to query the CT logs of Let’s Encrypt directly (let alone those of all CAs).

Moreover, searching the CT logs for certain domain names (like meeque.de) is not trivial. You’d basically have to download the whole log and search it entry by entry (or create your own search index over all entries). There might be open-source software that that could help (e.g. Let’s Encrypt’s own CT Woodpecker) but I haven’t checked that out yet.

Luckily, others have solved all these problems and are providing CT log monitoring as a service. The nice people at Sectigo provide such service for free at crt.sh. I’ve been using their web UI for manual certificate searches for a while now. E.g. here’s a list of all certs for my meeque.de domain, including its sub-domains. crt.sh provides data in machine friendly formats, too: JSON for search results and PEM for certs. So I wrote a small bash script that queries crt.sh for my domains and downloads the relevant cert chains into a local tracking directory. I’ve also setup a cron-job to do that on a regular basis.

So, let’s revoke already

With that we can circle back to the revocation topic. My script also helps me using certbot for sending ACME revocation requests for any tracked cert. All of that works without knowing the certificate’s private key or the private key of a Let’s Encrypt account. Certbot will simply create a new Let’s Encrypt account under the hood whenever it cannot find an existing one in local configuration. And Let’s Encrypt allows you to revoke a certificate that has been issued to another account, as long as you can prove ownership of all the domains included in the certificate. You just have to fulfill the domain ownership challenges, similar to when requesting a new cert.

There’s a small catch though: ACME supports pre-authorization, which allows clients to prove domain ownership (by fulfilling challenges) as a stand-alone operation. But that operation seems to be optional and I’m not sure, if Let’s Encrypt supports it. In any case, certbot does not support stand-alone pre-authorization as of today (or does not document it).

My workaround is simple: I’ll just ask certbot to obtain a new cert for my domains and fulfill all necessary challenges. After that, my brand new Let’s Encrypt account will have authorization for my domains. With that, Let’s Encrypt will allow me to revoke any of the certificates that I’ve found in CT logs. Well, at least for those domains that I still own.

So far, this only works for revoking certificates that have been issued by Let’s Encrypt. I guess it would be easy to add support for other CAs that implement the ACME protocol. I’d just need some kind of mapping between CA root certs and ACME URLs… For now, I’d have to take manual action, if I ever find a cert from another CA in the CT logs for my domain. To find out, if that ever happens, my next step will be setting up alert notifications that will warn me whenever an unknown cert shows up…

Let’s Encrypt! [en]

… is where I’m getting the TLS certificates for this blog nowadays (after moving away from CAcert). I’ve been using Let’s Encrypt at work now and then. Many colleagues in my department are heavy users and my employer is a sponsor. So I knew what to expect and how to get started. Nevertheless, here’s a couple of experiences that I’d like to share…

Let’s Encrypt is all about automation, which eventually lead to the ACME standard. There seems to be a myriad of ACME clients out there, but Let’s Encrypt recommends certbot for getting started. So I defaulted to that one.

Certbot is fairly opinionated and makes it easy to get going without thinking too much about configuration details. No need to tinker with keys and CSRs, certbot does it under the hood. There’s some decisions to be made though…

Domain Ownership Challenges

First decision was, which challenge to use to prove my ownership of meeque.de? Using a DNS challenge would be nice, because it’s the only way to get wildcard certs from Let’s Encrypt. However, it would require giving certbot access to my DNS configuration, which I’ve recently moved to Route 53. But I don’t want to get too tight with the evil empire and I don’t need wildcard certs for now. So I opted for an HTTP challenge.

Even then, certbot offers a plethora of plugins that fulfill the HTTP challenge and install the resulting certificates in a web server. E.g. the standalone plugin spins up it’s own little web server, just for fulfilling challenges. There’s also a certbot plugin for nginx, the web server that I’m using for TLS-termination. But letting certbot tinker with my nginx configuration seems kinda invasive. Besides, it would require manual wiring, because I’m running nginx isolated in a Docker container.

So I picked the certbot webroot plugin instead and I like its minimalism. You just point it to a local directory where it can create challenge files. You can then use any web server you like to expose these files via HTTP, so that Let’s Encrypt can verify them. I’ve extended my existing nginx configuration for that. And since I’m running nginx in a container, I’m using Docker mounts to ensure that both certbot and nginx can access the challenge files. Works like a charm!

Deploying Certificates

Some certbot plugins go further than just sending ACME requests and fulfilling challenges. They also install the certs in a web-server. The webroot plugin does not do that though.

But that’s not a problem: certbot puts new certificates (and the corresponding private keys) in a predictable directory. All I need to do is point my nginx configuration to the right files. Once again, I’m using Docker mounts to ensure that both certbot and nginx can access the cert files.

In a typical nginx setup, you’d use separate virtual servers for HTTP and HTTPS traffic. And you’d repeat that for all DNS domains that you want to host. That causes a small bootstrapping problem:

  • In order to serve HTTPS traffic you need a certificate.
  • But in order to get a certificate from Let’s Encrypt you need a running HTTP server to fulfill ACME challenges.

There are several ways around this problem, e.g. bootstrapping with self-signed certs or spinning up a temporary web server just for the challenges. I went a step further, by using two full-fledged nginx servers, both isolated in their own Docker container:

  • The first nginx server (“challenger”) only serves HTTP traffic. And only ACME HTTP challenge files. It redirects all other requests to HTTPS.
    This server starts successfully, even when I recreate my hosting environment from scratch.
  • The second nginx server (“webfront”) only serves HTTPS traffic. It performs TLS termination for this blog (and could be extended to serve other virtual hosts).
    This server fails to start after I recreate the hosting environment from scratch, because nginx will not find the cert and key files that I’ve configured. However, a quick run of certbot will fix that condition and restart this server.

In practice, I’ve automated all of the above, with Terraform and Ansible. I can easily delete the whole host from my environment and get everything running from scratch within a couple of minutes. Including Let’s Encrypt certificates! (I’ve tested that just last week.)

What else?

Yupp, using another nginx instance just for ACME challenges seems a little wasteful. But I think there’s some elegance to it. And Docker makes it easy to implement this setup.

That covers my basic certificate needs. I can obtain certs from scratch and renew them regularly. I have a simple cron job for that part.

But there’s more to working with certificates. Just think monitoring and revocation. More on that soon…

Goodbye CAcert [en]

When I started this blog back in 2010, I wanted HTTPS, but I didn’t want to pay extra for it. Back then that wasn’t as easy as it is today. So I compromised and got my TLS certificates from CAcert. Problem was that almost no OS or browser vendor trusted their certs. Debian and Ubuntu did make it part of their ca-certificates package, which worked fine for myself, but very few other people.

Anyway, according to the changelog, Debian has removed CAcert back in 2014 after lots of discussion. Looks like Ubuntu followed immediately, because they have a very similar changelog entry. And I only realized today, over 7 years later. The CAcert website and wiki also look pretty stale by now.

The other problem was that requesting certs from CAcert was a manual task. They had a nice web interface, and they would send email reminders before your cert expired. According to my mail archive, my last CAcert certificate had expired back in 2018. And I just never bothered to request a new one.

Of course, a lot has changed since those ancient times. Let’s Encrypt has done a very good job filling CAcert’s niche. Ever since I revived this blog a couple of months ago, I’ve been using their certs. But that’s another story…

Die Stones leben noch [de]

… aber MCA ist tot. Keith Flint ist tot. Sebastian Hackert ist tot. Und jetzt ist auch noch einer meiner Lieblingsmoderatoren bei FM4 gestorben: Martin Blumenau.

Er bleibt mir vor allem als Moderator der Wunschsendung FM4 Zimmerservice in Erinnerung. Er hatte da diesen gewissen Wiener Schmäh. (Zumindest erschien einen außenstehenden Piefke wie mir das so.) Er konnte mit den Hörerwünschen zum Teil sehr hart ins Gericht gehen. Auch mal mitten im Song abbrechen: “Nein, das geht jetzt überhaupt nicht.” Immer hatte er eine gute Begründung für jeden Verriss parat. Aber auch die richtigen lobenden Worte für die Sachen, die er dann doch ausgespielt hat.

Habe erst gestern beim Nachhören von Davidecks zufälling erfahren, dass Martin Blumenau letzte Woche verstorben ist. Und, dass er damals in den Neunzigern einer der Mitgründer von FM4 gewesen ist.

DNA replication lifehack [en]

I’ve recently posted about these talks on “DNA: The Code of Life” that I found. I really enjoyed them, even though most of the contents were not fundamentally new to me. However, I want to highlight one specific topic that I did learn, and that kinda blew my mind…

I had not even been aware of this particular DNA replication problem, let alone the solution. One part of that replication process is adding nucleosides to match the single-stranded-DNA template and forming phosphodiester bonds in the backbone of the daughter strand. That’s the job of DNA polymerase. It turns out that these highly conserved enzymes only work in one direction: they always traverse the DNA template from ‘3 end to ‘5 end. (In other words, they move along the growing daughter strand in 5’ to ‘3 direction and add nucleosides at the 3’ end.)

That’s pretty straight-forward for one of the daughter strands, called the leading strand. There, the DNA polymerase sits right behind the replication fork and traverses the DNA template in its ‘3 to ‘5 direction. The leading strand “grows” in the same direction, so no problem here.

However, the other daughter strand, called the lagging strand, is anti-parallel to that. It “grows” in ‘5 to 3’ direction of the template strand. But DNA polymerase does not work in that direction! Instead, it has to work backwards on the lagging strand, assembling the daughter strand segment by segment. There’s an intricate machinery of other enzymes that coordinate that, which includes forming temporary loops of DNA. Here’s an illustration of what it looks like:

My description and illustration are not very intuitive. It becomes more clear when watching the video from this original source:

What’s truly weird is that there are no fundamental chemical or physical reasons that would prevent the existence of a polymerase enzyme that works in the other direction. It just seems that a polymerase that traverses the DNA template from ‘3 end to ‘5 end evolved first, alongside the “hack” described above. Since then, different variations of DNA polymerases have evolved in various branches of the tree of life. But they are all variations on the same theme, whereas it would require a major re-haul for a polymerase to work the other way round. I think this is similar to the homochirality observed elsewhere in biology.

There are many more molecular biology videos at that WEHI place. I’ve seem similar ones elsewhere, but I’m surprised how old these are. Looks pretty neat for 2003. It seems that some of that has been used in a Björk video a while back.