Skip to content

[Feature Request] Guidelines for Keystone authentication token provider backend #568

Closed

Description

@markus-hentsch

Preface

To issue, manage and validate authentication tokens (bearer tokens), Keystone currently offers two backends1 (called providers):

  • Fernet
    • was introduced in Kilo and made the default in the Pike release, deprecating UUID tokens
    • all tokens are encrypted
    • shared symmetric key repository between Keystone instances that needs to be rotated in sync
  • JWS
    • was introduced in the Stein release als an alternative to Fernet
    • tokens are only signed, not encrypted
    • each Keystone server has its own signing key pair, which can be rotated individually

Motivation

The current default token provider in Keystone is based on Fernet.
By now, Fernet is a pretty old standard with no visible maintainership over the last decade:

  • The Fernet spec has not received updates since 2014 and is still limited to AES1282.
  • Updating Fernet to support AES192 and AES256 was attempted 8 years ago but was not implemented due to the lack of maintainership3.
  • Concerns raised about the spec failing to meet current security recommendations were left unanswered4.

Although python-cryptography actively maintains the implementation of Fernet, it is limited to the design choices of the Fernet spec, e.g. limited to AES128.

Keystone actually shares some of these concerns, which was the main motivation behind introducing the alternative JWS token provider backend5. In contrast to Fernet, JSON Web Signature (JWS) is a widely adopted and more recent IETF standard.

Since there was no activity in recent years, it does not seem like Fernet will receive updates any time soon. As a result, its design choices will become more and more outdated as security recommendations will shift towards stronger algorithms over time due to the technical progress.

Request

SCS should evaluate whether the shortcomings of the Fernet token provider are a concern that should be adressed now or in the foreseeable future.

Resulting actions could be implementing a guideline or standard for SCS clouds to favor the JWS token provider in case Fernet is deemed insufficient.

Footnotes

  1. https://docs.openstack.org/keystone/latest//admin/tokens-overview.html#token-providers ↩

  2. https://github.com/fernet/spec/blob/20dead475f53f11d20592baf29ad697163afc0cd/Spec.md ↩

  3. https://github.com/fernet/spec/pull/17 ↩

  4. https://github.com/fernet/spec/issues/8 ↩

  5. https://specs.openstack.org/openstack/keystone-specs/specs/keystone/stein/json-web-tokens.html#problem-description ↩

Activity

  1. added
    enhancement
    SCS-VP10
    on Mar 13, 2024
  2. markus-hentsch commented on Mar 13, 2024

    @markus-hentsch
    Author

    We discussed this in today's IaaS and IAM calls. Key points:

    • the question was raised whether in the course of the R7 cycle the default could be switched to JWS
    • since Fernet is used in most clouds as far as we can tell, JWS would need proper testing in SCS to ensure it is ready for production
    • concern was raised about the migration for existing clouds from Fernet to JWS due to long-running processes (such as VM migrations) needing active authentication; a downtime will be required to switch
    • SCS may not want to be the only entity mandating JWS token provider usage when everybody else is still using Fernet
      • instead, bringing the discussion upstream and pushing them to change the default was considered as a preferred alternative to tackle this
    • the question was raised if OAuth could be implemented instead of switching the token provider
  3. markus-hentsch commented on Mar 13, 2024

    @markus-hentsch
    Author

    Cross-referencing the Barbican plugins discussion here since it is related: SovereignCloudStack/standards#509 (comment)

  4. markus-hentsch commented on Mar 14, 2024

    @markus-hentsch
    Author

    Thoughts on security implications

    Disclaimer: The following is not a professional audit of token security but just my thoughts about the matter based on the information I have gathered so far. It is meant to provide a rough picture of what the implications of Fernet's design choices could be at the time of writing. It might not cover all resulting attack vectors or threats.

    Preface

    The Fernet spec1 states the following about the key structure:

    A fernet key is the base64url encoding of the following
    fields:

    Signing-key ‖ Encryption-key
    
    • Signing-key, 128 bits
    • Encryption-key, 128 bits

    Scenario A: Decryption

    An adversary is able to decrypt existing auth tokens originally issued by the Fernet token provider of Keystone.

    Implications:

    • only compromises the confidentiality of the data an auth token carries, which is limited to identity information of the current authentication (authenticated IDs, roles, project, ...)2

    Requirements:

    • this might only require the AES-128 part of the Fernet key, thus only the last 128 bits of the key
    • an adversary would need to either be able to break the encryption to reconstruct at least the second half of the key (128 bit) or be able to guess it

    Assessment:

    • the exposed data does not seem to provide a critical threat; the alternative JWS token provider does not encrypt it at all in the first place

    Scenario B: Encryption

    An Adversary is able to encrypt auth tokens with a Fernet key reconstructed from one or multiple collected auth tokens.

    Implications:

    • being able to encrypt a new Fernet token makes it possible to craft valid authentication for arbitrary auth scopes and targets as long as the target IDs are known

    Requirements:

    • this would require both the AES and signing key parts of a Keystone Fernet key to craft valid tokens, thus the full 256 bit of the key
    • an adversary would need to either be able to break both the encryption and signing algorithms to reconstruct the full Fernet key (256 bit) or be able to guess it

    Assessment:

    • in a proper setup, Fernet keys are rotated in the Keystone servers regularly
    • thus, the time it takes to break/guess the full 256 bits of a Fernet key would need to be smaller than the key rotation time frame in order to be able to successfully use crafted tokens for a currently valid Fernet key
    • successfully crafting tokens for older Fernet keys that have already been rotated out of the Keystone cluster does not seem to pose any threat since they won't be accepted by Keystone anymore

    Bottom line

    The only real threat seems to be scenario B. Since Fernet tokens are both encrypted and signed, the AES-128 encryption key (128 bit) is most likely not sufficient to craft valid tokens that will be accepted by Keystone because they also need to be signed using the signing key, which consists of another 128 bits. Thus, successfully crafting a valid auth token requires 256 bit of key material in total.

    Having a lower-grade algorithm for the encryption part (AES-128 as opposed to AES-192 or AES-256) does not seem to be problematic here as the encrypted portion of an auth token does not carry highly sensitive information which could be used to compromise things on their own.
    For comparison, the JWS token provider does not encrypt this information at all.

    Footnotes

    1. https://github.com/fernet/spec/blob/master/Spec.md#key-format ↩

    2. https://files.openstack.org/docs/keystone/2023.2/_modules/keystone/token/providers/fernet/core.html#Provider.generate_id_and_issued_at ↩

  5. markus-hentsch commented on Mar 14, 2024

    @markus-hentsch
    Author

    Based on the thoughts I collected above, I think there is no pressing need currently for SCS to strictly push JWS as long as there is no known vulnerability or weakness for Fernet specifically. Going away from Fernet would be more about future-proofness than concrete security concerns at the time of writing.

  6. josephineSei commented on Mar 14, 2024

    @josephineSei

    Based on the thoughts I collected above, I think there is no pressing need currently for SCS to strictly push JWS as long as there is no known vulnerability or weakness for Fernet specifically. Going away from Fernet would be more about future-proofness than concrete security concerns at the time of writing.

    I read through the security implications and I share Markus opinion.

  7. markus-hentsch commented on Mar 27, 2024

    @markus-hentsch
    Author

    We discussed this in the SCS IaaS community call on 2024-03-20 and concluded that there currently is no need to establish any restrictions or guidelines as both provider backends currently offered by OpenStack (Fernet and JWS) are valid choices based on the evaluation above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCS-VP10enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions