fix(lambdaweb): accept a policy Resource in any partition, region or account (#6863)

This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-10-28 20:04:40 -04:00
1 parent 096d336fab
commit fc1388da6f
4 files changed
+49 -2

No files matched your search

@@ -1524,13 +1524,21 @@ public class LambdaWebService implements Resettable {
throw policySyntax();
}
}
String function = AwsArnUtils.parse(functionArn).resource();
for (String resource : policyValues(statement.get("Resource"))) {
if (!resource.equals(functionArn) && !resource.startsWith(functionArn + "/")) {
if (!namesFunction(resource, function)) {
throw policySyntax();
}
}
}
/** AWS reads only the service and the resource, so any prefix, partition, region or account passes. */
private static boolean namesFunction(String resource, String function) {
String[] parts = resource.split(":", 6);
return parts.length == 6 && "lambda".equals(parts[2])
&& (parts[5].equals(function) || parts[5].equals(function + "*") || parts[5].startsWith(function + "/"));
}
private static void requireNotPublic(JsonNode statement) {
if (statement.path("Effect").asText().equalsIgnoreCase("Allow") && isPublicPrincipal(statement.get("Principal"))
&& !hasTrustedCondition(statement.path("Condition"))) {