An API is a contract between a caller and a callee. The most common forms of API abuse are caused by the caller failing to honor its end of this contract. For example, if a program fails to 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 abuses 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.
ASP.NET MVC Bad Practices: Optional Submodel With Required Property
The ASP.NET MVC framework will try to bind request parameters to model properties, including submodels.
If a submodel is optional -- that is, the parent model has a property without the
[Required]
attribute -- and if an attacker does not communicate that submodel, then the parent property will have a null
value and the required fields of the child model will not be asserted by model validation. This is one form of an under-posting attack.Consider the following the model class definitions:
public class ChildModel
{
public ChildModel()
{
}
[Required]
public String RequiredProperty { get; set; }
}
public class ParentModel
{
public ParentModel()
{
}
public ChildModel Child { get; set; }
}
If an attacker does not communicate a value for the
ParentModel.Child
property, then the ChildModel.RequiredProperty
property will have a [Required]
which is not asserted. This may produce unexpected and undesirable results.