CVE-2021-3850: Adodb/adodb php Authentication Bypass Vulnerability

CRITICAL
Advisory Identifier: GHSA-65mj-7c86-79jf
CVSS 9.1
CWE-287 CWE-305
Published
Advisory Summary

CVE-2021-3850 is a CRITICAL (CVSS 9.1) authentication bypass vulnerability (CWE-287: Improper Authentication) affecting Adodb/adodb php libraries in the Packagist ecosystem. The issue involves authentication bypass in adodb/adodb. Remediation is available by upgrading affected packages to version 5.20.21, 5.21.4.

CVE-2021-3850 at a Glance

CVE Identifier CVE-2021-3850
GHSA Identifier GHSA-65mj-7c86-79jf
Severity CRITICAL
CVSS v3.1 Base Score 9.1
CWE Classification CWE-287: Improper Authentication
Affected Product Adodb/adodb php
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 9.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2021-3850

To remediate this vulnerability, upgrade all affected Adodb/adodb php dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

adodb/adodb-php fixed: 5.20.21
Upgrade adodb/adodb-php to 5.20.21
adodb/adodb-php fixed: 5.21.4
Upgrade adodb/adodb-php to 5.21.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for adodb/adodb-php

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-3850, inspect your project dependencies for Adodb/adodb php:

inspect dependencies for adodb/adodb-php

Analyze the terminal output to locate any version of Adodb/adodb php in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.20.21), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-287: Improper Authentication, where when an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct. In Adodb/adodb php, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact An attacker can inject values into a PostgreSQL connection string by providing a parameter surrounded by single quotes. Depending on how the library is used in the client software, this may allow an attacker to bypass the login process, gain access to the server's IP address, etc. ### Patches The vulnerability is fixed in ADOdb versions 5.20.21 (952de6c4273d9b1e91c2b838044f8c2111150c29) and 5.21.4 or later (b4d5ce70034c5aac3a1d51d317d93c037a0938d2). The simplest patch is to delete line 29 in `drivers/adodb-postgres64.inc.php`: ```php diff --git a/drivers/adodb-postgres64.inc.php b/drivers/adodb-postgres64.inc.php index d04b7f67..729d7141 100644 --- a/drivers/adodb-postgres64.inc.php +++ b/drivers/adodb-postgres64.inc.php @@ -26,7 +26,6 @@ function adodb_addslashes($s) { $len = strlen($s); if ($len == 0) return "''"; - if (strncmp($s,"'",1) === 0 && substr($s,$len-1) == "'") return $s; // already quoted return "'".addslashes($s)."'"; } ``` ### Workarounds Ensure the parameters passed to *ADOConnection::connect()* or related functions (_nConnect()_, _pConnect()_) are not surrounded by single quotes. ### Credits Thanks to **Emmet Leahy** (@meme-lord) of Sorcery Ltd for reporting this vulnerability, and to the [huntr](https://huntr.dev/) team for their support. ### References - Original issue report https://huntr.dev/bounties/bdf5f216-4499-4225-a737-b28bc6f5801c/ - ADOdb reference issue #793 ### For more information If you have any questions or comments about this advisory: * Add a note in issue #793 * Contact the maintainers on [Gitter](https://gitter.im/adodb/adodb)

CVE-2021-3850 Affected Adodb/adodb php Versions

2 component(s)
Fixed Versions:
5.20.215.21.4
Product / Package Ecosystem Affected Versions Fixed Version
adodb/adodb-php
Packagist
< 5.20.21
5.20.21
adodb/adodb-php
Packagist
≥ 5.21.0
< 5.21.4
5.21.4

References

Frequently Asked Questions

What is CVE-2021-3850?
CVE-2021-3850 is a security vulnerability in Adodb/adodb php involving Authentication Bypass in ADOdb/ADOdb under CWE-287: Improper Authentication.
Which Adodb/adodb php versions are affected?
Affected versions include releases prior to 5.20.21, 5.21.4 across affected packages: adodb/adodb-php.
What version fixes CVE-2021-3850?
Upgrading to 5.20.21, 5.21.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is adodb/adodb-php affected?
Yes, adodb/adodb-php is affected in releases prior to 5.20.21, 5.21.4. Upgrade your dependency to 5.20.21, 5.21.4 or later.
What is the CVSS score of CVE-2021-3850?
CVE-2021-3850 has a CVSS v3.1 base score of 9.1 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2021-3850?
CVE-2021-3850 is classified under CWE-287: Improper Authentication (When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.).
How can I check Packagist dependencies for CVE-2021-3850?
Run the dependency tree command: 'inspect dependencies for adodb/adodb-php'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-65mj-7c86-79jf",
  "modified" : "2022-02-07T22:34:28Z",
  "published" : "2022-01-27T15:23:19Z",
  "aliases" : [ "CVE-2021-3850" ],
  "summary" : "Authentication Bypass in ADOdb/ADOdb",
  "details" : "### Impact\n\nAn attacker can inject values into a PostgreSQL connection string by providing a parameter surrounded by single quotes.\n\nDepending on how the library is used in the client software, this may allow an attacker to bypass the login process, gain access to the server's IP address, etc.\n\n### Patches\n\nThe vulnerability is fixed in ADOdb versions 5.20.21 (952de6c4273d9b1e91c2b838044f8c2111150c29) and 5.21.4 or later (b4d5ce70034c5aac3a1d51d317d93c037a0938d2).\n\nThe simplest patch is to delete line 29 in `drivers/adodb-postgres64.inc.php`:\n\n```php\ndiff --git a/drivers/adodb-postgres64.inc.php b/drivers/adodb-postgres64.inc.php\nindex d04b7f67..729d7141 100644\n--- a/drivers/adodb-postgres64.inc.php\n+++ b/drivers/adodb-postgres64.inc.php\n@@ -26,7 +26,6 @@ function adodb_addslashes($s)\n {\n    $len = strlen($s);\n    if ($len == 0) return \"''\";\n-   if (strncmp($s,\"'\",1) === 0 && substr($s,$len-1) == \"'\") return $s; // already quoted\n \n    return \"'\".addslashes($s).\"'\";\n }\n```\n\n### Workarounds\n\nEnsure the parameters passed to *ADOConnection::connect()* or related functions (_nConnect()_, _pConnect()_) are not surrounded by single quotes.\n\n### Credits\n\nThanks to **Emmet Leahy** (@meme-lord) of Sorcery Ltd for reporting this vulnerability, and to the [huntr](https://huntr.dev/) team for their support.\n\n### References\n\n- Original issue report https://huntr.dev/bounties/bdf5f216-4499-4225-a737-b28bc6f5801c/\n- ADOdb reference issue #793 \n\n### For more information\n\nIf you have any questions or comments about this advisory:\n* Add a note in issue #793\n* Contact the maintainers on [Gitter](https://gitter.im/adodb/adodb)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "adodb/adodb-php"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.20.21"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.20.20"
    }
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "adodb/adodb-php"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.21.0"
      }, {
        "fixed" : "5.21.4"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.21.3"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ADOdb/ADOdb/security/advisories/GHSA-65mj-7c86-79jf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-3850"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ADOdb/ADOdb/issues/793"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ADOdb/ADOdb/commit/952de6c4273d9b1e91c2b838044f8c2111150c29"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ADOdb/ADOdb/commit/b4d5ce70034c5aac3a1d51d317d93c037a0938d2"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ADOdb/ADOdb"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.dev/bounties/bdf5f216-4499-4225-a737-b28bc6f5801c"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2022/02/msg00006.html"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2022/dsa-5101"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-287", "CWE-305" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-01-24T22:39:29Z",
    "nvd_published_at" : "2022-01-25T15:15:00Z"
  }
}