Skip to content

Commit 06dd988

Browse files
authored
Merge pull request #4669 from darranl/WFCORE-5511/16.x
[16.x] [WFCORE-5511] wildfly-core: Invalid Sensitivity Classification of Vault Expression
2 parents 07bb4bf + 955163f commit 06dd988

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

controller/src/main/java/org/jboss/as/controller/access/constraint/SensitiveVaultExpressionConstraint.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
package org.jboss.as.controller.access.constraint;
2424

25-
import org.jboss.as.controller.ExpressionResolver;
26-
import org.jboss.as.controller.VaultReader;
25+
import java.util.regex.Pattern;
26+
2727
import org.jboss.as.controller.access.Action;
2828
import org.jboss.as.controller.access.JmxAction;
2929
import org.jboss.as.controller.access.JmxTarget;
@@ -45,6 +45,8 @@ public class SensitiveVaultExpressionConstraint extends AllowAllowNotConstraint
4545

4646
public static final ConstraintFactory FACTORY = new Factory();
4747

48+
private static final Pattern VAULT_EXPRESSION_PATTERN = Pattern.compile(".*\\$\\{VAULT::.*::.*::.*}.*");
49+
4850
private static final SensitiveVaultExpressionConstraint SENSITIVE = new SensitiveVaultExpressionConstraint(true);
4951
private static final SensitiveVaultExpressionConstraint NOT_SENSITIVE = new SensitiveVaultExpressionConstraint(false);
5052
private static final SensitiveVaultExpressionConstraint ALLOWS = new SensitiveVaultExpressionConstraint(true, true);
@@ -123,12 +125,7 @@ private boolean isSensitiveValue(ModelNode value) {
123125
if (value.getType() == ModelType.EXPRESSION
124126
|| value.getType() == ModelType.STRING) {
125127
String valueString = value.asString();
126-
if (ExpressionResolver.EXPRESSION_PATTERN.matcher(valueString).matches()) {
127-
int start = valueString.indexOf("${") + 2;
128-
int end = valueString.indexOf("}", start);
129-
valueString = valueString.substring(start, end);
130-
return VaultReader.STANDARD_VAULT_PATTERN.matcher(valueString).matches();
131-
}
128+
return VAULT_EXPRESSION_PATTERN.matcher(valueString).matches();
132129
}
133130
return false;
134131
}

testsuite/rbac/src/test/java/org/jboss/as/test/integration/mgmt/access/VaultExpressionSensitivityTestCase.java

+12
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,18 @@ public void testReadNonSensitiveWriteNonSensitive() throws Exception {
226226
}
227227
}
228228

229+
/*
230+
* Test if the Monitor role can smuggle a vault expression to retrieve the value from the vault.
231+
*/
232+
@Test
233+
public void testHiddenExpression() throws Exception {
234+
ModelControllerClient client = getClientForUser(RbacUtil.MAINTAINER_USER);
235+
236+
ModelNode operation = createOpNode("subsystem=logging/logger=vault-test", ADD);
237+
operation.get("level").set("${someproperty:XXX} " + vaultPassword);
238+
RbacUtil.executeOperation(client, operation, Outcome.UNAUTHORIZED);
239+
}
240+
229241
private void test(String userName, boolean canRead, boolean canWrite) throws Exception {
230242
ModelControllerClient client = getClientForUser(userName);
231243

0 commit comments

Comments
 (0)