[
https://issues.apache.org/jira/browse/WW-4146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13718454#comment-13718454
]
bruce liu edited comment on WW-4146 at 7/24/13 3:10 PM:
--------------------------------------------------------
i don't agree that it will reverse the whole architecture of Struts and let
appliaction firewall to solve problem .
maybe i am simple, but here is my simple idea :
i add an field in class ParametersInterceptor:
private static ConcurrentHashMap<Class, Set<String>> properyCache = new
ConcurrentHashMap<Class, Set<String>>();
in method setParameters, i will replace that loop like below :
Class actionClass = action.getClass();
Map<String, Expression> propertySet = properyCache.get(actionClass);
if(propertySet == null) {
synchronized(actionClass) {
propertySet = new HashSet<String>();
// reflect actionClass and put properties into an set
propertySet .
}
}
for (Map.Entry<String, Object> entry : acceptableParameters.entrySet()) {
String name = entry.getKey();
Object value = entry.getValue();
if (propertySet.contains(name)) {
// maybe we should use other check strategy not contains method to deal
with expression like user.address
try {
newStack.setParameter(name, value);
} catch (RuntimeException e) {
// some code do log here, i ignore it .
}
}
}
i think it may work and needn't to change much .
as long as there is a cache and user can control what will be cached , no
matter what container you use, it will be a hidden trouble .
was (Author: coderbee):
i don't agree that it will reverse the whole architecture of Struts and let
appliaction firewall to solve problem .
maybe i am simple, but here is my simple idea :
i add an field in class ParametersInterceptor:
private static ConcurrentHashMap<Class, Set<String>> properyCache = new
ConcurrentHashMap<Class, Set<String>>();
in method setParameters, i will replace that loop like below :
Class actionClass = action.getClass();
Map<String, Expression> propertySet = properyCache.get(actionClass);
if(propertySet == null) {
synchronized(actionClass) {
propertySet = new HashSet<String>();
// reflect actionClass and put properties into an set
propertySet .
}
}
for (Map.Entry<String, Object> entry : acceptableParameters.entrySet()) {
String name = entry.getKey();
Object value = entry.getValue();
if (propertySet.contains(name)) {
// maybe we should use other check strategy not contains method to deal
with expression like user.address
try {
newStack.setParameter(name, value);
} catch (RuntimeException e) {
// some code do log here, i ignore it .
}
}
}
i think it may work and needn't to change much .
as long as there is a cache and use can control what will be cached , no matter
what container you use, it will be a hidden trouble .
> cache attack at OgnlUtil.expressions
> -------------------------------------
>
> Key: WW-4146
> URL: https://issues.apache.org/jira/browse/WW-4146
> Project: Struts 2
> Issue Type: Bug
> Components: Expression Language
> Affects Versions: 2.3.15.1
> Reporter: bruce liu
> Fix For: 2.3.17
>
>
> in class com.opensymphony.xwork2.ognl.OgnlUtil, code :
> {code:java}
> tree = expressions.get(expression);
> if (tree == null) {
> tree = Ognl.parseExpression(expression);
> expressions.putIfAbsent(expression, tree);
> }
> {code}
> every parameter in the request cached in field expressions which is an
> instances of ConcurrentMap<String, Object>, use parameterName as key. so i
> construct huge different parameters that has different name (like "abc[123],
> abc[124]" ), they all cached in expressions, this cause outofmemory error,
> and let map acted like a list .
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira