Any signed-in user can retrieve another user's record by ID
Source references: 2The read-user endpoint requires authentication but does not compare current_user.id with user_id as the update and delete endpoints do. An authenticated user can select any integer ID, and the endpoint returns the fields included in the User response model.
One ordinary account could enumerate and read other users' profiles. The exact disclosure depends on the User response model, which is not provided, but the authorization gap affects every field that model exposes.
The read-by-ID endpoint only requires a logged-in caller and does not verify that the caller owns the record or has an administrator role; the update endpoint in the same file explicitly performs an ID check. If adopted, any authenticated user could try enumerating IDs and receive fields exposed by the User response model. The exact disclosure is unknown because that model is not provided. Users should require a stated access policy, ownership/role checks, and a minimal response schema.
@router.get("/{user_id}", response_model=User)async def read_user( user_id: int, db: AsyncSession = Depends(get_db), current_user: User = Depends(get_current_user)): """Get user by ID.""" user = await user_service.repository.get(db, user_id) if not user: raise HTTPException(status_code=404, detail="User not found") return userShow 1 other places
@router.patch("/{user_id}", response_model=User)async def update_user( user_id: int, user_in: UserUpdate, db: AsyncSession = Depends(get_db), current_user: User = Depends(get_current_user)): """Update user.""" if current_user.id != user_id: raise HTTPException(status_code=403, detail="Not authorized")