• Browse topics
Login
Login

SNYK LEARN LOGIN

OTHER REGIONS

For Snyk Enterprise customers with regional contracts. More info

Broken object property level authorization

Failing to enforce access control

Select your ecosystem

Broken object property level authorization: the basics

What is broken object property level authorization?

Broken object property level authorization occurs when an API fails to enforce proper access control for individual object properties. This can lead to unauthorized disclosure or modification of sensitive data. Such vulnerabilities arise when APIs expose more data than necessary (excessive data exposure) or fail to validate user permissions when modifying object properties (mass assignment). Attackers exploit this by inspecting API responses, crafting malicious requests, and manipulating object properties.

About this lesson

In this lesson, you will learn how broken object property level authorization vulnerabilities occur, how attackers exploit them, and how to secure your APIs. This includes an engaging scenario demonstrating the vulnerability, an under-the-hood technical breakdown, and mitigation strategies.

FUN FACT

Hidden in plain sight

In 2023, researchers from Cornell University developed EDEFuzz, the first automated tool designed to detect Excessive Data Exposure vulnerabilities. Tested on 69 websites from the Alexa Top-200, EDEFuzz uncovered 33,365 potential leaks.

Broken object property level authorization in action

Let's take a look at a fictitious vacation rental company. We have access to their API and want to do some exploring... or testing

Testing out an API

  • STEP 1
  • STEP 2
  • STEP 3
  • STEP 4
  • STEP 5

Setting the stage

While testing out API endpoints, we encounter something unexpected in the JSON response for the `/api/booking/details` endpoint. Let's take a look!

broken-object-1

Broken object property level authorization under the hood

In the example above, the API lacked schema validation, exposing sensitive properties like admin_notes and payment_token. Attackers exploit this using tools to inspect JSON responses. The API’s /update endpoint also failed to restrict which properties could be modified, allowing unauthorized changes to critical properties like total_price and user_role.

The Python example shows an endpoint at /api/booking/update that allows updates to booking objects. The code retrieves a booking object using get_booking and iterates over the key-value pairs in the request payload, dynamically setting object attributes with setattr.

This approach is highly insecure because it lacks validation of the fields being updated. Malicious actors can modify sensitive properties or inject unexpected data, potentially bypassing access control checks or corrupting the object. By allowing unrestricted updates, the endpoint creates significant risks to the integrity and security of the data.

As we seen above, broken object property level authorization occurs when an application fails to properly enforce access controls on specific properties or fields of an object. This vulnerability can have severe consequences, leading to unauthorized data access, privilege escalation, financial fraud, reputation damage, compliance violations, and even system instability.

One major impact is unauthorized data access. Attackers may exploit this weakness to access sensitive information that should be restricted. For example, they could view private user details such as email addresses, phone numbers, or financial information. In some cases, they might gain access to confidential business data, including trade secrets or employee records.

Another significant risk is privilege escalation. When authorization checks are improperly enforced, attackers can modify properties they shouldn’t have access to, allowing them to elevate their privileges. For instance, an attacker could change a user’s role to gain administrative rights or alter permissions on a file or resource to grant themselves access.

Financial fraud is another potential consequence, like in the example above. Exploiting weak authorization controls, attackers could manipulate transactional data or financial records. For example, they might adjust the amount or recipient of a payment or modify billing and shipping information to redirect goods or services. Or get a rental for the low price of $50!

Finally, this vulnerability can lead to system instability. Unauthorized modifications to object properties may cause system malfunctions, data corruption, or service disruptions. For example, attackers might change critical configurations that affect system performance or inject invalid or malicious data that causes application errors.

Scan your code & stay secure with Snyk - for FREE!

Did you know you can use Snyk for free to verify that your code
doesn't include this or other vulnerabilities?

Scan your code

Broken object property level authorization mitigation

Mitigating broken object property level authorization requires a combination of secure API design and careful implementation practices to ensure robust protection against unauthorized access.

A secure API design is essential to prevent unauthorized access to object properties. One effective approach is to use explicit allowlisting through schema validation, which defines the allowed properties for responses and updates. This ensures that only the intended fields can be accessed or modified. Additionally, adhering to the principle of least privilege is crucial; access should be restricted based on roles and permissions, ensuring users can only interact with the properties they are authorized to access. Furthermore, access control must be enforced at the property level by implementing checks that validate whether a user has the necessary permissions for each specific property.

Proper implementation details are equally important to safeguard against this vulnerability. Input validation should be performed rigorously, and property-level restrictions must be enforced to prevent unauthorized modifications. Developers should avoid using generic deserialization functions that automatically bind input to internal objects, as these can inadvertently expose sensitive properties. Logging and monitoring should also be implemented to detect and respond to unauthorized access attempts, providing an additional layer of security and visibility.

The Python code secures the /api/booking/update endpoint by introducing an allowed_updates set containing only the permitted fields, dates and comments. The setattr function updates object attributes only if the field exists in allowed_updates.

This mitigation addresses the mass assignment vulnerability by explicitly allowlisting fields that can be updated. Attempts to modify unauthorized fields will be ignored.

Mitigating this type of vulnerability in any language follows the same concept: explicitly control which fields can be updated or returned.

Quiz

Test your knowledge!

Quiz

What is the primary cause of broken object property level authorization vulnerabilities?

Keep learning

Learn more about broken object property level authorization with these resources:

Congratulations

You’ve learned the risks and mitigation strategies for broken object property level authorization. Apply these practices to secure your APIs and safeguard sensitive data. Don’t forget to explore more lessons on API security!