Repository navigation
fix(security): batch of backend security-hardening fixes - #36156
Conversation
…ntials intact - Add SecurityUtil.sameIdentifier, which compares names, emails and email domains by their Locale.ROOT lower-case forms, the normalization stored names get. String.equalsIgnoreCase also compares upper-case forms and so equates distinct names. Use it for the self checks in UserResource and ActivityResource, the admin-name checks, session binding, adminEmails and the email-domain allow-lists. Normalize user names and emails with Locale.ROOT. - POST /users/generateToken mints tokens for bot users only; people use personal access tokens, which can be revoked. - A PUT or CSV row that carries no authentication mechanism keeps the stored one instead of dropping it. - Bot seeding and app bot creation refuse an existing account of the same name that is not a bot. - A bot can no longer be created for a soft-deleted user who is not a bot. - Self sign-up requires the email the caller's token carries. - Impersonation evaluates the target user with its domains loaded.
…ment - Legacy claim flow: a provider-issued token must carry an email in allowedEmailDomains when that list is set, and the email must be the one stored on the account the user name resolves to. A provider token never signs in to a bot account. - SAML: every response must be current and issued to this service provider (Conditions and SubjectConfirmationData NotOnOrAfter, SessionNotOnOrAfter, audience, Destination against the configured ACS URL), whatever strictMode is set to. Test Login applies the same rule. A rejected response is a 401. - Public Entra ID clients accept tokens only from the tenant the authority names; multi-tenant authorities are unchanged. - Basic auth: a self-registered account with a confirmation still pending cannot sign in, including through the MCP login form. The registration domain allow-list compares domains with sameIdentifier. - LDAP: a wrong password is counted towards the login lockout (UnboundID reports a rejected bind by throwing), and a successful bind clears the count.
…nd off new endpoints - Version and history endpoints redact the stored snapshot the way the entity's own reads do: EntityResource gains a snapshotRedaction hook that User (drops authenticationMechanism), every ServiceEntityResource (masks the connection), IngestionPipeline and Workflow override. The service follower, PATCH, delete and restore responses, and their follower change events, are masked too. - A connection keeps its stored secret only while it points where it did: ConnectionSecretsGuard refuses a PATCH, PUT or test-connection workflow that changes an endpoint field while leaving a secret masked, encrypted or equal to the stored one. Admins and bots are unaffected. - getSettingByName resolves the setting name to a SettingsType before the access checks, and refuses a row whose type is not the one requested, so an accent-insensitive DB collation cannot return the auth configuration. - Settings reject a secret sent already Fernet-encrypted unless it is the one the setting holds, so a setting cannot decrypt another's token.
authorizeRequests(ANY) tried each request and passed as soon as one allowed access, swallowing the AuthorizationException the others threw. An explicit Deny rule threw the same exception as "no rule allowed it", so a Deny on one request was ignored when a sibling request allowed access — for example query listing checks ViewBasic on the query and ViewQueries on the parent table, and a table Deny on ViewQueries was overridden. CompiledRule.evaluateDenyRule now throws PolicyDeniedException, a subclass the ANY loop rethrows while it still skips a plain "not allowed" to the next request.
…d workflows - A service's pipelines field listed pipelines a deny rule hides; it is now filtered to the ones the caller may view (admins and bots see all). - Attaching or detaching a query to an asset, through /usage or queryUsedIn on create and PUT, checks EditQueries on each asset, so a query cannot be moved into another domain's asset without that permission. - A tag-based deny rule now sees inherited tags: the authorization ResourceContext runs tag inheritance after loading the entity's own tags. - A team no longer stores its parents' domains as its own, so they do not survive the parent's domain being removed. - A description-only app PATCH no longer reinstalls or unschedules the app; rescheduling needs EditAll. An app trigger with a config override needs EditAll, not just Trigger. - The reverse-ingestion trigger resolves the service from the store and requires a service entity type. The Spark-engine trigger confirms the stored request is a Spark request before applying the lighter create check.
…ces and lineage - Query cost records are now subject to the query's search RBAC: they are a child of the query for RBAC, and their document carries the query's owners, tags and domains at the top level, so a deny on the query hides them. The query-cost-by-service aggregation drops groups whose query the caller cannot view. - LLM model and MCP server search documents get their service's domain, so a service domain change propagates instead of leaving them domainless. - The OpenSearch RBAC query cache key includes a policy generation that bumps whenever the policy caches are dropped, so a policy-rule or role-policy edit is not served stale for the cache TTL. - MCP root_cause_analysis authorizes the real entity by FQN and runs the lineage view filter over its upstream producers, so an inherited-domain node is not returned to a caller denied it. - Moving a Context Center page rewrites a descendant FQN only at a real "." boundary, so a sibling that merely shares a prefix is left alone. - A SearchIndex reindex keeps its field-level tags.
…import - The audit/change-event filter matched excluded endpoints with a substring check, so a write whose path embeds one (through a matrix parameter or an encoded separator) skipped auditing. It now shares JwtFilter.isExcludedEndpoint, which matches the resource path exactly after dropping matrix parameters. - Search preview runs with caller-supplied settings that can stall the cluster; it now requires admin, like the settings write it previews. - Table CSV import validated the whole table on every row, which made a large import quadratic in its column count; it validates once after applying the rows. A row naming a missing parent column no longer dereferences null.
A javascript: or data: URL in a learning resource runs in the product's origin when the UI frames or links it. The backend restricted the scheme for Link and PDF only, so Storylane, Video and Article accepted any scheme. - LearningResourceRepository requires an http or https URL for every type. - The Storylane, Video and Article players pass the URL through getSafeHttpUrl before framing or linking it, so a stored unsafe URL is dropped rather than executed.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
The Entra authority version segment, the email separator and the connection field name were raw literals in equals/contains calls.
The bot-name check was covered by a unit test that mocked three repositories and the entity registry. An integration test now installs an app whose bot name a person already holds, and checks that the saved account is unchanged and that neither the bot nor the app is created. A refused install now answers 400 instead of an unhandled 500.
The SAML response validator spelled out javax.servlet.http.HttpServletRequest, and two JwtFilterTest lines called Mockito.mockStatic by its full name although it is statically imported.
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|
…g-oct # Conflicts: # openmetadata-service/src/test/java/org/openmetadata/service/security/auth/LdapDirectoryValidationTest.java
Main's msal-mock fixture now signs its ID token with the mock IdP, and that token carried no tid claim. The fixture's authority names a tenant, and a public Entra client accepts only tokens from the tenant its authority names, so every scenario failed with "Token tenant 'null' is not the tenant configured for sign-in". The mock's /test/id-token takes an optional tenantId and signs it as tid, as Entra ID does, and the fixture passes its own tenant.
Code Review ✅ Approved 9 closed / 9 findings🔴 High risk · Sign-in, authorization, and connection-secret changes could enable account takeover, unauthorized writes, or credential exposure if checks are flawed. Security-hardening batch covering authorization deny-rule precedence, secret handling on write paths, login and SSO token validation, and bot account checks. Resolved this session: ANY-mode Deny precedence depending on request order, retarget guard missing ✅ 9 closed✅ Security: ANY-mode Deny precedence depends on request order
✅ Security: Retarget guard misses
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
❌ UI Checkstyle Failed❌ Bundle Runtime CheckA route chunk loads but one of its chunks still exports Fix locally (fast - only checks files changed in this branch): make ui-checkstyle-changed |
|
|
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|



Summary
A batch of backend security-hardening fixes from an internal review, grouped by area into one commit each:
Each commit carries its own regression tests. Details are tracked internally.
Labelled
skip-pr-checks.Tracking: open-metadata/openmetadata-collate#7797
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge based on this follow-up review.Summary
This PR hardens account checks, sign-in, secret handling, permissions, and search access.
Reviews (16) · Last reviewed commit: "refactor: import types instead of naming..." · Reviewed by Greptile