CWE-227: Improper Fulfillment of API Contract ('API Abuse')
Weakness ID: 227
The software uses an API in a manner contrary to its intended use.
An API is a contract between a caller and a callee. The most common forms of API misuse occurs when the caller does not honor its end of this contract. For example, if a program does not call chdir() after calling chroot(), it violates the contract that specifies how to change the active root directory in a secure fashion. Another good example of library abuse is expecting the callee to return trustworthy DNS information to the caller. In this case, the caller misuses the callee API by making certain assumptions about its behavior (that the return value can be used for authentication purposes). One can also violate the caller-callee contract from the other side. For example, if a coder subclasses SecureRandom and returns a non-random value, the contract is violated.
Time of Introduction
Architecture and Design
Technical Impact: Quality degradation; Unexpected state