The Mass Assignment vulnerability is a lack of data input validation that allows an attacker to modify data or elevate privileges by manipulating payload data. In the case of an object database, for example, if the payload maps directly to the stored data and is inserted directly, without input validation compared against authorisation levels, then the attacker can craft a payload that alters data not intended to be altered.
To prevent against Mass Assignment APIs need to validate input against a blacklist or preferably a whitelist so that only the expected fields of the payload are evaluated, coupled with authorisation validation to ensure the client has the correct privileges on those fields. This ensures that data can only be modified by a client that is granted the rights to modify that data.
|Threat agents/Attack vectors||Security Weakness||Impacts|
|API Specific : Exploitability 2||Prevalence 2 : Detectability 2||Technical 2 : Business Specific|
|Exploitation usually requires an understanding of the business logic, objects’ relations, and the API structure. Exploitation of mass assignment is easier in APIs, since by design they expose the underlying implementation of the application along with the properties’ names.||Modern frameworks encourage developers to use functions that automatically bind input from the client into code variables and internal objects. Attackers can use this methodology to update or overwrite sensitive object’s properties that the developers never intended to expose.||Exploitation may lead to privilege escalation, data tampering, bypass of security mechanisms, and more.|
Source: OWASP Mass Assignment
While, in general, Mass Assignment is an API issue to solve an APIM can facilitate the process. Validation of the payload through, for example, a JSON schema ensures that the payload contains only the expected fields.
Additionally an APIM can validate authentication and authorisation by scope. This ensures that the client has the correct credentials before the API processes the request.
Payload validation can be implemented in various ways with the Tyk APIM.
- JSON Schema validation to ensure the payload meets the defined schema, and rejects payloads that do not.
- Body Transformation allows using string template syntax, which is a powerful tool for generating the desired output from the input.
- Custom Plugins for more complex cases or logic not satisfied by the first 2, users can write custom plugins in a variety of languages, either directly or through gRPC calls, to implement their requirements.
- Request Method Transformation while not directly a Mass Assignment prevention, it is a feature that can help ensure that APIs are called with the correct methods.
In addition to the technical solutions mentioned above, Tyk also recommends considering splitting Admin APIs from client facing APIs. By having the Admin usage of APIs separate from client facing APIs then different policies, payload validation methods, authentication and authorisation checks in the APIM can be separated and managed under different governance models providing a clear split between the roles.