github.com/lestrrat-go/jwx/v2@v2.0.21/Changes (about)

     1  Changes
     2  =======
     3  
     4  v2 has many incompatibilities with v1. To see the full list of differences between
     5  v1 and v2, please read the Changes-v2.md file (https://github.com/lestrrat-go/jwx/blob/develop/v2/Changes-v2.md)
     6  
     7  v2.0.21 07 Mar 2024
     8  [Security]
     9    * [jwe] Added `jwe.Settings(jwe.WithMaxDecompressBufferSize(int64))` to specify the
    10      maximum size of a decompressed JWE payload. The default value is 10MB. If you
    11      are compressing payloads greater than this and want to decompress it during
    12      a call to `jwe.Decrypt`, you need to explicitly set a value large enough to
    13      hold that data.
    14  
    15      The same option can be passed to `jwe.Decrypt` to control this behavior on
    16      a per-message basis.
    17    * [jwe] Added documentation stating that `jwe.WithMaxBufferSize` option will be
    18      renamed in future versions, i.e. v3
    19  
    20  v2.0.20 20 Feb 2024
    21  [New Features]
    22    * [jwe] Added `jwe.Settings(WithMaxBufferSize(int64))` to set the maximum size of
    23      internal buffers. The default value is 256MB. Most users do not need to change
    24      this value.
    25    * [jws] Allow `jws.WithCompact()` and `jws.WithJSON()` to be passed to `jws.Parse()` and
    26      `jws.Verify()`. These options control the expected serialization format for the
    27      JWS message.
    28    * [jwt] Add `jwt.WithCompactOnly()` to specify that only compact serialization can
    29      be used for `jwt.Parse()`. Previously, by virtue of `jws.Parse()` allowing either
    30      JSON or Compact serialization format, `jwt.Parse()` also alloed JSON serialization
    31      where as RFC7519 explicitly states that only compact serialization should be
    32      used. For backward compatibility the default behavior is not changed, but you
    33      can set this global option for jwt: `jwt.Settings(jwt.WithCompactOnly(true))`
    34  
    35  [Miscellaneous]
    36    * Internal key conversions should now allow private keys to be used in place of
    37      public keys. This would allow you to pass private keys where public keys are
    38      expected.
    39  
    40  v2.0.19 09 Jan 2024
    41  [New Features]
    42    * [jws] Added jws.IsVerificationError to check if the error returned by `jws.Verify`
    43      was caused by actual verification step or something else, for example, while fetching
    44      a key from datasource
    45  
    46  [Security Fixes]
    47    * [jws] JWS messages formated in full JSON format (i.e. not the compact format, which
    48      consists of three base64 strings concatenated with a '.') with missing "protected"
    49      headers could cause a panic, thereby introducing a possiblity of a DoS.
    50  
    51      This has been fixed so that the `jws.Parse` function succeeds in parsing a JWS message
    52      lacking a protected header. Calling `jws.Verify` on this same JWS message will result
    53      in a failed verification attempt. Note that this behavior will differ slightly when
    54      parsing JWS messages in compact form, which result in an error. 
    55  
    56  v2.0.18 03 Dec 2023
    57  [Security Fixes]
    58    * [jwe] A large number in p2c parameter for PBKDF2 based encryptions could cause a DoS attack,
    59      similar to https://nvd.nist.gov/vuln/detail/CVE-2022-36083.  All users who use JWE via this
    60      package should upgrade. While the JOSE spec allows for encryption using JWE on JWTs, users of
    61      the `jwt` package are not immediately susceptible unless they explicitly try to decrypt
    62      JWTs -- by default the `jwt` package verifies signatures, but does not decrypt messages.
    63      [GHSA-7f9x-gw85-8grf]
    64  
    65  v2.0.17 20 Nov 2023
    66  [Bug Fixes]
    67    * [jws] Previously, `jws.UnregisterSigner` did not remove the previous signer instance when
    68      the signer was registered and unregistered multiple times (#1016). This has been fixed.
    69  
    70  [New Features]
    71    * [jwe] (EXPERIMENTAL) `jwe.WithCEK` has been added to extract the content encryption key (CEK) from the Decrypt operation.
    72    * [jwe] (EXPERIMENTAL) `jwe.EncryptStatic` has been added to encrypt content using a static CEK.
    73      Using static CEKs has serious security implications, and you should not use
    74      this unless you completely understand the risks involved.
    75  
    76  v2.0.16 31 Oct 2023
    77  [Security]
    78    * [jws] ECDSA signature verification requires us to check if the signature
    79      is of the desired length of bytes, but this check that used to exist before
    80      had been removed in #65, resulting in certain malformed signatures to pass
    81      verification.
    82  
    83      One of the ways this could happen if R is a 31 byte integer and S is 32 byte integer,
    84      both containing the correct signature values, but R is not zero-padded.
    85  
    86         Correct = R: [ 0 , ... ] (32 bytes) S: [ ... ] (32 bytes)
    87         Wrong   = R: [ ... ] (31 bytes)     S: [ ... ] (32 bytes)
    88  
    89      In order for this check to pass, you would still need to have all 63 bytes
    90      populated with the correct signature. The only modification a bad actor
    91      may be able to do is to add one more byte at the end, in which case the
    92      first 32 bytes (including what would have been S's first byte) is used for R,
    93      and S would contain the rest. But this will only result in the verification to
    94      fail. Therefore this in itself should not pose any security risk, albeit
    95      allowing some illegally formated messages to be verified.
    96  
    97    * [jwk] `jwk.Key` objects now have a `Validate()` method to validate the data
    98      stored in the keys. However, this still does not necessarily mean that the key's
    99      are valid for use in cryptographic operations. If `Validate()` is successful,
   100      it only means that the keys are in the right _format_, including the presence
   101      of required fields and that certain fields have proper length, etc.
   102  
   103  [New Features]
   104    * [jws] Added `jws.WithValidateKey()` to force calling `key.Validate()` before
   105      signing or verification.
   106  
   107    * [jws] `jws.Sign()` now returns a special type of error that can hold the
   108      individual errors from the signers. The stringification is still the same
   109      as before to preserve backwards compatibility.
   110  
   111    * [jwk] Added `jwk.IsKeyValidationError` that checks if an error is an error
   112      from `key.Validate()`.
   113  
   114  [Bug Fixes]
   115    * [jwt] `jwt.ParseInsecure()` was running verification if you provided a key
   116      via `jwt.WithKey()` or `jwt.WithKeySet()` (#1007)
   117  
   118  v2.0.15 19 20 Oct 2023
   119  [Bug fixes]
   120    * [jws] jws.Sign() now properly check for valid algorithm / key type pair when
   121      the key implements crypto.Signer. This was caused by the fact that when 
   122      jws.WithKey() accepted keys that implemented crypto.Signer, there really
   123      is no way to robustly check what algorithm the crypto.Signer implements.
   124  
   125      The code has now been modified to check for KNOWN key types, i.e. those
   126      that are defined in Go standard library, and those that are defined in
   127      this library. For example, now calling jws.Sign() with jws.WithKey(jwa.RS256, ecdsaKey)
   128      where ecdsaKey is either an instance of *ecdsa.PrivateKey or jwk.ECDSAPrivateKey
   129      will produce an error.
   130  
   131      However, if you use a separate library that wraps some KMS library which implements
   132      crypto.Signer, this same check will not be performed due to the fact that
   133      it is an unknown library to us. And there's no way to query a crypto.Signer
   134      for its algorithm family.
   135  
   136  v2.0.14 17 Oct 2023
   137  [New Features]
   138    * [jwk] jwk.IsPrivateKey(), as well as jwk.AsymmetricKey has been added.
   139      The function can be used to tell if a jwk.Key is a private key of an
   140      asymmetric key pair.
   141  [Security]
   142    * golang.org/x/crypto has been updated to 0.14.0. The update contains a fix for HTTP/2
   143      rapid reset DoS vulnerability, which some security scanning softwares may flag.
   144      However, do note that this library is NOT affected by the issue, as it does not have
   145      the capability to serve as an HTTP/2 server. This is included in this release
   146      document so that users will be able to tell why this library may be flagged
   147      when/if their scanning software do so.
   148  
   149  v2.0.13 26 Sep 2023
   150  [New Features]
   151    * [jwk] jwk.Equal has been added. Please note that this is equivalent to
   152    comparing the keys' thumbprints, therefore it does NOT take in consideration
   153    non-essential fields.
   154  
   155  [Miscellaneous]
   156    * Various documentation fixes and additions.
   157  
   158  v2.0.12 - 11 Aug 2023
   159  [Bug fixes]
   160    * [jwt] jwt.Serializer was ignoring JWE flags (#951)
   161  
   162  [Miscellaneous]
   163    * [jwk] Check for seed length on OKP JWKs to avoid panics (#947)
   164    * [jws] Documentation for jws.WithKeySet()
   165  
   166  v2.0.11 - 14 Jun 2023
   167  [Security]
   168    * Potential Padding Oracle Attack Vulnerability and Timing Attack Vulnerability 
   169      for JWE AES-CBC encrypted payloads affecting all v2 releases up to v2.0.10,
   170      all v1 releases up to v1.2.25, and all v0 releases up to v0.9.2 have been reported by
   171      @shogo82148.
   172  
   173      Please note that v0 versions will NOT receive fixes.
   174      This release fixes these vulnerabilities for the v2 series.
   175  
   176  v2.0.10 - 12 Jun 2023
   177  [New Features]
   178    * [jwe] (EXPERIMENTAL) Added `jwe.KeyEncrypter` and `jwe.KeyDecrypter` interfaces
   179      that works in similar ways as how `crypto.Signer` works for signature
   180      generation and verification. It can act as the interface for your encryption/decryption
   181      keys that are for example stored in an hardware device.
   182  
   183      This feature is labeled experimental because the API for the above interfaces have not
   184      been battle tested, and may need to changed yet. Please be aware that until the API
   185      is deemed stable, you may have to adapat our code to these possible changes,
   186      _even_ during minor version upgrades of this library.
   187     
   188  [Bug fixes]
   189    * Registering JWS signers/verifiers did not work since v2.0.0, because the
   190      way we handle algorithm names changed in 2aa98ce6884187180a7145b73da78c859dd46c84.
   191      (We previously thought that this would be checked by the example code, but it
   192       apparently failed to flag us properly)
   193  
   194      The logic behind managing the internal database has been fixed, and
   195      `jws.RegisterSigner` and `jws.RegisterVerifier` now properly hooks into the new
   196      `jwa.RegisterSignatureAlgorithm` to automatically register new algorithm names
   197      (#910, #911)
   198  [Miscellaneous]
   199    * Added limited support for github.com/segmentio/asm/base64. Compile your code
   200      with the `jwx_asmbase64` build tag. This feature is EXPERIMENTAL.
   201  
   202      Through limited testing, the use of a faster base64 library provide 1~5% increase
   203      in throughput on average. It might make more difference if the input/output is large.
   204      If you care about this performance improvement, you should probably enable
   205      `goccy` JSON parser as well, by specifying `jwx_goccy,jwx_asmbase64` in your build call.
   206    * Slightly changed the way global variables underneath `jwk.Fetch` are initialized and
   207      configured. `jwk.Fetch` creates an object that spawns wokers to fetch JWKS when it's
   208      first called.
   209      You can now also use `jwk.SetGlobalFetcher()` to set a fetcher object which you can
   210      control.
   211  
   212  v2.0.9 - 21 Mar 2023
   213  [Security Fixes]
   214    * Updated use of golang.org/x/crypto to v0.7.0
   215  [Bug fixes]
   216    * Emitted PEM file for EC private key types used the wrong PEM armor (#875)
   217  [Miscellaneous]
   218    * Banners for generated files have been modified to allow tools to pick them up (#867)
   219    * Remove unused variables around ReadFileOption (#866)
   220    * Fix test failures
   221    * Support bazel out of the box
   222    * Now you can create JWS messages using `{"alg":"none"}`, by calling `jws.Sign()`
   223      with `jws.WithInsecureNoSignature()` option. (#888, #890).
   224  
   225      Note that there is no way to call
   226      `jws.Verify()` while allowing `{"alg":"none"}` as you wouldn't be _verifying_
   227      the message if we allowed the "none" algorithm. `jws.Parse()` will parse such
   228      messages witout verification.
   229  
   230      `jwt` also allows you to sign using alg="none", but there's no symmetrical
   231      way to verify such messages.
   232  
   233  v2.0.8 - 25 Nov 2022
   234  [Security Fixes]
   235    * [jws][jwe] Starting from go 1.19, code related to elliptic algorithms
   236      panics (instead of returning an error) when certain methods
   237      such as `ScalarMult` are called using points that are not on the
   238      elliptic curve being used.
   239  
   240      Using inputs that cause this condition, and you accept unverified JWK
   241      from the outside it may be possible for a third-party to cause panics
   242      in your program.
   243  
   244      This has been fixed by verifying that the point being used is actually
   245      on the curve before such computations (#840)
   246  [Miscellaneous]
   247    * `jwx.GuessFormat` now returns `jwx.InvalidFormat` when the heuristics
   248      is sure that the buffer format is invalid.
   249  
   250  v2.0.7 - 15 Nov 2022
   251  [New features]
   252    * [jwt] Each `jwt.Token` now has an `Options()` method
   253    * [jwt] `jwt.Settings(jwt.WithFlattenedAudience(true))` has a slightly
   254      different semantic than before. Instead of changing a global variable,
   255      it now specifies that the default value of each per-token option for
   256      `jwt.FlattenAudience` is true.
   257  
   258      Therefore, this is what happens:
   259  
   260         // No global settings
   261         tok := jwt.New()
   262         tok.Options.IsEnabled(jwt.FlattenAudience) // false
   263  
   264         // With global settings
   265         jwt.Settings(jwt.WithFlattenedAudience(true))
   266         tok := jwt.New()
   267         tok.Options.IsEnabled(jwt.FlattenAudience) // true
   268         // But you can still turn FlattenAudience off for this
   269         // token alone
   270         tok.Options.Disable(jwt.FlattenAudience)
   271  
   272      Note that while unlikely to happen for users relying on the old behavior,
   273      this change DOES introduce timing issues: whereas old versions switched the
   274      JSON marshaling for ALL tokens immediately after calling `jwt.Settings`,
   275      the new behavior does NOT affect tokens that have been created before the
   276      call to `jwt.Settings` (but marshaled afterwards).
   277  
   278      So the following may happen:
   279  
   280        // < v2.0.7
   281        tok := jwt.New() 
   282        jwt.Settings(jwt.WithFlattenedAudience(true))
   283        json.Marshal(tok) // flatten = on
   284  
   285        // >= v2.0.7
   286        tok := jwt.New() // flatten = off
   287        jwt.Settings(jwt.WithFlattenedAudience(true))
   288        json.Marshal(tok) // flatten is still off
   289  
   290      It is recommended that you only set the global setting once at the
   291      very beginning of your program to avoid problems.
   292  
   293      Also note that `Clone()` copies the settings as well.
   294  
   295  [Miscellaneous]
   296    * WithCompact's stringification should have been that of the
   297      internal indentity struct ("WithSerialization"), but it was
   298      wrongly producing "WithCompact". This has been fixed.
   299    * Go Workspaces have been enabled within this module.
   300      - When developing, modules will refer to the main jwx module that they
   301        are part of. This allows us to explicitly specify the dependency version
   302        in, for example, ./cmd/jwx/go.mod but still develop against the local version.
   303      - If you are using `goimports` and other tools, you might want to upgrade
   304        binaries -- for example, when using vim-go's auto-format-on-save feature,
   305        my old binaries took well over 5~10 seconds to compute the import paths.
   306        This was fixed when I switched to using go1.19, and upgraded the binaries
   307        used by vim-go
   308  
   309  v2.0.6 - 25 Aug 2022
   310  [Bug fixes][Security]
   311    * [jwe] Agreement Party UInfo and VInfo (apv/apu) were not properly being
   312      passed to the functions to compute the aad when encrypting using ECDH-ES
   313      family of algorithms. Therefore, when using apu/apv, messages encrypted
   314      via this module would have failed to be properly decrypted.
   315  
   316      Please note that bogus encrypted messages would not have succeed being
   317      decrypted (i.e. this problem does not allow spoofed messages to be decrypted).
   318      Therefore this would not have caused unwanted data to to creep in --
   319      however it did pose problems for data to be sent and decrypted from this module
   320      when using ECDH-ES with apu/apv.
   321  
   322      While not extensively tested, we believe this regression was introduced
   323      with the v2 release.
   324  
   325  v2.0.5 - 11 Aug 2022
   326  [Bug fixes]
   327    * [jwt] Remove stray debug log
   328    * [jwk] Fix x5u field name, caused by a typo
   329    * [misc] Update golangci-lint action to v3; v2 was causing weird problems
   330  
   331  v2.0.4 - 19 Jul 2022
   332  [Bug Fixes]
   333    * [jwk] github.com/lestrrat-go/httprc, which jwk.Cache depends on,
   334      had a problem with inserting URLs to be re-fetched into its queue.
   335      As a result it could have been the case that some JWKS were not
   336      updated properly. Please upgrade if you use jwk.Cache.
   337  
   338    * [jwk] cert.Get could fail with an out of bounds index look up
   339  
   340    * [jwk] Fix doc buglet in `KeyType()` method
   341  
   342  [New Features]
   343    * [jws] Add `jws.WithMultipleKeysPerKeyID()` sub-option to allow non-unique
   344      key IDs in a given JWK set. By default we assume that a key ID is unique
   345      within a key set, but enabling this option allows you to handle JWK sets
   346      that contain multiple keys that contain the same key ID.
   347  
   348    * [jwt] Before v2.0.1, sub-second accuracy for time based fields
   349      (i.e. `iat`, `exp`, `nbf`) were not respected. Because of this the code
   350      to evaluate this code had always truncated any-subsecond portion
   351      of these fields, and therefore no sub-second comparisons worked.
   352      A new option for validation `jwt.WithTruncation()` has been added
   353      to workaround this. This option controls the value used to truncate
   354      the time fields. When set to 0, sub-second comparison would be
   355      possible.
   356      FIY, truncatation will still happen because we do not want to
   357      use the monotonic clocks when making comparisons. It's just that
   358      truncating using `0` as its argument effectively only strips out
   359      the monotonic clock
   360  
   361  v2.0.3 - 13 Jun 2022
   362  [Bug Fixes]
   363    * [jwk] Update dependency on github.com/lestrrat-go/httprc to v1.0.2 to
   364      avoid unintended blocking in the update goroutine for jwk.Cache
   365  
   366  v2.0.2 - 23 May 2022
   367  [Bug Fixes][Security]
   368    * [jwe] An old bug from at least 7 years ago existed in handling AES-CBC unpadding,
   369      where the unpad operation might remove more bytes than necessary (#744)
   370      This affects all jwx code that is available before v2.0.2 and v1.2.25.
   371  
   372  [New Features]
   373    * [jwt] RFC3339 timestamps are also accepted for Numeric Date types in JWT tokens.
   374      This allows users to parse servers that errnously use RFC3339 timestamps in
   375      some pre-defined fields. You can change this behavior by setting 
   376      `jwt.WithNumericDateParsePedantic` to `false`
   377    * [jwt] `jwt.WithNumericDateParsePedantic` has been added. This is a global
   378      option that is set using `jwt.Settings`
   379  
   380  v2.0.1 - 06 May 2022
   381    * [jwk] `jwk.Set` had erronously been documented as not returning an error
   382      when the same key already exists in the set. This is a behavior change
   383      since v2, and it was missing in the docs (#730)
   384    * [jwt] `jwt.ErrMissingRequiredClaim` has been deprecated. Please use
   385      `jwt.ErrRequiredClaim` instead.
   386    * [jwt] `jwt.WithNumericDateParsePrecision` and `jwt.WithNumericDateFormatPrecision`
   387      have been added to parse and format fractional seconds. These options can be
   388      passed to `jwt.Settings`.
   389      The default precision is set to 0, and fractional portions are not parsed nor
   390      formatted. The precision may be set up to 9.
   391    * `golang.org/x/crypto` has been upgraded (#724)
   392    * `io/ioutil` has been removed from the source code.
   393  
   394  v2.0.0 - 24 Apr 2022
   395    * This i the first v2 release, which represents a set of design changes
   396      that were learnt over the previous 2 years. As a result the v2 API
   397      should be much more consistent and uniform across packages, and
   398      should be much more flexible to accomodate real-world needs.
   399      
   400      For a complete list of changes, please see the Changes-v2.md file,
   401      or check the diff at https://github.com/lestrrat-go/jwx/compare/v1...v2
   402  
   403  [Miscellaneous]
   404    * Minor house cleaning on code generation tools
   405  
   406  [jwt]
   407    * `jwt.ErrMissingRequiredClaim()` has been added
   408  
   409  v2.0.0-beta2 - 16 Apr 2022
   410  [jwk]
   411    * Updated `jwk.Set` API and reflected pending changes from v1 which were
   412      left over. Please see Changes-v2.md file for details.
   413  
   414    * Added `jwk.CachedSet`, a shim over `jwk.Cache` that allows you to
   415      have to write wrappers around `jwk.Cache` that retrieves a particular
   416      `jwk.Set` out of it. You can use it to, for example, pass `jwk.CachedSet`
   417      to a `jws.Verify`
   418  
   419        cache := jwk.NewCache(ctx)
   420        cache.Register(ctx, jwksURL)
   421        cachedSet := jwk.NewCachedSet(cache, jwksURL)
   422        jws.Verify(signed, jws.WithKeySet(cachedSet))
   423  
   424  v2.0.0-beta1 - 09 Apr 2022
   425  [Miscellaneous]
   426    * Renamed Changes.v2 to Changes-v2.md
   427    * Housecleaning for lint action.
   428    * While v2 was not affected, ported over equivalent test for #681 to catch
   429      regressions in the future.
   430    * Please note that there is no stability guarantees on pre-releases.
   431  
   432  v2.0.0-alpha1 - 04 Apr 2022
   433    * Initial pre-release of v2 line. Please note that there is no stability guarantees
   434      on pre-releases.