Các cách xuất hiện
Implementation : Logic errors related to operator precedence may cause problems even during normal operation, so they are probably discovered quickly during the testing phase. If testing is incomplete or there is a strong reliance on manual review of the code, then these errors may not be discovered before the software is deployed.
Nền tảng áp dụng
Ngôn ngữ
Lớp: Not Language-Specific (Rarely)
Tên: C (Rarely)
Tên: C++ (Rarely)
Tên: Python (Undetermined)
Hậu quả phổ biến
| Phạm vi |
Tác động |
Khả năng xảy ra |
Confidentiality Integrity Availability | Varies by Context, Unexpected State
Ghi chú: While often just a bug, operator precedence logic errors can have serious consequences if they are used in security-critical code, such as making an authentication decision. The consequences will vary based on the context surrounding the incorrect precedence. In a security decision, violations of integrity or confidentiality are the most likely results. Otherwise, a crash may occur due to the software reaching an unexpected state. | |
Ví dụ đã quan sát
| Tài liệu tham khảo |
Mô tả |
| Chain: calculation expression does not use parentheses to address operator precedence (CWE-783), causing an incorrect calculation (CWE-682) leading to a buffer overflow (CWE-787). |
| Authentication module allows authentication bypass because it uses "(x = call(args) == SUCCESS)" instead of "((x = call(args)) == SUCCESS)". |
| Chain: Language interpreter calculates wrong buffer size (CWE-131) by using "size = ptr ? X : Y" instead of "size = (ptr ? X : Y)" expression. |
| Chain: product does not properly check the result of a reverse DNS lookup because of operator precedence (CWE-783), allowing bypass of DNS-based access restrictions. |
Các biện pháp giảm thiểu tiềm năng
Phases : Implementation
Regularly wrap sub-expressions in parentheses, especially in security-critical code.
Phương pháp phát hiện
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.)
Hiệu quả : High
Ghi chú ánh xạ lỗ hổng
Lý do : This CWE entry is at the Base level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.
Bình luận : 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.
Tài liệu tham khảo
REF-704
EXP00-C. Use parentheses for precedence of operation
CERT.
https://www.securecoding.cert.org/confluence/display/seccode/EXP00-C.+Use+parentheses+for+precedence+of+operation REF-62
The Art of Software Security Assessment
Mark Dowd, John McDonald, Justin Schuh.
REF-1534
Automated Technical Debt Measure, Version 2
OMG.
https://www.omg.org/spec/ATDM2/1.0/PDF REF-1541
Secure Coding Guide for Python
OpenSSF.
https://best.openssf.org/Secure-Coding-Guide-for-Python/
Gửi
| Tên |
Tổ chức |
Ngày |
Ngày phát hành |
Version |
| CWE Content Team |
MITRE |
2009-07-16 +00:00 |
2009-07-27 +00:00 |
1.5 |
Sửa đổi
| Tên |
Tổ chức |
Ngày |
Bình luận |
| CWE Content Team |
MITRE |
2009-12-28 +00:00 |
updated Observed_Examples |
| CWE Content Team |
MITRE |
2011-06-27 +00:00 |
updated Common_Consequences |
| CWE Content Team |
MITRE |
2012-05-11 +00:00 |
updated Demonstrative_Examples, References, Relationships |
| CWE Content Team |
MITRE |
2017-11-08 +00:00 |
updated Taxonomy_Mappings, Time_of_Introduction |
| CWE Content Team |
MITRE |
2019-01-03 +00:00 |
updated Taxonomy_Mappings |
| CWE Content Team |
MITRE |
2019-06-20 +00:00 |
updated Type |
| CWE Content Team |
MITRE |
2020-02-24 +00:00 |
updated Relationships |
| CWE Content Team |
MITRE |
2020-08-20 +00:00 |
updated Relationships |
| CWE Content Team |
MITRE |
2021-03-15 +00:00 |
updated Relationships |
| CWE Content Team |
MITRE |
2023-01-31 +00:00 |
updated Description |
| CWE Content Team |
MITRE |
2023-04-27 +00:00 |
updated Relationships |
| CWE Content Team |
MITRE |
2023-06-29 +00:00 |
updated Mapping_Notes |
| CWE Content Team |
MITRE |
2025-12-11 +00:00 |
updated Detection_Factors, Weakness_Ordinalities |
| CWE Content Team |
MITRE |
2026-10-28 +00:00 |
updated Applicable_Platforms, Common_Consequences, Description, Observed_Examples, References, Relationships, Taxonomy_Mappings |