Skip to content

fix: only update metadata enable status within the same namespace (#6615) - #7047

Open
wy471x wants to merge 1 commit into
apache:masterfrom
wy471x:fix_MetaDataServiceImpl.enabledByIdsAndNamespaceId-updates-metadata-across-namespaces
Open

fix: only update metadata enable status within the same namespace (#6615)#7047
wy471x wants to merge 1 commit into
apache:masterfrom
wy471x:fix_MetaDataServiceImpl.enabledByIdsAndNamespaceId-updates-metadata-across-namespaces

Conversation

@wy471x

@wy471x wy471x commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

Summary

Fixes #6615. MetaDataServiceImpl.enabledByIdsAndNamespaceId checked existence with a namespace-scoped query but passed the caller-supplied raw ids to MetaDataMapper.updateEnableBatch, whose SQL only filters by id IN (...). A caller scoped to one namespace could therefore enable/disable metadata rows that belong to another namespace.

Changes

  1. MetaDataServiceImpl.enabledByIdsAndNamespaceId (shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/MetaDataServiceImpl.java:132) — updateEnableBatch now receives only the ids of the rows returned by the namespace-scoped selectByIdListAndNamespaceId query (ListUtil.map(metaDataDoList, MetaDataDO::getId)) instead of the raw request ids. Mapper SQL and event publishing behavior are unchanged.

Test Cases

  1. MetaDataServiceTest.testEnabledOnlyUpdatesIdsWithinNamespace — verifies that when the request contains ids belonging to another namespace but the scoped select returns only the current namespace's row, updateEnableBatch and onEnabled only receive the current namespace's id.

Verification

  • ./mvnw -pl shenyu-admin clean install -Dmaven.javadoc.skip=true -Dtest=org.apache.shenyu.admin.service.MetaDataServiceTest -DfailIfNoTests=false — BUILD SUCCESS; Tests run: 16, Failures: 0, Errors: 0, Skipped: 0.
  • Checkstyle: 0 violations.
  • RAT: Unapproved 0, unknown 0, generated 0.

close #6615

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] MetaDataServiceImpl.enabledByIdsAndNamespaceId updates metadata across namespaces (cross-namespace authorization bypass)

1 participant