<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Koen Rouwhorst on Medium]]></title>
        <description><![CDATA[Stories by Koen Rouwhorst on Medium]]></description>
        <link>https://medium.com/@koenrh?source=rss-56600ac0f743------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*flkiRgIyIOrd94ye1iC9Jw.png</url>
            <title>Stories by Koen Rouwhorst on Medium</title>
            <link>https://medium.com/@koenrh?source=rss-56600ac0f743------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 09:11:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@koenrh/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Russia’s certificate authority for sanctioned organizations]]></title>
            <link>https://medium.com/@koenrh/russias-certificate-authority-for-sanctioned-organizations-645d61af8ac6?source=rss-56600ac0f743------2</link>
            <guid isPermaLink="false">https://medium.com/p/645d61af8ac6</guid>
            <category><![CDATA[russia]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Koen Rouwhorst]]></dc:creator>
            <pubDate>Fri, 08 Apr 2022 13:54:12 GMT</pubDate>
            <atom:updated>2022-05-03T14:55:49.474Z</atom:updated>
            <content:encoded><![CDATA[<p>After Russia’s invasion of Ukraine, several countries and blocs have imposed sweeping sanctions on Russian companies, banks, and individuals. Anticipating these sanctions, we have seen the Russian government taking steps to reduce their dependence on foreign internet infrastructure.</p><p>In early March, the Russian Ministry of Digital Development started recommending users to install a browser that supports the “Russian certificate” if they want to ensure access to all websites and online services. In particular, they mentioned <a href="https://browser.yandex.ru/">Yandex.Browser</a> and <a href="https://browser.ru/">Atom</a> as browsers that already support this certificate.</p><p>This special certificate is the root certificate of Russia’s new national certificate authority. They created this certificate authority to support Russian organizations that had their certificates revoked or not renewed due to the sanctions. In the past weeks, well-known public certificate authorities like <a href="https://knowledge.digicert.com/solution/Embargoed-Countries-and-Regions.html">DigiCert</a> and <a href="https://sectigo.com/knowledge-base/detail/Banned-Country-List-1527076085907/kA01N000000zFKI">Sectigo</a> have fully stopped the issuance of certificates with DNS names for Russian top-level domains and certificates for Russian organizations.</p><p>In this post, I will discuss why the Russian government created a national certificate authority and why it is asking users to install specific browsers. I will also explain how one of these browsers, Yandex Browser, has implemented support for this certificate authority.</p><h4>Certificate authorities and root stores</h4><p>If you visit a website over a secure connection (HTTPS), the server presents the client with a digital certificate. This certificate includes the identity of the website, public keys and signatures that the client uses to verify whether it can be trusted. These digital certificates are issued by certificate authorities.</p><p>Operating systems and some browsers ship with a list of certificates of certificate authorities. These are the certificate authorities that are considered trusted. Your browser verifies that a presented certificate “chains back” to one of these root certificates, as depicted in the image below. These lists of root certificates are also known as root stores, and they are managed by root programs. Apple, Microsoft, and Mozilla all operate their own root programs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*97O_WvRvAGAWsxfHeNWD4g.png" /><figcaption>Browser, root store, and certificate chain</figcaption></figure><p>It is clear that the Russian government rushed to set up this certificate authority. It was put together in a matter of weeks, and is therefore not included yet in any of the formal root programs. It is not clear if they eventually intend to follow to the Baseline Requirements, a set of policies and technical requirements for inclusion in root stores.</p><p>Since this “Russian certificate” is currently not included in any root store, it is not trusted by any modern operating system or browser. They had to find a way to either get users to install the certificate manually or get them to use a browser that supports this Russian certificate authority out of the box. They worked with two Russian tech companies, Yandex and VK (formerly Mail.ru), to add support for this certificate authority to their browsers.</p><h4>Yandex Browser</h4><p>Yandex Browser was the first to add support for Russia’s new certificate authority. Any website that uses a certificate that is signed by this certificate authority is trusted by Yandex Browser. There are several organizations that have already migrated some of their websites to the new certificates, including the National Reserve Bank, as depicted below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aQb0ZBr8HjshKGQldXybxA.png" /><figcaption>Yandex Browser with the website of the National Reserve Bank using the new certificate</figcaption></figure><p>Yandex Browser is based on the open-source Chromium platform. At least on macOS, most Chromium derivatives use the operating system’s root store. This is what made me curious to understand how Yandex added support for this custom root certificate.</p><h4>Reverse engineering</h4><p>I started by installing the Yandex Browser in a virtual machine running macOS and configured it to forward all HTTP traffic to <a href="https://portswigger.net/burp/documentation/desktop/tools/proxy">Burp Proxy</a>. Sifting through all the HTTP requests to Yandex services, I could see the browser retrieving remote configuration files, from allowlisted extensions to URL rewrite rules. What caught my attention was the HTTP request to retrieve a configuration file named custom_root_certs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JUITG_9xZg8Fjmzf3m_iTQ.png" /><figcaption>Yandex Browser HTTP request to retrieve the custom root certificates</figcaption></figure><p>Unfortunately, the contents of all configuration files were scrambled. Looking closely at the different configuration files, their response sizes provided a clue. The size of all of them were multiples of 16 bytes, which could be an indication that the contents (16 byte blocks) are encrypted with a common block cipher like AES.</p><p>I picked Hopper and LLDB to reverse engineer Yandex Browser and understand how it loads and decrypts the remote configuration files. All the bits that I was interested in were packed up in the Yandex Framework binary. After a bit of puzzling, I learned that the configuration files are encrypted using AES in CBC mode with a 256-bit key.</p><pre>00000000 ad a5 29 77 9c 87 35 0d 52 79 bd 69 2e a6 06 bf<br>00000010 f3 20 98 0e a7 7d 3e 84 e8 a0 28 ae 8b d7 a4 0d<br>...</pre><p>The first block (of 16 bytes) makes up the initialization vector (IV):</p><pre>ad a5 29 77 9c 87 35 0d 52 79 bd 69 2e a6 06 bf</pre><p>All configuration files are encrypted with the same 256-bit encryption key that was hard-coded in the Yandex Framework binary.</p><pre>2e 35 49 28 6f 52 5b 4c 47 4a 37 67 47 72 34 2a 51 2d 54 77 39 30 4d 38 56 4e 61 36 44 5e 69 6f</pre><p>Given the encrypted file custom_root_certs, the encryption key and the initialization vector, it can be decrypted using OpenSSL:</p><pre>tail -c +17 ./custom_root_certs | openssl aes-256-cbc -d \<br>    -K 2e3549286f525b4c474a37674772342a512d547739304d38564e6136445e696f -iv ada529779c87350d5279bd692ea606bf | less</pre><h4>Configuration container</h4><p>The plaintext is a JSON document with the following structure:</p><pre>{<br>  &quot;version&quot;: 1,<br>  &quot;data&quot;: &quot;[data]&quot;,<br>  &quot;signature&quot;: &quot;[signature]&quot;<br>}</pre><p>It is a JSON-based container where the contents are stored in the data field. In most cases, this is an encoded JSON string itself. In turn, the value of the signature field is a 256-byte signature over the value of the data field. It took me a little while to figure out what signature algorithm was used to produce this signature. It turned out to be digitally signed using a 1024-bit RSA key with a SHA-1 hash function.</p><p>Given the data and the signature stored in the files custom_root_certs.dat and custom_root_certs.sig, respectively. The signature can be verified using OpenSSL:</p><pre>openssl dgst -sha1 -verify pubkey_1024_0xB3C4A10.pem -signature ./custom_root_certs.sig ./custom_root_certs.dat</pre><p>These configurations are persisted on disk in encrypted form in files named configs_part1.json and configs_part1.json. On macOS, these files can be found in the directory $HOME/Library/Application Support/Yandex/YandexBrowser. It is not clear to me why Yandex went through the effort to encrypt the configuration files other than to obfuscate the contents to make analyzing them a tiny bit harder. The digital signature ensures that the integrity of the configuration files can be verified anyway.</p><h4>Custom root certificates</h4><p>In the previous sections I explained how Yandex Browser loads, decrypts and verifies the individual configuration files. For the ‘custom root certificates’ configuration file, find below a simplified representation of the JSON data:</p><pre>{<br>  &quot;host_masks&quot;: [<br>    &quot;*.vtb.ru&quot;,<br>    &quot;*.sberbank.ru&quot;,<br>    &quot;*.psbank.ru&quot;,<br>    &quot;*.vtb.com&quot;,<br>    &quot;gazprombank.ru&quot;,<br>    &quot;www.gazprombank.ru&quot;,<br>    &quot;...&quot;<br>  ],<br>  &quot;root_certs&quot;: [<br>    &quot;-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----\n&quot;<br>  ]<br>}</pre><p>The JSON structure contains two values, with keys root_certs and host_masks. The two values respectively contain a list of PEM-encoded root certificates and a list of DNS names for which these root certificates are allowed to be used to make trust decisions. The list of ‘host masks’ contains DNS names of organizations for which a certificate has been issued.</p><p>The list of names in the host_masks field is a subset of the “List of domains for which security certificates have been issued” as published on the <a href="https://www.gosuslugi.ru/tls">TLS page</a> of Gosuslugi public services portal. This list can be seen as a low-tech, non-verifiable log of all certificates that have been issued thus far. It is used by Yandex Browser as an allowlist of host names for which the Russian Trusted Root CA can be used to make trust decisions.</p><p>What I found a bit concerning is that Yandex has built this infrastructure where they can remotely add additional custom root certificates to a user’s browser. In theory, this could be used to deliver a custom root certificate to a subset of the users in a transparent and very targeted fashion. For example, based on IP address or the unique client identifier included in the HTTP request. Which, in turn, could be abused to decrypt their HTTPS communications.</p><h4>Russian Trusted Root CA</h4><p>At the moment, the root_certs field contains a single PEM-encoded RSA root certificate of the Russian Trusted Root CA. This is the same certificate as the &quot;CA Root Certificate&quot; published on the Gosuslugi portal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*StG6-jkwI8IH11hYP8FJqQ.png" /><figcaption>Russian CA hierarchy</figcaption></figure><p>Russia’s national certificate authority has a simple structure. At the top of the certificate hierarchy is the Russian Trusted Root CA. Issued leaf certificates ultimately chain up to this root CA. Between the root CA and the leaf certificates, there is the subordinate CA that is used for both certificate signing and certificate revocation list (CRL) signing.</p><p>To obtain a certificate and have it trusted by the supported browsers, you have to <a href="https://www.gosuslugi.ru/600283/1/form">submit a request</a> to the Ministry of Digital Development. This request is said to be reviewed within five business days. If approved, the certificate is issued and the DNS names on the certificate are added to a <a href="https://github.com/koenrh/russian-trusted-root-ca/blob/main/tls_list.csv">public list</a>. Yandex adds the newly added DNS names to their ‘custom root certificates’ remote configuration file. As soon as all Yandex Browser clients have picked up the configuration changes, the new certificate works.</p><p>The Russian government is operating a very bare-bones certificate authority. It does not conform to the <a href="https://sectigo.com/resource-library/what-are-the-baseline-requirements">Baseline Requirements</a> or the policies of the public root programs. Just based on a cursory review of the certificates issued so far, I already identified a number of issues. Certificate serial numbers are sequential, not random, and do not have the minimum 64 bits of entropy. Issued certificates are not published to a certificate transparency log (<strong><em>Update</em></strong><em>: Certificate Transparency is now supported. See update at the bottom.</em>), which makes it impossible to independently audit them and detect potential issues like mis-issuance. There are other issues that show not all inputs are validated properly, which may indicate that certificate issuance is a semi-manual process. For example, there is <a href="https://github.com/koenrh/russian-trusted-root-ca/blob/main/certificates/1118302.pem">one certificate</a> where the Common Name is not included in the ‘Subject Alternative Names’ field. I don’t know if they intend to take the necessary steps to become a publicly trusted certificate authority. If they do, they would have a long road ahead of them.</p><p>There were some suggestions that the purpose of this new certificate authority is to allow the Russian government to intercept and decrypt all HTTPS communications. This is what the Kazakh government has been <a href="https://blog.mozilla.org/netpolicy/2020/12/18/kazakhstan-root-2020/">attempting</a> to do since 2015 by asking citizens to install a special root certificate. There are no indications that this is the case in Russia. Their certificate authority operates more like a normal certificate authority, in the sense that it only issues certificates for DNS names for which the ownership could be verified. Furthermore, browsers like Yandex have implemented technical controls to prevent this certificate authority from being used for DNS names that are not on the allowlist.</p><p>This is not to say that the infrastructure could not be repurposed to decrypt intercepted HTTPS communications, but the purpose appears to be to support Russian organizations that may soon be unable to find a certificate authority to issue them publicly trusted certificates.</p><p>For anyone interested, I have added all files referenced in this post to a public <a href="https://github.com/koenrh/russian-trusted-root-ca">GitHub repository</a>, including all certificates that are currently being used in the wild.</p><p><strong>Update (May 3, 2022)</strong></p><p>Yandex reached out to me to share that they have added support for Certificate Transparency to Yandex Browser, requiring all new certificates to be logged to a Certificate Transparency log. New certificates are logged to three separate Certificate Transparency logs operated by Yandex, VK, and the Russian government (<a href="https://browser-resources.s3.yandex.net/ctlog/ctlog.json">JSON-based log list</a>). A signed certificate timestamp (SCT) is attached to the certificates. Yandex is planning to freeze updates to the allowlist once users have upgraded to the latest version of Yandex Browser with Certificate Transparency support for the Russian Trusted Root CA. The allowlist will be fully removed after all certificates without an embedded SCT have expired. This is a step in the right direction to make this certificate authority publicly accountable. I have not reviewed the implementation yet.</p><p>If you can, please consider making a donation to the <a href="https://www.comebackalive.in.ua/">Come Back Alive Foundation</a> (and ask your employer to match your gift) to help save Ukraine and Ukrainians. Slava Ukraini!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=645d61af8ac6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Underscoring the “private” in private key]]></title>
            <link>https://medium.com/@koenrh/underscoring-the-private-in-private-key-5591dc9de7f6?source=rss-56600ac0f743------2</link>
            <guid isPermaLink="false">https://medium.com/p/5591dc9de7f6</guid>
            <category><![CDATA[application-security]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Koen Rouwhorst]]></dc:creator>
            <pubDate>Fri, 26 Jul 2019 13:08:51 GMT</pubDate>
            <atom:updated>2021-11-29T14:52:32.672Z</atom:updated>
            <content:encoded><![CDATA[<p>Last weekend, Eric Lawrence <a href="https://twitter.com/ericlaw/status/1152322086892912640">found</a> that the Amazon Music app, <a href="https://medium.com/bugbountywriteup/zoom-zero-day-4-million-webcams-maybe-an-rce-just-get-them-to-visit-your-website-ac75c83f4ef5">like Zoom</a>, can automatically be launched from web pages without any user interaction. The way this works is through a local web server that accepts HTTP requests from web pages to instantly launch the Amazon Music app to play a particular song. This bypasses the built-in safety net in browsers that seek confirmation from users before launching an application. The right way to implement this feature is to register and use a custom protocol handler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ONtxgnB2iFHry0Ba.png" /><figcaption>Safari confirmation prompt for launching an application</figcaption></figure><p>However, that wasn’t the thing that stood out. The local web server is accessible over HTTPS using a public DNS name ( amazonmusiclocal.com) that resolves to 127.0.0.1. This is unusual, because browsers consider localhost to be a secure context, which means that you can make HTTP requests to localhost (e.g. http://localhost:8080) from an HTTPS origin. If it is possible to establish an HTTPS connection using the aforementioned public DNS name, chances are that the private key for the publicly trusted certificate is likely hard-coded somewhere in the application binaries.</p><p>To verify whether that was the case, I installed the Amazon Music app in a clean virtual machine. Which allowed me to identify the Amazon Music local web server by listing the processes that are listening on any given port. As depicted below, the Amazon Music Helper process is listening on TCP port 18800. It is also interesting to note that it binds to <em>any</em> interface, not just the loopback interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qzFHli-mlK9NBdgF.png" /><figcaption><em>Amazon Music local web server listening on the loopback interface</em></figcaption></figure><p>Then I used cURL to verify that the local web server presents a valid and publicly trusted certificate and that we can successfully establish an HTTPS connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NuI7JkpJEdKADPAf.png" /><figcaption><em>Using cURL to establish an HTTPS connection with amazonmusiclocal.com</em></figcaption></figure><p>The local web server is handled by the <em>Amazon Music Helper</em> program. If the RSA private key is hard-coded in that binary, then it should be fairly straightforward to locate it by looking for known indicators. For example, a PEM or DER encoded 2048-bit RSA private key, can be recognized by byte sequences 30 82 04 and 4d 49 49 45 (Base64 string &quot;MIIE&quot;), respectively. Unfortunately, this yielded no results.</p><p>The next step I took was to load the binary into a disassembler to dive a little deeper. What immediately stood out was the procedure at 0x10000ac0 labeled Morpho::HttpDispatcher::parseCertAndKey() and its calls to the following procedures:</p><ul><li>Morpho::HelperServer::getAesKey()</li><li>Morpho::HelperServer::getAesIV()</li><li>Morpho::AesEncryptor::decrypt() (two times)</li></ul><p>This indicated that both the RSA private key and the leaf certificate were encrypted using AES. The respective hexadecimal-encoded ciphertexts, as shown below, are copied into memory, and then read by the two decrypt() calls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6rB0MuZVIJzDXVcR.png" /><figcaption><em>Private key and leaf certificate ciphertexts</em></figcaption></figure><p>To decrypt the private key and leaf certificate, I had to find the AES encryption key and initialization vector (IV). Unfortunately, I couldn’t easily find either of them hard-coded in the binary. Hence, I opted to use a debugger (LLDB) instead to launch the Amazon Music Helper program, set breakpoints right before the decryption calls, and read the encryption key and IV from memory.</p><ul><li>256-bit key: fb4098e00b3fb0562a625d96599b2be6a3876ccfc21908c1cb173850745d1cd5</li><li>128-bit IV: 3ac0660ee766394f65a6eb26ae3dbf84</li></ul><p>Given the RSA private key and leaf certificate ciphertexts are saved as files key.der.enc and certificate.pem.enc, respectively, both can be decrypted using the following OpenSSL commands. The ciphertexts and the decrypted private key and leaf certificate can be found <a href="https://gist.github.com/koenrh/bab4e7b44441c0cfe54b7ba3e16e86df">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8Dwqmg1w9yFaMXlS.png" /><figcaption>Decrypting RSA private key used by Amazon Music</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zcY7PQzE5JF3dXNV.png" /><figcaption>Decrypting certificate used by Amazon Music</figcaption></figure><p>To verify that the private key corresponds to the public key in the leaf certificate, the SHA-256 hash of the public key derived from the private key can be compared to the SHA-256 hash of the public key in the <a href="https://crt.sh/?id=1688943653">leaf certificate</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A2lb_0c6T47VNgvT.png" /><figcaption>Validate that private key belongs to public key in certificate used by Amazon Music</figcaption></figure><p>It should be obvious to anyone, but private keys are meant to remain private. This holds also true for the private key that corresponds to the public key in the publicly trusted certificates for <a href="https://www.amazonmusiclocal.com/">www.amazonmusiclocal.com</a> that Amazon shipped with the Amazon Music app. For reasons unclear to me, Amazon obscured this fact by encrypting private key and only hard-coding the ciphertext. As demonstrated, this doesn&#39;t make a difference as long as the encryption key is trivially recoverable. As outlined in the CA/Browser Forum&#39;s <a href="https://cabforum.org/wp-content/uploads/CA-Browser-Forum-BR-1.6.5.pdf">Baseline Requirements</a>, this is considered a key compromise, which means that private key should be revoked.</p><p><a href="https://cabforum.org/wp-content/uploads/CA-Browser-Forum-BR-1.6.5.pdf"><strong>Baseline Requirements</strong></a><strong> (1.6.1. Definitions):</strong></p><blockquote>A Private Key is said to be compromised if its value has been disclosed to an unauthorized person or an unauthorized person has had access to it.</blockquote><p><a href="https://cabforum.org/wp-content/uploads/CA-Browser-Forum-BR-1.6.5.pdf"><strong>Baseline Requirements</strong></a><strong> (4.9.1.2. Reasons for Revoking a Subordinate CA Certificate):</strong></p><blockquote><em>The CA SHALL revoke a Certificate within 24 hours if one or more of the following occurs:</em></blockquote><blockquote>1. The Subscriber requests in writing that the CA revoke the Certificate;<br>2. The Subscriber notifies the CA that the original certificate request was not authorized and does not retroactively grant authorization;<br>3. The CA obtains evidence that the Subscriber’s Private Key corresponding to the Public Key in the Certificate suffered a Key Compromise; or<br>4. The CA obtains evidence that the validation of domain authorization or control for any Fully-Qualified Domain Name or IP address in the Certificate should not be relied upon.</blockquote><p>There was no need to report the certificate to the issuing certificate authority, which also happened to be Amazon, because the <a href="https://crt.sh/?id=1688943653">certificate</a> was revoked within hours after Eric Lawrence’s <a href="https://twitter.com/ericlaw/status/1152322086892912640">original tweet</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LXY4gUYT-e8lxzau.png" /><figcaption><em>Requesting OCSP revocation status</em> of certificate used by Amazon Music local web server</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5591dc9de7f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A tale of private key reuse]]></title>
            <link>https://medium.com/@koenrh/a-tale-of-private-key-reuse-8ff0cb766fa5?source=rss-56600ac0f743------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ff0cb766fa5</guid>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Koen Rouwhorst]]></dc:creator>
            <pubDate>Fri, 18 Jan 2019 06:51:00 GMT</pubDate>
            <atom:updated>2021-11-29T15:14:11.590Z</atom:updated>
            <content:encoded><![CDATA[<p>In 2017, while attempting to get some DRM-enabled video player to work on my Mac, I stumbled upon a hard-coded private key. The corresponding public key was used in a valid and publicly trusted <a href="https://twitter.com/koenrh/status/876699612681293825">Cisco certificate</a>. This further piqued my interest in the internet PKI, and made me wonder how many private keys I would be able to find. In the months that followed I found and reported many hundreds of certificates of which the private key was compromised. In this post, I want to focus on one particular compromised key.</p><p>I started out by building tools to scan the internet and public data sources (e.g. <a href="https://cloud.google.com/bigquery/public-data/github">GitHub’s public data set</a>) for PEM and DER-encoded keys and certificates. After scanning for a while, I inserted the collected raw certificates and keys into a local document database for further analysis. This allowed me to quickly identify publicly trusted certificates with known-compromised keys by filtering out all non-publicly trusted certificates, and joining the certificates with the private keys on the SHA-256 hash of the extracted public key ( <a href="https://tools.ietf.org/html/rfc5280#section-4.1.2.7">Subject Public Key Info</a>). Grouping and counting the certificates on this hash showed that there were multiple certificates that shared the very same RSA public key. Searching the certificate transparency logs showed there were a few dozen in total.</p><p>Details of the compromised RSA key:</p><ul><li>SHA-256 hash of the SubjectPublicKeyInfo: 2bf95e73d665fbdcf525f08420573df075ea81759e46b7554a2afa1b68d3bebe</li><li>Raw PEM-encoded <a href="https://gist.github.com/koenrh/6f2aaeca9661dbcd7f7a5521f5c0b249#file-privkey-pem">private</a> and <a href="https://gist.github.com/koenrh/6f2aaeca9661dbcd7f7a5521f5c0b249#file-pubkey-pem">public key</a>.</li><li>Certificates that use this public key: <a href="https://crt.sh/?spkisha256=2bf95e73d665fbdcf525f08420573df075ea81759e46b7554a2afa1b68d3bebe">crt.sh</a>, <a href="https://censys.io/certificates?q=parsed.subject_key_info.fingerprint_sha256%3A2bf95e73d665fbdcf525f08420573df075ea81759e46b7554a2afa1b68d3bebe">Censys</a>.</li></ul><p>In the end I had a list of a little over 60 certificates that all used the same compromised key (<a href="https://gist.github.com/koenrh/5bf209b21eebd9546bfa65fbaa86286b">full list</a>). These certificates were valid for DNS names of seemingly-unrelated customers, which ruled out the possibility that one customer simply reused their private key in different certificates. This made me curious to figure out the source of the compromise.</p><p>I had two leads to go on:</p><ul><li>The raw private key was found in two unrelated GitHub repositories that hosted the source code of a WordPress website.</li><li>A significant number of the DNS names for which these certificates were valid pointed (or had pointed to in the past) to DigitalOcean’s IP space.</li></ul><p>I also recalled one incident from a few years ago where Hetzner Online, a well-known German web hosting provider, had provisioned servers with <a href="https://blogs.intevation.de/thomas/hetzner-duplicate-ed25519-ssh-host-keys/">identical SSH host keys</a>. Which made me think that this case might as well be related to using some base image with hard-coded keys. What strengthened this thought was that I found that DigitalOcean, for a while, allowed customers to quickly install popular web apps using virtual machine images provided by Bitnami ( <a href="https://web.archive.org/web/20150905122006/https://digitalocean.bitnami.com/">archived page</a>).</p><p>After scanning some of the virtual machine images for WordPress, I quickly found the private key in one of the WordPress images. These are the steps to reproduce:</p><ol><li>Download the file <a href="https://downloads.bitnami.com/files/stacks/wordpress/4.9.1-0/bitnami-wordpress-4.9.1-0-linux-debian-8-x86_64.zip">bitnami-wordpress-4.9.1–0-linux-debian-8-x86_64.zip.</a></li><li>The zip file should match the SHA-256 checksum: 59a970bf147aeaf125aec78f538127dff4799b28dabd705c6705d8e38155dd82.</li><li>Unzip the contents (a single VMX configuration file, and multiple VMDK files).</li><li>Find the private key in the bitnami-wordpress-4.9.1-0-linux-debian-8-x86_64-s001.vmdk file at offset 0x163C6000 (and the next 4096 bytes).</li><li>Extract the key using a tool such as <a href="https://github.com/ReFirmLabs/binwalk">binwalk</a>.</li></ol><p>Provided you saved the extracted private key with the original file name, server.key, you could verify that it matches the compromised private key by calculating the SHA-256 hash of the Subject Public Key Info using OpenSSL:</p><pre>$ openssl rsa -in server.key -pubout | openssl rsa -pubin -outform der | openssl dgst -sha256 writing RSA key writing RSA key 2bf95e73d665fbdcf525f08420573df075ea81759e46b7554a2afa1b68d3bebe</pre><p>This issue was reported to Bitnami on January 14, 2018. As per my suggestion, they released new versions of the virtual machine images for WordPress (and all Apache-powered catalog apps) to generate the default key at first-boot time. They also updated the existing documentation with instructions on how to furnish a new key before requesting the issuance of an SSL certificate. The fix is included in WordPress image <strong>version 4.9.2–1</strong> and later.</p><p>After the original issue was fixed, and after I had reported several dozen certificates, I thought the case was closed. But then, over the course of 2018, I noticed that there were still new certificates being issued with the aforementioned compromised key. Most recently these two:</p><ul><li><a href="https://crt.sh/?id=877626319">greatwalksofaustralia.com.au</a> (valid until October 23, 2019)</li><li><a href="https://crt.sh/?id=829263927">childrenfirstfoundation.org.au</a> (valid until October 9, 2019)</li></ul><p>This means that:</p><ul><li>Certificate authorities allow the same key to be reused by different customers. They do not appear to proactively check whether a key was used before, and block the key accordingly.</li><li>And worse, certificate authorities allow keys to be reused even after they themselves previously revoked a certificate with that key (with the reason code ‘keyCompromise’).</li></ul><p>At least Comodo (now Sectigo) eventually added the compromised key to their internal blacklist to prevent future issuance of certificates with that key. It appears this is not something certificate authorities do proactively when a key compromise is reported to them. As far as I understand, per the <a href="https://cabforum.org/wp-content/uploads/CA-Browser-Forum-BR-1.6.2.pdf">Baseline Requirements</a>, they are not required to do so.</p><p>In a brief email correspondence, Rob Stradling also pointed out that he previously made some <a href="https://mailarchive.ietf.org/arch/msg/trans/tB8YhAapz_6RN9MJVMKlRCR9HK0">suggestions</a> for future improvements in this area.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ff0cb766fa5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Protecting our mission-critical domain names]]></title>
            <link>https://medium.com/blendle-engineering/protecting-our-mission-critical-domain-names-e9807db9d84c?source=rss-56600ac0f743------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9807db9d84c</guid>
            <category><![CDATA[domains]]></category>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[domain-names]]></category>
            <dc:creator><![CDATA[Koen Rouwhorst]]></dc:creator>
            <pubDate>Fri, 29 Sep 2017 12:57:23 GMT</pubDate>
            <atom:updated>2019-01-11T00:03:46.898Z</atom:updated>
            <content:encoded><![CDATA[<p>At <a href="https://blendle.com/">Blendle</a> we recently thoroughly reviewed the security of our domain names. In this blog post we will describe what we have learned, and what measures we have taken since to protect the domain names that are critical to the operation of our business.</p><h3>About registries and registrars</h3><p>First, a few words on the different entities involved in the domain name ecosystem. In order to reserve a domain name, a registrant must register it with a registrar or one of their resellers. Some of the largest and most well-known registrars include eNom, Tucows, and Network Solutions. Once a domain name is registered, the registrar sends the domain name information up to the registry operator that, in turn, enters the information into a centralised registry database. While registrars are responsible for the day-to-day business of selling domain names, registry operators are responsible for maintaining the registry for a top-level domain name. Verisign is the most well-known of all registries, and is the authoritative operator for the top-level domain names <em>com</em>, and <em>net</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*vtHEX5ZjLhaFDu7xTrFuVg.png" /><figcaption>A simplified overview of how registrants, registrars, and name servers fit together.</figcaption></figure><h3>What is domain hijacking?</h3><p>Domain hijacking (or domain theft) is the practice of changing the registration of a domain name without the permission of its legal registrant. It works by tricking the registrar into updating the name servers of the domain or contact information associated with the domain. The registrar pushes these changes up to the registry, after which others will treat those changes as authoritative. In the worst case, attackers managed to move the domain to a new registrar, making a recovery process far more difficult. In which case your only hope is to appeal to the registrar that lost your domain name, or the registrar the attacker managed to transfer the domain name to, and hope the registrar does the right thing. If that doesn’t help, the only option left is to file a legal complaint with the internet’s governing body, <a href="https://www.icann.org/">ICANN</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*ssUr-WCoQsLpgUqHrSLuwg.png" /><figcaption>An attacker abusing privileges to push changes to the registry.</figcaption></figure><h4>Examples</h4><p>These are some examples of domain hijacking incidents that made the news in the past couple of years.</p><ul><li>In 2012, social bookmarking service Diigo <a href="https://techcrunch.com/2012/10/27/social-annotation-site-diigo-com-recovering-after-domain-hijacking-nightmare/">lost control</a> of their domain. Attackers managed to transfer the domain to another registrar. As a result, millions of customers couldn’t access the site for over two days.</li><li>In 2013, the the Syrian Electronic Army (SEA) <a href="https://blog.cloudflare.com/details-behind-todays-internet-hacks/">hacked</a> the New York Times’ registrar, and updated the name servers for <em>nytimes.com</em>.</li><li>In 2013, the domain name of Michael Lee’s graphic design and advertising business, <em>mla.com</em>, <a href="http://web.archive.org/web/20141001081551/http://www.huffingtonpost.com/2014/09/29/domain-theft_n_5877510.html">was stolen</a>. His business lost about $200,000 in sales, which forced him to lay off personnel. It took him almost two years to get the domain name back.</li><li>In 2014, Jordan Reid, a popular lifestyle blogger, had the domain name <em>ramshackleglam.com</em> stolen. She got the domain name back in several days after intervention of her lawyers and the FBI.</li><li>In 2015, the domain name of ShadesDaddy was <a href="http://www.shadesdaddyblog.com/shadesdaddy-com-domain-hijacked-hackers-china-redirecting-websites/">stolen</a> for 11 days. The company lost about $50,000 in revenue, which forced the company to lay off six of their eight employees.</li><li>In 2016, criminals <a href="https://www.wired.com/2017/04/hackers-hijacked-banks-entire-online-operation/">hijacked</a> the domain name of a major Brazilian bank. All of the bank’s operations were under attackers’ control for more than five hours. In that five-hour window, customers were redirected to phishing sites, which allowed the attackers to steal the customers’ login credentials.</li></ul><h3>What is the problem?</h3><p>Domain hijacking, as explained in the previous section, occurs at the registrar level. Until recently, we had all our domain names managed by multiple registrars. Unfortunately, these registrars compete mostly with each other on price, and security is not their main focus. We identified several issues, listed in no particular order:</p><ul><li>No support for multiple users under the same registrant account.</li><li>Insufficient authentication validation of requests through phone or email.</li><li>No support for two-factor authentication.</li><li>No support for multiple authorisation levels, any privileged user can undo security settings.</li><li>No two-person (or split-password) rule.</li></ul><p>Most registrars only offer a single user account, which doesn’t work for organisations, because employees, who have the passwords, will eventually leave. The domain names, on the other hand, stay with the organisation. Also, most registrars allow any privileged user to undo security settings, allowing them to initiate transfers and update name servers. There is no two-person (or split-password) rule, which means that anyone who has access to the registrar account is able to make updates to the domains, whether it is an attacker who compromised your registrar account or an employee gone rogue.</p><h3>Lock down all the things!</h3><p>Before we started talking to candidate registrars, we defined the following requirements:</p><ul><li>Registry locks are applied consistently to mission-critical domain names, e.g. <a href="https://blendle.com/">blendle.com</a>, and other customer-facing domain names like <em>blendlecdn.com</em>, and <em>blendleimg.com</em>.</li><li>Role-based contacts (e.g. “Blendle Hostmaster”) are used to prevent individuals from being targeted by attackers.</li><li>Domain names are renewed automatically, such that the window of expiration is at no time less than one year, preventing accidental loss of the domain name.</li><li>Multi-user, out-of-band, approval process is used to unlock domain names for updates.</li></ul><p>Domain names can be locked at the registrar level using a ‘registrar lock’, which prevents updates, including transfers and deletions, unless the lock is explicitly removed. However, this lock doesn’t mean much for security. If an attacker gains access to your account, they can remove the lock themselves, and make whatever changes they want.</p><p>A registry lock, on the other hand, provides much more security, because it prevents updates by <em>any</em> registrar. Removal of this lock requires “out-of-band” communication between the registrar and the registry (e.g. Verisign). It’s a manual process, and thus very costly, which means there aren’t many registrars that have implemented it.</p><p>In the past few months, we have talked to many registrars, asking them about support for registrar- and registry-level locks, and unlocking procedures. Unfortunately, we only found handful registrars that could, or were willing to, meet our requirements:</p><ul><li><a href="https://www.cloudflare.com/registrar/">Cloudflare</a></li><li><a href="https://www.cscglobal.com/">CSC</a></li><li><a href="https://www.markmonitor.com/">MarkMonitor</a></li></ul><p>CSC and MarkMonitor have a background in brand- and intellectual property protection, but all offer more or less the same security features. If you are already a Cloudflare customer (on the Enterprise plan), it makes sense to look at their <a href="https://www.cloudflare.com/registrar/">Registrar</a> product. We ultimately partnered with CSC to manage our domain portfolio, and lock down our mission-critical domain names.</p><h4>Authorisation process</h4><p>In order to transfer or update a registry-locked domain name, the lock needs to be removed (temporarily). This is what our unlocking procedure looks like:</p><ol><li>An administrator in our organisation requests an update (e.g. name server change) to a registry-locked domain name, implicitly requesting the registry lock ) removed.</li><li>Removal of the lock needs to be approved by each and every designated representative (e.g. legal, management) of our organisation. They are contacted by the registrar via telephone, and required to provide the pre-agreed passphrase.</li><li>On behalf of the registrar an authorised individual submits a request to the registry operator (Verisign) to remove the registry lock.</li><li>This individual is then contacted by the registry operator via phone, and required to provide the pre-agreed passphrase in order for the domain name to be unlocked.</li><li>A time-window opens up in which changes can be made.</li></ol><h3>Check your domain locks</h3><p>In order to check whether a domain is locked at the registry level, you could, for example, use Verisign’s <a href="https://www.verisign.com/en_US/domain-names/whois/index.xhtml">whois lookup tool</a>. After you enter the domain name, and hit enter, in the whois record, you find up to four “Domain Status” fields: “Delete”, “Renew”, “Transfer”, and “Update”. Of which “Delete”, “Transfer”, and “Update” are critical for locking your domain. Your domain is registry-locked if the record includes these domain statuses:</p><ul><li>serverDeleteProhibited</li><li>serverTransferProhibited</li><li>serverUpdateProhibited</li></ul><p>If the whois record for your domain only includes the mandatory clientUpdateProhibited status, it means the domain is only locked at the registrar, but not at the registry.</p><p>Here is the whois record for blendle.com, the domain name most critical to our business. The three “server” statuses indicate that the domain is locked at the registry level.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e2fcdeb54859031b92c38a6494b8840/href">https://medium.com/media/1e2fcdeb54859031b92c38a6494b8840/href</a></iframe><h3>What we learned</h3><p>The domain name <a href="https://blendle.com/">blendle.com</a> is one of our most valuable assets, as it represents our (online) identity. But just as important are the domain names that we use in our production environment (e.g. APIs, CDN, email).</p><p>What we learned is that most registrars aren’t very well-equipped to offer the level protection that we require for these domain names that are critical to our operation. We were somewhat surprised to learn how exposed our domain names really were. For attackers, it takes relatively little effort to compromise a registrar account, and transfer away a domain name, but for an organisation it takes considerably more effort to recover from that situation. This is largely caused by the way most registrars operate. They operate on volume, and thus have little incentive to invest in (expensive) security controls.</p><p>We have put our high-profile and mission-critical domain names in the hands of a registrar that has demonstrated convincingly that they take protecting domain names very serious. There are no silver bullets in security, but through security controls and strict procedures we have raised the bar significantly higher for attackers.</p><p>It will take some coordination to implement these measures, and, of course, a much heftier recurring fee, but we are convinced that it is well worth the investment. Just consider how even a temporary loss of your main domain name would affect your operation.</p><p><em>If you have any questions, send me a direct message on </em><a href="https://twitter.com/koenrh"><em>Twitter</em></a><em> or send me an email at </em><a href="/service/mailto:koenrh@blendle.com"><em>koenrh@blendle.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9807db9d84c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/blendle-engineering/protecting-our-mission-critical-domain-names-e9807db9d84c">Protecting our mission-critical domain names</a> was originally published in <a href="https://medium.com/blendle-engineering">Blendle Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GitHub bug bounty hunting]]></title>
            <link>https://medium.com/@koenrh/github-bug-bounty-hunting-741de324be1c?source=rss-56600ac0f743------2</link>
            <guid isPermaLink="false">https://medium.com/p/741de324be1c</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <dc:creator><![CDATA[Koen Rouwhorst]]></dc:creator>
            <pubDate>Sun, 07 Feb 2016 14:31:01 GMT</pubDate>
            <atom:updated>2016-02-07T19:23:53.247Z</atom:updated>
            <content:encoded><![CDATA[<p>Last month, I went hunting for security bugs in <a href="https://github.com/">GitHub</a>, a popular platform for sharing and collaborating on code. After spending many hours mapping out GitHub’s infrastructure, and testing for weaknesses without any significant results or leads, I shifted my focus to the service providers. This is a write-up about two of the issues I found, which both have since been addressed.</p><h4>Trawling Amazon S3 buckets</h4><p>There aren’t many organisations that don’t use <a href="https://aws.amazon.com/s3/">Amazon S3</a> for object storage in some way, and there aren’t many organisations that have correctly configured all of their S3 buckets either. That’s because it’s far too easy to screw up a bucket’s access control list (ACL), granting anonymous or any authenticated AWS users read and/or write access. Assuming GitHub would be no exception, I started compiling a list of their S3 buckets, based on information from public sources. (Un)fortunately, this resulted in only a few buckets containing static assets that were configured properly anyway.</p><p>But then I realised many S3 buckets have very predictable names. They almost always consist of two or three parts: an organisation name, a name describing the bucket’s contents, and an optional suffix (usually the environment, e.g. “production”), separated by periods, hyphens, or underscores. I wrote a very straightforward script to enumerate the bucket names using a word list and a suffix list. What is nice is that you don’t actually need to interact with any of the AWS APIs to check for a bucket’s existence, you could simply query a DNS server, because existing buckets leave distinguishable DNS responses.</p><p>With a list of about a dozen names of buckets possibly belonging to GitHub, I ran another script to determine which buckets were accessible by anonymous or authenticated AWS users. I found one S3 bucket that wasn’t configured properly, which allowed anyone to list the bucket’s contents and download objects. I later learned that among the objects in this bucket were internal GitHub infrastructure graphs, which is the kind of information an attacker would be looking for.</p><p>The issue was addressed by GitHub by updating the bucket’s configuration. A useful auditing tool for AWS services is <a href="https://github.com/iSECPartners/Scout2">Scout2</a> by iSEC, which is capable of highlighting misconfigured S3 buckets.</p><h4>Taking over domain names</h4><p>The other, far more interesting, vulnerability I found was in the systems of one of GitHub’s CDN providers that would have allowed an attacker to take over arbitrary sub domains of both <em>github.io</em>, and <em>githubusercontent.com</em>, including sub domain names that were already in use, e.g. <em>raw.githubusercontent.com</em>, and existing GitHub Pages domains.</p><p>This issue was caused by a bug in a procedure that checks whether a particular domain name could be claimed, and assigned to an account with this CDN provider. This procedure uses Mozilla’s <a href="https://publicsuffix.org/list/">Public Suffix List</a>, a curated list of all levels (e.g. <em>co.uk</em>) at which a domain name may be registered for a particular top-level domain, to check whether a domain name can be registered. The problem was that if someone would assign the domain name <em>foo.example.org</em> to their account, and the parent suffix (i.e. <em>example.org</em>) is on that list, then it would not verify whether <em>example.org</em> was already in use by someone else. Since both <em>github.io</em> and <em>githubusercontent.com</em> are on that list, anyone could claim any of the sub domains.</p><p>The GitHub domain entries on the <a href="https://github.com/publicsuffix/list/blob/24caf4f72bf42a87559685e7211796c94855a90c/public_suffix_list.dat#L11106-L11109">Public Suffix List</a>:</p><pre>// Submitted by Ben Toews &lt;<a href="/service/mailto:btoews@github.com">btoews@github.com</a>&gt; 2014–02–06<br>github.io<br>githubusercontent.com</pre><p>At the point where an attacker was able to assign any of the aforementioned GitHub domain names to their account, he or she could point these domain names to literally any back-end, and thus fully control the domain. What made this bug particularly interesting was that an attacker could even use GitHub’s TLS certificate for services on their account. Which is great from an exploitability perspective, because an attacker would be able to transparently man-in-the-middle any (existing) sub domain of both <em>github.io</em> and <em>githubusercontent.com</em>, and, for example, serve malicious content for (specific) requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*T9PBfJ9B4lX1JNBMaqRLCg.png" /><figcaption>Take-over of a GitHub sub domain.</figcaption></figure><p>Some GitHub services that were vulnerable:</p><ul><li><strong>github.io</strong>: Serves GitHub Pages.</li><li><strong>raw.githubusercontent.com</strong>: Serves raw file content from GitHub repositories.</li><li><strong>gist.githubusercontent.com</strong>: Serves raw file content from GitHub gists.</li></ul><p>The issue was addressed by GitHub’s CDN provider by removing the GitHub domain names from (their version) of the PSL. They also reviewed all other entries on the list to make sure there was no further impact.</p><p>Both vulnerabilities were awarded a monetary bounty. I asked GitHub to donate the bounty for the first vulnerability to <a href="https://www.torproject.org/">The Tor Project</a>, because they do important work, and need more (independent) funding. I would like to thank GitHub for <a href="https://bounty.github.com/#faq-1">matching</a> the donation.</p><p>GitHub also put up a <a href="https://bounty.github.com/researchers/koenrh.html">hunter profile</a> on their bug bounty website, along with descriptions of both vulnerabilities.</p><h3>GitHub Security on Twitter</h3><p>Thanks @koenrh for reporting a user-content subdomain takeover vulnerability in our CDN https://bounty.github.com/researchers/koenrh.html ...</p><h3>GitHub Security on Twitter</h3><p>Thanks to @koenrh for finding a hole in our S3 permissions and for donating his reward to @torproject! https://bounty.github.com/researchers/koenrh.html ...</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=741de324be1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[No, the U.S. Army did not read the emails of a Belgian MP]]></title>
            <link>https://medium.com/@koenrh/no-the-u-s-army-did-not-read-the-emails-of-a-belgian-mp-21d04b683086?source=rss-56600ac0f743------2</link>
            <guid isPermaLink="false">https://medium.com/p/21d04b683086</guid>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Koen Rouwhorst]]></dc:creator>
            <pubDate>Sat, 02 Nov 2013 18:26:14 GMT</pubDate>
            <atom:updated>2021-11-29T15:21:36.852Z</atom:updated>
            <content:encoded><![CDATA[<p>Today, someone <a href="https://twitter.com/legalift/status/396628823883534336">pointed</a> me at an <a href="https://www.standaard.be/cnt/dmf20131102_00820363">article</a> in Belgian newspaper <em>De Standaard</em> in which Karolien Grosemans, a Belgian MP of the New Flemish Alliance (N-VA), claimed the U.S. Army had read one of her emails. In this email she asked an expert for advice on a draft legislation on cyber attacks and security, hence the subject field of the email contained the words “cyberaanvallen” (cyber attacks) and “cyber security”.</p><p>She said the expert showed her evidence that the email, addressed to the expert’s Mail.com address, was routed through a U.S. military base in the southeast of Arizona, Fort Huachuca. This so-called “evidence”, however, consists solely of a single email header line, as depicted below. According to the expert this header shows the route the message has traveled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/0*tq8AtSLRkgQnGuZH" /><figcaption>“message opened by mailclient 6.73.3.0 (6.73.1.0)”</figcaption></figure><p>When I read this line I didn’t immediately think of the two four-part numbers as IP addresses. The expert, however, believes either of the numbers is the IP address of the client that opened the email. He’s right that both IP addresses are owned by the U.S. Army, but that’s no coincidence as the 6.0.0.0/8 netblock (6.0.0.0 to 6.255.255.255) is allocated to the U.S. Army Information Systems Command (USAISC).</p><p>This expert may want to take off his tinfoil hat, because both numbers are, in fact, version numbers of <a href="https://encrypted.google.com/search?q=%22service.mail.com%2Fcallgate%22">software</a> that runs on the servers of GMX Mail, the company that operates Mail.com. This header is added to every single email that drops into a Mail.com inbox.</p><p>It may surprise Ms. Grosemans and her expert, but if the U.S. Army (or one of the three-letter agencies, for that matter) did read your email it’s not very likely you would find a note saying they did so. And before (falsely) accusing an organisation of breaking into your inbox and reading your emails, you may want to consult a true expert.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21d04b683086" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[No, the NSA was not behind the DigiNotar hack]]></title>
            <link>https://medium.com/@koenrh/no-the-nsa-was-not-behind-the-diginotar-hack-6868ff23d5d1?source=rss-56600ac0f743------2</link>
            <guid isPermaLink="false">https://medium.com/p/6868ff23d5d1</guid>
            <category><![CDATA[intelligence]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Koen Rouwhorst]]></dc:creator>
            <pubDate>Sat, 14 Sep 2013 17:28:35 GMT</pubDate>
            <atom:updated>2021-11-29T14:32:41.443Z</atom:updated>
            <content:encoded><![CDATA[<p>On Tuesday I found that former Dutch certificate authority DigiNotar, known for its security breach in 2011, was <a href="https://web.archive.org/web/20140219041610/http://storify.com/koen/diginotar-mentioned-in-globo-video-report">briefly mentioned</a> in a Globo video report about NSA spying on Sunday. I documented the finding in a few tweets and put the four frames (of the same slide) that mentioned the name DigiNotar together in an <a href="https://web.archive.org/web/20130916071155/http://imgur.com/a/g3UGP">album</a>. Because the slide was only partly visible I had a difficult time making any sense of it. So, I <a href="https://web.archive.org/web/20140301151327/https://twitter.com/koenrh/status/377452439882186752">wrote down</a> what I considered to be plausible:</p><blockquote>From the part of the text that is visible I suspect at least NSA’s ‘Flying Pig’ was used in some investigation of the security breach.</blockquote><p>A few days later, when the news had reached the other side of the Atlantic, crypto guru Bruce Schneier posted an article on how the NSA runs man-in-the-middle (MITM) attacks on the internet. In the next-to-last paragraph he mentioned the DigiNotar slide and wrote:</p><blockquote>From the part of the text that is visible I suspect at least NSA’s ‘Flying Pig’ was used in some investigation of the security breach.</blockquote><p>I disagree, as do <a href="https://twitter.com/mauritsmartijn/status/378515785129267200">others</a>. I don’t think this partly visible slide implies either. Unfortunately, as long as the full text is not public and we don’t see documents that prove otherwise, there will be speculation about NSA’s involvement in the hack. Therefore, I analysed the video one more time, frame by frame, to see whether I missed something. And yes, I did miss something, it turned out that I missed the very frame that revealed more of the contents:</p><blockquote>Diginotar certificate authority compromise:</blockquote><blockquote>Private keys of legitimate certificate authority, Diginotar, stolen by hacker</blockquote><blockquote>FLYING PIG was used to identify a FIS using them to launch a MITM against</blockquote><figure><img alt="Slide on the DigiNotar certifcate authority compromise" src="https://cdn-images-1.medium.com/max/780/0*mGzX_Pi0iZHeHh8H" /><figcaption>Slide on the DigiNotar certificate authority compromise</figcaption></figure><p>According to the slide depicted above, a GCHQ program called <a href="http://www.slate.com/blogs/future_tense/2013/09/09/shifting_shadow_stormbrew_flying_pig_new_snowden_documents_show_nsa_deemed.html">FLYING PIG</a> (SSL profiling) was used to identify a foreign intelligence service (‘FIS’ in intelligence-speak) that used the stolen private keys to launch a man-in-the-middle attack. It’s highly unlikely that the identified foreign intelligence service refers to the NSA, because both agencies are working together very closely. I think we can put the speculations to rest that the DigiNotar hack was either the work of the NSA, or exploited by the NSA. Though, I don’t want to completely rule out that second possibility that the NSA or GCHQ exploited the hack to perform a MITM attack themselves, but there’s absolutely no proof to be found in these slides.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6868ff23d5d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What an e-book watermark looks like]]></title>
            <link>https://medium.com/@koenrh/what-an-e-book-watermark-looks-like-ff6b63fb9014?source=rss-56600ac0f743------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff6b63fb9014</guid>
            <dc:creator><![CDATA[Koen Rouwhorst]]></dc:creator>
            <pubDate>Sat, 07 Sep 2013 17:31:28 GMT</pubDate>
            <atom:updated>2021-11-29T15:25:25.222Z</atom:updated>
            <content:encoded><![CDATA[<p>In recent weeks, there was some fuss about a <a href="https://boingboing.net/2013/08/16/dutch-ebook-sellers-promise-to.html">new agreement</a> between digital book distribution platform eBoekhuis and connected vendors. This agreement obliges vendors to hand over previously-private customer information to anti-piracy group BREIN, should a purchased e-book at some point turn up on the internet (e.g. BitTorrent, Usenet, file-sharing sites). In order to trace a book back to the customer, a transaction code is watermarked into it. When I noticed one of the eBookhuis-connected vendors (i.e. Bol.com) started selling watermarked e-books, I bought one to see what this watermark would look like.</p><p>The digital book is served as an EPUB file which basically is an archive containing pages, stylesheets and images. The first thing I noticed is that book has a warning page that contains two codes of respectively 56 and 13 characters:</p><pre>YG3LNlQxBT1TNW01DEgBNWhnBDfKMVYwBWAFaARvLmdcag3hV1AFblM9</pre><pre>520e70ac6bcd8</pre><p>I suspect the first string is the transaction code that uniquely identifies a purchase at the vendor, the latter code represents the date and time of purchase as a big endian Unix 32-bit hex value. Translating the value <em>520e70ac6bcd8</em> to a human-readable date gives: <em>Wednesday, 16 august 2013 20:34:20 +0200</em>. This date time code (together with the EAN) is used as a key to the eBoekhuis platform to download the book.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/0*4N4lMY6JQEYk2BpV" /><figcaption><em>Watermark image</em></figcaption></figure><p>Other pages in the book all have the same image at the bottom that is nearly impossible to notice with your naked eye. The image is embedded as a Base64 encoded string (see the image depicted above), decoding (using the <em>openssl base64</em> command) it results in an image with the dimensions of 1 by a few hundred pixels. When seen with a naked eye it looks like a thin white line. If you use the eyedropper tool to inspect the image you will see that it consists of bars of variable widths in two different colors: white (#FFFFFF) and a little bit less white (#FEFEFE). When you replace either of the colors with black and enlarge the image vertically by 100 pixels you will see an image of a barcode similar to the one depicted below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/0*C-qzZINognboYPfX.png" /><figcaption><em>Barcode</em></figcaption></figure><p>Replacing a single color in an image can easily be accomplished by using ImageMagick. The following line of code replaces the color of all pixels with black that do have the same color as the pixel found at position 1,1.</p><pre>convert original.png -fill black -draw &#39;color 1,1 replace&#39; output.png</pre><p>So, what data is encoded in this barcode? Let’s first translate the bars and spaces to binary form where each bar represents a binary one and each space represents a binary zero. This binary string of ones and zeroes has a length of 392. Remember that the transaction mentioned earlier has a length of 56 characters. Assuming the barcode doesn’t use start or stop codes, each character is encoded using seven bits (dividing 392 by 56 gives 7). The <a href="https://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters">standard ASCII encoding table</a> uses seven bits to represent each character. When mapping the 7-bit blocks to characters you can see almost immediately that it results in a string equal to the transaction code. So, the barcode you find on each page in the book represents the transaction code encoded in 7-bit ASCII.</p><p>Do note that information might be encoded in other ways as well, for example using random variations of text. Images (e.g. cover, photos) itself can be watermarked as well.</p><p>For those asking, the transaction code, timestamp or other identifiers seen in this post are fake, for obvious reasons.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff6b63fb9014" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>