Skip to content

Commit 4c62429

Browse files
committed
Improved: Check parameters passed in URLs (OFBIZ-13295)
Prevents possible stream exploitation
1 parent e158ea8 commit 4c62429

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ControlFilter.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
import java.util.ArrayList;
2626
import java.util.Arrays;
2727
import java.util.Collections;
28+
import java.util.LinkedList;
2829
import java.util.List;
30+
import java.util.Map;
2931
import java.util.Set;
3032
import java.util.stream.Collectors;
3133

@@ -165,6 +167,35 @@ public void doFilter(HttpServletRequest req, HttpServletResponse resp, FilterCha
165167
String context = req.getContextPath();
166168
HttpSession session = req.getSession();
167169

170+
// Prevents stream exploitation
171+
Map<String, Object> parameters = UtilHttp.getParameterMap(req);
172+
boolean reject = false;
173+
if (!parameters.isEmpty()) {
174+
for (String key : parameters.keySet()) {
175+
Object object = parameters.get(key);
176+
if (object.getClass().equals(String.class)) {
177+
String val = (String) object;
178+
if (val.contains("<")) {
179+
reject = true;
180+
}
181+
} else {
182+
@SuppressWarnings("unchecked")
183+
LinkedList<String> vals = (LinkedList<String>) parameters.get(key);
184+
for (String aVal : vals) {
185+
if (aVal.contains("<")) {
186+
reject = true;
187+
}
188+
}
189+
}
190+
}
191+
if (reject) {
192+
Debug.logError("For security reason this URL is not accepted", MODULE);
193+
throw new RuntimeException("For security reason this URL is not accepted");
194+
}
195+
}
196+
197+
198+
168199
// Check if we are told to redirect everything.
169200
if (redirectAll) {
170201
// little trick here so we don't loop on ourselves

0 commit comments

Comments
 (0)