Mozilla is considering taking action against two Certificate Authorities, WoSign and StartCom after an investigation into improper behavior, including not reporting that the WoSign bought StartCom outright.
As I wrote about earlier, this blog used a StartCom TLS certificate, under their StartSSL brand, which was free. At the time, the only reason why I didn’t pick Let’s Encrypt was because the certificate expiration is every 3 months. However, given the contents of the report, I would much rather use an organization that wants to make the web better – not exploit it.
Obtaining and installing the new certificate, turned out to to be an easy process.
Obtaining A Certificate From Let’s Encrypt
I used the certbot client to obtain a certificate. On my mac, I installed via Homebrew:
$ brew install certbot
certbot can request and install the certificate, if it’s executed in the same machine that runs the web-server. In my case, I just wanted the certificates to be generated and downloaded locally.
$ sudo certbot certonly --manual
During the in-terminal process, certbot will ask for the intended domain and instruct you to make available some specified content at a particular url in that domain. This is to prove that you the person requesting the TLS certificate is an administrator for that domain. For me, this involved copying one new file to my hosting service.
After that, the certificate is issued immediately and available locally at /etc/letsencrypt/live/ylan.segal-family.com (your domain will vary).
Installing The New Certificate
The last time I installed a certificate, I had to open a support ticket at Nearly Free Speech. Since then, they have made the process automated and available from the control panel. The instructions are to paste into the provided form the certificate (including the full cert chain) and private key, all into the same field:
$ cat fullchain.pem privkey.pem | pbcopy
A few seconds later, the new certificate was installed and being served on this domain.
The Let’s Encrypt process ended up being simpler than StartSSL, since there was no need to manually create the private key and certificate signing request: It’s all done with one command.
While working on an HTTP API that serves binary files to client applications, I came upon some unexpected behavior.
Imagine that we have a /file/:id endpoint, but that instead of responding with the binary, it redirects to an external storage service, like AWS S3. Our endpoint is also protected, so that users need an access token. A typical request/response cycle:
curl, as requested, followed the redirect response, but in doing so, it included the original Authorization header in the request to another domain1. We have just leaked our secret and gave a valid token to access our system to a third party. To be fair, after some thought, I think it’s reasonable for curl to interpret that the header is to be sent in all requests, since we are also telling it to follow redirects. From the manual:
WARNING: headers set with this option will be set in all requests - even after redirects are followed, like when told with -L, --location. This can lead to the header being sent to other hosts than the original host, so sensitive headers should be used with caution combined with following redirects.
Who does that?
curl’s behavior (sending specifically set headers on redirects) was also observed on some other User Agents, notably the library used by one of our client applications. However, it doesn’t seem to be universal. For example httpie, does not leak the header:
As you can see, the Authorization header is conspicuous for its absence in the second request.
Since we can’t predict the behavior of all User Agents that are going to use our API, we can design our APIs differently on the server.
Use Token As a Parameter
If we are using OAuth2 (which my example implies, because the use of a Bearer token), the specification allows for the token to be passed as a URI Query Parameter named access_token. Since that makes it part of the original URL it will certainly not be included by any client that follows redirection. However, I have seen the used flagged as risky by several security audits. One of the objections is that parameters in URLs are commonly written to logs and expose tokens unnecessarily.
The OAuth2 specification also allows a Form-Encoded Body Parameter also named access_token. This gets aournd the fact that the token is part of the URL and won’t be sent on any redirect. However, the request must have an application/x-www-form-urlencoded content type, which may conflict with the rest of the application wanting it to be application/json or similar.
Use Basic Authentication
Basic Authentication is a method for a User Agent to provide credentials to the server (usually username and password). Most User Agents have good support for it and understand that its use is limited to the original URL.
Of course, redirecting is not the only option: Your endpoint can act as a proxy and read the contents from the external server and pass along to the client. The penalty is that the client connection to your server will stay open longer, consume more computation resources and transfer more data than a redirect.
Be careful when redirecting to external servers and you are using header-based authentication. Some clients may forward those headers along to a third party.
We can ignore the 404 response. This is a made up example, and it’s irrelevant how the external server actually responded.↩
Gary Bernhardt writes a great article on types, type systems and the differences in typing in different programming languages. He clarifies some of the adjective commonly associates with types: static, dynamic, weak, strong. It’s a very interesting read, as are some of the comments in the gist. Gary has also re-started his Destroy All Software screencast series: I haven’t watched any of the new ones, but I learned a lot from the old ones.
Troy Hunt explores the services that CloudFlare provides as a content delivery network (CDN), in particular with respect to SSL (or, more properly, TLS). As with most interesting things in life, it’s not black and white: CloudFlare is not evil – like some recent blog post claim – and provides valuable services, but users need to be aware what the security guarantees are, or more importantly what they are not. Security is hard and nuanced. The more you know…
In the last few weeks I have been reading a lot on data pipelines. Many companies have been moving from centralized databases for all their data to distributed systems that present a set of challenges. In particular: How to make the data produced in one system available to other systems in a robust and consistent manner. In this articles Jay Kreps explains the Log in detail – the underlying abstraction necessary to understand database systems, replication, transactions, etc. The Log, in this context, refers to a storage abstraction that is append-only, totally-ordered sequence of records, ordered by time. The article is long, but thorough and absolutely worth your time. Many of the concepts are similar to what is described on a post about Apache Samza, also a enlightening read.
Papers We Love San Diego is having their first meeting later this month, which unfortunately I won’t be able to attend. I was somewhat intimidated about reading Computer Science papers because of my lack of formal training, but Martin Kleppmann’s paper is very approachable. I found the paper very interesting and insightful and found that I was familiar with most of the concepts on which the paper is based. I’m looking forward to the next meeting.
A few hops away from a story in Hacker News, I found this whimsical introduction to Zero-Knowledge protocols, which I was ignorant of. If the topic piques your interested, read another introductory article.
Salary negotiation can be uncomfortable. It’s a skill that we usually get to practice only once every few years. In the first part of a series, Haseeb gives out practical advice on how and why to negotiate your salary. I found the part about exploding offers particularly interesting. As it happens, I last year I received an exploding job offer that was good until the end of the day!. I played my cards pretty much as the author suggests: The company never relented. They would not give me any more time. I walked away without any regrets. That particular company’s high pressure tactics, more than anything else, tells me that I would not have been a good fit.
AkitaOnRails write on his perspective on Crystal – a new programming language that aims to be type-checked, compile to native code and have a syntax similar to Ruby. I have played with Crystal myself recently and found the discussion thoughtful and interesting. Lately, it seems that Crystal is gathering some steam, especially since Mike Perham ported Sidekiq and has been tweeting about it.
Erik Dietrich lays down his requirements that companies must meet for him to consider working for them. My list would certainly be different, but that is the point. There is high demand for Software Engineers. It might now hold for other industries, where people don’t have much choice but to take what is offered. Instead of taking the first option that is presented, let’s be more mindful of what we want from an employer.
Notwithstanding the cliché title, this articles shows how easy it is to get security wrong. The tragic part is that the security flaws come from a Certificate Authority, StartCom. As it happens, it’s the CA used for the certificate of this very blog (at the time of writing). I’ll have to re-consider that decision soon. Also clear from the story, is that Let’s Encrypt is putting some pressure on CAs – which functionality StartCom was trying to replicate. Some CAs are even trying to steal their brand.
Unix tools have been around for a long time and haven’t changed much. Joey Hess took it upon himself to evaluate new simple tools that he thought are missing (and rejected some ideas in the process). I downloaded moreutils as soon as I read the descriptions. I am sure they will come in handy very soon. Kudos.