[Regression] External user can see all projects regardless of project membership (SZ-127)
rk@tigase.net opened 4 days ago

Summary

External users can see all projects in the project list regardless of which projects they have been explicitly invited to. An external user invited to one project can see all projects in the system. The ExternalUserPolicy enforcement point is not correctly scoping the project list query to invited projects only.

Steps to Reproduce

  1. Create an external user with system-level DEVELOPER role
  2. Invite the external user to exactly one private project
  3. Log in as the external user
  4. Navigate to the project list
  5. Observe all projects are visible — not just the invited project

Expected Behavior

External users should only see projects they have been explicitly invited to as a member. All other projects — regardless of visibility type — should be invisible to external users.

Actual Behavior

External user sees all projects in the system. System-level DEVELOPER role appears to override per-project ExternalUserPolicy access control, bypassing project membership checks entirely.

  • rk@tigase.net commented 4 days ago

    Root Cause (suspected)

    Project list query does not apply ExternalUserPolicy filter predicate when the current user is external. System-level role grants broad read access that supersedes per-project membership enforcement.

    Fix

    In ProjectService.getProjects() (or equivalent list endpoint):

    • Detect if current user is external
    • If external, scope project list query to projects where the user has an explicit membership record
    • Internal users continue to see all projects per existing policy
    • SZ-78 — External users must not hold ADMIN/PROJECT_MANAGER roles (enforcement not yet implemented — may be contributing factor)
    • ExternalUserPolicy enforcement point audit recommended after fix
  • rk@tigase.net commented 4 days ago

    Breakdown:

    Find the project list query — 15 min Add the external user filter predicate — 30 min Verify ExternalUserPolicy is being applied correctly elsewhere — 30 min Test fix locally — 30 min Rebuild image, redeploy, verify — 15 min

  • rk@tigase.net commented 4 days ago
    rksuma@Ramakrishnans-MacBook-Pro sztab % git status
    On branch release/1.10.0
    Your branch is up to date with 'origin/release/1.10.0'.
    
    nothing to commit, working tree clean
    rksuma@Ramakrishnans-MacBook-Pro sztab % git checkout -b fix/SZ-127-external-user-project-visibility
    Switched to a new branch 'fix/SZ-127-external-user-project-visibility'
    rksuma@Ramakrishnans-MacBook-Pro sztab %       
    
    
  • rk@tigase.net changed state to 'In Progress' 4 days ago
    Previous Value Current Value
    Open
    In Progress
  • rk@tigase.net commented 4 days ago

    Found the Root cause and the fix:

    The ProjectController is injected with externalUserPolicy, securityUtils, and userService but isn't using them for the list endpoint. Fix:

    @GetMapping
    @PreAuthorize("isAuthenticated()")
    public ResponseEntity<Page<ProjectDto>> getAllProjects(
            final Pageable pageable,
            final Authentication authentication) {
    
        final User currentUser = securityUtils.getCurrentUser(authentication);
    
        final Page<ProjectDto> dtos;
        if (currentUser.isExternal()) {
            dtos = projectService.getAllProjectsForExternalUser(currentUser, pageable)
                    .map(projectMapper::toDto);
        } else {
            dtos = projectService.getAllProjects(pageable)
                    .map(projectMapper::toDto);
        }
    
        return ResponseEntity.ok(dtos);
    }
    

    Added 3 unit tests to cover this which would have exposed this problem.

  • rk@tigase.net changed state to 'Pending approval' 4 days ago
    Previous Value Current Value
    In Progress
    Pending approval
  • rk@tigase.net referenced from other issue 3 days ago
  • rk@tigase.net referenced from other issue 19 hours ago
  • rk@tigase.net commented 4 hours ago

    Fix merged into wolsonsc

  • rk@tigase.net changed state to 'Closed' 4 hours ago
    Previous Value Current Value
    Pending approval
    Closed
issue 1 of 1
Type
Bug
Priority
Blocker
Assignee
Version
1.10.0
Sprints
n/a
Customer
n/a
Issue Votes (0)
Watchers (3)
Reference
SZ-127
Please wait...
Page is in error, reload to recover