{"id":2219,"date":"2017-07-18T13:14:04","date_gmt":"2017-07-18T20:14:04","guid":{"rendered":"https:\/\/blog.mozilla.org\/security\/?p=2219"},"modified":"2017-07-18T13:19:09","modified_gmt":"2017-07-18T20:19:09","slug":"web-service-audits-firefox-accounts","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/","title":{"rendered":"A Security Audit of Firefox Accounts"},"content":{"rendered":"<p style=\"text-indent: 20px;\"><a href=\"https:\/\/blog.mozilla.org\/security\/files\/2017\/07\/FXA-01-report.pdf\"><img decoding=\"async\" loading=\"lazy\" class=\"alignright wp-image-2222 size-medium\" src=\"https:\/\/blog.mozilla.org\/security\/files\/2017\/07\/Screenshot-2017-7-18-FXA-01-report-pdf-252x326.png\" alt=\"FXA-01-report\" width=\"252\" height=\"326\" srcset=\"https:\/\/blog.mozilla.org\/security\/files\/2017\/07\/Screenshot-2017-7-18-FXA-01-report-pdf-252x326.png 252w, https:\/\/blog.mozilla.org\/security\/files\/2017\/07\/Screenshot-2017-7-18-FXA-01-report-pdf-768x994.png 768w, https:\/\/blog.mozilla.org\/security\/files\/2017\/07\/Screenshot-2017-7-18-FXA-01-report-pdf-600x777.png 600w, https:\/\/blog.mozilla.org\/security\/files\/2017\/07\/Screenshot-2017-7-18-FXA-01-report-pdf.png 978w\" sizes=\"(max-width: 252px) 100vw, 252px\" \/><\/a>To provide <a href=\"https:\/\/www.mozilla.org\/en-US\/about\/manifesto\/#principle-08\">transparency<\/a> into our ongoing efforts to protect your <a href=\"https:\/\/www.mozilla.org\/en-US\/about\/manifesto\/#principle-04\">privacy and security<\/a> on the Internet, we are releasing a security audit of <a href=\"https:\/\/wiki.mozilla.org\/Identity\/Firefox-Accounts\">Firefox Accounts (FxA)<\/a> that <a href=\"http:\/\/cure53.de\/\">Cure53<\/a> conducted last fall. At Mozilla, we sponsor <a href=\"https:\/\/wiki.mozilla.org\/MOSS\/Secure_Open_Source\">security audits<\/a> of core open source software underpinning the Web and Internet, <a href=\"https:\/\/blog.mozilla.org\/security\/2017\/05\/11\/relaunching-web-bug-bounty-program\/\">recently relaunched our web bug bounty program<\/a>, find and fix vulnerabilities ourselves, and open source our code for anyone to review. Despite being available to more reviewers, open source software is <a href=\"https:\/\/en.wikipedia.org\/wiki\/Linus%27s_Law#Validity\">not necessarily reviewed more thoroughly or frequently<\/a> than closed source software, and the extra attention from third party reviewers can find outstanding issues and vulnerabilities. To augment our other initiatives and improve the overall security of our web services, we engage third party organizations to audit the security and review the code of specific services.<\/p>\n<p style=\"text-indent: 20px;\">As Firefox\u2019s central authentication service FxA is a natural first target. Its security is critical to millions of users who rely on it to authenticate with our most sensitive services, such as <a href=\"https:\/\/addons.mozilla.org\/en-US\/firefox\/\">addons.mozilla.org<\/a> and <a href=\"https:\/\/www.mozilla.org\/en-US\/firefox\/sync\/\">Sync<\/a>. <a href=\"https:\/\/cure53.de\/\">Cure53<\/a> ran a comprehensive security audit that encompassed the web services powering FxA and the <a href=\"https:\/\/github.com\/mozilla\/fxa-auth-server\/wiki\/onepw-protocol\">cryptographic protocol<\/a> used to protect user accounts and data. They identified 15 issues, none of which were exploited or put user data at risk.<\/p>\n<p style=\"text-indent: 20px;\">We thank <a href=\"http:\/\/cure53.de\/\">Cure53<\/a> for reviewing FxA and increasing our trust in the backbone of Firefox\u2019s identity system. The audit is a step toward providing higher quality and more secure services to our users, which we will continue to improve through our various security initiatives. In the rest of this blog post, we discuss the technical details of the four highest severity issues. The report is available <a href=\"https:\/\/blog.mozilla.org\/security\/files\/2017\/07\/FXA-01-report.pdf\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a> and you can sign up or log into Firefox Accounts on your desktop or mobile device at: <a href=\"https:\/\/accounts.firefox.com\/signup\">https:\/\/accounts.firefox.com\/signup<\/a><\/p>\n<p>&nbsp;<\/p>\n<h4>FXA-01-001 HTML injection via unsanitized FxA relier Name<\/h4>\n<h6><\/h6>\n<p style=\"text-indent: 20px;\">The one issue Cure53 ranked as critical, <i>FXA-01-001 HTML injection via unsanitized FxA relier Name<\/i>, resulted from displaying the name of a relier without HTML escaping on the relier registration page. This issue was not exploitable from outside Mozilla, because the endpoint for registering new reliers is not open to the public. A strict <a href=\"https:\/\/wiki.mozilla.org\/Security\/CSP\">Content Security Policy<\/a> (CSP) blocked most Cross-Site-Scripting (XSS) on the page, but an attacker could still exfiltrate sensitive authentication data via scriptless attacks and deface or repurpose the page for phishing. To <a href=\"https:\/\/github.com\/mozilla\/fxa-content-server\/pull\/4296#issuecomment-259120151\">fix the vulnerability<\/a> soon after Cure53 reported it to us, we updated the template language to escape all variables and use an explicit naming convention for unescaped variables. Third party relier names are now sanitized and escaped.<\/p>\n<h4>FXA-01-004 XSS via unsanitized Output on JSON Endpoints<\/h4>\n<h6><\/h6>\n<p style=\"text-indent: 20px;\">The first of three issues ranked high, <i>FXA-01-004 XSS via unsanitized Output on JSON Endpoints<\/i>, affected legacy browsers handling JSON endpoints with user controlled fields in the beginning of the response. For responses like the following:<\/p>\n<pre>    {\r\n        \"id\": \"81730c8682f1efa5\",\r\n        \"name\": \"&lt;img src=x onerror=alert(1)&gt;\",\r\n        \"trusted\": false,\r\n        \"image_uri\": \"\",\r\n        \"redirect_uri\": \"javascript:alert(1)\"\r\n    }\r\n<\/pre>\n<p>an attacker could set the <em>name<\/em> or <em>redirect_uri<\/em> such that legacy browsers sniff the initial bytes of a response, incorrectly guess the MIME type as HTML instead of JSON, and execute user defined scripts. \u00a0We added the HTTP header X-Content-Type-Options: nosniff (XCTO) to disable MIME type sniffing, and wrote <a href=\"https:\/\/github.com\/g-k\/restify-safe-json-formatter\/\">middleware<\/a> and patches for the <a href=\"https:\/\/github.com\/expressjs\/express\/pull\/3269\">web<\/a> <a href=\"https:\/\/github.com\/hapijs\/hapi\/pull\/3506\">frameworks<\/a> to unicode escape &lt;, &gt;, and &amp; characters in JSON responses.<\/p>\n<h4>FXA-01-014 Weak client-side Key Stretching<\/h4>\n<h6><\/h6>\n<p style=\"text-indent: 20px;\">The second issue with a high severity ranking, <i>FXA-01-014 Weak client-side Key Stretching<\/i>, is <i>\u201ca tradeoff between security and efficiency\u201d<\/i>. <a href=\"https:\/\/github.com\/mozilla\/fxa-auth-server\/wiki\/onepw-protocol\">The onepw protocol<\/a> threat model includes an adversary capable of breaking or bypassing TLS. Consequently, we run 1,000 iterations of <a href=\"https:\/\/en.wikipedia.org\/wiki\/PBKDF2\">PBKDF2<\/a> on user devices to avoid sending passwords directly to the server, which runs a further 2<sup>16<\/sup> scrypt iterations on the PBKDF2-stretched password before storing it. Cure53 recommended storing PBKDF2 passwords with a higher work factor of roughly 256,000 iterations, but concluded \u201c<i>an exact recommendation on the number of iterations cannot be supplied in this instance<\/i>\u201d. To keep performance acceptable on less powerful devices, we have not increased the work factor yet.<\/p>\n<h4>FXA-01-010 Possible RCE if Application is run in a malicious Path<\/h4>\n<h6><\/h6>\n<p style=\"text-indent: 20px;\">The final high severity issue, <i>FXA-01-010 Possible RCE if Application is run in a malicious Path<\/i>, affected people running FxA web servers from insecure paths in development mode. The servers exposed an endpoint that executes shell commands to determine the release version and git commit they\u2019re running in development mode. For example, the command below returns the current git commit:<\/p>\n<blockquote>\n<pre><em>var gitDir = path.resolve(__dirname, '..', '..', '.git')\r\nvar cmd = util.format('git --git-dir=%s rev-parse HEAD', gitDir)\r\nexec(cmd, \u2026)<\/em><\/pre>\n<\/blockquote>\n<p>Cure53 noted malicious commands like <i>rm -rf * <\/i>in the directory path <a href=\"https:\/\/nodejs.org\/api\/globals.html#globals_dirname\">__dirname global<\/a> would be executed and recommended filtering and quoting parameters. We modified the script to use the <a href=\"https:\/\/nodejs.org\/api\/child_process.html#child_process_child_process_exec_command_options_callback\">cwd option<\/a> and avoid filtering the parameter entirely:<\/p>\n<blockquote>\n<pre><em>var cmd = 'git rev-parse HEAD'\r\nexec(cmd, { env: { GIT_CONFIG: gitDir } } ...)<\/em><\/pre>\n<\/blockquote>\n<p>Mozilla does not run servers from insecure paths, but some users host their own FxA services and it is always good to consider malicious input from all sources.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-indent: 20px;\">We reviewed the higher ranked issues from the report, circumstances limiting their impact, and how we fixed and addressed them. We invite you to <a href=\"https:\/\/github.com\/mozilla\/fxa\/blob\/master\/CONTRIBUTING.md\">contribute to developing Firefox Accounts<\/a> and report security issues through <a href=\"https:\/\/www.mozilla.org\/en-US\/security\/web-bug-bounty\/\">our bug bounty program<\/a> as we continue to improve the security of Firefox Accounts and other core services.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To provide transparency into our ongoing efforts to protect your privacy and security on the Internet, we are releasing a security audit of Firefox Accounts (FxA) that Cure53 conducted last &hellip; <a class=\"go\" href=\"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/\">Read more<\/a><\/p>\n","protected":false},"author":1488,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69],"tags":[45512,335],"coauthors":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>A Security Audit of Firefox Accounts - Mozilla Security Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Greg Guthe\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/\",\"url\":\"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/\",\"name\":\"A Security Audit of Firefox Accounts - Mozilla Security Blog\",\"isPartOf\":{\"@id\":\"https:\/\/blog.mozilla.org\/security\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/blog.mozilla.org\/security\/files\/2017\/07\/Screenshot-2017-7-18-FXA-01-report-pdf-252x326.png\",\"datePublished\":\"2017-07-18T20:14:04+00:00\",\"dateModified\":\"2017-07-18T20:19:09+00:00\",\"author\":{\"@id\":\"https:\/\/blog.mozilla.org\/security\/#\/schema\/person\/9bbbd07cc9bd3668a31c830cca9cdb20\"},\"breadcrumb\":{\"@id\":\"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/#primaryimage\",\"url\":\"https:\/\/blog.mozilla.org\/security\/files\/2017\/07\/Screenshot-2017-7-18-FXA-01-report-pdf.png\",\"contentUrl\":\"https:\/\/blog.mozilla.org\/security\/files\/2017\/07\/Screenshot-2017-7-18-FXA-01-report-pdf.png\",\"width\":978,\"height\":1266},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blog.mozilla.org\/security\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A Security Audit of Firefox Accounts\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.mozilla.org\/security\/#website\",\"url\":\"https:\/\/blog.mozilla.org\/security\/\",\"name\":\"Mozilla Security Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.mozilla.org\/security\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.mozilla.org\/security\/#\/schema\/person\/9bbbd07cc9bd3668a31c830cca9cdb20\",\"name\":\"Greg Guthe\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/blog.mozilla.org\/security\/#\/schema\/person\/image\/c972c5187c75056ad21d55efb30f9a5d\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/60f00396b5d00f887058f9d88a061787?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/60f00396b5d00f887058f9d88a061787?s=96&d=identicon&r=g\",\"caption\":\"Greg Guthe\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"A Security Audit of Firefox Accounts - Mozilla Security Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/","twitter_misc":{"Written by":"Greg Guthe","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/","url":"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/","name":"A Security Audit of Firefox Accounts - Mozilla Security Blog","isPartOf":{"@id":"https:\/\/blog.mozilla.org\/security\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/#primaryimage"},"image":{"@id":"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/#primaryimage"},"thumbnailUrl":"https:\/\/blog.mozilla.org\/security\/files\/2017\/07\/Screenshot-2017-7-18-FXA-01-report-pdf-252x326.png","datePublished":"2017-07-18T20:14:04+00:00","dateModified":"2017-07-18T20:19:09+00:00","author":{"@id":"https:\/\/blog.mozilla.org\/security\/#\/schema\/person\/9bbbd07cc9bd3668a31c830cca9cdb20"},"breadcrumb":{"@id":"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/#primaryimage","url":"https:\/\/blog.mozilla.org\/security\/files\/2017\/07\/Screenshot-2017-7-18-FXA-01-report-pdf.png","contentUrl":"https:\/\/blog.mozilla.org\/security\/files\/2017\/07\/Screenshot-2017-7-18-FXA-01-report-pdf.png","width":978,"height":1266},{"@type":"BreadcrumbList","@id":"https:\/\/blog.mozilla.org\/security\/2017\/07\/18\/web-service-audits-firefox-accounts\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.mozilla.org\/security\/"},{"@type":"ListItem","position":2,"name":"A Security Audit of Firefox Accounts"}]},{"@type":"WebSite","@id":"https:\/\/blog.mozilla.org\/security\/#website","url":"https:\/\/blog.mozilla.org\/security\/","name":"Mozilla Security Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.mozilla.org\/security\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.mozilla.org\/security\/#\/schema\/person\/9bbbd07cc9bd3668a31c830cca9cdb20","name":"Greg Guthe","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/blog.mozilla.org\/security\/#\/schema\/person\/image\/c972c5187c75056ad21d55efb30f9a5d","url":"https:\/\/secure.gravatar.com\/avatar\/60f00396b5d00f887058f9d88a061787?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/60f00396b5d00f887058f9d88a061787?s=96&d=identicon&r=g","caption":"Greg Guthe"}}]}},"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/security\/wp-json\/wp\/v2\/posts\/2219"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/security\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/security\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/security\/wp-json\/wp\/v2\/users\/1488"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/security\/wp-json\/wp\/v2\/comments?post=2219"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/security\/wp-json\/wp\/v2\/posts\/2219\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/security\/wp-json\/wp\/v2\/media?parent=2219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/security\/wp-json\/wp\/v2\/categories?post=2219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/security\/wp-json\/wp\/v2\/tags?post=2219"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blog.mozilla.org\/security\/wp-json\/wp\/v2\/coauthors?post=2219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}