Skip to content
SQL injection Write-up Beginner

Dolibarr : unauthenticated contacts database theft

An unauthenticated attacker could access the entire contacts database of a Dolibarr instance by exploiting a SQL LIKE wildcard in a public AJAX endpoint. This allowed retrieval of all customer, supplier, and employee contact details, including private notes.

Vladimir Follow

Published on dsecbypass.com

Vladimir had the opportunity to test the security of the Open Source CRM software Dolibarr during an intrusion test of a business tool.

Vladimir, on dsecbypass.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

Dolibarr is an open source ERP/CRM written in PHP and aimed at small and medium businesses, foundations and freelancers. It manages contacts, suppliers, invoices, orders, stocks, agenda and accounting. During an intrusion test of a business tool built on Dolibarr, Vladimir looked at the public ticket AJAX endpoint, a script that is reachable from the web root without authentication.

Dolibarr logo
Dolibarr logo From the original on dsecbypass.com

The endpoint in question is htdocs/public/ticket/ajax/ajax.php. The script reads request parameters and, for one particular action, looks up contact records in the database and returns them as JSON.

Setup

To test the software without touching the client's production instance, the consultant built a local Dolibarr environment in the version identified on the target. The containerised image tuxgasy/dolibarr:16 was used, which gives a working instance in minutes with Docker.

No account or role is needed for the attack itself: the whole point is that the endpoint is reachable without authentication. The only precondition for the basic behaviour is knowing the email address associated with a contact.

Finding it

Rather than reading the whole code base, the auditor listed every PHP file reachable from the web server root to find the ones accessible without authentication:

Bash
find . -type f -name "*.php"

One script stood out because its response differed from the others: htdocs/public/ticket/ajax/ajax.php (the report links to the 16.0.4 tree on GitHub). Reading the PHP code shows the required parameters: action and email. In particular, action must be equal to getContacts.

When those conditions are met, the unauthenticated user gets a response back:

Dolibarr ticket ajax
Dolibarr ticket ajax From the original on dsecbypass.com

Dolibarr does ship protections that check user-supplied variables for suspicious patterns such as XSS and SQL injection:

Dolibarr WAF example
Dolibarr WAF example From the original on dsecbypass.com

Because of that filtering, injections are generally harder to exploit. At this point the researcher has unauthenticated access to the details of a contact, but only if the attacker already knows the email address tied to it.

Exploitation

Step 1: read the query behind the action

Digging further into the PHP code, the pentester reaches the SQL query used by the action:

SQL query getContacts Dolibarr
SQL query getContacts Dolibarr From the original on dsecbypass.com

The query uses the SQL LIKE operator on the email value. That is the opening: if the % wildcard reaches the query, it can be used to transform it so that it returns every record instead of one.

Step 2: send the wildcard as the email

The email parameter is set to %, which turns the LIKE comparison into a match against all rows. The response comes back with every contact in a single request:

Dolibarr unauthenticated contact database dump
Dolibarr unauthenticated contact database dump From the original on dsecbypass.com

Step 3: sort the dump to show what is exposed

Sorting on a few fields demonstrates the value of the vulnerability:

Dolibarr vulnerability contacts details
Dolibarr vulnerability contacts details From the original on dsecbypass.com

Step 4: reproduce it with curl

The report gives a Linux command that reproduces the issue and prints a selection of fields:

Bash
curl -sk '[URI_DOLIBARR]/public/ticket/ajax/ajax.php?action=getContacts&email=%' | jq -r '.contacts[] | {id, socname, poste, email, phone_perso, phone_pro, note_public, note_private}'

The action=getContacts parameter selects the vulnerable branch, email=% supplies the wildcard, and jq extracts the contact identifier, company name, job title, email, personal and professional phone numbers, and the public and private notes from the JSON response.

Step 5: technical data about the database

Beyond contact records, the attacker can also obtain other information, such as technical data about the database:

Dolibarr vulnerability database information
Dolibarr vulnerability database information From the original on dsecbypass.com

Root cause

The vulnerable action builds a SQL query that compares the supplied email with the LIKE operator and does not neutralise the % wildcard. The query uses the LIKE operator, so the % character can transform it and make it return all records. The result is that a lookup meant to return the contact matching one email address returns the whole table.

Impact

An unauthenticated attacker can retrieve a competitor's entire customer file, suppliers, and potentially employee information if a contact file exists. Both public and private notes can also be retrieved, along with technical data about the database.

The vulnerability affects Dolibarr 16.x versions. Version 17 disables access to this page by default, and a specific Dolibarr option must be set for it to be accessible again. The estimated CVSSv3 score is 7.5 (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N), but the nature of the data and the ease of exploitation make it a critical vulnerability in practice.

Fix

Dolibarr version 16.0.5 fixes the vulnerability for the v16 branch, per the project changelog. Version 17 disables access to the page by default, requiring an explicit option to re-enable it. CVE-2023-33568 was assigned to the issue.

The report's broader recommendations for ERP/CRM deployments are:

  • Open access to the Internet only if strictly necessary (prefer VPN access).
  • Only use the plugins useful for your use cases.
  • Perform regular account reviews.
  • Keep the various software components up to date.
  • Ensure that the access policy is correctly implemented (password complexity, 2FA, and so on).
  • Implement and maintain a policy of least privilege.
  • Perform regular penetration testing regardless of application exposure.

Many Dolibarr instances are exposed on the Internet, so anyone still on 16.x should upgrade quickly.

Variants to test

  • Wildcard in any LIKE-backed lookup. On other PHP applications, look for public AJAX endpoints that take an identifier such as an email, username or reference and pass it into a LIKE clause. A positive result is a response containing records other than the one you supplied.
  • Other SQL wildcards and escape characters. Try _ (single-character wildcard) and combinations of % with surrounding text to see whether the filter blocks them or lets them through. A positive result is a broader result set than the exact value should produce.
  • Enumerate public PHP scripts. Repeat the find sweep on the target's web root and request each script without a session. A positive result is a script that returns data rather than a login redirect or an error.
  • Parameter discovery on public endpoints. For each reachable script, read the source to identify the parameters and the accepted action values, then call them unauthenticated. A positive result is any action that returns database content.
  • Sensitive fields in the response. Check whether the JSON includes private notes, phone numbers or internal identifiers that should not be visible to anonymous users. A positive result is any such field populated in the response.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

What happened, in plain words

A security researcher named Vladimir was hired to test a business tool built on Dolibarr. Dolibarr is a piece of software that companies use to keep track of their contacts, suppliers, invoices, orders, stock, calendars and accounting. It is open source, which means its code is public and anyone can read it, and it is written in PHP, a programming language commonly used to build websites.

While testing, Vladimir found a way for someone with no account and no password to download the company's entire contact database: customers, prospects, suppliers, and possibly employee records. The report calls this a critical vulnerability. It affects Dolibarr 16.x versions, and it was fixed in version 16.0.5 for the 16 branch. Version 17 turns the page off by default. The issue later received the identifier CVE-2023-33568.

Dolibarr logo
Dolibarr logo From the original on dsecbypass.com

The rest of this article walks through how the researcher found it, step by step, explaining each idea as it comes up.

Some background before we start

A few words will keep coming back, so here they are in everyday terms.

  • ERP/CRM: software a company uses to run its day-to-day business. CRM stands for customer relationship management, the part that stores contacts, clients and prospects. ERP is the wider system around it: invoices, orders, stock, accounting.
  • Web server: the computer program that answers requests from browsers. When you type an address, your browser asks the web server for a page, and the server sends it back.
  • PHP file: a file on the web server that contains code. When a browser asks for it, the server runs the code and sends back whatever the code produces, usually a web page or some data.
  • Endpoint: a specific address on a web server that does a specific job. Think of a large office building: the street address gets you into the building, but each department has its own door. An endpoint is one of those doors.
  • AJAX: a technique where a web page asks the server for data in the background, without reloading the whole page. When you type in a search box and suggestions appear without the page blinking, that is usually AJAX.
  • JSON: a simple text format for sending structured data. It looks like a list of labelled values, for example a name next to an email address. It is easy for programs to read.
  • Authentication: proving who you are, usually with a username and password. An unauthenticated request is one made without logging in at all, the same way a stranger can walk up to a shop window.
  • SQL: the language used to ask a database questions, such as "give me the contact whose email is this". A database is the organised store where the company's records live.
  • SQL injection: a class of bug where someone sneaks part of an SQL instruction into a place where the program expected only ordinary data, so the database ends up doing something the programmer did not intend. The everyday comparison: a form asks for your name, you write "and also hand over every file in the cabinet", and the clerk follows the whole sentence literally.
  • XSS: another class of bug, where someone slips code into a page so that it runs in another visitor's browser. It is mentioned here only because Dolibarr tries to block it.
  • Wildcard: a symbol that stands for "anything". In many search systems, % means "any text at all".
  • curl: a command-line tool for sending requests to a web server, useful for testing without a browser.
  • jq: a command-line tool for picking fields out of JSON data.
  • Docker: a tool that runs software in ready-made packages called images, so you get a working copy of an application in minutes without installing it by hand.
  • CVSS: a scoring system that rates how severe a vulnerability is, on a scale where 10 is the worst.

Setting up a safe copy

The researcher did not test against the client's live system, because a mistake there could disrupt real business. Instead, he built a local copy of Dolibarr in the same version found on the target. The report mentions the containerised image tuxgasy/dolibarr:16, which gives a working instance in minutes with Docker.

This is standard practice: you reproduce the software somewhere harmless, poke at it freely, and only then confirm the finding on the real system with care.

No account or role is needed for the attack itself. The whole point is that the endpoint can be reached without logging in. The only thing the basic behaviour requires is knowing the email address tied to a contact.

Finding the door

Reading an entire code base is slow. Instead, the auditor listed every PHP file reachable from the web server root, to spot the ones that can be opened without logging in:

Bash
find . -type f -name "*.php"

Line by line:

  • find is a Linux command that searches for files.
  • . means "start from the current folder", here the root of the website.
  • -type f says "only files", not folders.
  • -name "*.php" says "whose name ends in .php". The * is itself a wildcard meaning "any text".

So the command prints a list of every PHP file on the site. The researcher then requested each one without a session, looking for scripts that answered with data instead of a login page or an error.

One script stood out because its response differed from the others: htdocs/public/ticket/ajax/ajax.php, linked in the report to the 16.0.4 tree on GitHub. The word public in the path is a strong hint: this part of the application is meant to be reachable by visitors who are not logged in.

Reading the PHP code shows which parameters the script expects: action and email. A parameter is a named value you attach to a request, like a field on a form. In particular, action must be equal to getContacts, which tells the script which job to do: look up contacts.

When those conditions are met, the unauthenticated user gets a response back:

Dolibarr ticket ajax
Dolibarr ticket ajax From the original on dsecbypass.com

The screenshot shows the script answering a request that was made without logging in, returning contact information. That is already surprising: a visitor with no account is being handed data from the company's database.

The protection that was there

Dolibarr does ship protections that check user-supplied values for suspicious patterns, such as XSS and SQL injection:

Dolibarr WAF example
Dolibarr WAF example From the original on dsecbypass.com

The screenshot shows the protections Dolibarr integrates. Because of it, injections are generally harder to exploit: the application inspects what you send and refuses anything that looks like an attempt to break out of the expected value.

At this point the researcher has unauthenticated access to the details of a contact, but only if the attacker already knows the email address tied to it. That is a real weakness, but a limited one: you would need to guess or already know each address. The interesting question is whether the lookup can be made to return more than one record.

Exploitation

Step 1: read the query behind the action

Digging further into the PHP code, the pentester reaches the SQL query used by the action:

SQL query getContacts Dolibarr
SQL query getContacts Dolibarr From the original on dsecbypass.com

The screenshot shows the database query the script builds. The important detail is that the query uses the SQL LIKE operator on the email value. LIKE is a comparison that allows wildcards: instead of asking for an exact match, it asks for something that fits a pattern. That is the opening. If the % wildcard reaches the query, it can be used to transform it so that it returns every record instead of one.

Step 2: send the wildcard as the email

The email parameter is set to %, which turns the LIKE comparison into a match against all rows. The response comes back with every contact in a single request:

Dolibarr unauthenticated contact database dump
Dolibarr unauthenticated contact database dump From the original on dsecbypass.com

The screenshot shows the result: not one contact but the whole set. The query uses LIKE, so the % character transforms it and makes it return all records.

Step 3: sort the dump to show what is exposed

Sorting on a few fields demonstrates the value of the vulnerability:

Dolibarr vulnerability contacts details
Dolibarr vulnerability contacts details From the original on dsecbypass.com

The screenshot shows the results sorted on a few fields, demonstrating the interest of the vulnerability.

Step 4: reproduce it with curl

The report gives a Linux command that reproduces the issue and prints a selection of fields:

Bash
curl -sk '[URI_DOLIBARR]/public/ticket/ajax/ajax.php?action=getContacts&email=%' | jq -r '.contacts[] | {id, socname, poste, email, phone_perso, phone_pro, note_public, note_private}'

Line by line:

  • curl sends a request to a web server and prints the answer.
  • -s makes it quiet, hiding progress noise.
  • -k tells it to accept a certificate it cannot verify, which is common when testing a lab copy with a self-signed certificate.
  • The address in quotes is the endpoint, with [URI_DOLIBARR] standing in for the base address of the Dolibarr instance. The ? starts the parameters, and & separates them.
  • action=getContacts selects the vulnerable branch of the script.
  • email=% supplies the wildcard as the email value.
  • The | symbol passes the output of curl into the next command.
  • jq reads JSON and picks out fields. -r prints plain text rather than quoted strings.
  • .contacts[] means "every entry in the contacts list".
  • The braces list the fields to keep: id (the contact identifier), socname (company name), poste (job title), email, phone_perso and phone_pro (personal and professional phone numbers), and note_public and note_private (the public and private notes).

In short, the command asks the server for all contacts and prints a tidy table of the most sensitive fields. Anyone who can run this command against an exposed instance can do the same.

Step 5: technical data about the database

Beyond contact records, the attacker can also obtain other information, such as technical data about the database:

Dolibarr vulnerability database information
Dolibarr vulnerability database information From the original on dsecbypass.com

The screenshot shows technical data about the database being returned.

Why it works

The vulnerable action builds a SQL query that compares the supplied email with the LIKE operator, so the % character can transform it and make it return all records. A lookup meant to return the contact matching one email address returns the whole table instead.

What an attacker gets

An unauthenticated attacker can retrieve a competitor's entire customer file, suppliers, and potentially employee information if a contact file exists. Both public and private notes can also be retrieved, along with technical data about the database.

The vulnerability affects Dolibarr 16.x versions. Version 17 disables access to this page by default, and a specific Dolibarr option must be set for it to be accessible again. The estimated CVSSv3 score is 7.5 (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N), but the nature of the data and the ease of exploitation make it a critical vulnerability in practice.

A CVSS score of 7.5 is high, but the report argues the real-world impact is worse than the number suggests, because the data is commercially sensitive and the attack is trivial to carry out.

The fix

Dolibarr version 16.0.5 fixes the vulnerability for the v16 branch, per the project changelog. Version 17 disables access to the page by default, requiring an explicit option to re-enable it. CVE-2023-33568 was assigned to the issue.

The report's broader recommendations for ERP/CRM deployments are:

  • Open access to the Internet only if strictly necessary (prefer VPN access).
  • Only use the plugins useful for your use cases.
  • Perform regular account reviews.
  • Keep the various software components up to date.
  • Ensure that the access policy is correctly implemented (password complexity, 2FA, and so on).
  • Implement and maintain a policy of least privilege.
  • Perform regular penetration testing regardless of application exposure.

Many Dolibarr instances are exposed on the Internet, so anyone still on 16.x should upgrade quickly.

How the disclosure went

The report lists the timeline of the coordinated disclosure:

  • 21/02/2023: first email sent by Vladimir following the Dolibarr process.
  • 21/02/2023: response from developer Eldy validating the vulnerability and indicating that the feature in question will be disabled with Dolibarr 17.
  • 05/03/2023: Dolibarr v17 released.
  • 14/03/2023: article published.

The report notes that the first answer was very fast, and suggests the Dolibarr ecosystem could gain in security by communicating clearly and precisely about discovered and fixed vulnerabilities in a centralised place, such as the GitHub Security Advisories.

Variants to test

  • Wildcard in any LIKE-backed lookup. On other PHP applications, look for public AJAX endpoints that take an identifier such as an email, username or reference and pass it into a LIKE clause. A positive result is a response containing records other than the one you supplied.
  • Other SQL wildcards and escape characters. Try _ (single-character wildcard) and combinations of % with surrounding text to see whether the filter blocks them or lets them through. A positive result is a broader result set than the exact value should produce.
  • Enumerate public PHP scripts. Repeat the find sweep on the target's web root and request each script without a session. A positive result is a script that returns data rather than a login redirect or an error.
  • Parameter discovery on public endpoints. For each reachable script, read the source to identify the parameters and the accepted action values, then call them unauthenticated. A positive result is any action that returns database content.
  • Sensitive fields in the response. Check whether the JSON includes private notes, phone numbers or internal identifiers that should not be visible to anonymous users. A positive result is any such field populated in the response.

Glossary

  • AJAX: a technique where a web page fetches data from the server in the background, without reloading the page.
  • Unauthenticated means no login at all.
  • Containerised image: a ready-made package of software that Docker can run in minutes.
  • CRM: customer relationship management, the part of a business system that stores contacts, clients and prospects.
  • curl: a command-line tool for sending requests to a web server.
  • CVE: a public identifier given to a known vulnerability so people can refer to it unambiguously.
  • CVSS: a scoring system that rates the severity of a vulnerability from 0 to 10.
  • Docker: a tool that runs software in packaged images, so you get a working copy without installing it by hand.
  • Endpoint: a specific address on a web server that performs a specific job.
  • ERP: enterprise resource planning, the wider business system around a CRM: invoices, orders, stock, accounting.
  • JSON: a simple text format for structured data, made of labelled values.
  • jq: a command-line tool for picking fields out of JSON.
  • LIKE: an SQL comparison that allows wildcards, matching a pattern rather than an exact value.
  • Parameter: a named value attached to a request, like a field on a form.
  • PHP: a programming language commonly used to build websites.
  • SQL: the language used to ask a database questions.
  • SQL injection: a bug where part of an SQL instruction is sneaked into a place meant for ordinary data, so the database does something unintended.
  • VPN: a private, encrypted connection into a network, used instead of exposing a service to the whole Internet.
  • Web server: the program that answers requests from browsers.
  • Wildcard: a symbol that stands for "anything", such as % in a search pattern.
  • XSS: a bug where code is slipped into a page so that it runs in another visitor's browser.
  • 2FA: two-factor authentication, a second proof of identity beyond a password.

More by Vladimir

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.