-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addressing Mass Assignment vulnerabilities with @NoBind annotation for domain objects [SPR-13835] #18408
Comments
Anton Abashkin commented |
Juergen Hoeller commented We have been considering such a mechanism before - either whitelisting bindable fields or blacklisting non-binding fields through an annotation as you suggest - but never got around to work out the details. I'll take your request as an opportunity to revisit this topic for 4.3... Juergen |
Juergen Hoeller commented Technically, we would implement such an auto-disallow for specifically annotated fields at the The lower-level Juergen |
Juergen Hoeller commented Unfortunately, this turns out out to be non-trivial to implement at the Juergen |
For 6.1 we've added enhanced support for constructor binding in This provides an option to use data binding such that the request parameters used are determined by the Object structure, and not the other way around. I am closing this as superseded for now, but we are open to further feedback. |
Anton Abashkin opened SPR-13835 and commented
Most modern frameworks provide a convenience mechanism for binding form data to a domain object. Spring MVC is no exception.
While such a function is certainly indispensable, it exposes the application to the risk of a mass assignment vulnerability http://www.hpenterprisesecurity.com/vulncat/en/vulncat/java/mass_assignment_sensitive_field_exposure.html
A very serious vulnerability, this is actually how GitHub got hacked back in 2012 http://www.infoq.com/news/2012/03/GitHub-Compromised
Currently, Spring MVC does address this issue by providing two methods:
http://docs.spring.io/autorepo/docs/spring-framework/3.1.x/javadoc-api/org/springframework/validation/DataBinder.html#setAllowedFields%28java.lang.String...%29
http://docs.spring.io/autorepo/docs/spring-framework/3.1.x/javadoc-api/org/springframework/validation/DataBinder.html#setDisallowedFields%28java.lang.String...%29
While obviously a step in the right direction, this approach is not always optimal, the reason being the developer must set this in each controller using
@InitBinder
. This duplicates effort and is error prone.One alternative for the developer is to create Data Transfer Objects (DTOs). While this does indeed provide protection, as well as other architectural benefits, it is not practiced by many developers.
I believe the optimal way to address this is to do something similar to what the the Play Framework does by providing a
@NoBind
annotation: https://www.playframework.com/documentation/1.4.x/controllers#nobindingExpressing these constraints directly in the domain object using annotations seems optimal from both a development and security auditing point of view
Thoughts?
Issue Links:
2 votes, 5 watchers
The text was updated successfully, but these errors were encountered: