CWE-662
Weakness DiscouragedImproper Synchronization
Abstraction: Class · Status: Draft
The product utilizes multiple threads, processes, components, or systems to allow temporary access to a shared resource that can only be exclusive to one process at a time, but it does not properly synchronize these actions, which might cause simultaneous accesses of this resource by multiple threads or processes.
Synchronization mechanisms vary widely, but they may include locking, mutexes, and semaphores.
Mapping guidance
This CWE entry is a level-1 Class (i.e., a child of a Pillar). It might have lower-level children that would be more appropriate
Examine children of this entry to see if there is a better fit
Relationships and members
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.)
Notes
Research Gap
Deeper research is necessary for synchronization and related mechanisms, including locks, mutexes, semaphores, and other mechanisms. Multiple entries are dependent on this research, which includes relationships to concurrency, race conditions, reentrant functions, etc. CWE-662 and its children - including CWE-667, CWE-820, CWE-821, and others - may need to be modified significantly, along with their relationships.
Content history
Submitted by members of the CWE community to extend early CWE versions
updated Potential_Mitigations, Time_of_Introduction
updated Relationships
updated Relationships
updated Relationships, Taxonomy_Mappings
updated Related_Attack_Patterns
updated Relationships
updated Name, Relationships
updated Description, Relationships, Taxonomy_Mappings
updated Common_Consequences, Relationships, Taxonomy_Mappings
updated Relationships, Taxonomy_Mappings
updated Relationships
updated Potential_Mitigations
updated Relationships
updated Relationships, Taxonomy_Mappings
updated Taxonomy_Mappings
updated Relationships, Taxonomy_Mappings
updated Type
updated Description, Maintenance_Notes, Relationships
updated Description, Relationships
updated Relationships
updated Relationships
updated Description
updated Relationships
updated Mapping_Notes
updated Demonstrative_Examples, Observed_Examples
updated Mapping_Notes
updated Applicable_Platforms, Description, Detection_Factors, Relationships, Weakness_Ordinalities
updated Maintenance_Notes, Research_Gaps
updated Background_Details, Common_Consequences, Description, References
86 vulnerabilities reference this CWE, most recent first.
GHSA-HW6F-3H4F-J29Q
Vulnerability from github – Published: 2023-02-06 21:30 – Updated: 2023-02-14 03:30In ccd, there is a possible use after free due to a race condition. This could lead to local escalation of privilege with System execution privileges needed. User interaction is not needed for exploitation. Patch ID: ALPS07341261; Issue ID: ALPS07341261.
{
"affected": [],
"aliases": [
"CVE-2022-32643"
],
"database_specific": {
"cwe_ids": [
"CWE-662"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-02-06T20:15:00Z",
"severity": "MODERATE"
},
"details": "In ccd, there is a possible use after free due to a race condition. This could lead to local escalation of privilege with System execution privileges needed. User interaction is not needed for exploitation. Patch ID: ALPS07341261; Issue ID: ALPS07341261.",
"id": "GHSA-hw6f-3h4f-j29q",
"modified": "2023-02-14T03:30:21Z",
"published": "2023-02-06T21:30:30Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-32643"
},
{
"type": "WEB",
"url": "https://corp.mediatek.com/product-security-bulletin/February-2023"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-J42V-6WPM-R847
Vulnerability from github – Published: 2021-08-25 20:50 – Updated: 2021-08-19 18:55An issue was discovered in the thex crate through 2020-12-08 for Rust. Thex allows cross-thread data races of non-Send types.
{
"affected": [
{
"package": {
"ecosystem": "crates.io",
"name": "thex"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "0.1.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2020-35927"
],
"database_specific": {
"cwe_ids": [
"CWE-662"
],
"github_reviewed": true,
"github_reviewed_at": "2021-08-19T18:55:21Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "An issue was discovered in the thex crate through 2020-12-08 for Rust. Thex\u003cT\u003e allows cross-thread data races of non-Send types.",
"id": "GHSA-j42v-6wpm-r847",
"modified": "2021-08-19T18:55:21Z",
"published": "2021-08-25T20:50:26Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-35927"
},
{
"type": "WEB",
"url": "https://rustsec.org/advisories/RUSTSEC-2020-0090.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "Data races in thex"
}
GHSA-J882-WWWR-7R6Q
Vulnerability from github – Published: 2025-04-07 15:31 – Updated: 2025-04-07 15:31FISCO BCOS 3.11.0 has an issue with synchronization of the transaction pool that can, for example, be observed when a malicious node (that has modified the codebase to allow a large min_seal_time value) joins a blockchain network.
{
"affected": [],
"aliases": [
"CVE-2024-58131"
],
"database_specific": {
"cwe_ids": [
"CWE-662",
"CWE-821"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-04-06T03:15:13Z",
"severity": "MODERATE"
},
"details": "FISCO BCOS 3.11.0 has an issue with synchronization of the transaction pool that can, for example, be observed when a malicious node (that has modified the codebase to allow a large min_seal_time value) joins a blockchain network.",
"id": "GHSA-j882-wwwr-7r6q",
"modified": "2025-04-07T15:31:13Z",
"published": "2025-04-07T15:31:13Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-58131"
},
{
"type": "WEB",
"url": "https://github.com/FISCO-BCOS/FISCO-BCOS/issues/4656"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:N/A:L",
"type": "CVSS_V3"
}
]
}
GHSA-JJ89-MXRF-Q72J
Vulnerability from github – Published: 2023-01-03 21:30 – Updated: 2023-01-10 03:30In disp, there is a possible use after free due to a race condition. This could lead to local escalation of privilege with System execution privileges needed. User interaction is not needed for exploitation. Patch ID: ALPS06535964; Issue ID: ALPS06535964.
{
"affected": [],
"aliases": [
"CVE-2022-32648"
],
"database_specific": {
"cwe_ids": [
"CWE-662"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-01-03T21:15:00Z",
"severity": "MODERATE"
},
"details": "In disp, there is a possible use after free due to a race condition. This could lead to local escalation of privilege with System execution privileges needed. User interaction is not needed for exploitation. Patch ID: ALPS06535964; Issue ID: ALPS06535964.",
"id": "GHSA-jj89-mxrf-q72j",
"modified": "2023-01-10T03:30:27Z",
"published": "2023-01-03T21:30:20Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-32648"
},
{
"type": "WEB",
"url": "https://corp.mediatek.com/product-security-bulletin/January-2023"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-JPGQ-R68H-X9Q2
Vulnerability from github – Published: 2026-01-13 18:31 – Updated: 2026-07-30 06:32In the Linux kernel, the following vulnerability has been resolved:
net/handshake: duplicate handshake cancellations leak socket
When a handshake request is cancelled it is removed from the handshake_net->hn_requests list, but it is still present in the handshake_rhashtbl until it is destroyed.
If a second cancellation request arrives for the same handshake request, then remove_pending() will return false... and assuming HANDSHAKE_F_REQ_COMPLETED isn't set in req->hr_flags, we'll continue processing through the out_true label, where we put another reference on the sock and a refcount underflow occurs.
This can happen for example if a handshake times out - particularly if the SUNRPC client sends the AUTH_TLS probe to the server but doesn't follow it up with the ClientHello due to a problem with tlshd. When the timeout is hit on the server, the server will send a FIN, which triggers a cancellation request via xs_reset_transport(). When the timeout is hit on the client, another cancellation request happens via xs_tls_handshake_sync().
Add a test_and_set_bit(HANDSHAKE_F_REQ_COMPLETED) in the pending cancel path so duplicate cancels can be detected.
{
"affected": [],
"aliases": [
"CVE-2025-68775"
],
"database_specific": {
"cwe_ids": [
"CWE-662"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-01-13T16:15:57Z",
"severity": "CRITICAL"
},
"details": "In the Linux kernel, the following vulnerability has been resolved:\n\nnet/handshake: duplicate handshake cancellations leak socket\n\nWhen a handshake request is cancelled it is removed from the\nhandshake_net-\u003ehn_requests list, but it is still present in the\nhandshake_rhashtbl until it is destroyed.\n\nIf a second cancellation request arrives for the same handshake request,\nthen remove_pending() will return false... and assuming\nHANDSHAKE_F_REQ_COMPLETED isn\u0027t set in req-\u003ehr_flags, we\u0027ll continue\nprocessing through the out_true label, where we put another reference on\nthe sock and a refcount underflow occurs.\n\nThis can happen for example if a handshake times out - particularly if\nthe SUNRPC client sends the AUTH_TLS probe to the server but doesn\u0027t\nfollow it up with the ClientHello due to a problem with tlshd. When the\ntimeout is hit on the server, the server will send a FIN, which triggers\na cancellation request via xs_reset_transport(). When the timeout is\nhit on the client, another cancellation request happens via\nxs_tls_handshake_sync().\n\nAdd a test_and_set_bit(HANDSHAKE_F_REQ_COMPLETED) in the pending cancel\npath so duplicate cancels can be detected.",
"id": "GHSA-jpgq-r68h-x9q2",
"modified": "2026-07-30T06:32:27Z",
"published": "2026-01-13T18:31:03Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-68775"
},
{
"type": "WEB",
"url": "https://git.kernel.org/stable/c/011ae80c49d9bfa5b4336f8bd387cd25c7593663"
},
{
"type": "WEB",
"url": "https://git.kernel.org/stable/c/15564bd67e2975002f2a8e9defee33e321d3183f"
},
{
"type": "WEB",
"url": "https://git.kernel.org/stable/c/3c330f1dee3cd92b57e19b9d21dc8ce5970b09be"
},
{
"type": "WEB",
"url": "https://git.kernel.org/stable/c/e1641177e7fb48a0a5a06658d4aab51da6656659"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-JPHW-P3M6-PJ3C
Vulnerability from github – Published: 2021-08-25 20:51 – Updated: 2023-06-13 20:04Affected versions of this crate unconditionally implemented Send for types used in queue implementations (InnerSend, InnerRecv, FutInnerSend, FutInnerRecv).
This allows users to send non-Send types to other threads, which can lead to data race bugs or other undefined behavior.
The flaw was corrected in v0.1.7 by adding T: Send bound to to the Send impl of four data types explained above.
{
"affected": [
{
"package": {
"ecosystem": "crates.io",
"name": "multiqueue2"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.1.7"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2020-36214"
],
"database_specific": {
"cwe_ids": [
"CWE-662"
],
"github_reviewed": true,
"github_reviewed_at": "2021-08-19T18:47:21Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "Affected versions of this crate unconditionally implemented Send for types used in queue implementations (InnerSend\u003cRW, T\u003e, InnerRecv\u003cRW, T\u003e, FutInnerSend\u003cRW, T\u003e, FutInnerRecv\u003cRW, T\u003e).\n\nThis allows users to send non-Send types to other threads, which can lead to data race bugs or other undefined behavior.\n\nThe flaw was corrected in v0.1.7 by adding T: Send bound to to the Send impl of four data types explained above.",
"id": "GHSA-jphw-p3m6-pj3c",
"modified": "2023-06-13T20:04:07Z",
"published": "2021-08-25T20:51:54Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-36214"
},
{
"type": "WEB",
"url": "https://github.com/abbychau/multiqueue2/issues/10"
},
{
"type": "PACKAGE",
"url": "https://github.com/abbychau/multiqueue2"
},
{
"type": "WEB",
"url": "https://rustsec.org/advisories/RUSTSEC-2020-0106.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "Data races in multiqueue2"
}
GHSA-JR7C-W77W-XHX7
Vulnerability from github – Published: 2023-03-07 21:30 – Updated: 2023-03-13 06:30In adsp, there is a possible double free due to a race condition. This could lead to local escalation of privilege with System execution privileges needed. User interaction is not needed for exploitation. Patch ID: ALPS07628532; Issue ID: ALPS07628532.
{
"affected": [],
"aliases": [
"CVE-2023-20625"
],
"database_specific": {
"cwe_ids": [
"CWE-662"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-03-07T21:15:00Z",
"severity": "MODERATE"
},
"details": "In adsp, there is a possible double free due to a race condition. This could lead to local escalation of privilege with System execution privileges needed. User interaction is not needed for exploitation. Patch ID: ALPS07628532; Issue ID: ALPS07628532.",
"id": "GHSA-jr7c-w77w-xhx7",
"modified": "2023-03-13T06:30:25Z",
"published": "2023-03-07T21:30:17Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-20625"
},
{
"type": "WEB",
"url": "https://corp.mediatek.com/product-security-bulletin/March-2023"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-M939-J537-P48W
Vulnerability from github – Published: 2022-11-09 12:00 – Updated: 2022-11-10 19:01In vcu, there is a possible memory corruption due to a race condition. This could lead to local escalation of privilege with System execution privileges needed. User interaction is not needed for exploitation. Patch ID: ALPS07206340; Issue ID: ALPS07206340.
{
"affected": [],
"aliases": [
"CVE-2022-32613"
],
"database_specific": {
"cwe_ids": [
"CWE-662"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2022-11-08T21:15:00Z",
"severity": "MODERATE"
},
"details": "In vcu, there is a possible memory corruption due to a race condition. This could lead to local escalation of privilege with System execution privileges needed. User interaction is not needed for exploitation. Patch ID: ALPS07206340; Issue ID: ALPS07206340.",
"id": "GHSA-m939-j537-p48w",
"modified": "2022-11-10T19:01:11Z",
"published": "2022-11-09T12:00:22Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-32613"
},
{
"type": "WEB",
"url": "https://corp.mediatek.com/product-security-bulletin/November-2022"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-MM4M-QG48-F7WC
Vulnerability from github – Published: 2021-08-25 21:01 – Updated: 2022-06-14 20:12rust-vmm vm-memory before 0.1.1 and 0.2.x before 0.2.1 allows attackers to cause a denial of service (loss of IP networking) because read_obj and write_obj do not properly access memory. This affects aarch64 (with musl or glibc) and x86_64 (with musl).
{
"affected": [
{
"package": {
"ecosystem": "crates.io",
"name": "vm-memory"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.1.1"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"package": {
"ecosystem": "crates.io",
"name": "vm-memory"
},
"ranges": [
{
"events": [
{
"introduced": "0.2.0"
},
{
"fixed": "0.2.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2020-13759"
],
"database_specific": {
"cwe_ids": [
"CWE-362",
"CWE-662"
],
"github_reviewed": true,
"github_reviewed_at": "2021-07-26T20:45:48Z",
"nvd_published_at": "2020-06-02T19:15:00Z",
"severity": "HIGH"
},
"details": "rust-vmm vm-memory before 0.1.1 and 0.2.x before 0.2.1 allows attackers to cause a denial of service (loss of IP networking) because read_obj and write_obj do not properly access memory. This affects aarch64 (with musl or glibc) and x86_64 (with musl).",
"id": "GHSA-mm4m-qg48-f7wc",
"modified": "2022-06-14T20:12:33Z",
"published": "2021-08-25T21:01:29Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-13759"
},
{
"type": "WEB",
"url": "https://github.com/rust-vmm/vm-memory/issues/93"
},
{
"type": "PACKAGE",
"url": "https://github.com/rust-vmm/vm-memory"
},
{
"type": "WEB",
"url": "https://github.com/rust-vmm/vm-memory/releases/tag/v0.1.1"
},
{
"type": "WEB",
"url": "https://github.com/rust-vmm/vm-memory/releases/tag/v0.2.1"
},
{
"type": "WEB",
"url": "https://rustsec.org/advisories/RUSTSEC-2020-0157.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "Improper Synchronization and Race Condition in vm-memory"
}
GHSA-MPX2-CMQF-859J
Vulnerability from github – Published: 2026-07-29 09:31 – Updated: 2026-10-30 15:32In the Linux kernel, the following vulnerability has been resolved:
perf/core: Detach event groups during remove_on_exec
perf_event_remove_on_exec() removes events by calling perf_event_exit_event(). For top-level events, this removes the event from the context with DETACH_EXIT only.
This can leave inconsistent group state when a removed event is a group leader and the group contains siblings without remove_on_exec. If the group was active, the surviving siblings can remain active and attached to the removed leader's sibling list, but are no longer represented by a valid group leader on the PMU context active lists.
A later close of the removed leader uses DETACH_GROUP and can promote the still-active siblings from this stale group state. The next schedule-in can then add an already-linked active_list entry again, corrupting the PMU context active list.
With DEBUG_LIST enabled, this is caught as a list_add double-add in merge_sched_in().
Fix this by detaching group relationships when remove_on_exec removes an event. This preserves the existing task-exit and revoke behavior, while ensuring surviving siblings are ungrouped before the removed event leaves the context.
{
"affected": [],
"aliases": [
"CVE-2026-64556"
],
"database_specific": {
"cwe_ids": [
"CWE-662"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-07-29T09:16:30Z",
"severity": "HIGH"
},
"details": "In the Linux kernel, the following vulnerability has been resolved:\n\nperf/core: Detach event groups during remove_on_exec\n\nperf_event_remove_on_exec() removes events by calling\nperf_event_exit_event(). For top-level events, this removes the event from\nthe context with DETACH_EXIT only.\n\nThis can leave inconsistent group state when a removed event is a group\nleader and the group contains siblings without remove_on_exec. If the group\nwas active, the surviving siblings can remain active and attached to the\nremoved leader\u0027s sibling list, but are no longer represented by a valid\ngroup leader on the PMU context active lists.\n\nA later close of the removed leader uses DETACH_GROUP and can promote the\nstill-active siblings from this stale group state. The next schedule-in can\nthen add an already-linked active_list entry again, corrupting the PMU\ncontext active list.\n\nWith DEBUG_LIST enabled, this is caught as a list_add double-add in\nmerge_sched_in().\n\nFix this by detaching group relationships when remove_on_exec removes an\nevent. This preserves the existing task-exit and revoke behavior, while\nensuring surviving siblings are ungrouped before the removed event leaves\nthe context.",
"id": "GHSA-mpx2-cmqf-859j",
"modified": "2026-10-30T15:32:58Z",
"published": "2026-07-29T09:31:30Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-64556"
},
{
"type": "WEB",
"url": "https://git.kernel.org/stable/c/037a3c43edfb597665dd34457cd22b14692f2ba3"
},
{
"type": "WEB",
"url": "https://git.kernel.org/stable/c/06ccef0434e98058ddae7bcebc901f93d22b7653"
},
{
"type": "WEB",
"url": "https://git.kernel.org/stable/c/1d3e1102273f09180262496658e7eeed8a5a7b59"
},
{
"type": "WEB",
"url": "https://git.kernel.org/stable/c/39358e856fb89e62e3c8d7389a2dc4ec33dbe90e"
},
{
"type": "WEB",
"url": "https://git.kernel.org/stable/c/4cdb1b3ab96eb1b7eb70bc5c82fede334bd60df2"
},
{
"type": "WEB",
"url": "https://git.kernel.org/stable/c/a2d5d3ee7b6e3953114726b1521e62123ab5b043"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
Mitigation
Use industry standard APIs to synchronize your code.
CAPEC-25: Forced Deadlock
The adversary triggers and exploits a deadlock condition in the target software to cause a denial of service. A deadlock can occur when two or more competing actions are waiting for each other to finish, and thus neither ever does. Deadlock conditions can be difficult to detect.
CAPEC-26: Leveraging Race Conditions
The adversary targets a race condition occurring when multiple processes access and manipulate the same resource concurrently, and the outcome of the execution depends on the particular order in which the access takes place. The adversary can leverage a race condition by "running the race", modifying the resource and modifying the normal execution flow. For instance, a race condition can occur while accessing a file: the adversary can trick the system by replacing the original file with their version and cause the system to read the malicious file.
CAPEC-27: Leveraging Race Conditions via Symbolic Links
This attack leverages the use of symbolic links (Symlinks) in order to write to sensitive files. An attacker can create a Symlink link to a target file not otherwise accessible to them. When the privileged program tries to create a temporary file with the same name as the Symlink link, it will actually write to the target file pointed to by the attackers' Symlink link. If the attacker can insert malicious content in the temporary file they will be writing to the sensitive file by using the Symlink. The race occurs because the system checks if the temporary file exists, then creates the file. The attacker would typically create the Symlink during the interval between the check and the creation of the temporary file.
CAPEC-29: Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions
This attack targets a race condition occurring between the time of check (state) for a resource and the time of use of a resource. A typical example is file access. The adversary can leverage a file access race condition by "running the race", meaning that they would modify the resource between the first time the target program accesses the file and the time the target program uses the file. During that period of time, the adversary could replace or modify the file, causing the application to behave unexpectedly.