I wrote the Ruby bindings for the Enquo Project, my attempt to bring queryable encryption to all databases, using the Rutie library.
Recently, I ve rewritten the bindings to use Magnus instead, and I thought I d put down my thoughts about the whole situation.
The Story So Far
The Enquo Project core cryptography is all written in Rust, as seems to be the vogue these days.
Rust is fast, safe, and easily interoperable with most of the rest of the modern software development ecosystem, making it a good choice as a language to implement the cryptographic primitives that Enquo needs, like Order-Revealing Encryption.
Of course, since not everyone writes their applications in Rust, we need to provide the functionality of the Enquo client in the languages that people do use, such as Ruby, Python, and so on.
Since re-writing all that cryptographic code in a myriad of languages would be tedious and error-prone, we instead provide bindings to the core Rust code.
These are just thin shims of code that translate the data types and function calls between Rust and the target language.
Wrong sort of shim, but canned language bindings would be handy
As I m most familiar with Ruby and its development ecosystem (particularly Ruby on Rails), it was natural that I d make Ruby bindings for Enquo as my first target.
Rummaging around, it seemed that Rutie was a good library to use, so off I went.
What are Rutie and Magnus, Anyway?
Both libraries share the same goal: provide the ability to write some Rust code, run that through a compiler, and produce something that can be loaded by the Ruby interpreter and used just like any other Ruby class.
They re both fairly high level interfaces, trying to abstract away much of the gory details, and do a lot of the common heavy lifting that can make writing bindings fiddly and annoying.
Things like mapping data types (like strings and integers) between Rust data types and the closest equivalents in Ruby.
This mapping never goes perfectly smoothly.
For example, Ruby integers don t have a fixed range of values they can represent you can store a huge number like 2256 more-or-less as easily as you can the number 12.
But Rust, being a lower-level language, only has a set of integer types that have fixed boundaries, like the u32 type, which can only store integers between zero and about four billion (232 - 1, to be precise).
There s also lots of little things that need to be just right, also, like translating the different memory management approaches of the languages, and dealing with a myriad of fiddly little issues like passing arguments and return values in and out of method calls, helpers for defining classes and methods (and pointing to the correct Rust functions), and so on.
This is what I imagine it looks like inside these libraries
(Herv Cozanet / Wikimedia Commons, CC-BY-SA)
All in all, these libraries are fairly significant pieces of work, and I m mighty glad that someone else has taken on the job of building (and maintaining!) them.
So Why the Change?
Good question.
It s important to say at the outset that there s nothing particularly wrong with Rutie.
I found using Rutie to be very straightforward, and the Ruby bindings came together very quickly and easily.
If someone chose to use Rutie for their project, I m sure they d have a good experience.
What made me take the time to rewrite using Magnus was a set of a few tiny things, which together gave me enough of a shove to do the work.
Firstly, I d had a hiccup with Rutie s support of newer versions of Ruby, particularly 3.2 (PR).
Also, I d hit a couple of segfault issues, which were ultimately caused by Ruby garbage-collecting data out from underneath me.
These were ultimately my fault, of course, but Rutie wasn t helping me out in avoiding the problems in the first place.
Finally, while Rutie helped translate data types, there was still a bit of boilerplate and ugliness that needed to be included.
This wasn t a showstopper, but I m appreciating the extra smoothness that Magnus provides here.
As an example, here s what s required in Rutie to get native Rust data types from Ruby method parameters (and the self reference to the current object):
fn enquo_field_decrypt_text(ciphertext_obj: RString, context_obj: RString) -> RString
let ciphertext = ciphertext_obj.to_str_unchecked();
let context = context_obj.to_vec_u8_unchecked();
let field = rbself.get_data(&*FIELD_WRAPPER);
// etc etc etc
The equivalent in Magnus is just the function signature:
You can also see there that Magnus signals an exception via the Result return value, while Rutie s approach to raising an exception involves poking the Ruby VM directly, which always struck me as a bit ugly.
There are several other minor things in Magnus (like its cleaner approach to wrapping structs so they can be stored in Ruby objects) that I m appreciating, too.
Never discount the power of ergonomics for making a happy developer.
The End Result
I spent a bit over half of last weekend doing the rewrite maybe ten hours of so.
Since Magnus did more type checking and data validation, and its approach to error handling was smoother, I took the opportunity to rewrite a bunch of Ruby wrapper code I d written (which just existed to check things like ranges of values and string encodings) into Rust, as well.
To make sure that the conversion was accurate, I added a heap more unit tests to the bindings.
I also took the opportunity to restructure the codebase to split the code for the different Ruby classes into separate files, which I hadn t done initially as the code had originally accreted, rather than being purposefully written.
All up, though, my rewrite ended up removing over 60 lines (excluding the extra specs I added):
Considering that I was translating from a higher level language into a lower level one, the removal of so much code is quite remarkable.
Magnus was able to automagically replace rather a lot of raise ArgumentError if something.isnt_right code in those .rb files.
So, in conclusion, if you, too, are building Ruby extensions in Rust, while Rutie is a solid choice (and you probably should stick with it if you re already using it), I highly recommend giving Magnus a look for your next extension.
Just some of the organisations that leaked data in 2022
It seems like just about every day there s another report of another company getting hacked and having its sensitive data (or, worse, the sensitive data of its customers) stolen.
Sometimes, people s most intimate information gets dumped for the world to see.
Other times it s just used for identity theft, extortion, and other crimes.
In the least worst case, the attacker gets cold feet, but people suffer stress and inconvenience from having to replace identity documents.
A great way to protect information from being leaked is to encrypt it.
We encrypt data while it s being sent over the Internet (with TLS), and we encrypt it when it s at rest (with disk or volume encryption).
Yet, everyone s data seems to still get stolen on a regular basis.
Why?
Because the data is kept online in an unencrypted form, sitting in the database while its being used.
This means that attackers can just connect to the database, or trick the application into dumping the database, and all the data is just lying there, waiting to be misused.
It s Not the Devs Fault, Though
You may be thinking that leaving an entire database full of sensitive data unencrypted seems like a terrible idea.
And you re right: it is a terrible idea.
But it s seemingly unavoidable.
The problem is that in order to do what a database does best (query, sort, and aggregate data), it needs to be able to know what the data is.
When you encrypt data, however, all the database sees is a locked box.
Not very useful for a database
The database can t tell what s in the locked box whether it s a number equal to 42, or a date that s less than 2023-01-01, or a string that contains the substring foo .
Every value is just an opaque blob of stuff , and the database is rendered completely useless.
Since modern applications usually rely pretty heavily on their database, it s essentially impossible to build an application if you ve turned your database into a glorified flat-file by encrypting everything in it.
Thus, it s hardly surprising that developers have to leave the data laying around unencrypted, for anyone to come along and take.
Introducing Enquo
I said before that having data unencrypted in a database is seemingly unavoidable.
That s because there are some innovative cryptographic techniques that can make it possible to query encrypted data.
Indeed
The purpose of the Enquo project is to provide a common set of cryptographic primitives that implement ENcrypted QUery Operations (ie Enquo ), and integrate those operations into databases, ORMs, and anywhere else that could benefit.
The end goal is to provide the ability to encrypt all the data stored in any database server, while still allowing the data to be queried and aggregated.
So far, the project consists of these components:
the enquo-core library, that implements queryable encrypted integers, dates, and text in Rust and Ruby;
a PostgreSQL extension, pg_enquo, that allows PostgreSQL to query encrypted data; and
a Rails ActiveRecord extension, ActiveEnquo, that augments ActiveRecord to do the encryption/decryption required.
Support for other languages and ORMs is designed to be as straightforward as possible, and integration with other databases is mostly dependent on their own extensibility.
The project s core tenets emphasise both uncompromising security, and a friendly developer experience.
Naturally, all Enquo code is open source, released under the MIT licence.
Would You Like To Know More?
Everyone who uses a database...
If all this sounds relevant to your interests:
If you use Ruby on Rails and PostgreSQL, you re halfway home already.
Follow the ActiveEnquo getting started tutorial and see how much of your data Enquo can already protect.
When you find data you want to encrypt but can t, tell me about it.
If you use Ruby and PostgreSQL with another ORM, such as Sequel, writing a plugin to support Enquo shouldn t be too difficult.
The ActiveEnquo code should give you a good start.
If you get stuck, get in touch.
If you use PostgreSQL with another programming language, tell me what language you use and we ll work together to get bindings for that library created.
If you use another database server, support is coming for your database of choice eventually, but at present there s no timeline on support.
On the off chance that you happen to be a hard-core database hacking expert, and would like to work on getting Enquo support in your preferred database server, I d love to talk to you.
Let s say you re someone who happens to discover an AWS account number, and would
like to take a stab at guessing what IAM users might be valid in that account.
Tricky problem, right? Not with this One Weird Trick!
In your own AWS account, create a KMS key and try to reference an ARN
representing an IAM user in the other account as the principal. If the policy
is accepted by PutKeyPolicy, then that IAM account exists, and if the error
says Policy contains a statement with one or more invalid principals then the
user doesn t exist.
As an example, say you want to guess at IAM users in AWS account 111111111111.
Then make sure this statement is in your key policy:
"Sid": "Test existence of user",
"Effect": "Allow",
"Principal":
"AWS": "arn:aws:iam::111111111111:user/bob"
,
"Action": "kms:DescribeKey",
"Resource": "*"
If that policy is accepted, then the account has an IAM user named bob.
Otherwise, the user doesn t exist. Scripting this is left as an exercise for
the reader.
Sadly, wildcards aren t accepted in the username portion of the ARN, otherwise
you could do some funky searching with ...:user/a*, ...:user/b*, etc. You
can t have everything; where would you put it all?
I did mention this to AWS as an account enumeration risk. They re of the opinion
that it s a good thing you can know what users exist in random other AWS accounts.
I guess that means this is a technique you can put in your toolbox safe in the
knowledge it ll work forever.
Given this is intended behaviour, I assume you don t need to use a key policy
for this, but that s where I stumbled over it. Also, you can probably use it
to enumerate roles and anything else that can be a principal, but since I
don t see as much use for that, I didn t bother exploring it.
There you are, then. If you ever need to guess at IAM users in another AWS account,
now you can!
I switched from Jekyll to Hugo last week for a variety of reasons.
One thing that was missing was a port of the jekyll-static-comments plugin that I used to use.
I liked it because it saved readers from being tracked by Disqus or other comments solutions, and it required no javascript.
To comment, users would email me their comment following a template attached to the bottom of each post.
I then piped their email through a script to add it to the right post.
As an added benefit, I could delegate comment spam detection to my mail server.
I ve managed to reimplement this setup using Hugo.
For those who are interested in a similar setup, here is what you need to do.
Pages with comments
Instead of being single files, pages need to be leaf bundles.
For example, this means that your blog post must be located at /content/blog/2021-03-12-static-comments-in-hugo/index.md instead of /content/blog/2021-03-12-static-comments-in-hugo.md.
This lets you store the comments as page resources in the subdirectory /content/blog/2021-03-12-static-comments-in-hugo/comments/.
Partials
You should create a comments.html partial and include it in the layout for the pages which should get comments:
<divclass="post-comments"><pclass="comment-notice"><b>Comments</b>: To comment on this post,
send me an email following the template below. Your email address
will not be posted, unless you choose to include it in
the <spanstyle="font-family: monospace;">link:</span> field.</p><preclass="comment-notice">
To: Your Name <your.email<span>@</span>example.org>
Subject: [blog-comment] .Page.RelPermalink
post_id: .Page.RelPermalink
author: [How should you be identified? Usually your name or "Anonymous"]
link: [optional link to your website]
Your comments here. Markdown syntax accepted.</pre>
$scratch := newScratch
$scratch.Set "comments" (.Resources.Match "comments/*yml")
if eq 1 (len ($scratch.Get "comments"))
<h2>1 Comment</h2>
else
<h2> len ($scratch.Get "comments") Comments</h2>
end
range ($scratch.Get "comments")
<divclass="post-comment % cycle 'odd', 'even' % ">
$comment := (.Content transform.Unmarshal)
<spanclass="post-meta">
- $comment.date dateFormat "Jan 2, 2006 at 15:04" -
</span><h3class="comment-header">
if $comment.link
<ahref=" $comment.link "> $comment.author </a>
else
$comment.author
end
<br/></h3>
$comment.comment markdownify
</div>
end
</div>
Comments
To associate comments received by email to posts, I pipe them from mutt (using the keybinding) to the following (admittedly janky) shell script.
It takes the comment, reformats it appropriately, and puts it in the post s comments subdirectory.
Note that it determines which filename to use based on the email s contents, so make sure to check that the email doesn t contain anything nefarious before you pipe it into the script!
#!/bin/sh
# Copyright (C) 2016-2021 Ryan Kavanagh <rak@rak.ac># Distributed under the ISC licenseBLOG_BASE="/media/t/work/blog"MESSAGE=$(cat)EMAIL=$(echo"$ MESSAGE" grep "From:" sed -e 's/From[^<]*<\?\([^>]*\)>\?.*/\1/g;s/@/-at-/g')DATE=$(echo"$ MESSAGE" grep "Date:" sed -e 's/Date:\s*//g' xargs -0 date -Iseconds -u -d)POST_ID=$(echo"$ MESSAGE" grep "post_id:" sed -e 's/post_id: //g')COMMENTS_DIR="$ BLOG_BASE/content/$ POST_ID/comments/"COMMENT_FILE="$ COMMENTS_DIR/$ DATE_$ EMAIL.yml"# Strip out the email headers and whitespace until the start of the commentCOMMENT_WHOLE=$(echo"$ MESSAGE" sed -e '/^\s*$/,$!d;/^[^\s]/,$!d')# Indent everything after the comment headerCOMMENT_INDENTED=$(echo"$ COMMENT_WHOLE" sed -e '/^\s*$/,$ s/.*/ &/g ')# And add the comment headerCOMMENT_PREFIXED=$(echo"$ COMMENT_INDENTED" sed -e '0,/^\s*$/ s/^\s*$/comment: / ')[ -d "$ COMMENTS_DIR"] mkdir -p "$ COMMENTS_DIR"echo"Saving the comment to $ COMMENT_FILE"echo"date: $ DATE" tee "$ COMMENT_FILE"echo"$ COMMENT_PREFIXED" tee -a "$ COMMENT_FILE"
For example, the following comment in an email body:
post_id: /blog/2021-03-12-static-comments-in-hugo/
author: Ryan Kavanagh
link: https://rak.ac/
Dear self,
Here is a test comment for your blog post.
It supports *markdown* **syntax** and stuff .
Best,
Yourself
results in a file content/blog/2021-03-12-static-comments-in-hugo/comments/2021-03-12T18:47:25+00:00_rak-at-example.org.yml containing:
date:2021-03-12T18:47:25+00:00post_id:/blog/2021-03-12-static-comments-in-hugo/author:Ryan Kavanaghlink:https://rak.ac/comment: Dear self,
Here is a test comment for your blog post.
It supports *markdown* **syntax** and stuff .
Best,
Yourself
You can see the rendered output at the bottom of this page.
Because posting private keys on the Internet is a bad idea, some
people like to redact their private keys, so that it looks kinda-sorta like a private key,
but it isn t actually giving away anything secret. Unfortunately, due to the way that
private keys are represented, it is easy to redact a key in such a way that it
doesn t actually redact anything at all. RSA private keys are particularly bad at this,
but the problem can (potentially) apply to other keys as well.
I ll show you a bit of Inside Baseball with key formats, and then demonstrate the practical
implications. Finally, we ll go through a practical worked example from an actual not-really-redacted
key I recently stumbled across in my travels.
The Private Lives of Private Keys
Here is what a typical private key looks like, when you come across it:
Obviously, there s some hidden meaning in there computers don t encrypt
things by shouting BEGIN RSA PRIVATE KEY! , after all. What is between the
BEGIN/END lines above is, in fact, a
base64-encoded
DER format
ASN.1 structure representing a PKCS#1 private
key.
In simple terms, it s a list of numbers very important numbers. The list
of numbers is, in order:
A version number (0);
The public modulus , commonly referred to as n ;
The public exponent , or e (which is almost always 65,537, for various unimportant reasons);
The private exponent , or d ;
The two private primes , or p and q ;
Two exponents, which are known as dmp1 and dmq1 ; and
A coefficient, known as iqmp .
Why Is This a Problem?
The thing is, only three of those numbers are actually required in a private
key. The rest, whilst useful to allow the RSA encryption and decryption to be
more efficient, aren t necessary. The three absolutely required values are
e, p, and q.
Of the other numbers, most of them are at least about the same size as each
of p and q. So of the total data in an RSA key, less than a quarter of the
data is required. Let me show you with the above toy key, by breaking it
down piece by piece1:
MGI DER for this is a sequence
CAQ version (0)
CxjdTmecltJEz2PLMpS4BXn
AgMBAAe
ECEDKtuwD17gpagnASq1zQTYd
ECCQDVTYVsjjF7IQp
IJANUYZsIjRsR3q
AgkAkahDUXL0RSdmp1
ECCB78r2SnsJC9dmq1
AghaOK3FsKoELg==iqmp
Remember that in order to reconstruct all of these values, all I need are
e, p, and q and e is pretty much always 65,537. So I could redact
almost all of this key, and still give all the important, private bits of this
key. Let me show you:
Now, I doubt that anyone is going to redact a key precisely like
this but then again, this isn t a typical RSA key. They usually
look a lot more like this:
People typically redact keys by deleting whole lines, and usually replacing them
with [...] and the like. But only about 345 of those 1588 characters
(excluding the header and footer) are required to construct the entire key.
You can redact about 4/5ths of that giant blob of stuff, and your private parts
(or at least, those of your key) are still left uncomfortably exposed.
But Wait! There s More!
Remember how I said that everything in the key other than e, p,
and q could be derived from those three numbers? Let s talk about one
of those numbers: n.
This is known as the public modulus (because, along with e, it is also
present in the public key). It is very easy to calculate: n = p * q. It
is also very early in the key (the second number, in fact).
Since n = p * q, it follows that q = n / p. Thus, as long
as the key is intact up to p, you can derive q by simple division.
Real World Redaction
At this point, I d like to introduce an acquaintance of mine: Mr. Johan Finn.
He is the proud owner of the GitHub repo johanfinn/scripts.
For a while, his repo contained a script that contained a poorly-redacted private
key. He since deleted it, by making a new commit, but of course because
git never really deletes anything, it s
still available.
Of course, Mr. Finn may delete the repo, or force-push a new history without
that commit, so here is the redacted private key, with a bit of the surrounding
shell script, for our illustrative pleasure:
Now, if you try to reconstruct this key by removing the obvious garbage
lines (the ones that are all repeated characters, some of which aren t even valid
base64 characters), it still isn t a key at least, openssl pkey
doesn t want anything to do with it. The key is very much still in there,
though, as we shall soon see.
Using a gem I wrote and a quick bit of
Ruby, we can extract a complete private key. The irb session looks something
like this:
What I ve done, in case you don t speak Ruby, is take the two chunks of
plausible-looking base64 data, chuck them together into a variable named b64,
unbase64 it into a variable named der, pass that into a new DerParse
instance, and then walk the DER value tree until I got all the values I need.
Interestingly, the q value actually traverses the split in the two chunks,
which means that there s always the possibility that there are lines missing
from the key. However, since p and q are supposed to be prime, we can
sanity check them to see if corruption is likely to have occurred:
Excellent! The chances of a corrupted file producing valid-but-incorrect prime
numbers isn t huge, so we can be fairly confident that we ve got the real p
and q. Now, with the help of another one of my
creations we can use e, p,
and q to create a fully-operational battle key:
and there you have it. One fairly redacted-looking private key brought back
to life by maths and far too much free time.
Sorry Mr. Finn, I hope you re not still using that key on anything
Internet-facing.
What About Other Key Types?
EC keys are very different beasts, but they have much the same problems as RSA
keys. A typical EC key contains both private and public data, and the public
portion is twice the size so only about 1/3 of the data in the key is
private material. It is quite plausible that you can redact an EC key and
leave all the actually private bits exposed.
What Do We Do About It?
In short: don t ever try and redact real private keys. For documentation purposes,
just put KEY GOES HERE in the appropriate spot, or something like that. Store your
secrets somewhere that isn t a public (or even private!) git repo.
Generating a dummy private key and sticking it in there isn t a great idea,
for different reasons: people have this odd habit of reusing demo keys in
real
life.
There s no need to encourage that sort of thing.
Technically the pieces aren t 100% aligned with the underlying DER, because of how base64 works.
I felt it was easier to understand if I stuck to chopping up the base64, rather than
decoding into DER and then chopping up the DER.
Whether you re a TDD zealot, or you just occasionally write a quick script
to reproduce some bug, it s a rare coder who doesn t see value in some sort
of automated testing. Yet, somehow, in all of the new-age Infrastructure
as Code mania, we appear to have forgotten this, and the tools that are
commonly used for implementing Infrastructure as Code have absolutely
woeful support for developing your Infrastructure Code. I believe this
has to change.
At present, the state of the art in testing system automation code appears
to be, spin up a test system, run the manifest/state/whatever, and then use
something like serverspec or
testinfra to SSH in and make sure
everything looks OK . It s automated, at least, but it isn t exactly a quick
process. Many people don t even apply that degree of rigour to their system
config systems, and rely on manual testing, or even just doing it live! ,
to shake out the bugs they ve introduced.
Speed in testing is essential. As the edit-build-test-debug cycle gets
longer, frustration grows exponentially. If it takes two minutes to get a
something went wrong report out of my tests, I m not going to run them
very often. If I m not running my tests very often, then I m not likely to
write tests much, and suddenly oops. Everything s on fire. In
traditional software development, the unit tests are the backbone of the
fast feedback cycle. You re running thousands of tests per second,
ideally, and an entire test run might take 5-10 seconds. That s the sweet
spot, where you can code and test in a rapid cycle of ever-increasing
awesomeness.
Interestingly, when I ask the users of most infrastructure management
systems about unit testing, they either get a blank look on their face, or,
at best, point me in the direction of the likes of Test
Kitchen, which is described
quite clearly as an integration platform, not a unit testing platform.
Puppet has rspec-puppet, which is a pretty solid
unit testing framework for Puppet manifests although it isn t widely
used. Others, though nobody seems to have any ideas. The blank look
is near-universal.
If infrastructure developers want to be taken seriously, we need to learn
a little about what s involved in the development part of the title we ve
bestowed upon ourselves. This means knowing what the various types of testing
are, and having tools which enable and encourage that testing. It also means
things like release management, documentation, modularity and reusability,
and considering backwards compatibility.
All of this needs to apply to everything that is within the remit of the
infrastructure developer. You don t get to hand-wave away any of this just
because it s just configuration! . This goes double when your just
configuration! is a hundred lines of YAML interspersed with templating
directives (SaltStack, I m looking at
you).
We are an IT security company from Spain.
We have detected sensitive information belonging to Banesco Banco Universal,
C.A. clientes.
As authorized representative in the resolution of IT security incidents
affecting Banesco Banco Universal, C.A., we demand the deletion of the
content related to Banesco Banco Universal, C.A, clients. This content
violates the law about electronic crime in Venezuela (see Ley Especial
sobre Delitos Inform ticos de Venezuela , Chapter III, Articles 20 y 23).
Note the complete lack of any information regarding what URLs, or even which
site(s), they consider to be problematic. Nope, just delete all our
stuff! and a wave of the against the law somewhere! stick.
Would you like to comment on why you think that DNSSEC+DANE are not a
possible and much better alternative?
Where DANE fails to be a feasible alternative to the current system is that
it is not widely acknowledged to be superior in every possible way . A
weak demonstration of this is that no browser has implemented DANE support,
and very few other TLS-using applications have, either. The only thing I
use which has DANE support that I m aware of is Postfix and SMTP is an
application in which the limitations of DANE have far less impact.
My understanding of the limitations of DANE, for large-scale deployment, are
enumerated below.
DNS Is Awful
Quoting Google security engineer Adam Langley:
But many (~4% in past tests) of users can t resolve a TXT record when they
can resolve an A record for the same name. In practice, consumer DNS is
hijacked by many devices that do a poor job of implementing DNS.
Consider that TXT records are far, far older than TLSA records. It seems
likely that TLSA records would fail to be retrieved greater than 4% of the
time. Extrapolate to the likely failure rate for lookup of TLSA records would
be, and imagine what that would do to the reliability of DANE verification.
It would either be completely unworkable, or else would cause a whole new
round of just click through the security error training. Ugh.
This also impacts DNSSEC itself. Lots of recursive resolvers don t validate
DNSSEC, and some providers mangle DNS responses in some way, which breaks
DNSSEC. Since OSes don t support DNSSEC validation by default (for
example, by having the name resolution APIs indicate DNSSEC validation
status), browsers would essentially have to ship their own validating
resolver code.
Some people have concerns around the single point of control for DNS
records, too. While the weakest link nature of the CA model is terribad,
there is a significant body of opinion that replacing it with a single,
minimally-accountable organisation like ICANN isn t a great trade.
Finally, performance is also a concern. Having to go out-of-band to
retrieve TLSA records delays page generation, and nobody likes slow page
loads.
DNSSEC Is Awful
Lots of people don t like DNSSEC, for all sorts of reasons. While I don t
think it is quite as bad as people make out (I ve deployed it for most
zones I
manage,
there are some legitimate issues that mean browser vendors aren t willing to
rely on DNSSEC.
1024 bit RSA keys are quite common throughout the DNSSEC system.
Getting rid of 1024 bit keys in the PKI has been a long-running effort;
doing the same for DNSSEC is likely to take quite a while. Yes, rapid
rotation is possible, by splitting key-signing and zone-signing (a good
design choice), but since it can t be enforced, it s entirely likely that
long-lived 1024 bit keys for signing DNSSEC zones is the rule, rather than
exception.
DNS Providers are Awful
While we all poke fun at CAs who get compromised, consider how often
someone s DNS control panel gets compromised. Now ponder the fact that, if
DANE is supported, TLSA records can be manipulated in that DNS control
panel. Those records would then automatically be DNSSEC signed by the DNS
provider and served up to anyone who comes along. Ouch.
In theory, of course, you should choose a suitably secure DNS provider, to
prevent this problem. Given that there are regular hijackings of
high-profile domains (which, presumably, the owners of those domains would
also want to prevent), there is something in the DNS service provider
market which prevents optimal consumer behaviour. Market for
lemons,
perchance?
Conclusion
None of these problems are unsolvable, although none are trivial. I like
DANE as a concept, and I d really, really like to see it succeed.
However, the problems I ve listed above are all reasonable objections, made
by people who have their hands in browser codebases, and so unless they re
fixed, I don t see that anyone s going to be able to rely on DANE on the
Internet for a long, long time to come.
The Internet is going
encrypted.
Revelations of mass-surveillance of Internet traffic has given the Internet
community the motivation to roll out encrypted services the biggest of
which is undoubtedly HTTP.
The weak point, though, is SSL Certification Authorities. These are trusted
third parties who are supposed to validate that a person requesting a
certificate for a domain is authorised to have a certificate for that
domain. It is no secret that these companies have
failed to do the job entrusted to them,
again, and
again,
and
again.
Oh, and another
one.
However, at this point, doing away with CAs and finding some other mechanism
isn t feasible. There is no clear alternative, and the inertia in the
current system is overwhelming, to the point where it would take a decade or
more to migrate away from the CA-backed SSL certificate ecosystem, even if
there was something that was widely acknowledged to be superior in every
possible way.
This is where Certificate
Transparency comes in. This
protocol, which works as part of the existing CA ecosystem, requires CAs
to publish every certificate they issue, in order for the certificate to be
considered valid by browsers and other user agents. While it doesn t
guarantee to prevent misissuance, it does mean that a CA can t cover up or
try to minimise the impact of a breach or other screwup their actions are
fully public, for everyone to see.
Much of Certificate Transparency s power, however, is diminished if nobody
is looking at the certificates which are being published. That is why I
have launched sslaware.com, a site for searching the
database of logged certificates. At present, it is rather minimalist,
however I intend on adding more features, such as real-time notifications
(if a new cert for your domain or organisation is logged, you ll get an
e-mail about it), and more advanced searching capabilities.
If you care about the security of your website, you should check out
SSL Aware and see what certificates have been issued
for your site. You may be unpleasantly surprised.
Internet references saved for May 2015
Instead of keeping substantial tabs open until I have read all of them, or
losing them in the jungle of browser bookmarks, I have written a script
that collects them into a file per month, and turns them into markdown files
for my blog. This way I sort of know where to find them, and if I do not, some
internet search might. And if I wish, I can even choose to share it.
The programming talent myth [LWN.net]
Jacob Kaplan-Moss is known for his work on Django but, as he would describe
in his keynote, many think he had more to do with its creation than he
actually did. While his talk ranged quite a bit, the theme covered
something that software development organizations and open source
projects may be grappling with: a myth about developer performance and how
it impacts the industry. It was a thought-provoking talk that was
frequently punctuated by applause; these are the kinds of issues that the
Python community tries to confront head on, so the talk was aimed well.
Matt Palmer: The Vicious Circle of Documentation
Why are there so many more undocumented systems than documented ones out
there, and how can we cause more well-documented systems to exist? The
answer isn t people are lazy , and the solution is simple though not
easy.
Jono Bacon, Dealing With Disrespect
This book is about helping us to focus on good people creating good things,
to preserve that spirit of sharing, and to protect against those whose
primary contribution is obstruction and disrespect
OFTC: Automatically Identifying Using SSL + CertFP
This page describes how to use SSL with a certificate fingerprint to
automatically identify your registered nickname with NickServ on connect.
You must have an IRC client that supports SSL with a client certificate.
Fran ois Marier: Usual Debian Server Setup
I manage a few servers for myself, friends and family as well as for the
Libravatar project. Here is how I customize recent releases of Debian on
those servers.
How to name things: the hardest problem in programming
Developers can get better at their craft by learning from the great writers
who mastered theirs. Writing software isn t the same as writing a novel,
but there are parallels. Besides, advice from writers is better because
writers have been struggling with their craft for many centuries, not just
a few decades. It s better-written as well. This talk shares great writers
best advice for coders: Stephen King on refactoring, Anne Rice on
development hardware, Hemingway on modelling with personas, and Neil Gaiman
on everything.
Ever worked at a company (or on a codebase, or whatever) where it seemed
like, no matter what the question was, the answer was written down somewhere
you could easily find it? Most people haven t, sadly, but they do exist,
and I can assure you that it is an absolute pleasure.
On the other hand, practically everyone has experienced completely
undocumented systems and processes, where knowledge is shared by
word-of-mouth, or lost every time someone quits.
Why are there so many more undocumented systems than documented ones out
there, and how can we cause more well-documented systems to exist? The
answer isn t people are lazy , and the solution is simple though not
easy.
Why Johnny Doesn t Read
When someone needs to know something, they might go look for some
documentation, or they might ask someone else or just guess wildly. The
behaviour look for documentation is often reinforced negatively, by the
result documentation doesn t exist .
At the same time, the behaviours ask someone and guess wildly are
positively reinforced, by the results I get my question answered and/or
at least I can get on with my work . Over time, people optimise their
behaviour by skipping the look for documentation step, and just go
straight to asking other people (or guessing wildly).
Why Johnny Doesn t Write
When someone writes documentation, they re hoping that people will read it
and not have to ask them questions in order to be productive and do the
right thing. Hence, the behaviour write documentation is negatively
reinforced by the results I still get asked questions , and nobody does
things the right way around here, dammit!
Worse, though, is that there is very little positive reinforcement for the
author: when someone does read the docs, and thus doesn t ask a question,
the author almost certainly doesn t know they dodged a bullet. Similarly,
when someone does things the right way, it s unlikely that anyone will
notice. It s only the mistakes that catch the attention.
Given that the experience of writing documentation tends to skew towards the
negative, it s not surprising that eventually, the time spent writing
documentation is reallocated to other, more utility-producing activities.
Death Spiral
The combination of these two situations is self-reinforcing. While a
suitably motivated reader might start by strictly looking for
documentation, or an author initially be enthused to always fully
documenting their work, over time the reflex will be for readers to just
go ask someone, because there s never any documentation! , and for authors
to not write documentation because nobody bothers to read what I write
anyway! .
It is important to recognise that this iterative feedback loop is the
natural state of the reader/author ecosystem, resulting in something akin
to thermodynamic entropy. To avoid
the system descending into chaos, energy needs to be constantly applied to
keep the system in order.
The Solution
Effective methods for avoiding the vicious circle can be derived from the
things that cause it. Change the forces that apply themselves to readers
and authors, and they will behave differently.
On the reader s side, the most effective way to encourage people to read
documentation is for it to consistently exist. This means that those in
control of a project or system mustn t consider something done until the
documentation is in a good state. Patches shouldn t be landed, and releases
shouldn t be made, unless the documentation is altered to match the
functional changes being made. Yes, this requires discipline, which is just
a form of energy application to prevent entropic decay.
Writing documentation should be an explicit and well-understood part of
somebody s job description. Whoever is responsible for documentation needs
to be given the time to do it properly. Writing well takes time and mental
energy, and that time needs to be factored into the plans. Never forget
that skimping on documentation, like short-changing QA or customer support,
is a false economy that will cost more in the long term than it saves in the
short term.
Even if the documentation exists, though, some people are going to tend
towards asking people rather than consulting the documentation. This isn t
a moral failing on their part, but only happens when they believe that
asking someone is more beneficial to them than going to the documentation.
To change the behaviour, you need to change the belief.
You could change the belief by increasing the cost of asking. You could
fire (or hellban) anyone who ever asks a question that is answered in the
documentation. But you shouldn t. You could yell
RTFM! at everyone who
asks a question. Thankfully that s one acronym that s falling out of
favour.
Alternately, you can reduce the cost of getting the answer from the
documentation. Possibly the largest single productivity boost for
programmers, for example, has been the existence of Google. Whatever your
problem, there s a pretty good chance that a search or two will find a
solution. For your private documentation, you probably don t have the power
of Google available, but decent full-text search systems are available. Use
them.
Finally, authors would benefit from more positive reinforcement. If you
find good documentation, let the author know! It requires a lot of effort
(comparatively) to look up an author s contact details and send them a nice
e-mail. The like button is a more low-energy way of achieving a similar
outcome you click the button, and the author gets a warm, fuzzy feeling.
If your internal documentation system doesn t have some way to close the
loop and let readers easily give authors a bit of kudos, fix it so it does.
Heck, even if authors just know that a page they wrote was loaded N times
in the past week, that s better than the current situation, in which
deafening silence persists, punctuated by the occasional plaintive cry of
Hey, do you know how to ? .
Do you have any other ideas for how to encourage readers to read, and for
authors to write?
You may have heard that Uber has been under a bit of fire lately for its
desires to hire private investigators to dig up dirt on journalists who
are critical of
Uber.
From using users ride data for party
entertainment,
putting the assistance dogs of blind passengers in the
trunk,
adding a surcharge to reduce the number of dodgy
drivers,
or even booking rides with competitors and then cancelling, or using the
ride to try and convince the driver to change
teams,
it s pretty clear that Uber is a pretty good example of how companies are
inherently
sociopathic.
However, most of those examples are internal stupidities that happened to be
made public. It s a very rare company that doesn t do all sorts of shady
things, on the assumption that the world will never find out about them.
Uber goes quite a bit further, though, and is so out-of-touch with the world
that it blogs about analysing people s sexual activity for
amusement.
You ll note that if you follow the above link, it sends you to the Wayback
Machine, and not Uber s own site. That s because
the original page has recently turned
into a 404. Why? Probably because someone at Uber realised that
bragging about how Uber employees can amuse themselves by perving on your
one night stands might not be a great idea. That still leaves the question
open of what sort of a corporate culture makes anyone ever think that
inspecting user data for amusement would be a good thing, let alone
publicising it? It s horrific.
Thankfully, despite Uber s fairly transparent attempt at whitewashing
( clearwashing ?), the good ol Wayback Machine helps us to remember what
really went on. It would be amusing if Uber tried to pressure the Internet
Archive to remove their copies of this blog post (don t bother, Uber; I ve
got a Save As button and I m not afraid to use it).
In any event, I ve never used Uber (not that I ve got one-night stands to
analyse, anyway), and I ll certainly not be patronising them in the future.
If you re not keen on companies amusing themselves with your private data, I
suggest you might consider doing the same.
Unless you ve been living under a firewalled rock, you know that IPv6 is
coming. There s also a good chance that you ve heard that IPv6 doesn t have
NAT. Or, if you pay close attention to the minutiae of IPv6 development,
you ve heard that IPv6 does have NAT, but you don t have to (and
shouldn t) use it.
So let s say we ll skip NAT for IPv6. Fair enough. However, let s say you
have this use case:
A bunch of containers that need Internet access
That are running in a VM
On your laptop
Behind your home router!
For IPv4, you d just layer on the NAT, right? While SIP and IPsec might
have kittens trying to work through three layers of NAT, for most things
it ll Just Work.
In the Grand Future of IPv6, without NAT, how the hell do you make that
happen? The answer is Prefix
Delegation , which allows
routers to delegate management of a chunk of address space to downstream
routers, and allow those downstream routers to, in turn, delegate pieces of
that chunk to downstream routers.
In the case of our not-so-hypothetical containers-in-VM-on-laptop-at-home
scenario, it would look like this:
My border router (a DNS-323 running
Debian) asks
my ISP for a delegated prefix, using DHCPv6. The ISP delegates a
/561. One /64 out of that is allocated to the network
directly attached to the internal interface, and the rest goes into the
pool , as /60 blocks (so I ve got 15 of them to delegate, if required).
My laptop gets an address on the LAN between itself and the DNS-323 via
stateless auto-addressing ( SLAAC ). It also uses DHCPv6 to request one
of the /60 blocks from the DNS-323. The laptop puts one /64 from
that block as the address space for the virtual LAN (actually a Linux
bridge) that connects the laptop to all my VMs, and puts the other 15
/64 blocks into a pool for delegation.
The VM that will be running the set of containers under test gets an
address on the all VMs virtual LAN via SLAAC, and then requests a
delegated /64 to use for the all containers virtual LAN (another
bridge, this one running on the VM itself) that the containers will each
connect to themselves.
Now, almost all of this Just Works. The current releases of ISC
DHCP support prefix delegation just
fine, and a bit of shell script plumbing between the client and server seals
the deal the client needs to rewrite the server s config file to tell it
the netblock from which it can delegate.
Except for one teensy, tiny problem routing. When the DHCP server
delegates a netblock to a particular machine, the routing table needs to
get updated so that packets going to that netblock actually get sent to the
machine the netblock was delegated to. Without that, traffic destined for
the containers (or the VM) won t actually make it to its destination, and a
one-way Internet connection isn t a whole lot of use.
I cannot understand why this problem hasn t been tripped over before.
It s
absolutely fundamental to the correct operation of the delegation system.
Some people advocate running a dynamic routing protocol, but that s a
sledgehammer to crack a nut if ever I saw one.
Actually, I know this problem has been tripped over before, by
OpenWrt.
Their solution, however, was to use a PHP script to scan logfiles and add
routes. Suffice it to say, that wasn t an option I was keen on exploring.
Instead, I decided to patch ISC DHCP so that the server can run an external
script to add the necessary routes, and perhaps modify firewall rules and
also to reverse the process when the delegation is released (or expired).
If anyone else wants to play around with it, I ve put it up on
Github.
I don t make any promises that it s the right way to do it, necessarily,
but it works, and the script I ve added in
contrib/prefix-delegation-routing.rb
shows how it can be used to good effect. By the way, if anyone knows how
pull requests work over at ISC, drop me a line. From the look of their
website, they don t appear to accept (or at least encourage) external
contributions.
So, that s one small patch for DHCP, one giant leap for my home network.
The standard recommendation is for ISPs to delegate each end-user
customer a /48 (giving 65,536 /64 networks); my ISP is being a
little conservative in only giving me 256 /64s. It works fine for
my purposes, but if you re an ISP getting set for deploying IPv6, make
life easy on your customers and give them a /48.
If you re someone who doesn t like Debian s policy of automatically starting
on install (or its heinous cousin, the RUN or ENABLE variable in
/etc/default/<service>), then running an init system other than systemd
should work out nicely.
For some reason, I seem to end up writing software for
veryesotericuse-cases.
Today, though, I think I ve outdone myself: I sat down and wrote a Ruby
library to get and set process resource limits those things that nobody
ever thinks about except when they run out of file
descriptors.
I didn t even have a direct need for it. Recently I was grovelling through
the EventMachine codebase, looking at the filehandle limit code, and noticed
that the pure-ruby implementation didn t manipulate filehandle limits. I
considered adding it, then realised that there wasn t a library available to
do it. Since I haven t berked around with FFI
for a while, I decided to write rlimit.
Now to find the time to write that patch for EventMachine
Since I doubt there are many people who have a burning need to manipulate
rlimits in Ruby, this gem will no doubt sit quiet and undisturbed in the
dark, dusty corners of rubygems.org. However, for the three people on earth
who find this useful: you re welcome.
If you ve noticed your chrome/chromium on Linux having problems since you
upgraded to somewhere around version 35/36, you re not alone. Thankfully,
it s relatively easy to workaround. It will hit people who keep their
browser open for a long time, or who have lots of tabs (or if you re like
me, and do both).
To tell if you re suffering from this particular problem, crack open your
~/.xsession-errors file (or wherever your system logs stdout/stderr from
programs running under X), and look for lines that look like this:
[22161:22185:0830/124533:ERROR:shared_memory_posix.cc(231)]
Creating shared memory in /dev/shm/.org.chromium.Chromium.gFTQSy
failed: Too many open files
If you see those errors, congratulations! The rest of this blog post will
be of use to you.
There s probably a myriad of bugs open about this problem, but the one I
found was #367037: Shared memory-related tab
crash. It turns
out there s a file handle leak in the chromium codebase somewhere, relating
to shared memory handling. There s no fix available, but the workaround is
quite simple: increase the number of files that processes are allowed to
have open.
System-wide, you can do this by creating a file
/etc/security/limits.d/local-nofile.conf, containing this line:
* - nofile 65535
You could also edit /etc/security/limits.conf to contain the same line, if
you were so inclined. Note that this will only take effect next time you
login, or perhaps even only when you restart X (or, at worst, your entire
machine).
This doesn t help you if you ve got Chromium already open and you d like to
stop it from crashing Right Now (perhaps restarting your machine would be a
terrible hardship, causing you to lose your hard-won uptime record), then
you can use a magical tool called prlimit.
The prlimit syscall is available if you re running a Linux 2.6.36 or later
kernel, and running at least glibc 2.13. You ll have a prlimit command
line program if you ve got util-linux 2.21 or later. If not, you can use
the example source code in the prlimit(2) manpage, changing RLIMIT_CPU
to RLIMIT_NOFILE, and then running it like this:
prlimit <PID> 65535 65535
The <PID> argument is taken from the first number in the log messages from
.xsession-errors in the example above, it s 22161.
And now, you can go back to using your tabs as ersatz bookmarks, like I do.
$ sudo apt-get install -y leiningen
[...]
$ lein new scratch
[...]
$ cd scratch
$ lein repl
Downloading: org/clojure/clojure/1.3.0/clojure-1.3.0.pom from repository central at http://repo1.maven.org/maven2
Transferring 5K from central
Downloading: org/sonatype/oss/oss-parent/5/oss-parent-5.pom from repository central at http://repo1.maven.org/maven2
Transferring 4K from central
Downloading: org/clojure/clojure/1.3.0/clojure-1.3.0.jar from repository central at http://repo1.maven.org/maven2
Transferring 3311K from central
[...]
Wait what? lein downloads some random JARs from a website over
HTTP1, with, as far as far I can tell, no verification that
what I m asking for is what I m getting (has nobody ever heard of
Man-in-the-Middle attacks in Maven land?). It downloads a .sha1 file to
(presumably) do integrity checking, but that s no safety net if I can
serve you a dodgy .jar, I can serve you an equally-dodgy .sha1 file, too
(also, SHA256 is where all the cool kids are at these days). Finally,
jarsigner tells me that there s no signature on the .jar itself, either.
It gets better, though. The repo1.maven.org site is served by the
fastly.net2 pseudo-CDN3, which adds another
set of points in the chain which can be subverted to hijack and spoof
traffic. More routers, more DNS zones, and more servers.
I ve seen Debian take a kicking more than once because packages aren t
individually signed, or because packages aren t served over HTTPS. But at
least Debian s packages can be verified by chaining to a signature made by
a well-known, widely-distributed key, signed by two Debian Developers with
very well-connected keys.
This repository, on the other hand oy gevalt. There are OpenPGP (GPG)
signatures available for each package (tack .asc onto the end of the
.jar URL), but no attempt was made to download the signatures for the
.jar I downloaded. Even if the signature was downloaded and checked,
there s no way for me (or anyone) to trust the signature the signature
was made by a key that s signed by one other key, which itself has no
signatures. If I were an attacker, it wouldn t be hard for me to replace
that key chain with one of my own devising.
Even ignoring everyone living behind a government- or company-run
intercepting proxy, and everyone using public wifi, it s pretty well common
knowledge by now (thanks to Edward Snowden) that playing silly-buggers with
Internet traffic isn t hard to do, and there s no shortage of evidence that
it is, in fact, done on a routine basis by all manner of people. Serving up
executable code to a large number of people, in that threat environment,
with no way for them to have any reasonable assurance that code is
trustworthy, is very disappointing.
Please, for the good of the Internet, improve your act, Maven. Putting
HTTPS on your distribution would be a bare minimum. There are attacks on
SSL, sure, but they re a lot harder to pull off than sitting on public wifi
hijacking TCP connections. Far better would be to start mandating
signatures, requiring signature checks to pass, and having all signatures
chain to a well-known, widely-trusted, and properly secured trust root.
Signing all keys that are allowed to upload to maven.org with a maven.org
distribution root key (itself kept in hardware and only used offline), and
then verifying that all signatures chain to that key, wouldn t be insanely
difficult, and would greatly improve the security of the software supply
chain. Sure, it wouldn t be perfect, but don t make the perfect the enemy
of the good. Cost-effective improvements are possible here.
Yes, security is hard. But you don t get to ignore it just because of that,
when you re creating an attractive nuisance for anyone who wants to own up a
whole passel of machines by slipping some dodgy code into a widely-used
package.
To add insult to injury, it appears to ignore my
http_proxy environment variable, and the repo1.maven.org server
returns plain-text error responses with Content-Type: text/xml. But
at this point, that s just icing on the shit cake.
At one point in the past, my then-employer (a hosting
provider) blocked Fastly s caching servers from their network because
they took down a customer site with a massive number of requests to a
single resource, and the incoming request traffic was indistinguishable
from a botnet-sourced DDoS attack. The requests were coming from IP
space registered to a number of different ISPs, with no distinguishing
rDNS (184-106-82-243.static.cloud-ips.com doesn t help me to
distinguish between I m a professionally-run distributed proxy and
I m a pwned box here to hammer your site into the ground ).
Pretty much all of the new breed of so-called CDNs aren t
actually pro-actively distributing content, they re just proxies.
That isn t a bad thing, per se, but I rather dislike the far-too-common
practice of installing varnish (and perhaps mod_pagespeed, if they re
providing advanced capabilities) on a couple of AWS instances, and
hanging out your shingle as a CDN. I prefer a bit of truth in my
advertising.