CVE-2020-15120: Ihatemoney Authorization Bypass Vulnerability

MODERATE
Advisory Identifier: GHSA-67j9-c52g-w2q9
CVSS 4.9
CWE-863
Published
Advisory Summary

CVE-2020-15120 is a MODERATE (CVSS 4.9) authorization bypass vulnerability (CWE-863: Incorrect Authorization) affecting Ihatemoney libraries in the PyPI ecosystem. The issue involves authorization bypass in i hate money. Remediation is available by upgrading affected packages to version 4.1.5.

CVE-2020-15120 at a Glance

CVE Identifier CVE-2020-15120
GHSA Identifier GHSA-67j9-c52g-w2q9
Severity MODERATE
CVSS v3.1 Base Score 4.9
CWE Classification CWE-863: Incorrect Authorization
Affected Product Ihatemoney
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 4.9

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

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

How to Fix CVE-2020-15120

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

ihatemoney fixed: 4.1.5
pip install ihatemoney>=4.1.5
Verify Direct and Transitive Dependencies

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

pip show ihatemoney

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2020-15120, inspect your installed packages using pip:

pip show ihatemoney

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

Note: The pip show ihatemoney command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-863: Incorrect Authorization, where the product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. In Ihatemoney, 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 authenticated member of one project can modify and delete members of another project, without knowledge of this other project's private code. This can be further exploited to access all bills of another project without knowledge of this other project's private code. With the default configuration, anybody is allowed to create a new project. An attacker can create a new project and then use it to become authenticated and exploit this flaw. As such, the exposure is similar to an unauthenticated attack, because it is trivial to become authenticated. ### Patches ```diff ihatemoney/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ihatemoney/models.py b/ihatemoney/models.py index fe7b519..5691c75 100644 --- a/ihatemoney/models.py +++ b/ihatemoney/models.py @@ -380,7 +380,7 @@ class Person(db.Model): def get_by_name(self, name, project): return ( Person.query.filter(Person.name == name) - .filter(Project.id == project.id) + .filter(Person.project_id == project.id) .one() ) @@ -389,7 +389,7 @@ class Person(db.Model): project = g.project return ( Person.query.filter(Person.id == id) - .filter(Project.id == project.id) + .filter(Person.project_id == project.id) .one() ) ``` ### Workarounds To limit the impact, it is possible to disable public project creation by setting `ALLOW_PUBLIC_PROJECT_CREATION = False` in the configuration (see [documentation](https://ihatemoney.readthedocs.io/en/latest/configuration.html)). Existing users will still be able to exploit the flaw, but this will prevent an external attacker from creating a new project. ### For more information `Person.query.get()` and `Person.query.get_by_name()` were mistakenly running a database join on the Project table without constraining the result. As a result, `Person.query.get(42, "projectfoo")` would return the Person with id=42, even if it is not associated to the project "projectfoo". The only condition is that "projectfoo" must exist. This flaw can be exploited in several places: 1) API: PUT requests to `/api/projects/<project>/members/<personID>` will succeed even though `<personID>` is not a member of `<project>`. This allows an authenticated attacker to alter the state of a member (name, weight, activated) in any project. In addition, the altered member will no longer be associated with its original project but will be associated to the attacker project instead, breaking many features of IHateMoney. For instance, bills referencing the altered member will no longer be visible in the original project. This causes an additional information disclosure and loss of integrity on bills: the attacker will now be able to see, edit and delete bills belonging to the altered member, because IHateMoney now believes that these bills are associated to the attacker project through the altered member. For instance, assume that `Person(id=42)` is a member of project "targetProject", and that the attacker has access to another project "attackerProject" with the private code "attackerPassword". The attacker can modify `Person(id=42)` with this command: $ curl -X PUT -d "name=Pwn3d&activated=1" --basic -u attackerProject:attackerPassword http://$SERVER/api/projects/attackerProject/members/42 The attacker can now see, edit and delete bills paid by `Person(id=42)` by simply browsing to http://$SERVER/attackerProject/ 2) Editing a member through the web interface at `/<project>/members/<personID>/edit` will succeed even though `<personID>` is not a member of `<project>`. This is very similar to the PUT exploit. Reusing the same example, the attacker needs to login to its "attackerProject" project with the private code "attackerPassword". It can then alter the state of `Person(id=42)` by accessing the edit form at the following URL: http://$SERVER/attackerProject/members/42/edit Again, as a result of the alteration, the altered member will become associated to the project "attackerProject", resulting in the same information disclosure and loss of integrity on bills. 3) API: DELETE requests to `/api/projects/<project>/members/<personID>` will similarly allow to delete the member `<personID>` even if it belongs to a different project than `<project>`. $ curl -X DELETE --basic -u attackerProject:attackerPassword http://$SERVER/api/projects/attackerProject/members/42 The impact is less serious than with PUT, because DELETE only deactivates a member (it does not really delete it). All these exploits require authentication: an attacker needs to know a valid project name and its associated "private code". Once this requirement is fullfilled, the attacker can exploit this flaw to alter the state of members in any other project, without needing to know the target project name or its private code. `Person.query.get_by_name()` suffers from the same issue as `Person.query.get()`. It has an additional issue: if multiple Person objects with the same name exist (this is possible if they are associated to different projects), `get_by_name()` will crash with `MultipleResultsFound` because of the call to `one()`. However, since `Person.query.get_by_name()` is currently not used anywhere in IHateMoney, the bug affecting this function has no impact and is not exploitable.

CVE-2020-15120 Affected Ihatemoney Versions

1 component(s)
Fixed Versions:
4.1.5
Product / Package Ecosystem Affected Versions Fixed Version
ihatemoney
PyPI
< 4.1.5
4.1.5

References

Frequently Asked Questions

What is CVE-2020-15120?
CVE-2020-15120 is a security vulnerability in Ihatemoney involving Authorization Bypass in I hate money under CWE-863: Incorrect Authorization.
Which Ihatemoney versions are affected?
Affected versions include releases prior to 4.1.5 across affected packages: ihatemoney.
What version fixes CVE-2020-15120?
Upgrading to 4.1.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is ihatemoney affected?
Yes, ihatemoney is affected in releases prior to 4.1.5. Upgrade your dependency to 4.1.5 or later.
What is the CVSS score of CVE-2020-15120?
CVE-2020-15120 has a CVSS v3.1 base score of 4.9 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2020-15120?
CVE-2020-15120 is classified under CWE-863: Incorrect Authorization (The product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check.).
How can I check PyPI dependencies for CVE-2020-15120?
Run the dependency tree command: 'pip show ihatemoney'. 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-67j9-c52g-w2q9",
  "modified" : "2024-09-23T17:00:56Z",
  "published" : "2020-07-27T17:47:52Z",
  "aliases" : [ "CVE-2020-15120" ],
  "summary" : "Authorization Bypass in I hate money",
  "details" : "### Impact\nAn authenticated member of one project can modify and delete members of another project, without knowledge of this other project's private code. This can be further exploited to access all bills of another project without knowledge of this other project's private code.\n\nWith the default configuration, anybody is allowed to create a new project. An attacker can create a new project and then use it to become authenticated and exploit this flaw. As such, the exposure is similar to an unauthenticated attack, because it is trivial to become authenticated.\n\n### Patches\n```diff\n ihatemoney/models.py | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/ihatemoney/models.py b/ihatemoney/models.py\nindex fe7b519..5691c75 100644\n--- a/ihatemoney/models.py\n+++ b/ihatemoney/models.py\n@@ -380,7 +380,7 @@ class Person(db.Model):\n         def get_by_name(self, name, project):\n             return (\n                 Person.query.filter(Person.name == name)\n-                .filter(Project.id == project.id)\n+                .filter(Person.project_id == project.id)\n                 .one()\n             )\n \n@@ -389,7 +389,7 @@ class Person(db.Model):\n                 project = g.project\n             return (\n                 Person.query.filter(Person.id == id)\n-                .filter(Project.id == project.id)\n+                .filter(Person.project_id == project.id)\n                 .one()\n             )\n \n```\n\n### Workarounds\n\nTo limit the impact, it is possible to disable public project creation by setting `ALLOW_PUBLIC_PROJECT_CREATION = False` in the configuration (see [documentation](https://ihatemoney.readthedocs.io/en/latest/configuration.html)). Existing users will still be able to exploit the flaw, but this will prevent an external attacker from creating a new project.\n\n### For more information\n\n`Person.query.get()` and `Person.query.get_by_name()` were mistakenly running a database join on the Project table without constraining the result.\n\nAs a result, `Person.query.get(42, \"projectfoo\")` would return the Person with id=42, even if it is not associated to the project \"projectfoo\".  The only condition is that \"projectfoo\" must exist.\n\nThis flaw can be exploited in several places:\n\n1) API: PUT requests to `/api/projects/<project>/members/<personID>` will succeed even though `<personID>` is not a member of `<project>`.\n\n   This allows an authenticated attacker to alter the state of a member (name, weight, activated) in any project.  In addition, the altered member will no longer be associated with its original project but will be associated to the attacker project instead, breaking many features of IHateMoney.  For instance, bills referencing the altered member will no longer be visible in the original project.\n\n   This causes an additional information disclosure and loss of integrity on bills: the attacker will now be able to see, edit and delete bills belonging to the altered member, because IHateMoney now believes that these bills are associated to the attacker project through the altered member.\n\n   For instance, assume that `Person(id=42)` is a member of project \"targetProject\", and that the attacker has access to another project \"attackerProject\" with the private code \"attackerPassword\".  The attacker can modify `Person(id=42)` with this command:\n\n     $ curl -X PUT -d \"name=Pwn3d&activated=1\" --basic -u attackerProject:attackerPassword http://$SERVER/api/projects/attackerProject/members/42\n\n   The attacker can now see, edit and delete bills paid by `Person(id=42)` by simply browsing to http://$SERVER/attackerProject/\n\n2) Editing a member through the web interface at `/<project>/members/<personID>/edit` will succeed even though `<personID>` is not a member of `<project>`.\n\n   This is very similar to the PUT exploit.  Reusing the same example, the attacker needs to login to its \"attackerProject\" project with the private code \"attackerPassword\".  It can then alter the state of `Person(id=42)` by accessing the edit form at the following URL:\n\n     http://$SERVER/attackerProject/members/42/edit\n\n   Again, as a result of the alteration, the altered member will become associated to the project \"attackerProject\", resulting in the same information disclosure and loss of integrity on bills.\n\n3) API: DELETE requests to `/api/projects/<project>/members/<personID>` will similarly allow to delete the member `<personID>` even if it belongs to a different project than `<project>`.\n\n     $ curl -X DELETE --basic -u attackerProject:attackerPassword http://$SERVER/api/projects/attackerProject/members/42\n\n   The impact is less serious than with PUT, because DELETE only deactivates a member (it does not really delete it).\n\nAll these exploits require authentication: an attacker needs to know a valid project name and its associated \"private code\".  Once this requirement is fullfilled, the attacker can exploit this flaw to alter the state of members in any other project, without needing to know the target project name or its private code.\n\n`Person.query.get_by_name()` suffers from the same issue as `Person.query.get()`.  It has an additional issue: if multiple Person objects with the same name exist (this is possible if they are associated to different projects), `get_by_name()` will crash with `MultipleResultsFound` because of the call to `one()`.\n\nHowever, since `Person.query.get_by_name()` is currently not used anywhere in IHateMoney, the bug affecting this function has no impact and is not exploitable.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "ihatemoney"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.1.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/spiral-project/ihatemoney/security/advisories/GHSA-67j9-c52g-w2q9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-15120"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/spiral-project/ihatemoney/commit/8d77cf5d5646e1d2d8ded13f0660638f57e98471"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/ihatemoney/PYSEC-2020-264.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/spiral-project/ihatemoney"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-863" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-07-27T17:47:33Z",
    "nvd_published_at" : null
  }
}