CWE-595
Weakness AllowedComparison of Object References Instead of Object Contents
Abstraction: Variant · Status: Incomplete
The product compares object references instead of the contents of the objects themselves, preventing it from detecting equivalent objects.
For example, in Java, comparing objects using == usually produces deceptive results, since the == operator compares object references rather than values; often, this means that using == for strings is actually comparing the strings' references, not their values.
Mapping guidance
This CWE entry is at the Variant level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.
Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.
Modes of introduction
Detection methods
Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Effectiveness: High
Content history
added/updated demonstrative examples
updated Time_of_Introduction
updated Description, Relationships, Other_Notes
updated Name
updated Demonstrative_Examples
updated Common_Consequences, Relationships, Taxonomy_Mappings
updated Common_Consequences, Demonstrative_Examples, Relationships, Taxonomy_Mappings
updated Potential_Mitigations
updated Applicable_Platforms, Common_Consequences
updated Relationships
updated Applicable_Platforms, Common_Consequences, Description, Other_Notes, Potential_Mitigations, References, Relationships, Type
updated Relationships, Taxonomy_Mappings
updated Relationships
updated Relationships
updated Demonstrative_Examples
updated Description
updated Detection_Factors, Relationships
updated Mapping_Notes
updated Demonstrative_Examples
updated References
updated Weakness_Ordinalities
updated Applicable_Platforms, References, Relationships, Taxonomy_Mappings
1 vulnerability references this CWE, most recent first.
GHSA-M5PR-WM6Q-X4G2
Vulnerability from github – Published: 2022-12-28 15:30 – Updated: 2023-01-10 15:44Comparison of Object References Instead of Object Contents in GitHub repository usememos/memos 0.9.0 and prior.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 0.9.0"
},
"package": {
"ecosystem": "Go",
"name": "github.com/usememos/memos"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.9.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2022-4812"
],
"database_specific": {
"cwe_ids": [
"CWE-595",
"CWE-639"
],
"github_reviewed": true,
"github_reviewed_at": "2022-12-30T22:11:56Z",
"nvd_published_at": "2022-12-28T14:15:00Z",
"severity": "MODERATE"
},
"details": "Comparison of Object References Instead of Object Contents in GitHub repository usememos/memos 0.9.0 and prior.",
"id": "GHSA-m5pr-wm6q-x4g2",
"modified": "2023-01-10T15:44:18Z",
"published": "2022-12-28T15:30:46Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-4812"
},
{
"type": "WEB",
"url": "https://github.com/usememos/memos/commit/3556ae4e651d9443dc3bb8a170dd3cc726517a53"
},
{
"type": "PACKAGE",
"url": "https://github.com/usememos/memos"
},
{
"type": "WEB",
"url": "https://huntr.dev/bounties/33924891-5c36-4b46-b417-98eaab688c4c"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N",
"type": "CVSS_V3"
}
],
"summary": "usememos/memos vulnerable to Comparison of Object References Instead of Object Contents"
}
Mitigation
In Java, use the equals() method to compare objects instead of the == operator. If using ==, it is important for performance reasons that your objects are created by a static factory, not by a constructor.
No CAPEC attack patterns related to this CWE.