Problem/Motivation
// Setting very low priority to ensure access checks are run after alters.
$events[RoutingEvents::ALTER][] = array('onRoutingRouteAlterSetAccessCheck', -1000);
Yeah. It's wishful thinking people won't make a mistake with priorities. core has -1024 weight RoutingEvents::ALTER subscribers so if someone takes those as an example, they will not have any access checks set on their routes.
It is very easy to create a bug over entity subscriber priorities. Relevant bug: field ui routes do not have methods set because of how event subscribers are prioritized.
Another relevant bug: we are so very loosely coupled that we ended up with two subscribers trying to decide what is an admin path. They obviously use slightly different logic. Both ended up broken. Different ways broken but broken none the less. RoutePreloader does not take a forced _admin_route into consideration while AdminRouteSubscriber considers paths like administration admin routes instead of just taking admin/* and admin as admin routes and then let the _admin_route option do the rest.
Proposed resolution
Fix the security bug here.
Remaining tasks
File followups for the other two.
User interface changes
API changes
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | 2351777_37.patch | 8.37 KB | chx |
| #37 | interdiff.txt | 1002 bytes | chx |
Comments
Comment #2
chx commentedComment #4
chx commentedI think about 5 fails left.
Comment #5
chx commentedComment #6
chx commentedScaled back significantly. Still, the bugs are fixed.
Comment #9
chx commentedComment #10
fabianx commentedSo my understanding of this issue is:
Core is currently not secure by default as you could easily set a priority that overrides the magic subscriber.
I think access checks as subscribers is a good idea, but having the access system be a subscriber itself is not.
The router is tied to the access system as it is a fundamental principle of Drupals system, so I don't see a problem hardcoding the security model - and having someone replace the whole RouterBuilder if they really need a different model.
while still allowing the flexibility of Access Route Subscribers ourselves.
Comment #11
pwolanin commentedSo, it does seems like at least the access portion should be hard-coded here, but why don't we start with a patch for just that?
Also, it seems like we should be injecting the AccessManager into the constructor of the RouteBuilder?
Comment #12
catchI think we could do with more docs on RouteBuilder::isAdminRoute() just to clarify exactly what the rules are. At one point we wanted paths under admin/* to default to admin, but with the option to override (might have been block preview use case), but not sure if that's still relevant.
Does any of the test coverage removed need refactoring rather than removal?
Otherwise looks like a great change and #10 summarizes the trade-offs very well.
Agree with #11 though - would be easier to review if we split into security and not-security chunks.
Comment #13
dawehnerYeah, security is a feature of the routing system, I would not be sure whether admin themes would be one of it. For request formats I would just drop that and keep logic on runtime to fallback to GET, POST.
Comment #14
chx commentedComment #15
chx commentedI still think that methods always being an array is better. Also, in general, running code on build time is better than running code runtime no matter how little. But, now that's a followup.
Comment #16
chx commentedAdded proper dependency, removed method, added test assertion. Should be ready.
Comment #17
dawehnerAwesome!
Comment #19
chx commentedEh, forgot to patch services to pass in access manager.
Comment #23
dawehnerLet's use usual setter injection in that case.
Comment #24
chx commentedWhy not wait for #2352641: Break router.builder dependency to break the loop?
Comment #27
claudiu.cristeaComment #28
claudiu.cristeareroll
Comment #29
claudiu.cristeaah
Comment #31
claudiu.cristeahere we go
Comment #32
chx commentedThanks so much! One nit: you forgot to delete the AccessRouteSubscriber.
Comment #33
larowlanwe need to re-order here, no sense having optional argument before non-optional
Other than that looks rtbc
Comment #34
chx commentedI do not see why is that optional but w/e.
Comment #35
larowlanassuming green - thanks
Comment #37
chx commentedComment #38
larowlan+1
Comment #39
dawehner+1
Comment #40
fabianx commentedRTBC + 1
Comment #41
klausiFixing tags and title.
Comment #42
chx commentedUnfollowed.
Comment #43
fabianx commentedTagging a parent issue and re-titling related to the new security initiative
Comment #44
catchHave been following along with this issue as well as the two sub-issues that sorted out the dependency chain. An implicit dependency that depends on subscriber priority and is always called is both riskier and more obfuscated than just having the explicit dependency here. Committed/pushed to 8.0.x, thanks!