CWE-574: EJB Bad Practices: Use of Synchronization Primitives
Official CWE-574 CWE context with Glexia analysis, remediation guidance, related CVEs, and ATT&CK context.
Glexia's Take
CWE-574: EJB Bad Practices: Use of Synchronization Primitives
EJB Bad Practices: Use of Synchronization Primitives represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.
Executive Impact
- Other: Quality Degradation
Developer Pattern
CWE-574 is the kind of defect developers can usually prevent with explicit validation, safer framework defaults, and tests that exercise hostile input or unsafe state transitions.
Confidence
high confidence from CWE-574, 4.20.
Official CWE Definition
CWE-574: EJB Bad Practices: Use of Synchronization Primitives
The product violates the Enterprise JavaBeans (EJB) specification by using thread synchronization primitives.
The Enterprise JavaBeans specification requires that every bean provider follow a set of programming guidelines designed to ensure that the bean will be portable and behave consistently in any EJB container. In this case, the product violates the following EJB guideline: "An enterprise bean must not use thread synchronization primitives to synchronize execution of multiple instances." The specification justifies this requirement in the following way: "This rule is required to ensure consistent runtime semantics because while some EJB containers may use a single JVM to execute all enterprise bean's instances, others may distribute the instances across multiple JVMs."
Developer And Remediation Guidance
How teams prevent and detect this weakness
Causes
- In the following Java example a Customer Entity EJB provides access to customer information in a database for a business application. However, the customer entity EJB uses the synchronized keyword for the set methods to attempt to provide thread safe synchronization for the member variables. The use of synchronized methods violate the restriction of the EJB specification against the use synchronization primitives within EJBs. Using synchronization primitives may cause inconsistent behavior of the EJB when used within different EJB containers.
Remediation
- Implementation: Do not use Synchronization Primitives when writing EJBs.
Detection
- Code review
- SAST
- DAST
- Focused regression tests
Mappings
Related CVEs, CWEs, and ATT&CK context
ATT&CK Relevance
ATT&CK relevance is shown only when reviewed or responsibly inferred.