{"id":107,"date":"2024-02-19T20:04:57","date_gmt":"2024-02-19T20:04:57","guid":{"rendered":"https:\/\/tolva.fr\/?p=107"},"modified":"2024-03-11T19:24:42","modified_gmt":"2024-03-11T19:24:42","slug":"whats-wrong-with-x11-forwarding","status":"publish","type":"post","link":"https:\/\/tolva.fr\/index.php\/2024\/02\/19\/whats-wrong-with-x11-forwarding\/","title":{"rendered":"What&rsquo;s wrong with X11 forwarding ?"},"content":{"rendered":"\n<p>I&rsquo;ve read on several places (such as <a href=\"https:\/\/cyber.gouv.fr\/sites\/default\/files\/2014\/01\/NT_OpenSSH.pdf\" data-type=\"link\" data-id=\"https:\/\/cyber.gouv.fr\/sites\/default\/files\/2014\/01\/NT_OpenSSH.pdf\">https:\/\/cyber.gouv.fr\/sites\/default\/files\/2014\/01\/NT_OpenSSH.pdf<\/a>) that X11 forwarding is <em>bad<\/em> ( well it&rsquo;s not what it&rsquo;s written, but it&rsquo;s what i remembered the first time i read this).<\/p>\n\n\n\n<p>I initially thought it was a common sense recommendation intended to reduce the attack surface, but i was wrong and it occurs that a compromised and\/or malicious ssh server can fully take control of the client.<\/p>\n\n\n\n<p>One of the best ressource i&rsquo;ve found about this is probably this document from SANS Institute (<a href=\"https:\/\/www.giac.org\/paper\/gcih\/571\/x11-forwarding-ssh-considered-harmful\/104780)\">https:\/\/www.giac.org\/paper\/gcih\/571\/x11-forwarding-ssh-considered-harmful\/104780)<\/a>.<\/p>\n\n\n\n<p>It was published in 2004, twenty years ago, so it is really not nothing new !<\/p>\n\n\n\n<p>Apparently, X11 uses a client\/server model: Applications that want to display something ask the X11 server to do so.<\/p>\n\n\n\n<p>Communication between client applications and X11 server is done through a Unix socket, and client have to authenticate themself using a value stored in the <code>~\/.Xauthority<\/code> file.<\/p>\n\n\n\n<p>X11 forwarding allows the ssh client to launch graphics applications on the server.<\/p>\n\n\n\n<p>In that situation, the remote application on the server interacts with the X11 server on the client via the ssh client. <\/p>\n\n\n\n<p>This allow such an application to display its graphics context on the client, but also to perform less legitimate action, such as take a screenshot of the client:<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1080\" style=\"aspect-ratio: 1920 \/ 1080;\" width=\"1920\" controls src=\"https:\/\/tolva.fr\/wp-content\/uploads\/2024\/02\/x11_screenshot.mp4\"><\/video><\/figure>\n\n\n\n<p>Or, even worse, log its keystroke:<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1080\" style=\"aspect-ratio: 1920 \/ 1080;\" width=\"1920\" controls src=\"https:\/\/tolva.fr\/wp-content\/uploads\/2024\/03\/x11_keylog.mp4\"><\/video><\/figure>\n\n\n\n<p>This attack worked on Ubuntu 16.04 (and earlier), where ssh version is 7.2p2.<\/p>\n\n\n\n<p>I performed some test on the ssh client to check which version is vulnerable.<\/p>\n\n\n\n<p>It occurs that ssh client 7.2p2 obtained via source compilation is not vulnerable, unless -Y (\u00ab\u00a0trusted X11 forwarding\u00a0\u00bb) option is used instead of -X option. <\/p>\n\n\n\n<p>The same behaviour occurs when compiling ssh client 7.6p2 and 8.6p2.<\/p>\n\n\n\n<p>This behaviour is not observed on ubuntu 18.04 and later. I suppose that some refactoring was made in X11 ?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&rsquo;ve read on several places (such as https:\/\/cyber.gouv.fr\/sites\/default\/files\/2014\/01\/NT_OpenSSH.pdf) that X11 forwarding is bad ( well it&rsquo;s not what it&rsquo;s written, but it&rsquo;s what i remembered the first time i read this). I initially thought it was a common sense recommendation intended to reduce the attack surface, but i was wrong and it occurs that a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-107","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/posts\/107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/comments?post=107"}],"version-history":[{"count":5,"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/posts\/107\/revisions"}],"predecessor-version":[{"id":128,"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/posts\/107\/revisions\/128"}],"wp:attachment":[{"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/media?parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/categories?post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tolva.fr\/index.php\/wp-json\/wp\/v2\/tags?post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}