add: jwt-allowed-skew-seconds config - #5199
Conversation
|
If 30 seconds is not enough skew, the problem must be fixed on the various machines: sync their clocks properly! I don't think it makes sense to add this. |
Agreed. Also, without any upper bound, this is very unsafe. |
Right but #5196 (comment) applies.
Implementers MAY provide for some small leeway, usually no more than a few minutes, to account for clock skew. One interesting thing is that the RFC only mentions that for the So what about two minutes maximum?
We could interpret that as 3 to 5 minutes. |
|
Found that Envoy has a skew of 60 seconds by default and doesn't have a max imposed (ref). |
375e3c9 to
26e60bf
Compare
For mitigating PostgREST#5196 when it happens. Was previously discussed it on PostgREST#4035 as a way to lower the skew for testing purposes, but this was dangerous as users could induce errors. To avoid the above, we don't allow lowering the value past our default of 30 seconds.
26e60bf to
edf6ae0
Compare
| Just skew | skew >= 30 && skew <= 300 -> pure skew | ||
| | otherwise -> fail "jwt-allowed-skew-seconds must be between 30 and 300" |
There was a problem hiding this comment.
Added a 300 seconds (5 minutes) max skew. Open to discuss if it should be lower.
|
Also found this standard that does consider
We could decide on a later change whether to change the default to 60 seconds. Or perhaps we can make this a |
Actually the above makes sense since the RFC doesn't really mandate validation against The RFC does conflict with https://openid.net/specs/fapi-security-profile-2_0-final.html, IIUC that does mention So I guess another option for a fix would be to stop validating |
|
None of what is discussed here makes any sense to me. The detailed report in #5196 (comment) allows two interpretations:
There is no point in adding such a feature without any indication of its usefulness. |
Yeah, it could possibly turn out that this config doesn't mitigate the timing related problem — what if the timing is way off? I think before progressing with this PR, we should actually try to debug the core issue first i.e merge and release #5197. |
I can agree with that, we need #5197 on v14 though as mentioned on #5189 (comment). Putting this on draft for now. |
|
I'm having a hard time reproducing #5196 (comment) again. Under synced clocks, perhaps the 30 clock skew is too big to get the iat failure. So I'm thinking, what's enough to prove #5196 is only that there's a skew defaultUpdateSettings :: UpdateSettings ()
defaultUpdateSettings =
UpdateSettings
{ updateFreq = 1000000 -- 1 second here
, updateSpawnThreshold = 3
, updateAction = return ()
, updateThreadName = "AutoUpdate"
}The cached time is only supposed to lag 1 second. |
|
So to do the above, we could have one of those Also I should be able to configure it to be lower than 30s. |
5c2ab0d to
3e47a6b
Compare
|
While #5208 was solved. I believe this should be added for testing/debugging purposes. Without this, it was impossible to confirm the previous fixes were ineffective #5196 (comment). I'm not seeing how #5196 would happen again, but I've said that in the past. So it'd be handy to have this to config to quickly override the skew to 0. Maybe that's something required in more security sensitive contexts too. |
For mitigating #5196 when it happens.
Was previously discussed it on #4035 as a way to lower the skew for testing purposes, but this was dangerous as users could induce errors.
To avoid the above, we don't allow lowering the value past our default of 30 seconds.