Repository navigation
fix(security): prevent unauthenticated disclosure of instance metadata [APP-14994] - #41598
Conversation
…a [APP-14994] Three API endpoints were accessible without authentication and leaked sensitive instance metadata to any caller: - /api/v1/users/features – removed from permitAll(); now requires an authenticated session. Feature flags are per-user data and must not be disclosed to anonymous callers. - /api/v1/tenants/current and /api/v1/consolidated-api/view – kept accessible without authentication (login page and public apps depend on them) but instanceId and adminEmailDomainHash are now suppressed from the response when the caller is anonymous. This eliminates disclosure of the unsalted SHA-256 admin-email-domain hash and the instance UUID while preserving the auth-provider discovery needed by the login page. Tests added: AuthGuardTest (controller-level 401 for /users/features) and two new cases in OrganizationServiceCETest that assert anonymous callers receive null instanceId/adminEmailDomainHash while authenticated callers still receive both fields. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
WalkthroughRemoved public GET access to Changes
Sequence DiagramsequenceDiagram
participant Client
participant SecurityContext as Security Context
participant OrgService as Organization Service
participant Response as Data Response
alt Authenticated User Request
Client->>SecurityContext: GET /api/v1/tenants/current
SecurityContext->>OrgService: authenticated principal
OrgService->>Response: include instanceId & adminEmailDomainHash
Response-->>Client: 200 OK (full metadata)
else Anonymous User Request
Client->>SecurityContext: GET /api/v1/tenants/current
SecurityContext->>OrgService: anonymous principal
OrgService->>Response: nullify instanceId & adminEmailDomainHash
Response-->>Client: 200 OK (sanitized)
else Unauthenticated to Protected Endpoint
Client->>SecurityContext: GET /api/v1/users/features
SecurityContext-->>Client: 401 Unauthorized
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/OrganizationServiceCEImpl.java (1)
164-167: Guard the principal cast before using it as aUser.
defaultIfEmpty(true)only helps when the security context is absent. In WebFlux security, an anonymous request can still carry anAuthenticationwhose default principal isanonymousUser, so this direct cast can fail before the anonymous fallback runs. Please gate the cast withinstanceof Userand then useUser.isAnonymous(). (docs.spring.vmware.com)Suggested hardening
- Mono<Boolean> isAnonymousMono = ReactiveSecurityContextHolder.getContext() - .map(ctx -> (User) ctx.getAuthentication().getPrincipal()) - .map(user -> Boolean.TRUE.equals(user.getIsAnonymous())) - .defaultIfEmpty(true); + Mono<Boolean> isAnonymousMono = ReactiveSecurityContextHolder.getContext() + .flatMap(ctx -> Mono.justOrEmpty(ctx.getAuthentication())) + .filter(authentication -> authentication.getPrincipal() instanceof User) + .map(authentication -> ((User) authentication.getPrincipal()).isAnonymous()) + .defaultIfEmpty(true);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/OrganizationServiceCEImpl.java` around lines 164 - 167, In OrganizationServiceCEImpl, the mapping from ReactiveSecurityContextHolder currently casts the principal to User directly; change the map chain to first check that ctx.getAuthentication() and ctx.getAuthentication().getPrincipal() are present and that principal instanceof User before casting, and then call ((User) principal).getIsAnonymous() (or User.isAnonymous()) to produce the boolean; keep defaultIfEmpty(true) to cover missing context but avoid a ClassCastException by gating the cast with an instanceof check in the mapping function.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@app/server/appsmith-server/src/test/java/com/appsmith/server/configurations/AuthGuardTest.java`:
- Around line 48-55: Update the test method
tenantCurrentEndpoint_unauthenticated_isAccessible in AuthGuardTest to assert
the response body nulls for sensitive fields: after the existing
.expectStatus().isOk(), add a body assertion using webTestClient's
.expectBody()/.jsonPath() to verify "$.instanceId" and "$.adminEmailDomainHash"
are null (e.g., .jsonPath("$.instanceId").isEqualTo(null) and
.jsonPath("$.adminEmailDomainHash").isEqualTo(null)). Keep the existing call
chain and only append these jsonPath assertions to confirm unauthenticated
responses suppress those fields.
---
Nitpick comments:
In
`@app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/OrganizationServiceCEImpl.java`:
- Around line 164-167: In OrganizationServiceCEImpl, the mapping from
ReactiveSecurityContextHolder currently casts the principal to User directly;
change the map chain to first check that ctx.getAuthentication() and
ctx.getAuthentication().getPrincipal() are present and that principal instanceof
User before casting, and then call ((User) principal).getIsAnonymous() (or
User.isAnonymous()) to produce the boolean; keep defaultIfEmpty(true) to cover
missing context but avoid a ClassCastException by gating the cast with an
instanceof check in the mapping function.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 735ed917-b65b-46e5-b764-1ea68153c551
📒 Files selected for processing (4)
app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/SecurityConfig.javaapp/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/OrganizationServiceCEImpl.javaapp/server/appsmith-server/src/test/java/com/appsmith/server/configurations/AuthGuardTest.javaapp/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/OrganizationServiceCETest.java
💤 Files with no reviewable changes (1)
- app/server/appsmith-server/src/main/java/com/appsmith/server/configurations/SecurityConfig.java
- Guard principal cast with instanceof User before casting in OrganizationServiceCEImpl to avoid ClassCastException when the security context holds a non-User anonymous principal - Extend AuthGuardTest to assert that instanceId and adminEmailDomainHash are absent from the /api/v1/tenants/current response for unauthenticated callers, not just that the endpoint returns 200 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/OrganizationServiceCEImpl.java (1)
162-178: Solid implementation with correct defensive guards.The
instanceof Userfilter before casting correctly handles Spring Security'sAnonymousAuthenticationToken(which holds aStringprincipal, notUser). ThedefaultIfEmpty(true)ensures missing security context (e.g., internal service calls) safely defaults to anonymous behavior.Minor observation:
Userhas a null-safeisAnonymous()method that returnsboolean, whereasgetIsAnonymous()returns the nullableBooleanfield. Since the field defaults tofalse, this works, but usingisAnonymous()would be marginally safer.,
Optional: use null-safe method
.filter(authentication -> authentication.getPrincipal() instanceof User) - .map(authentication -> ((User) authentication.getPrincipal()).getIsAnonymous()) + .map(authentication -> ((User) authentication.getPrincipal()).isAnonymous()) .defaultIfEmpty(true);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/OrganizationServiceCEImpl.java` around lines 162 - 178, Use the null-safe boolean accessor on User: change the mapping inside isAnonymousMono from .map(authentication -> ((User) authentication.getPrincipal()).getIsAnonymous()) to call the primitive-returning method .map(authentication -> ((User) authentication.getPrincipal()).isAnonymous()), so isAnonymousMono uses User.isAnonymous() (located in the ReactiveSecurityContextHolder -> isAnonymousMono construction) to avoid nullable Boolean handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/OrganizationServiceCEImpl.java`:
- Around line 162-178: Use the null-safe boolean accessor on User: change the
mapping inside isAnonymousMono from .map(authentication -> ((User)
authentication.getPrincipal()).getIsAnonymous()) to call the primitive-returning
method .map(authentication -> ((User)
authentication.getPrincipal()).isAnonymous()), so isAnonymousMono uses
User.isAnonymous() (located in the ReactiveSecurityContextHolder ->
isAnonymousMono construction) to avoid nullable Boolean handling.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9a04048f-4bfb-4e7a-8228-e917a656c7cf
📒 Files selected for processing (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/OrganizationServiceCEImpl.javaapp/server/appsmith-server/src/test/java/com/appsmith/server/configurations/AuthGuardTest.java
Failed server tests
|
| ServerWebExchangeMatchers.pathMatchers(HttpMethod.PUT, USER_URL + "/invite/confirm"), | ||
| ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, USER_URL + "/me"), | ||
| ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, "/v3/**"), | ||
| ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, USER_URL + "/features"), |
There was a problem hiding this comment.
qq: why was it present here? did we have any usecase for this?
There was a problem hiding this comment.
The endpoint was originally added to permitAll() so the client could fetch feature flags before authentication — for example, to enable/disable UI features on the login page itself. However, this also lets any unauthenticated caller enumerate which paid/enterprise features are enabled on the instance, which is the information-disclosure issue in APP-14994. Since the login page doesn't actually depend on these flags pre-auth, removing it from permitAll() is safe.
| .defaultIfEmpty(true); | ||
|
|
||
| Mono<Organization> clientOrganizationMono = isAnonymousMono.flatMap( | ||
| isAnonymous -> configService.getInstanceId().flatMap(instanceId -> { |
There was a problem hiding this comment.
Nit pick: for readability let's zip them together?
There was a problem hiding this comment.
Done in 47eb6e3 — switched to Mono.zip(isAnonymousMono, configService.getInstanceId()).flatMap(tuple -> { ... }) so both monos resolve concurrently and the lambda is flat. Also took the opportunity to apply the CodeRabbit nitpick: replaced getIsAnonymous() (nullable Boolean) with the null-safe isAnonymous() (boolean) method on User.
…4994] - Use null-safe boolean User#isAnonymous() instead of getIsAnonymous() - Zip isAnonymousMono and configService.getInstanceId() together for readability instead of nesting flatMap inside flatMap Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…us users [APP-15344] (#42001) ## Summary Fixes [APP-15344](https://linear.app/appsmith/issue/APP-15344): the unauthenticated `/api/v1/tenants/current` endpoint was returning internal configuration fields (Google Maps API key, license details, migration status, feature flags) to anonymous callers. This is the **CE portion** of the fix. The EE superset PR is [appsmith-ee#9305](appsmithorg/appsmith-ee#9305) (all server tests passing). **Approach:** Service-layer filtering strips post-login-only fields when the current user is anonymous, following the same pattern as APP-14994 (PR #41598). Only fields required by the login/signup page are preserved (branding, auth method flags, instance name, third-party auth list). Authenticated users receive the full unmodified response. **CE fields stripped for anonymous users:** - `googleMapsKey` (plaintext API key) - Full `license` envelope (replaced with minimal `{plan: FREE}`) - `isSignupDisabled`, `emailVerificationEnabled`, `isStrongPasswordPolicyEnabled` - `isAtomicPushAllowed`, `featuresWithPendingMigration`, `migrationStatus` - `pricingPlan` (Organization-level) **Changes:** 1. `OrganizationConfigurationCE.stripFieldsForAnonymousUser()` — strips CE config fields 2. `OrganizationServiceCEImpl.suppressFieldsForAnonymousUser()` — checks security context, calls strip if anonymous 3. `OrganizationServiceCEImpl.stripOrganizationFieldsForAnonymousUser()` — strips Organization-level fields (overridable by EE) ## Test Plan - [x] `getOrganizationConfig_AnonymousUser_StripsInternalConfiguration` — verifies sensitive fields are null - [x] `getOrganizationConfig_AnonymousUser_PreservesLoginPageFields` — verifies login-page fields remain - [x] `getOrganizationConfig_AuthenticatedUser_ExposesFullConfiguration` — no regression for authenticated users - [ ] Existing APP-14994 tests pass (instanceId/adminEmailDomainHash stripping) /ok-to-test tags="@tag.All" <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/29452470909> > Commit: 151a92e > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=29452470909&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Wed, 15 Jul 2026 22:42:14 UTC <!-- end of auto-generated comment: Cypress test results --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Security** * Anonymous users now receive only minimal organization configuration and license details. * Sensitive settings, pricing information, and privilege-related fields are hidden from unauthenticated access. * **Bug Fixes** * Authenticated users continue to receive complete organization configuration details, including updated settings. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
…98) (#17645) The template matched any Appsmith instance because /api/v1/tenants/current and /api/v1/consolidated-api/view intentionally stay reachable without authentication (the login page uses them) and still return a 200 JSON body after the fix. The fix in appsmithorg/appsmith#41598 (shipped in v1.98) instead: - removes instanceId and adminEmailDomainHash from those two responses for anonymous callers - makes /api/v1/users/features return 401 for anonymous callers Split the request so that the first two endpoints only match when one of the removed fields is present, and /api/v1/users/features only matches on an unauthenticated 200. Verified: no match against a patched v1.99 instance (previously matched on 2 URLs); matches against responses in the pre-fix shape. Co-authored-by: Claude Fable 5.1 <[email protected]>
Summary
Fixes APP-14994: three API endpoints were accessible without authentication and exposed sensitive instance metadata to any unauthenticated caller.
/api/v1/users/features— removed frompermitAll()inSecurityConfig; now returns 401 for unauthenticated requests. Feature flags are per-user data and must not be disclosed to anonymous callers./api/v1/tenants/current— kept accessible without authentication (the login page uses it to discover enabled auth providers), butinstanceIdandadminEmailDomainHashare now suppressed from the response when the caller is anonymous. This eliminates exposure of the unsalted SHA-256 admin-email-domain hash and the instance UUID./api/v1/consolidated-api/view— kept accessible without authentication (required for public/published apps), but the embeddedorganizationConfigno longer containsinstanceIdoradminEmailDomainHashfor anonymous callers (same service-layer fix as above).Changes
SecurityConfig.javaGET /api/v1/users/featuresfrompermitAll()OrganizationServiceCEImpl.javaReactiveSecurityContextHolderingetOrganizationConfiguration(); skip settinginstanceId/adminEmailDomainHashfor anonymous principalsOrganizationServiceCETest.javanullfor sensitive fields; authenticated caller gets non-null valuesAuthGuardTest.javaGET /api/v1/users/featuresreturns 401 for unauthenticated requests;GET /api/v1/tenants/currentremains accessibleTest plan
OrganizationServiceCETest#getOrganizationConfig_AnonymousUser_DoesNotExposeInstanceMetadata— assertsinstanceIdandadminEmailDomainHasharenullfor anonymous callersOrganizationServiceCETest#getOrganizationConfig_AuthenticatedUser_ExposesInstanceMetadata— asserts both fields are non-null for authenticated callersAuthGuardTest#featureFlagsEndpoint_unauthenticated_returns401— HTTP 401 for unauthenticatedGET /api/v1/users/featuresAuthGuardTest#tenantCurrentEndpoint_unauthenticated_isAccessible—GET /api/v1/tenants/currentstill returns 200 without authOrganizationServiceCETesttests pass (1 pre-existing disabled test skipped)🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests
Automation
/ok-to-test tags="@tag.All"
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/22959284307
Commit: 1bcf565
Cypress dashboard.
Tags:
@tag.AllSpec:
Wed, 11 Mar 2026 16:17:45 UTC