This repository was archived by the owner on May 29, 2026. It is now read-only.
fix: ZgwController base class + AC scope-gate + consumerHasScope fail-closed (C2/C3/H2/M3)#660
Merged
Conversation
…-closed (C2/C3/H2/M3) - Create abstract ZgwController so ZgwAuthMiddleware instanceof guard actually fires (C3) - Make AcController, ZrcController, ZtcController, DrcController, BrcController, NrcController extend ZgwController so all ZGW endpoints are covered by the middleware - Gate AC write ops (create/update/destroy) on ac.aanmaken/bijwerken/verwijderen scopes (C2) - Block heeftAlleAutorisaties=true unless requesting consumer is a superuser (C2) - Fail consumerHasScope/getConsumerAuthorisaties closed on null mapper, malformed JWT, missing client_id, and empty consumer — all previously returned permissive true/null (H2) - Remove internal JWT exception detail from HTTP response; log server-side only (M3)
This was referenced May 27, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Fixes four security findings from the deep review pass.
C3 — ZgwAuthMiddleware dead (abstract base class missing):
ZgwAuthMiddleware::beforeControllerusedinstanceof ZgwControllerbutZgwControllernever existed — the middleware always returned immediately without enforcing any scope check. Createslib/Controller/ZgwController.phpas an abstract marker base and makes all six ZGW controllers (AcController,ZrcController,ZtcController,DrcController,BrcController,NrcController) extend it.C2 — AC controller no scope-gating on writes:
Any valid JWT could
POST /api/ac/applicatieswithheeftAlleAutorisaties: trueto mint a superuser consumer. Write operations (create,update,destroy) now requireac.aanmaken/ac.bijwerken/ac.verwijderenscope respectively. SettingheeftAlleAutorisaties=trueadditionally requiresac.superuserscope (only granted to existing superusers).H2 — consumerHasScope / getConsumerAuthorisaties fail-permissive:
Multiple non-exception paths returned
true(scope granted) ornull(unrestricted) — null ConsumerMapper, malformed JWT, missingclient_id/iss, empty consumer set. All now returnfalse/[](deny/restricted).M3 — validateJwtAuth leaks internal JWT error messages:
Both
ZgwService::validateJwtAuthandZgwAuthMiddleware::beforeControllerechoed raw$e->getMessage()in 403 responses, exposing algorithm/issuer enumeration signals. Now logs detail server-side and returns only a generic message to the caller.Test plan
testZgwControllerIsAbstract— verifies the marker class is abstracttestZgwControllersExtendBase— verifies all 6 ZGW controllers extend ZgwControllerCloses #635, #636, #644, #652