Are breaches of JWT-based servers more damaging?

后端 未结 2 746
温柔的废话
温柔的废话 2020-12-16 06:40

UPDATE: I have concluded my research on this problem and posted a lengthy blog entry explaining my findings: The Unspoken Vulnerability of JWTs. I explain h

2条回答
  •  离开以前
    2020-12-16 07:22

    I believe you're thinking about this the wrong way. Don't get me wrong, it's great you're considering security, however the way you're approaching it in regards to double checking things server-side, adding additional checks that defeat the objective of stateless sessions, etc, appear to be along a one way street towards the end of your own sanity.

    To sum up the two standard approaches:

    • JWTs are sessionless state objects, MAC'd by a secret key held server side.

    • Traditional Session Identifiers are stored either in memory or in a database server-side, and as you say are often hashed to prevent sessions from being hijacked should this data be leaked.

    You are also right that write access is often harder for an attacker to achieve. The reason is that database data is often extracted from a target system via a SQL injection exploit. This almost always provides read access to data, but it is harder to insert data using this technique, although not impossible (some exploits actually result in full root access of the target machine being achieved).

    If you have a vulnerability that allows access to the key when using JWTs or one that allows database tables to be written to when using session identifiers, then it's game over - you are compromised because your user sessions can be hijacked.

    So not more damaging necessarily, it all depends on the depth of the vulnerability.

    Double check that the security of your JWT keys align with your risk appetite:

    • Where are they stored?
    • Who has access?
    • Where are backups stored?
    • Are different keys used in pre-production and production deployments of your app?

    The ways to mitigate is as good practise dictates with any web app:

    • Regular security assessments and penetration testing.
    • Security code reviews.
    • Intrusion detection and prevention (IDS/IPS).
    • WAF.

    These will help you evaluate where your real risks lie. It is pointless concentrating on one particular aspect of your application so much, because this will lead to the neglect of others, which may well be higher risk to your business model. JWTs aren't dangerous and have no more risk than other components of your system necessarily, however if you've chosen to use them you should make sure you're using them appropriately. Whether you are or not comes down to the particular context of your application and that is difficult to assess in a general sense, so I hope my answer guides you in the right direction.

提交回复
热议问题