{"id":2693,"date":"2023-03-13T13:37:09","date_gmt":"2023-03-13T12:37:09","guid":{"rendered":"https:\/\/www.dsecbypass.com\/?p=2693"},"modified":"2024-02-07T10:18:41","modified_gmt":"2024-02-07T09:18:41","slug":"dolibarr-pre-auth-contact-database-dump","status":"publish","type":"post","link":"https:\/\/www.dsecbypass.com\/en\/dolibarr-pre-auth-contact-database-dump\/","title":{"rendered":"Dolibarr : unauthenticated contacts database theft"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;4.17.3&#8243; _module_preset=&#8221;default&#8221; custom_padding=&#8221;0px||||false|false&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_row _builder_version=&#8221;4.17.3&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.17.3&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_image src=&#8221;https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolibarr_logo-300&#215;150.png&#8221; alt=&#8221;Dolibarr logo &#8221; title_text=&#8221;dolibarr logo&#8221; align=&#8221;center&#8221; _builder_version=&#8221;4.20.0&#8243; _module_preset=&#8221;default&#8221; background_color=&#8221;RGBA(255,255,255,0)&#8221; width=&#8221;50%&#8221; module_alignment=&#8221;center&#8221; global_colors_info=&#8221;{}&#8221;][\/et_pb_image][et_pb_text _builder_version=&#8221;4.23.2&#8243; _module_preset=&#8221;default&#8221; hover_enabled=&#8221;0&#8243; global_colors_info=&#8221;{}&#8221; sticky_enabled=&#8221;0&#8243;]<\/p>\n<p style=\"text-align: justify;\">Vladimir had the opportunity to test the security of the Open Source CRM software <a href=\"https:\/\/www.dolibarr.org\/\" target=\"_blank\" rel=\"noopener\" title=\"Dolibarr official website\">Dolibarr<\/a> during an <a href=\"https:\/\/www.dsecbypass.com\/en\/website-pentest\/\" title=\"Website security audit\">intrusion test<\/a> of a business tool.<\/p>\n<blockquote>\n<p class=\"tw-data-text tw-text-large tw-ta\" data-placeholder=\"Traduction\" id=\"tw-target-text\" style=\"text-align: left;\" dir=\"ltr\"><span class=\"Y2IQFc\" lang=\"fr\">Dolibarr ERP CRM is a modern software package to manage your company or foundation&#8217;s activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, &#8230;). It is open source software (written in PHP) and designed for small and medium businesses, foundations and freelancers. <\/span><\/p>\n<p class=\"tw-data-text tw-text-large tw-ta\" data-placeholder=\"Traduction\" style=\"text-align: left;\" dir=\"ltr\"><span class=\"Y2IQFc\" lang=\"fr\">Ref: https:\/\/github.com\/Dolibarr\/dolibarr<br \/><\/span><\/p>\n<\/blockquote>\n<p style=\"text-align: justify;\">Our pentester discovered a <strong>critical vulnerability<\/strong> exploitable by an <strong>unauthenticated attacker<\/strong>. It provides access to a <strong>competitor&#8217;s entire customer file,<\/strong> prospects, suppliers, and potentially employee information if a contact file exists. Both public and private notes can also be retrieved. Very easy to exploit, it <strong>affects Dolibarr 16.x versions<\/strong>.<\/p>\n<p style=\"text-align: justify;\"><strong>EDIT (22\/03\/2023)<\/strong> : Dolibarr version 16.0.5 fixes this vulnerability for v16. (<a href=\"https:\/\/github.com\/Dolibarr\/dolibarr\/blob\/16.0.5\/ChangeLog#L34\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/Dolibarr\/dolibarr\/blob\/16.0.5\/ChangeLog#L34<\/a>).<\/p>\n<p style=\"text-align: justify;\"><strong>EDIT2 (13\/06\/2023)<\/strong> : CVE-2023-33568 assigned.<strong><br \/><\/strong><\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;sauvegarder&#8221; _builder_version=&#8221;4.23.2&#8243; _module_preset=&#8221;default&#8221; hover_enabled=&#8221;0&#8243; global_colors_info=&#8221;{}&#8221; sticky_enabled=&#8221;0&#8243;]<\/p>\n<h2 class=\"part\" data-startline=\"14\" data-endline=\"14\">Discovery of the vulnerability<\/h2>\n<p>In order to perform tests on the software itself without impacting the client&#8217;s production, and having access to as much information as possible, the consultant created a local Dolibarr environment in the identified version.<\/p>\n<p>The containerized image <a href=\"https:\/\/hub.docker.com\/r\/tuxgasy\/dolibarr\" target=\"_blank\" rel=\"noopener\">https:\/\/hub.docker.com\/r\/tuxgasy\/dolibarr<\/a> allows one to have a functional environment in minutes with Docker to start hunting for vulnerabilities. The <code class=\"language-yaml\">tuxgasy\/dolibarr:16<\/code> image was used to discover this vulnerability.<\/p>\n<p>Without necessarily trying to delve too much into the details of the Dolibarr code base, the auditor simply listed all the PHP files accessible from the root of the web server in order to identify those which are accessible without authentication:<\/p>\n<blockquote>\n<p><strong>find . -type f -name &#8220;*.php&#8221;<\/strong><\/p>\n<\/blockquote>\n<p>One of the scripts thus accessible attracts attention because its response differs from the others:<a href=\"https:\/\/github.com\/Dolibarr\/dolibarr\/blob\/16.0.4\/htdocs\/public\/ticket\/ajax\/ajax.php\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/Dolibarr\/dolibarr\/blob\/16.0.4\/htdocs\/public\/ticket\/ajax\/ajax.php<\/a>.<\/p>\n<p>Reading the PHP code instructs us on the required parameters: <strong><em>action<\/em><\/strong> and <strong><em>email<\/em><\/strong>.<\/p>\n<p>In particular, <strong><em>action<\/em><\/strong> must be equal to &#8220;<span class=\"pl-s\"><strong>getContacts<\/strong><\/span>&#8220;.<\/p>\n<p><span class=\"pl-s\">When all conditions are met, the following response is returned to the unauthenticated user:<br \/><\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_first_try.png\" alt=\"Dolibarr ticket ajax\" class=\"wp-image-2658 aligncenter size-full\" width=\"864\" height=\"120\" srcset=\"https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_first_try.png 864w, https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_first_try-480x67.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 864px, 100vw\" \/>Dolibarr integrates some protections and checks that the variables sent by users do not contain suspicious patterns (XSS, SQL injections):<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_example_waf-1.png\" alt=\"Dolibarr WAF example\" class=\"wp-image-2662 aligncenter size-full\" width=\"937\" height=\"68\" srcset=\"https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_example_waf-1.png 937w, https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_example_waf-1-480x35.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 937px, 100vw\" \/><\/p>\n<p>If the parameters have been protected in this way, the injections are therefore generally more complex to exploit.<\/p>\n<p>We are therefore currently in the presence of unauthenticated access to the details of a contact, provided that the attacker knows the email address associated with it.<\/p>\n<p>Digging deeper into the PHP code, the pentester lands on the SQL query called:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_sql_like_contact.png\" alt=\"SQL query getContacts Dolibarr\" class=\"wp-image-2666 aligncenter size-full\" width=\"589\" height=\"834\" srcset=\"https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_sql_like_contact.png 589w, https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_sql_like_contact-480x680.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 589px, 100vw\" \/><\/p>\n<p>We can observe the use of the SQL LIKE operator: with a bit of luck the &#8216;<strong>%<\/strong>&#8216; character can be used to transform the query and make it return all the records!<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_json_dump_unauth.png\" alt=\"Dolibarr unauthenticated contact database dump\" class=\"wp-image-2670 aligncenter size-full\" width=\"965\" height=\"556\" srcset=\"https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_json_dump_unauth.png 965w, https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_json_dump_unauth-480x277.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 965px, 100vw\" \/><\/p>\n<p>All contact details are returned in a single request.<\/p>\n<p>A sorting on a few fields demonstrates the interest of this vulnerability:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_parse_json_basique-1-1024x340.png\" alt=\"Dolibarr vulnerability contacts details\" class=\"wp-image-2674 aligncenter size-large\" width=\"1024\" height=\"340\" srcset=\"https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_parse_json_basique-1-980x326.png 980w, https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_parse_json_basique-1-480x159.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/p>\n<p>An attacker could access a <strong>competitor&#8217;s entire customer file<\/strong>, suppliers, and potentially employee information if a contact file exists. Both public and private notes can also be retrieved.<\/p>\n<p>Attacker can get other information such as technical data about the database:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_json_dump_unauth_db_data-1024x47.png\" alt=\"Dolibarr vulnerability database information\" class=\"wp-image-2678 aligncenter size-large\" width=\"1024\" height=\"47\" srcset=\"https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_json_dump_unauth_db_data-980x45.png 980w, https:\/\/www.dsecbypass.com\/wp-content\/uploads\/2023\/02\/dolib_json_dump_unauth_db_data-480x22.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/p>\n<p><span class=\"ILfuVd\" lang=\"en\"><span class=\"hgKElc\"><\/span><\/span><\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;virus&#8221; _builder_version=&#8221;4.23.2&#8243; _module_preset=&#8221;default&#8221; hover_enabled=&#8221;0&#8243; global_colors_info=&#8221;{}&#8221; sticky_enabled=&#8221;0&#8243;]<\/p>\n<h2>Impact &amp; PoC<\/h2>\n<p>Dolibarr 16.x versions are affected. Version 17 disables access to this page by default, a specific Dolibarr option must be set for it to be accessible again.<\/p>\n<p>The estimated CVSSv3 score is 7.5 (<a href=\"https:\/\/nvd.nist.gov\/vuln-metrics\/cvss\/v3-calculator?vector=AV:N\/AC:L\/PR:N\/UI:N\/S:U\/C:H\/I:N\/A:N&amp;version=3.1\" target=\"_blank\" rel=\"noopener\">https:\/\/nvd.nist.gov\/vuln-metrics\/cvss\/v3-calculator?vector=AV:N\/AC:L\/PR:N\/UI:N\/S:U\/C:H\/I:N\/A:N&amp;version=3.1<\/a>), however the nature of the data and the ease of exploitation make it <strong>a critical vulnerability<\/strong>.<\/p>\n<p>Linux command to reproduce the vulnerability and display some arbitrary fields:<\/p>\n<blockquote>\n<p><strong>curl -sk &#8216;[URI_DOLIBARR]\/public\/ticket\/ajax\/ajax.php?action=getContacts&amp;email=%&#8217; | jq -r &#8216;.contacts[] | {id, socname, poste, email, phone_perso, phone_pro, note_public, note_private}&#8217;<\/strong><\/p>\n<\/blockquote>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;mobiles&#8221; _builder_version=&#8221;4.20.0&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;]<\/p>\n<h2>Recommendations<\/h2>\n<p>Business tools as important as an ERP\/CRM must be properly secured:<\/p>\n<ul>\n<li>Open access to the Internet only if strictly necessary (prefer VPN access)<\/li>\n<li>Only use the plugins useful for your use cases<\/li>\n<li>Perform regular account reviews<\/li>\n<li>Keep the various software components up to date<\/li>\n<li>Ensure that your access policy is correctly implemented (password complexity, 2FA, &#8230;)<\/li>\n<li>Implement, and maintain, a policy of least privilege<\/li>\n<li>Perform regular penetration testing (regardless of application exposure)<\/li>\n<\/ul>\n<p><span class=\"ILfuVd\" lang=\"en\"><span class=\"hgKElc\">\u2705<\/span><\/span> Many Dolibarr instances are exposed on the Internet: for those which are in version 16.x remember to upgrade quickly!<\/p>\n<p>[\/et_pb_text][et_pb_text module_id=&#8221;motsdepasse&#8221; _builder_version=&#8221;4.23.2&#8243; _module_preset=&#8221;default&#8221; hover_enabled=&#8221;0&#8243; global_colors_info=&#8221;{}&#8221; sticky_enabled=&#8221;0&#8243;]<\/p>\n<h2>Communication with the software publisher<\/h2>\n<p style=\"text-align: justify;\">Dolibarr&#8217;s Coordinated Disclosure Process is documented at the following URL: <a href=\"https:\/\/github.com\/Dolibarr\/dolibarr\/security\/policy\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/Dolibarr\/dolibarr\/security\/policy<\/a>.<\/p>\n<p style=\"text-align: justify;\">The firs answer was (very) fast. On the other hand, the Dolibarr ecosystem could gain in security by communicating in a clear and precise manner on the vulnerabilities discovered and fixed in a centralized place, such as the Github &#8220;Security Advisories&#8221;.<\/p>\n<p style=\"text-align: justify;\"><span style=\"text-decoration: underline;\">21\/02\/2023 :<\/span> First email sent by Vladimir following the Dolibarr process<\/p>\n<p><span style=\"text-decoration: underline;\">21\/02\/2023 :<\/span> Response from developer Eldy validating the vulnerability and indicating that the feature in question will be disabled with Dolibarr 17<\/p>\n<p><span style=\"text-decoration: underline;\">05\/03\/2023 :<\/span> Dolibarr v17 released<\/p>\n<p><span style=\"text-decoration: underline;\">14\/03\/2023 :<\/span> Article published<\/p>\n<p class=\"tw-data-text tw-text-large tw-ta\" data-placeholder=\"Traduction\" style=\"text-align: left;\" dir=\"ltr\"><span class=\"Y2IQFc\" lang=\"fr\"><\/span><\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row _builder_version=&#8221;4.17.3&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.17.3&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_text _builder_version=&#8221;4.23.2&#8243; _module_preset=&#8221;default&#8221; hover_enabled=&#8221;0&#8243; global_colors_info=&#8221;{}&#8221; sticky_enabled=&#8221;0&#8243;]<\/p>\n<p style=\"text-align: justify;\"><span>\ud83d\udee1\ufe0f DSecBypass accompanies you on the <a href=\"https:\/\/www.dsecbypass.com\/en\/website-pentest\/\" title=\"Internal penetration tests on your business applications\">security audits of your business applications<\/a>. Do not hesitate to <a href=\"https:\/\/www.dsecbypass.com\/en\/contact\/\">contact <\/a>us for additional information and\/or a personalized quote \ud83d\udcdd.<\/span><\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][et_pb_row _builder_version=&#8221;4.17.3&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.17.3&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_button button_url=&#8221;https:\/\/www.dsecbypass.com\/en\/contact\/&#8221; button_text=&#8221;CONTACT US&#8221; button_alignment=&#8221;center&#8221; _builder_version=&#8221;4.17.4&#8243; _module_preset=&#8221;default&#8221; custom_button=&#8221;on&#8221; button_text_size=&#8221;13px&#8221; button_bg_color=&#8221;#4328b7&#8243; button_border_width=&#8221;10px&#8221; button_border_color=&#8221;#4328b7&#8243; button_border_radius=&#8221;0px&#8221; button_letter_spacing=&#8221;2px&#8221; button_font=&#8221;Titillium Web|700||on|||||&#8221; background_layout=&#8221;dark&#8221; global_colors_info=&#8221;{}&#8221;][\/et_pb_button][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vladimir discovered a critical vulnerability that could be exploited by an unauthenticated attacker. It provides access to a competitor&#8217;s entire customer file, prospects, suppliers, and potentially employee information if a contact file exists. Both public and private notes can also be retrieved. Very easy to exploit, it affects Dolibarr 16.x versions.<\/p>\n","protected":false},"author":4,"featured_media":2671,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[34],"tags":[],"class_list":["post-2693","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-en"],"_links":{"self":[{"href":"https:\/\/www.dsecbypass.com\/en\/wp-json\/wp\/v2\/posts\/2693","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dsecbypass.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dsecbypass.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dsecbypass.com\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dsecbypass.com\/en\/wp-json\/wp\/v2\/comments?post=2693"}],"version-history":[{"count":41,"href":"https:\/\/www.dsecbypass.com\/en\/wp-json\/wp\/v2\/posts\/2693\/revisions"}],"predecessor-version":[{"id":3238,"href":"https:\/\/www.dsecbypass.com\/en\/wp-json\/wp\/v2\/posts\/2693\/revisions\/3238"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dsecbypass.com\/en\/wp-json\/wp\/v2\/media\/2671"}],"wp:attachment":[{"href":"https:\/\/www.dsecbypass.com\/en\/wp-json\/wp\/v2\/media?parent=2693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dsecbypass.com\/en\/wp-json\/wp\/v2\/categories?post=2693"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dsecbypass.com\/en\/wp-json\/wp\/v2\/tags?post=2693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}