fix(iam): audit super-admin and grant-escalation denials - #47
Merged
Conversation
klaudia-blazyczek-blurify
marked this pull request as ready for review
July 31, 2026 07:28
klaudia-blazyczek-blurify
requested review from
agniev-a-hub and
zaxovaiko
as code owners
July 31, 2026 07:28
marek-chmielowski-blurify
previously approved these changes
Jul 31, 2026
marek-chmielowski-blurify
previously approved these changes
Jul 31, 2026
zaxovaiko
reviewed
Jul 31, 2026
Comment on lines
+173
to
+180
| this.emitUnauthorized( | ||
| caller.userId, | ||
| caller.role, | ||
| resource, | ||
| missingAction, | ||
| caller.ip, | ||
| caller.userAgent, | ||
| ); |
Member
There was a problem hiding this comment.
I strongly suggest to use named parameters
zaxovaiko
reviewed
Jul 31, 2026
| if (this.rateLimiter) { | ||
| const key = makeRateLimitKey( | ||
| RATE_LIMIT_KEYS.ACCESS_DENIED_REPORT, | ||
| `${caller.userId}:${resource}:${level}`, |
Member
There was a problem hiding this comment.
Let's extract the key to some function (as we did before)
zaxovaiko
reviewed
Jul 31, 2026
| .route({ method: 'GET', path: '/iam/my-permissions' }) | ||
| .output(EffectivePermissionsSchema), | ||
|
|
||
| reportAccessDenied: oc |
Member
There was a problem hiding this comment.
What is the purpose of this endpoint?
zaxovaiko
previously approved these changes
Jul 31, 2026
zaxovaiko
dismissed stale reviews from agniev-a-hub, marek-chmielowski-blurify, and themself
via
July 31, 2026 12:40
a217e18
zaxovaiko
marked this pull request as draft
July 31, 2026 22:38
…-access-attempts # Conflicts: # .rulesync/rules/conventions.md
zaxovaiko
marked this pull request as ready for review
August 5, 2026 17:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
IamService.assertSuperAdminand the no-escalation check insetRolePermissionsnow emitidentity.user.unauthorized_accessbefore throwing, so these service-level denials are audited the same wayAdminGuarddenials always have been. BF-412.Why
Two service-level FORBIDDEN paths (
NotSuperAdminError,GrantEscalationError) throw before ever reachingAdminGuard.assert(), so they bypassed the guard's audit emission and produced noidentity.user.unauthorized_accessrow - even though the request genuinely reached the backend and was genuinely denied.Alternatives considered
An earlier version of this PR also added
AdminGuard.recordDeniedAccess/ an iamreportAccessDeniedroute so a frontend page guard could self-report a denial after blocking navigation client-side. Dropped per review: a client-side redirect never sends the underlying request, so it isn't a reliable audit signal - only a real backend request that hitsAdminGuard.assert()(or one of the two service-level checks above) is. The frontend continues to redirect + show a toast for inaccessible pages, without a separate audit entry.Risks
None. Changeset downgraded to
patch- no new public API, pure bug fix.