Artifact owner is not validated when using createArtifact
resource to update artifacts
#3949
Labels
createArtifact
resource to update artifacts
#3949
Description
Registry Version: latest
Persistence type: sql, in-memory
It is possible to update schema owned by another principal via createArtifact API resource (
POST /groups/{groupId}/artifacts
) with query parameterifExists=RETURN_OR_UPDATE
even when owner-only authorization (OBAC) is enabled.I think I found the root cause of this issue:
createArtifact
API method is annotated with@Authorized(style = AuthorizedStyle.GroupOnly, level = AuthorizedLevel.Write)
which makes sense when creating a new artifact (only group exists at this point). Seeapicurio-registry/app/src/main/java/io/apicurio/registry/rest/v2/GroupsResourceImpl.java
Line 779 in 97bc1aa
AbstractAccessController
doesn't take into consideration that this API method could be used to update artifacts (by setting query parameterifExists=RETURN_OR_UPDATE
) and never validates artifact owner for this request. Seeapicurio-registry/app/src/main/java/io/apicurio/registry/auth/AbstractAccessController.java
Line 35 in 97bc1aa
updateArtifact
API method is annotated with@Authorized(style = AuthorizedStyle.GroupAndArtifact, level = AuthorizedLevel.Write)
and will makeAbstractAccessController
validate artifact owner since the artifact should exist at this point - this is an expected behaviour when updating artifacts. Seeapicurio-registry/app/src/main/java/io/apicurio/registry/rest/v2/GroupsResourceImpl.java
Line 211 in 97bc1aa
createArtifact
method for both creating and updating artifacts. Seeapicurio-registry/utils/maven-plugin/src/main/java/io/apicurio/registry/maven/RegisterRegistryMojo.java
Line 169 in 97bc1aa
Environment
Running Apicurio Registry in k8s cluster. Here are some configuration properties that are relevant to this problem:
We are using both Apicurio Maven plugin and REST API for creating and updating schemas in Apicurio Registry.
Steps to Reproduce
Expected vs Actual Behaviour
Apicurio Registry should check artifact owner even when updating it via createArtifact API resource with
ifExists=RETURN_OR_UPDATE
when OBAC is enabled. Currently Apicurio Registry allows updating artifacts this way with different principal.Logs
The text was updated successfully, but these errors were encountered: