Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ISM add policy API recursive permission check causes stackoverflow #774

Closed
bowenlan-amzn opened this issue May 10, 2023 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@bowenlan-amzn
Copy link
Member

bowenlan-amzn commented May 10, 2023

Code: https://github.com/opensearch-project/index-management/blob/main/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/transport/action/addpolicy/TransportAddPolicyAction.kt#L158-L182

If user add policy to a large amount of indices in one call, this code logic just recursively call itself to check managed index permission one by one.
In the end, it will cause stackoverflow error and causes the node to go down.

[2023-05-09T14:38:56,649][ERROR][o.o.s.f.SecurityFilter   ] [3fd290699e29bc6eedad27f6fa967a48] Unexpected exception java.lang.StackOverflowError
java.lang.StackOverflowError
        at org.apache.logging.log4j.util.PropertiesUtil$Environment.access$200(PropertiesUtil.java:420)
        at org.apache.logging.log4j.util.PropertiesUtil.getStringProperty(PropertiesUtil.java:368)
        at org.apache.logging.log4j.util.PropertiesUtil.getBooleanProperty(PropertiesUtil.java:155)
        at org.apache.logging.log4j.status.StatusLogger.isDebugPropertyEnabled(StatusLogger.java:120)
        at org.apache.logging.log4j.status.StatusLogger.isEnabled(StatusLogger.java:403)
        at org.apache.logging.log4j.status.StatusLogger.isEnabled(StatusLogger.java:344)
        at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1930)
        at org.apache.logging.log4j.spi.AbstractLogger.warn(AbstractLogger.java:2805)
        at org.apache.logging.log4j.spi.AbstractLogger.handleLogMessageException(AbstractLogger.java:2225)
        at org.apache.logging.log4j.spi.AbstractLogger.tryLogMessage(AbstractLogger.java:2208)
        at org.apache.logging.log4j.spi.AbstractLogger.logMessageTrackRecursion(AbstractLogger.java:2159)
        at org.apache.logging.log4j.spi.AbstractLogger.logMessageSafely(AbstractLogger.java:2142)
        at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2058)
        at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1931)
        at org.apache.logging.log4j.spi.AbstractLogger.warn(AbstractLogger.java:2805)
        at org.apache.logging.log4j.spi.AbstractLogger.handleLogMessageException(AbstractLogger.java:2225)
        at org.apache.logging.log4j.spi.AbstractLogger.tryLogMessage(AbstractLogger.java:2208)
        at org.apache.logging.log4j.spi.AbstractLogger.logMessageTrackRecursion(AbstractLogger.java:2159)
        at org.apache.logging.log4j.spi.AbstractLogger.logMessageSafely(AbstractLogger.java:2142)
        at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2017)
        at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1983)
        at org.apache.logging.log4j.spi.AbstractLogger.error(AbstractLogger.java:750)
        at org.opensearch.security.filter.SecurityFilter.apply0(SecurityFilter.java:373)
        at org.opensearch.security.filter.SecurityFilter.apply(SecurityFilter.java:149)
        at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:217)
        at org.opensearch.performanceanalyzer.action.PerformanceAnalyzerActionFilter.apply(PerformanceAnalyzerActionFilter.java:78)
        at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:217)
        at org.opensearch.action.support.TransportAction.execute(TransportAction.java:189)
        at org.opensearch.action.support.TransportAction.execute(TransportAction.java:108)
        at org.opensearch.client.node.NodeClient.executeLocally(NodeClient.java:110)
        at org.opensearch.client.node.NodeClient.doExecute(NodeClient.java:97)
        at org.opensearch.client.support.AbstractClient.execute(AbstractClient.java:461)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.validateIndexPermissions(TransportAddPolicyAction.kt:160)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.proceed(TransportAddPolicyAction.kt:186)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.access$proceed(TransportAddPolicyAction.kt:103)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler$validateIndexPermissions$1.onFailure(TransportAddPolicyAction.kt:172)
        at org.opensearch.action.support.TransportAction$1.onFailure(TransportAction.java:123)
        at org.opensearch.security.filter.SecurityFilter.apply0(SecurityFilter.java:374)
        at org.opensearch.security.filter.SecurityFilter.apply(SecurityFilter.java:149)
        at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:217)
        at org.opensearch.performanceanalyzer.action.PerformanceAnalyzerActionFilter.apply(PerformanceAnalyzerActionFilter.java:78)
        at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:217)
        at org.opensearch.action.support.TransportAction.execute(TransportAction.java:189)
        at org.opensearch.action.support.TransportAction.execute(TransportAction.java:108)
        at org.opensearch.client.node.NodeClient.executeLocally(NodeClient.java:110)
        at org.opensearch.client.node.NodeClient.doExecute(NodeClient.java:97)
        at org.opensearch.client.support.AbstractClient.execute(AbstractClient.java:461)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.validateIndexPermissions(TransportAddPolicyAction.kt:160)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.proceed(TransportAddPolicyAction.kt:186)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.access$proceed(TransportAddPolicyAction.kt:103)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler$validateIndexPermissions$1.onFailure(TransportAddPolicyAction.kt:172)
        at org.opensearch.action.support.TransportAction$1.onFailure(TransportAction.java:123)
        at org.opensearch.security.filter.SecurityFilter.apply0(SecurityFilter.java:374)
        at org.opensearch.security.filter.SecurityFilter.apply(SecurityFilter.java:149)
        at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:217)
        at org.opensearch.performanceanalyzer.action.PerformanceAnalyzerActionFilter.apply(PerformanceAnalyzerActionFilter.java:78)
        at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:217)
        at org.opensearch.action.support.TransportAction.execute(TransportAction.java:189)
        at org.opensearch.action.support.TransportAction.execute(TransportAction.java:108)
        at org.opensearch.client.node.NodeClient.executeLocally(NodeClient.java:110)
        at org.opensearch.client.node.NodeClient.doExecute(NodeClient.java:97)
        at org.opensearch.client.support.AbstractClient.execute(AbstractClient.java:461)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.validateIndexPermissions(TransportAddPolicyAction.kt:160)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.proceed(TransportAddPolicyAction.kt:186)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.access$proceed(TransportAddPolicyAction.kt:103)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler$validateIndexPermissions$1.onFailure(TransportAddPolicyAction.kt:172)
        at org.opensearch.action.support.TransportAction$1.onFailure(TransportAction.java:123)
        at org.opensearch.security.filter.SecurityFilter.apply0(SecurityFilter.java:374)
        at org.opensearch.security.filter.SecurityFilter.apply(SecurityFilter.java:149)
        at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:217)
        at org.opensearch.performanceanalyzer.action.PerformanceAnalyzerActionFilter.apply(PerformanceAnalyzerActionFilter.java:78)
        at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:217)
        at org.opensearch.action.support.TransportAction.execute(TransportAction.java:189)
        at org.opensearch.action.support.TransportAction.execute(TransportAction.java:108)
        at org.opensearch.client.node.NodeClient.executeLocally(NodeClient.java:110)
        at org.opensearch.client.node.NodeClient.doExecute(NodeClient.java:97)
        at org.opensearch.client.support.AbstractClient.execute(AbstractClient.java:461)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.validateIndexPermissions(TransportAddPolicyAction.kt:160)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.proceed(TransportAddPolicyAction.kt:186)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.access$proceed(TransportAddPolicyAction.kt:103)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler$validateIndexPermissions$1.onResponse(TransportAddPolicyAction.kt:166)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler$validateIndexPermissions$1.onResponse(TransportAddPolicyAction.kt:163)
        at org.opensearch.action.support.TransportAction$1.onResponse(TransportAction.java:114)
        at org.opensearch.action.support.TransportAction$1.onResponse(TransportAction.java:108)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.managedIndex.TransportManagedIndexAction.doExecute(TransportManagedIndexAction.kt:30)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.managedIndex.TransportManagedIndexAction.doExecute(TransportManagedIndexAction.kt:20)
        at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:219)
        at org.opensearch.indexmanagement.rollup.actionfilter.FieldCapsFilter.apply(FieldCapsFilter.kt:118)
        at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:217)
        at org.opensearch.security.filter.SecurityFilter.apply0(SecurityFilter.java:264)
        at org.opensearch.security.filter.SecurityFilter.apply(SecurityFilter.java:149)
        at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:217)
        at org.opensearch.performanceanalyzer.action.PerformanceAnalyzerActionFilter.apply(PerformanceAnalyzerActionFilter.java:78)
        at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:217)
        at org.opensearch.action.support.TransportAction.execute(TransportAction.java:189)
        at org.opensearch.action.support.TransportAction.execute(TransportAction.java:108)
        at org.opensearch.client.node.NodeClient.executeLocally(NodeClient.java:110)
        at org.opensearch.client.node.NodeClient.doExecute(NodeClient.java:97)
        at org.opensearch.client.support.AbstractClient.execute(AbstractClient.java:461)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.validateIndexPermissions(TransportAddPolicyAction.kt:160)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.proceed(TransportAddPolicyAction.kt:186)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.access$proceed(TransportAddPolicyAction.kt:103)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler$validateIndexPermissions$1.onFailure(TransportAddPolicyAction.kt:172)
        at org.opensearch.action.support.TransportAction$1.onFailure(TransportAction.java:123)
        at org.opensearch.security.filter.SecurityFilter.apply0(SecurityFilter.java:374)
        at org.opensearch.security.filter.SecurityFilter.apply(SecurityFilter.java:149)
        at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:217)
        at org.opensearch.performanceanalyzer.action.PerformanceAnalyzerActionFilter.apply(PerformanceAnalyzerActionFilter.java:78)
        at org.opensearch.action.support.TransportAction$RequestFilterChain.proceed(TransportAction.java:217)
        at org.opensearch.action.support.TransportAction.execute(TransportAction.java:189)
        at org.opensearch.action.support.TransportAction.execute(TransportAction.java:108)
        at org.opensearch.client.node.NodeClient.executeLocally(NodeClient.java:110)
        at org.opensearch.client.node.NodeClient.doExecute(NodeClient.java:97)
        at org.opensearch.client.support.AbstractClient.execute(AbstractClient.java:461)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.validateIndexPermissions(TransportAddPolicyAction.kt:160)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.proceed(TransportAddPolicyAction.kt:186)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler.access$proceed(TransportAddPolicyAction.kt:103)
        at org.opensearch.indexmanagement.indexstatemanagement.transport.action.addpolicy.TransportAddPolicyAction$AddPolicyHandler$validateIndexPermissions$1.onFailure(TransportAddPolicyAction.kt:172)
@bowenlan-amzn bowenlan-amzn added the bug Something isn't working label May 10, 2023
@bowenlan-amzn
Copy link
Member Author

Cross reference previous same issue in Explain API: #419

@bowenlan-amzn
Copy link
Member Author

We also check managed index permission in coordinator https://github.com/opensearch-project/index-management/blob/main/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ManagedIndexCoordinator.kt#L403

Double check whether there's recursive call here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant