•  
      request #25689 [oidc-client] State comparison must be done in constant time
    Infos
    #25689
    Manuel Vacelet (vaceletm)
    2022-03-31 09:58
    2022-03-07 10:21
    27222
    Details
    [oidc-client] State comparison must be done in constant time
    Mediawiki Standalone
    development
    Empty
    • [ ] enhancement
    • [ ] internal improvement
    Robert Vogel (rvogel)
    Stage
    Dejan Savuljesku (dsavuljesku)
    Closed
    2022-03-31
    Attachments
    Empty
    References
    References list is empty

    Follow-ups

    User avatar
    Thomas Gerbet (tgerbet)2022-03-07 12:25

    Constant time means that the time needed to do the calculation is not dependent on the content of the inputs. Only the size of the inputs change change the time needed to do it.

    PHP does not compare string in constant time by default, it returns as soon as it finds a difference between the 2 strings. This means it might be possible to determine what the expected secret is, see timing attack. This is why it is a good practice to do such operations in constant time when manipulating secrets and/or doing crypto-related operations (at the very least it makes the whole process easier to audit).

    PHP has a function that allows to do string comparison in constant time, the misnamed hash_equals().