CWE-783: Operator Precedence Logic Error
The product uses an expression in which operator precedence causes incorrect logic to be used.
How it's found
Operator Precedence Logic Error is typically found by tracing untrusted input from where it enters the system to the point where it is used without the check or neutralization this weakness describes, combining manual code review with dynamic testing.
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.
Vulnerable vs. safe
// call method to authenticate username and password
// if authentication fails then return failure otherwise return successreturn isUser;
isUser = SUCCESS;int isUser = FAIL;if (isUser = AuthenticateUser(username, password) == FAIL) {}else {}return isUser;#define FAIL 0#define SUCCESS 1...int validateUser(char *username, char *password) {}...if ((isUser = AuthenticateUser(username, password)) == FAIL) {...Consequences
- Varies by Context, Unexpected State: The consequences will vary based on the context surrounding the incorrect precedence. In a security decision, integrity or confidentiality are the most likely results. Otherwise, a crash may occur due to the software reaching an unexpected state.
Mitigations
- Implementation: Regularly wrap sub-expressions in parentheses, especially in security-critical code.
Where this fits in a TurboPentest engagement
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Frequently asked questions
What is CWE-783?
The product uses an expression in which operator precedence causes incorrect logic to be used.
How do you find Operator Precedence Logic Error?
Operator Precedence Logic Error is typically found by tracing untrusted input from where it enters the system to the point where it is used without the check or neutralization this weakness describes, combining manual code review with dynamic testing.
What is the impact of CWE-783?
Varies by Context, Unexpected State: The consequences will vary based on the context surrounding the incorrect precedence. In a security decision, integrity or confidentiality are the most likely results. Otherwise, a crash may occur due to the software reaching an unexpected state.
Does TurboPentest test for Operator Precedence Logic Error?
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Related CWEs
Written and reviewed by
Michel Chamberland - Founder & CEO, IntegSec
CISSP, OSCP, OSCE, CEH, GIAC, CCSK · 20+ years in offensive security
Michel has spent 20+ years on offensive security teams including IBM X-Force Red and Trustwave SpiderLabs, leading penetration tests, red team engagements, and breach response for Fortune 500 customers. He is the founder of IntegSec and the architect of TurboPentest.
Find these issues before an attacker does
TurboPentest runs an agentic AI pentest against your target and reports findings with proof, from $99 per target.
Start a pentest