Attack Surface: Property Injection/Manipulation via Deserialization
- Description: Attackers can manipulate JSON payloads to set or modify object properties that should not be directly settable from external input. This can lead to unauthorized modification of application state or sensitive data if the application relies solely on
mjextension
for data binding without proper access control. - mjextension Contribution:
mjextension
automatically maps JSON keys to Objective-C properties based on naming conventions. If an object has properties that represent internal state or sensitive configurations, and these properties are accessible (even if not intended for external modification),mjextension
might inadvertently allow them to be set via a malicious JSON payload. - Example:
- Assume an Objective-C class
Configuration
has a propertyisAdminUser
(boolean) that should only be set internally by the application. - A malicious JSON payload includes
"isAdminUser": true
. - If the application deserializes this JSON into a
Configuration
object usingmjextension
without any filtering or access control, theisAdminUser
property might be unexpectedly set totrue
, potentially granting unauthorized administrative privileges.
- Assume an Objective-C class
- Impact: Unauthorized access, privilege escalation, data manipulation, security bypass.
- Risk Severity: High to Critical. If sensitive properties controlling access or critical application logic can be manipulated, the risk is Critical.
- Mitigation Strategies:
- Principle of Least Privilege: Design Objective-C classes to minimize publicly settable properties. Use
@private
or@protected
for properties that should not be directly accessible from outside the class. - Data Transfer Objects (DTOs): Use separate DTO classes specifically designed for receiving external data. These DTOs should only contain properties that are safe to be set from external input. Map data from DTOs to internal model objects after validation and sanitization.
- Property Filtering/Ignoring: If
mjextension
provides features to ignore or filter certain properties during deserialization, utilize them to prevent setting sensitive properties from external JSON. - Input Validation and Authorization: After deserialization, implement strict validation and authorization checks to ensure that the modified properties are within acceptable bounds and that the user or source is authorized to make these changes.
- Principle of Least Privilege: Design Objective-C classes to minimize publicly settable properties. Use
Attack Surface: Unintentional Exposure of Sensitive Data during Serialization
- Description: When serializing Objective-C objects back to JSON using
mjextension
for API responses or logging, sensitive data contained within these objects might be unintentionally exposed if not properly controlled. - mjextension Contribution:
mjextension
by default serializes all accessible properties of an Objective-C object. If developers are not careful about which properties are included during serialization, sensitive information might be inadvertently included in the JSON output. - Example:
- An Objective-C
UserProfile
object contains apasswordHash
property (which should not be exposed). - The application uses
mjextension
to serialize theUserProfile
object to JSON for an API response. - If the developer doesn't explicitly exclude the
passwordHash
property during serialization, it will be included in the JSON response and potentially exposed to unauthorized parties.
- An Objective-C
- Impact: Information disclosure, exposure of sensitive credentials, privacy violations.
- Risk Severity: Medium to High. If sensitive credentials or personally identifiable information (PII) are exposed, the risk is High.
- Mitigation Strategies:
- Explicit Property Selection for Serialization: Utilize
mjextension
's features (if available) to explicitly specify which properties should be included in the JSON output during serialization. Create a whitelist of properties to be serialized. - Data Transfer Objects (DTOs) for Responses: Create separate DTO classes specifically for API responses. These DTOs should only contain properties that are safe to be exposed. Map data from internal model objects to these DTOs before serialization.
- Property Exclusion/Ignoring during Serialization: If
mjextension
provides features to ignore or exclude certain properties during serialization, use them to prevent sensitive properties from being included in the JSON output. - Code Review and Security Audits: Carefully review code that uses
mjextension
for serialization to ensure that sensitive data is not being unintentionally exposed. Conduct security audits to identify potential information disclosure vulnerabilities.
- Explicit Property Selection for Serialization: Utilize