loading...
Cover image for How to avoid Insecure Binder Configuration in JAVA

How to avoid Insecure Binder Configuration in JAVA

wakeupmh profile image Marcos Henrique ใƒป2 min read

What is API ABUSE? ๐Ÿ˜ฅ

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.

Abstract ๐Ÿ™„

The framework binder used for binding the HTTP request parameters to the model class has not been explicitly configured to allow, or disallow certain attributes

Explanation ๐Ÿค“

To ease development and increase productivity, most modern frameworks allow an object to be automatically instantiated and populated with the HTTP request parameters whose names match an attribute of the class to be bound. Automatic instantiation and population of objects speeds up development, but can lead to serious problems if implemented without caution.

Any attribute in the bound classes, or nested classes, will be automatically bound to the HTTP request parameters. Therefore, malicious users will be able to assign a value to any attribute in bound or nested classes, even if they are not exposed to the client through web forms or API contracts.

The vulnerability ๐Ÿ˜ฉ

public class MyClasss implements Serializable {
  // some logic
}

The solution ๐Ÿ˜Š

Jackson provides an annotation that can be used on class level (JsonIgnoreProperties).

So simple, just add @JsonIgnoreProperties(ignoreUnknown = true) before the class.

Add the following to the top of your class (not to individual methods):

@JsonIgnoreProperties(ignoreUnknown = true)
public class MyClasss implements Serializable {
  // some logic
}

๐Ÿ‘‹

Posted on by:

wakeupmh profile

Marcos Henrique

@wakeupmh

"Programming isn't about what you know; it's about what you can figure out.โ€

Discussion

pic
Editor guide