paragonie/paseto
Reference PHP implementation of PASETO security tokens (v3/v4): safer alternative to JWT/JWE/JWS with modern crypto. Supports local and public tokens, includes PASERK integration for key serialization/wrapping, and works with Sodium (or sodium_compat).
This is mostly just a maintenance release that bumps some dependencies.
Though, a new dependency was added (symfony/polyfill-php83) and some of the existing dependencies had minor version bumps.
Full Changelog: https://github.com/paragonie/paseto/compare/v3.4.0...v3.5.0
Full Changelog: https://github.com/paragonie/paseto/compare/v3.3.0...v3.4.0
Version 3.3.0 has been deleted as it was accidentally tagged early.
Include updated test vector
Updated minimum version of paragonie/easy-ecc to 1.1.0.
Updated minimum version of paragonie/easy-ecc to 1.1.0.
Full Changelog: https://github.com/paragonie/paseto/compare/v3.1.1...v3.2.0
has method since get throws Exception by @oojacoboo in https://github.com/paragonie/paseto/pull/165Full Changelog: https://github.com/paragonie/paseto/compare/v3.0.2...v3.1.0
AsymmetricSecretKey now validates that the public key is correct for a given Ed25519 seed.AsymmetricSecretKey now validates that the public key is correct for a given Ed25519 seed.__toString() weirdness for PHP < 7.4isForVersion() helper to PASETO Key objects.
$key->isForVersion(new Version4) will return true if the key is intended for PASETO v4, and false otherwise.encodePem() to AsymmetricSecretKey and AsymmetricPublicKey.AsymmetricSecretKey::encode() for Version3 is to return the base64url encoding of the secret scalar, not of the PEM-encoded string.This is a feature release for the PHP implementation of PASETO.
->setNonExpiring(true) on your Builder or Parser objects.This is v2.0.0 of the PHP implementation of PASETO.
At a glance:
Version2 to Version4. If you weren't defining this in your code and relying on the default settings, you will need to be explicit before you upgrade.We've moved the PASETO Specification to another repository. In this updated specification, we have defined two new PASETO protocol versions.
If you'd like to read the full rationale for the design decisions made in Versions 3 and 4, these have been documented clearly here.
Although we strongly recommend migrating to the new versions (v1 -> v3, v2 -> v4), you are fine to continue using v1/v2 if the following assumptions hold true:
random_bytes() is working correctly (i.e. talking to the kernel's CSPRNG).v1.public tokens:
v2.local tokens:
If any of these assumptions are invalid, you MUST use the new versions to get the security properties you need out of PASETO. See the brief yet concise Migration Guide for more information.
If you aren't 100% sure you don't need the security properties offered by v3/v4, and have nothing preventing you from making the change (i.e. a hard dependency on RSA keys), then you should lean towards migrating.
It's better to have it and not need it, than need it and not have it.
Generally, no. That's why we aren't immediately deprecating their use. The complete answer requires a bit of nuance:
AEAD modes based on Polynomial MACs, such as AES-GCM and XChaCha20-Poly1305, do not offer message- or key-commitment. This means it's possible to construct two different plaintexts that, under two different keys, yield the same (nonce, ciphertext, tag) tuple. This means that a given PASETO v2 token might decode to two different payloads, under two different keys.
@thaidn disclosed an unfortunate failure mode that's unlikely to ever happen: If the CSPRNG returns a predictable output (for example, all NUL bytes), then the derived nonce will be the hash of your plaintext payload. RNG failures with PHP 7's CSPRNG are fatal errors, so a silently-failing CSPRNG is very unlikely, but if it ever did happen, attackers could leak your plaintext by brute-forcing the hash that produces the nonce. This is only relevant to v1.local and v2.local.
How RSA signatures are used in PASETO v1.public tokens do not offer Exclusive Ownership. Learn more about why it matters.
Bottom-line: digital signatures yield guarantees about a message for a given public key, not the other way round. -- Thomas Pornin
These are all nuisances we sought to fix in Version 3 and Version 4. As a result, the new versions offer a more robust argument for their security in a wider range of real-world use cases.
Use this to commit/verify that the same key was used for a given PASETO:
<?php
function v2key_commit(SymmetricKey $key): string {
return sodium_bin2hex(
sodium_crypto_generichash('MITIGATION_COMMIT_KEY', $key->raw())
);
}
function v2key_verify(SymmetricKey $key, string $commitment): bool {
$calc = v2key_commit($key);
return hash_equals($calc, $commitment);
}
Just store the commitment hash inside the footer, then verify it before parsing. Since this will be bundled with the token (and cryptographically bound to it through the Poly1305 authentication tag), even if an attacker can perform some trickery, v2key_verify() will return false if the target is decrypting the token with the wrong key.
No, a CVE ID is not appropriate for non-vulnerabilities.
If any system is specifically impacted by the Poly1305 issue in v2.local tokens, and sets up the condition that makes the complex attack possible, then a CVE would be appropriate for that specific application. This generally means "wrote our own key-wrapping scheme based on AES-GCM or ChaCha20-Poly1305".
Although the RNG failure mode sounds scary, the security of your entire system depends on the CSPRNG not failing. This is sort of like getting a DoS attack to work from root. You will almost certainly never be impacted by this.
If any system is affected by the lack of Exclusive Ownership in v1.public tokens, then a) we want to hear about this system and b) a CVE definitely would be appropriate for whatever was built--but EO was never a stated goal for v1.public tokens, so its absence doesn't qualify as a vulnerability in PASETO.
We believe that requesting a CVE identifier out of an abundance of caution will only create alert fatigue for the overwhelming majority of systems that will not be at risk.
The RFC work has been moved to paseto-standard/paseto-rfc
Fixes:
isValid()It turns out, we don't need permission from the IETF to use PASETO in the real world (i.e. OAuth2). This is fortunate, because it's unlikely for them to accept a JWT alternative in the first place, no matter how doomed their christened standard may be.
Based on the feedback we've already received from security and cryptography experts around the world, this is simple and usable enough to use in the real world. So there's no point in delaying a stable release any further.
The documentation and reference implementation has been updated with some feedback from the RFC review process (i.e. optional footer handling).
Protocol changes:
None. We're quite happy with the way Paseto is currently designed.
PHP Library Changes:
Documentation Changes:
We've completed draft-00 of our proposed RFC. This makes us one step closer to tagging v1.0.0.
Protocol changes:
None. We're quite happy with the way Paseto is currently designed.
PHP Library Changes:
setSignatureMode() instead of setEncryptionMode() for Version1. The end result was the same, but it's important to be explicit about our intent in our implementation.Protocol changes:
None. We're quite happy with the way Paseto is currently designed.
PHP Library Changes:
0 would not append to the token due to PHP's treatment of falsy values.Other Changes:
Special thanks to @aidantwoods for contributing a lot to this minor release.
Protocol changes:
None. We're quite happy with the way Paseto is currently designed.
PHP Library Changes:
Builder class, to make key management easier to reason about.Biggest change: We've changed our name from PAST to Paseto. It should be easier to find in a Google search.
Other fixes since v0.3.0:
This may be our last pre-1.0.0 release. The only thing left to do (barring the discovery of any cryptography flaws unique to Paseto) is documentation work, including drafting an RFC to submit to the IETF.
A lot has changed since v0.2.0! PAST is now a lot faster, simpler, and has a greater degree of misuse resistance.
seal has been removed.auth has been removed.enc has been renamed to local.sign has been renamed to public.PAST now has a basic reference implementation and a first draft for the specification.
Notable change to the cryptography since v0.1.0: We now feed data into MACs and signature algorithms in such a way to minimize the risk of canonicalization attacks. Although no practical exploits are known for HMAC-SHA384 or Poly1305, simply concatenating different values together as one giant string seems like a needlessly cavalier design decision. Our new serialization format should effectively mitigate any risks.
We're going to take some time to accept feedback from the community, polish up the documentation, and request review from professional cryptographers.
Unless a game-over protocol flaw is discovered, the current implementation should be assumed stable enough to serve as a reference point for developing implementations in other programming languages. However, don't deploy this in production until v1.0.0 has been tagged and released.
How can I help you explore Laravel packages today?