Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,26 @@ public void testMVELVulnerability() throws Exception {
exists -> exists == Boolean.FALSE, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
}

@Test
public void testMVELVulnerabilityWithListPropertyValues() throws Exception {
File vulnFile = new File("target/vuln-file-list.txt");
if (vulnFile.exists()) {
vulnFile.delete();
}
String vulnFileCanonicalPath = vulnFile.getCanonicalPath();
vulnFileCanonicalPath = vulnFileCanonicalPath.replace("\\", "\\\\"); // this is required for Windows support

Map<String, String> parameters = new HashMap<>();
parameters.put("VULN_FILE_PATH", vulnFileCanonicalPath);
HttpPost request = new HttpPost(getFullUrl(CONTEXT_URL));
request.setEntity(
new StringEntity(getValidatedBundleJSON("security/mvel-payload-list.json", parameters), ContentType.APPLICATION_JSON));
TestUtils.executeContextJSONRequest(request);

shouldBeTrueUntilEnd("Vulnerability successfully executed ! File created at " + vulnFileCanonicalPath, vulnFile::exists,
exists -> exists == Boolean.FALSE, DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
}

@Test
public void testPersonalization() throws Exception {

Expand Down
23 changes: 23 additions & 0 deletions itests/src/test/resources/security/mvel-payload-list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"filters": [
{
"id": "filter1",
"filters": [
{
"condition": {
"parameterValues": {
"propertyName": "firstName",
"comparisonOperator": "equals",
"propertyValues": [
"safe-value",
"script::Runtime r = Runtime.getRuntime(); r.exec(\"touch ###VULN_FILE_PATH###\");"
]
},
"type": "profilePropertyCondition"
}
}
]
}
],
"sessionId": "demo-session-id"
}
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,12 @@ private Condition sanitizeCondition(Condition condition) {
for (Map.Entry<String, Object> parameterEntry : condition.getParameterValues().entrySet()) {
Object sanitizedValue = sanitizeValue(parameterEntry.getValue());
if (sanitizedValue != null) {
newParameterValues.put(parameterEntry.getKey(), parameterEntry.getValue());
newParameterValues.put(parameterEntry.getKey(), sanitizedValue);
} else {
return null;
}
}
condition.setParameterValues(newParameterValues);
return condition;
}

Expand Down
Loading