IdentityManagement: Difference between revisions

From Traxel Wiki
Jump to navigation Jump to search
Line 2: Line 2:
= JWT =
= JWT =
== Secret Key Blast Radius ==
== Secret Key Blast Radius ==
I asked GPT for some tips on minimizing blast radius, to see if I was missing any options.
I asked GPT for some tips on minimizing blast radius, to see if I was missing any options. It didn't fully grasp that I was talking about the blast radius of the signing key, but the list still has some merit.
* '''Use Short-Lived Access Tokens''': By making the JWT access tokens short-lived, you limit the time an attacker has to use a stolen token. Typically, access tokens can have a lifetime of minutes to hours.
* '''Use Short-Lived Access Tokens''': By making the JWT access tokens short-lived, you limit the time an attacker has to use a stolen token. Typically, access tokens can have a lifetime of minutes to hours.
* '''Implement Refresh Tokens''': To complement short-lived access tokens, use longer-lived refresh tokens that are used solely to obtain new access tokens. Refresh tokens can be stored more securely and revoked if necessary. They should be used infrequently, only when the access token expires.
* '''Implement Refresh Tokens''': To complement short-lived access tokens, use longer-lived refresh tokens that are used solely to obtain new access tokens. Refresh tokens can be stored more securely and revoked if necessary. They should be used infrequently, only when the access token expires.

Revision as of 13:28, 8 November 2023

JWT

Secret Key Blast Radius

I asked GPT for some tips on minimizing blast radius, to see if I was missing any options. It didn't fully grasp that I was talking about the blast radius of the signing key, but the list still has some merit.

  • Use Short-Lived Access Tokens: By making the JWT access tokens short-lived, you limit the time an attacker has to use a stolen token. Typically, access tokens can have a lifetime of minutes to hours.
  • Implement Refresh Tokens: To complement short-lived access tokens, use longer-lived refresh tokens that are used solely to obtain new access tokens. Refresh tokens can be stored more securely and revoked if necessary. They should be used infrequently, only when the access token expires.
  • Token Rotation and Blacklisting: Regularly rotate JWT secret keys and implement a blacklist of tokens that have been logged out or invalidated. This list needs to be checked whenever tokens are used, which can add some overhead to your application.
  • Scope the Tokens: Include claims in your JWT that define the scope of what the token can do. For instance, a token might grant read access but not write access. This way, even if a token is compromised, it can only be used within its limited scope.
  • Use Asymmetric Cryptography: Instead of using a secret key for signing JWTs (symmetric cryptography), use asymmetric cryptography where a private key signs the token, and a public key verifies it. The public key can be shared freely, and without the private key, a compromised server cannot issue new tokens.
  • Secure Key Storage: Use hardware security modules (HSMs) or services like AWS KMS or HashiCorp Vault for managing the signing keys. These services keep the private key secure and perform signing operations without exposing the key, even to the server that uses it.
  • IP Whitelisting and Geofencing: Restrict the use of tokens to certain IP addresses or geolocations. This isn't always feasible, but for certain applications, it can significantly reduce the risk.
  • Per-Session Dynamic Secrets: For every session, dynamically create a JWT secret that is stored securely on the server and associated with that session. If a key is compromised, it only affects that session and not others.
  • Multi-factor Authentication (MFA): Require MFA to obtain a JWT, which significantly increases the difficulty of token theft.
  • Audit Logs and Anomaly Detection: Keep detailed logs of token issuance and use, and employ anomaly detection to look for unusual patterns that might indicate a token has been compromised.
  • Rate Limiting and Abuse Detection: Implement rate limiting and abuse detection mechanisms that can identify and block rapid, repeated requests that may suggest token misuse.