Congratulations!

[Valid Atom 1.0] This is a valid Atom 1.0 feed.

Recommendations

This feed is valid, but interoperability with the widest range of feed readers could be improved by implementing the following recommendations.

Source: http://www.paulhammond.org/feeds/journal.rss

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <feed xmlns="http://www.w3.org/2005/Atom">
  3.  
  4.  <title>Paul Hammond’s Journal</title>
  5.  <link href="http://www.paulhammond.org/feeds/journal" rel="self"/>
  6.  <link href="http://www.paulhammond.org/journal/" rel="alternate"/>
  7.  <id>tag:paulhammond.org,2008:feeds/atom</id>
  8.  <updated>2022-05-06T16:18:23-07:00</updated>
  9.  <author>
  10.    <name>Paul Hammond</name>
  11.  </author>
  12.  <entry>
  13.      <title>CVE-2021-31213</title>
  14.      <link href="http://www.paulhammond.org/2021/cve-2021-31213/" rel="alternate"/>
  15.      <id>tag:paulhammond.org,2008:post/1621959170</id>
  16.      <updated>2021-05-25T09:12:50-07:00</updated>
  17.      <content type="html">&lt;p&gt;Sometimes while I’m working on a project I have a sudden realization that two
  18. components aren’t connected the way everyone thinks they are. Often this is just
  19. a bug, usually one the team has been chasing for a while. Occasionally it’s a
  20. security hole. But I rarely get to write about it because the components are
  21. deep inside the infrastructure of a company that pays my wages.&lt;/p&gt;
  22. &lt;p&gt;Recently I had this experience while working with &lt;a href=&#34;https://code.visualstudio.com/docs/remote/containers&#34;&gt;Visual Studio Code Remote
  23. Containers&lt;/a&gt; which resulted in my first &lt;a href=&#34;https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-31213&#34;&gt;public CVE
  24. number&lt;/a&gt;, so I’m going to take a moment to write about it, remind
  25. you that it’s easy to escape a Docker container, and that developer laptops are
  26. probably the weakest link in any company’s security.&lt;/p&gt;
  27. &lt;p&gt;VS Code has an action called “Remote-Containers: Clone Repository in Container
  28. Volume” which automates the process of downloading a codebase, installing all of
  29. the dependencies in a Docker container, running that container, and attaching
  30. your editor. I found a small problem: it’s possible for code in the the
  31. repository to escape the sandbox provided by Docker and get root privileges on
  32. the host system.&lt;/p&gt;
  33. &lt;p&gt;To do this you need to do two things:&lt;/p&gt;
  34. &lt;ul&gt;
  35. &lt;li&gt;You need to run arbitrary code inside the container. Usually VSCode ignores the
  36. Docker &lt;a href=&#34;https://docs.docker.com/engine/reference/builder/#entrypoint&#34;&gt;entrypoint&lt;/a&gt; and always runs its own shell scripts, but there are many
  37. ways to get it to do something else. For example you can replace &lt;code&gt;/bin/sh&lt;/code&gt; with a
  38. shell script that runs whatever you want, or just provide a &lt;a href=&#34;https://code.visualstudio.com/docs/remote/devcontainerjson-reference&#34;&gt;&lt;code&gt;postCreate&lt;/code&gt; or
  39. &lt;code&gt;postAttach&lt;/code&gt; command&lt;/a&gt;.&lt;/li&gt;
  40. &lt;li&gt;You need to escape the container. The &lt;a href=&#34;https://code.visualstudio.com/docs/remote/devcontainerjson-reference&#34;&gt;&lt;code&gt;devcontainer.json&lt;/code&gt;&lt;/a&gt; file inside the
  41. repository can specify arguments to the &lt;code&gt;docker run&lt;/code&gt; command, which gives it the
  42. ability to mount almost any directory in the container. Notably you can mount
  43. the Docker socket file, and once you have access to that &lt;a href=&#34;https://news.ycombinator.com/item?id=17983623&#34;&gt;you can get root
  44. privileges on the host system&lt;/a&gt;.&lt;/li&gt;
  45. &lt;/ul&gt;
  46. &lt;p&gt;Combine these and someone just clicking on UI elements inside VSCode can find
  47. their laptop compromised. After I reported the issue Microsoft added a simple
  48. warning before you perform the action, which is about as good a fix as they can
  49. do given there are so many possible variations on both halves of this attack.&lt;/p&gt;
  50. &lt;p&gt;Even though I’m writing about it and I reported it to &lt;a href=&#34;https://www.microsoft.com/en-us/msrc&#34;&gt;Microsoft
  51. Security&lt;/a&gt;, I don’t think this is a serious bug. Programmers have been
  52. downloading untrusted code and running it locally since before I was born and
  53. there are much easier ways to convince them to do this than a little known
  54. feature of a VS Code extension. &lt;code&gt;curl | sudo bash&lt;/code&gt; or &lt;code&gt;./configure &amp;amp;&amp;amp; make &amp;amp;&amp;amp; sudo make install&lt;/code&gt; are the two obvious variations, but any time you run
  55. something like &lt;code&gt;npm install&lt;/code&gt; followed by &lt;code&gt;npm start&lt;/code&gt; you’re hoping that none of
  56. the repositories you just downloaded contain anything malicious.&lt;/p&gt;
  57. &lt;p&gt;I also think the style of containerized development environment that Microsoft
  58. are building is likely to eventually be more secure than directories on laptops,
  59. even if there are problems along the way. Variations on this attack will have to
  60. be more advanced to work on a hosted product such as &lt;a href=&#34;https://github.com/features/codespaces&#34;&gt;Github
  61. Codespaces&lt;/a&gt;. The costs of a sandbox escape there are a lot higher,
  62. so the development team does more work to avoid them and it’s more likely that
  63. centralized intrusion detection will catch an attack in action. And, even if
  64. someone did manage to escape, the impact is lower; they&amp;#39;ll only have access to a
  65. few other projects that happen to be running on the same server, and not access
  66. to all of your keys, tokens and every photo you’ve taken in the last few years.&lt;/p&gt;
  67. &lt;p&gt;My experience is that developers demand the ability to run anything they want on
  68. their computers, even at companies with tightly locked down device management
  69. policies. I’m also only aware of maybe a dozen companies where long-lived
  70. production credentials never ever touch developer laptops. Given the apparent
  71. rise of software supply chain attacks recently, I wonder if both of those should
  72. change. Or maybe we’ll keep stumbling along hoping for the best.&lt;/p&gt;
  73. </content>
  74.    </entry><entry>
  75.      <title>Faster Node.js VS Code containers with RAM disks</title>
  76.      <link href="http://www.paulhammond.org/2020/vscode-ramdisks/" rel="alternate"/>
  77.      <id>tag:paulhammond.org,2008:post/1603491734</id>
  78.      <updated>2020-10-23T15:22:14-07:00</updated>
  79.      <content type="html">&lt;p&gt;I’ve switched all of my development over to
  80. &lt;a href=&#34;https://code.visualstudio.com/docs/remote/containers&#34;&gt;VS Code Remote Containers&lt;/a&gt; and it’s working really well.
  81. Having every project isolated with its own runtime means I don’t have to upgrade
  82. every project at the same time, and I no longer find that half my projects have
  83. broken thanks to a macOS or homebrew upgrade.&lt;/p&gt;
  84. &lt;p&gt;The one challenge is that Node.js projects can be much slower when running in a
  85. container. This is not surprising, since these projects usually have tens of
  86. thousands of files inside the &lt;code&gt;node_modules&lt;/code&gt; directory. That directory is inside
  87. a &lt;a href=&#34;https://docs.docker.com/storage/bind-mounts/&#34;&gt;Docker bind mount&lt;/a&gt; and Hyperkit needs to do a lot of extra
  88. work to keep all those files in sync with the host computer.&lt;/p&gt;
  89. &lt;p&gt;The VS Code documentation discusses this problem and suggest
  90. &lt;a href=&#34;https://code.visualstudio.com/docs/remote/containers-advanced#_use-a-targeted-named-volume&#34;&gt;using a named volume to improve disk performance&lt;/a&gt;, but
  91. doing this requires managing Docker volumes outside of VS Code, and in my
  92. subjective experience didn’t seem to result in much improvement in speed.&lt;/p&gt;
  93. &lt;p&gt;Instead, I’ve started using RAM disks, which are faster and can be managed
  94. entirely within the &lt;code&gt;devcontainer.json&lt;/code&gt; file:&lt;/p&gt;
  95. &lt;pre&gt;&lt;code&gt;{
  96.  &amp;#34;name&amp;#34;: &amp;#34;node&amp;#34;,
  97.  &amp;#34;build&amp;#34;: { &amp;#34;dockerfile&amp;#34;: &amp;#34;Dockerfile&amp;#34; },
  98.  &amp;#34;runArgs&amp;#34;: [
  99.    &amp;#34;--tmpfs&amp;#34;,
  100.    &amp;#34;${containerWorkspaceFolder}/node_modules:exec&amp;#34;
  101.  ],
  102.  &amp;#34;postStartCommand&amp;#34;:
  103.    &amp;#34;sudo chown node node_modules &amp;amp;&amp;amp; npm i&amp;#34;,
  104.  …
  105. }
  106. &lt;/code&gt;&lt;/pre&gt;
  107. &lt;p&gt;The &lt;code&gt;runargs&lt;/code&gt; config adds an argument to the &lt;code&gt;docker run&lt;/code&gt; command. This
  108. particular argument tells Docker to create a new &lt;code&gt;tmpfs&lt;/code&gt; at
  109. &lt;code&gt;/workspaces/project/node_modules&lt;/code&gt; . The &lt;code&gt;exec&lt;/code&gt; flag is needed by a handful of
  110. packages that install helper scripts, otherwise Linux will ignore the executable
  111. bit on those files.&lt;/p&gt;
  112. &lt;p&gt;The &lt;code&gt;postStartCommand&lt;/code&gt; then ensures that every time the container is started we
  113. give the &lt;code&gt;node&lt;/code&gt; user write access to this directory. We also run &lt;code&gt;npm i&lt;/code&gt; for
  114. good measure.&lt;/p&gt;
  115. &lt;p&gt;The end result is a container where &lt;code&gt;node_modules&lt;/code&gt; is stored in RAM, and Docker
  116. knows that it’s not important data so doesn’t do extra work to sync it to disk.
  117. As a result everything is faster.&lt;/p&gt;
  118. </content>
  119.    </entry>
  120. </feed>
  121.  

If you would like to create a banner that links to this page (i.e. this validation result), do the following:

  1. Download the "valid Atom 1.0" banner.

  2. Upload the image to your own server. (This step is important. Please do not link directly to the image on this server.)

  3. Add this HTML to your page (change the image src attribute if necessary):

If you would like to create a text link instead, here is the URL you can use:

http://www.feedvalidator.org/check.cgi?url=http%3A//www.paulhammond.org/feeds/journal.rss

Copyright © 2002-9 Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda