You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Events: run guards before validating the call's data #861
On each event call, the server checks the call's data against the handler's data class before it runs the guards (docs/design/events.md, the call order around line 4995): verify the token, rebuild State, apply the browser's _model writes, validate the arguments, run _context, run the guards, run the handler.
So a caller that a guard will refuse still has its data fully validated first:
The server does the most expensive step of the call (validating a large or nested payload) for calls it then refuses.
A refused caller can get a 422 that describes its own input, where a 403 should come first.
Proposal: run _context and the guards before validating the arguments. Guards already read the unvalidated arguments through self.event.args, because one guard covers handlers with different data classes, and _context does not receive the validated data either, so neither depends on the order. Update the design doc's call order, the protocol spec if it states the order of error codes, and docs/design/trust_boundaries.md.
Related question to settle in the same change: guards see State after the browser's writes to _model fields are applied. A guard that reads a field the browser may write is checking a value the caller chose. Decide whether guards should see State as the token held it, before those writes, or whether the docs should say plainly that a guard must not trust a writable field.
Versioning: a refused caller with invalid data gets 403 instead of 422. Check the change against the 1.x rules; it may count as a security hardening. Suggested for 1.4.0.
Activity