ATLAS-5365: Missing SERVICE_NOTIFICATION_POST authorization on rest-notification NotificationREST POST /topic/{topicName}. - #716
Open
UmeshPatil-1 wants to merge 2 commits into
Open
Conversation
…ers,and move Jersey exception mappers to server-common with rest web.xml updates for Java 17 and JSON error parity with webapp.
…on Spring scan (like webapp).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Problem
The
rest-notification-webappmodule (introduced in ATLAS-5207) exposesPOST /api/atlas/v2/notification/topic/{topicName}on port 41000 as a headless REST side door for hook messages to Kafka.The main webapp
NotificationRESTalready enforcesSERVICE_NOTIFICATION_POSTviaAtlasAuthorizationUtils.verifyAccess(), but the rest-notification copy did not. This allowed any authenticated read-only user (e.g.rangertagsync/DATA_SCIENTIST) to POST hook messages (includingENTITY_CREATE_V2) toATLAS_HOOK, bypassing the authorization enforced on port 21000.Additionally, when authorization or validation exceptions were thrown on the rest server, responses were returned as HTTP 500 HTML (Jetty default) instead of the structured JSON error bodies returned by the main webapp (e.g.
ATLAS-403-00-001).Solution
This PR addresses both issues:
1. CVE authorization fix (rest-notification)
File:
rest-notification-webapp/src/main/java/org/apache/atlas/notification/rest/web/rest/NotificationREST.javaAdded the same authorization check as the main webapp:
Effect: Read-only users are denied before the message is published to Kafka. Admin users can still POST (HTTP 204).
2. Shared Jersey exception mappers (server-common)
Moved the following classes from
webapp/src/main/java/org/apache/atlas/web/errors/toserver-common/src/main/java/org/apache/atlas/server/common/errors/:AtlasBaseExceptionMapperAtlasBaseException→ JSON (403, 404, 400, etc.)AllExceptionMapperNotFoundExceptionMapperExceptionMapperUtilFile:
server-common/pom.xmlAdded
jersey-serverdependency (in addition to existingjersey-core) so mapper classes compile inserver-common— they implementjavax.ws.rs.ext.ExceptionMapperfromjersey-server.File:
webapp/src/test/java/org/apache/atlas/web/errors/*Updated imports to reference
org.apache.atlas.server.common.errors.*. Tests remain in webapp module (existing Atlas pattern). AddedtestUnauthorizedAccessResponse()inAtlasBaseExceptionMapperTestforATLAS-403-00-001coverage.ExceptionMapperUtilmethods changed fromprotectedtopublicto allow cross-package test access from webapp tests.How was this patch tested?
Build
mvn clean install -DskipITs=true
Result: BUILD SUCCESS. All modules including
server-common,webapp,rest-notification-webapp.Unit tests
Result: Exception mapper unit tests in webapp pass with updated imports from
server-common.Security test results (Tests A–G)
/notification/topic/ATLAS_HOOKATLAS-403-00-001ATLAS-403-00-001ATLAS-404-00-009ATLAS-400-00-101Related