Skip to content

Authorization Bypass in I hate money

Moderate severity GitHub Reviewed Published Jul 26, 2020 in spiral-project/ihatemoney • Updated Sep 23, 2024

Package

pip ihatemoney (pip)

Affected versions

< 4.1.5

Patched versions

4.1.5

Description

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

 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). 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.

References

@Glandos Glandos published to spiral-project/ihatemoney Jul 26, 2020
Reviewed Jul 27, 2020
Published to the GitHub Advisory Database Jul 27, 2020
Last updated Sep 23, 2024

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v4 base metrics

Exploitability Metrics
Attack Vector Network
Attack Complexity Low
Attack Requirements None
Privileges Required High
User interaction None
Vulnerable System Impact Metrics
Confidentiality None
Integrity High
Availability None
Subsequent System Impact Metrics
Confidentiality None
Integrity None
Availability None

CVSS v4 base metrics

Exploitability Metrics
Attack Vector: This metric reflects the context by which vulnerability exploitation is possible. This metric value (and consequently the resulting severity) will be larger the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable system. The assumption is that the number of potential attackers for a vulnerability that could be exploited from across a network is larger than the number of potential attackers that could exploit a vulnerability requiring physical access to a device, and therefore warrants a greater severity.
Attack Complexity: This metric captures measurable actions that must be taken by the attacker to actively evade or circumvent existing built-in security-enhancing conditions in order to obtain a working exploit. These are conditions whose primary purpose is to increase security and/or increase exploit engineering complexity. A vulnerability exploitable without a target-specific variable has a lower complexity than a vulnerability that would require non-trivial customization. This metric is meant to capture security mechanisms utilized by the vulnerable system.
Attack Requirements: This metric captures the prerequisite deployment and execution conditions or variables of the vulnerable system that enable the attack. These differ from security-enhancing techniques/technologies (ref Attack Complexity) as the primary purpose of these conditions is not to explicitly mitigate attacks, but rather, emerge naturally as a consequence of the deployment and execution of the vulnerable system.
Privileges Required: This metric describes the level of privileges an attacker must possess prior to successfully exploiting the vulnerability. The method by which the attacker obtains privileged credentials prior to the attack (e.g., free trial accounts), is outside the scope of this metric. Generally, self-service provisioned accounts do not constitute a privilege requirement if the attacker can grant themselves privileges as part of the attack.
User interaction: This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable system. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.
Vulnerable System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the VULNERABLE SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the VULNERABLE SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the VULNERABLE SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
Subsequent System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the SUBSEQUENT SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the SUBSEQUENT SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the SUBSEQUENT SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
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

EPSS score

0.050%
(20th percentile)

Weaknesses

CVE ID

CVE-2020-15120

GHSA ID

GHSA-67j9-c52g-w2q9

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.