[Security] Role endpoints return the raw IdentityRole entity instead of a DTO
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start with src/PublicApi/RoleManagementEndpoints/CreateRoleEndpoint.CreateRoleResponse.cs and the three sibling response files to see how each endpoint currently returns IdentityRole, then copy the UserDto pattern used for the #324 fix. On the client side follow Services/RoleManagementService.cs and the four Models/*RoleResponse.cs types into Pages/RolePage/* and the two Pages/UserPage files to see where the entity's extra fields are bound. Finish by mirroring tests/PublicApiIntegrationTests/Helpers/UserJsonAssert.cs so role responses assert only id and name, and run the PublicApi integration tests plus a BlazorAdmin build.
Written by the indexing model from the issue text.
Description
Summary
The role management endpoints serialize the ASP.NET Identity entity IdentityRole directly in their responses:
src/PublicApi/RoleManagementEndpoints/CreateRoleEndpoint.CreateRoleResponse.cs:14src/PublicApi/RoleManagementEndpoints/RoleGetByIdEndpoint.GetByIdRoleResponse.cs:17src/PublicApi/RoleManagementEndpoints/RoleListEndpoint.RoleListResponse.cs:17src/PublicApi/RoleManagementEndpoints/UpdateRoleEndpoint.UpdateRoleResponse.cs:15
This exposes NormalizedName and ConcurrencyStamp. Neither is secret, but it couples the public API contract to the Identity storage model. That is the same pattern that led to the PasswordHash leak in #324, where the user endpoints were fixed to return UserDto.
Impact (Low)
Internal persistence fields are visible to clients. Any future change to the role entity (custom role class, extra columns) would be published automatically.
Suggested fix
- Add a
RoleDto { Id, Name }and return it from all four endpoints. - Update BlazorAdmin, which binds
IdentityRolethroughout:Models/CreateRoleResponse.cs,Models/GetByIdRoleResponse.cs,Models/RoleListResponse.cs,Services/RoleManagementService.cs,Pages/RolePage/*,Pages/UserPage/Create.razor,Pages/UserPage/Edit.razor. - Reuse the allowlist approach from
tests/PublicApiIntegrationTests/Helpers/UserJsonAssert.cs(added in #329) to assert role responses only containidandname.
Found during the independent review of #329.
- Dominant language
- C#
- Stars
- 642
- Forks
- 320
- Avg merge
- 3h 9m
- Merged PRs (30d)
- 11
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NimblePros/eShopOnWeb
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NimblePros/eShopOnWeb#333 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
NimblePros/eShopOnWeb#332 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
NimblePros/eShopOnWeb#326 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
NimblePros/eShopOnWeb#325 ·
Maintainers usually reply within 1 day
-
Order detail page shows any user's orderPossibly taken @ardalis claimed this today. Openagent-assigned
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NimblePros/eShopOnWeb#315 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
All issues in NimblePros/eShopOnWeb
Similar issues
-
area-NavigationView bug needs-triage team-Controls
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
microsoft/microsoft-ui-xaml#12671 · 3 comments ·
Maintainers usually reply within 2 days
-
Retarget the extension to Fallout 10.5Possibly taken @ChrisonSimtian claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Improve time codes: status hint doesn't mention the new Shift+F7 / Shift+F8 "to check" navigationOpen
Difficulty 1/5 Under an hour Newbie friendliness 88/100
SubtitleEdit/subtitleedit#16943 ·
Maintainers usually reply within 1 day