Giter Site home page Giter Site logo

Comments (10)

MarkLodato avatar MarkLodato commented on July 19, 2024 1

I recommend against this. Such a feature has a history of security vulnerabilities, as @trishankatdatadog has said. The recommended solution is to make this a property of the public key so that only one algorithm can be used per key. If the public key / certificate does not indicate the hash algorithm (as is the case with x.509 certificates for ECDSA), then the application can hard-code a mapping as JWS does. For example, P-256 => SHA-256, P-384 => SHA-384, etc.

@laurentsimon can further expand if needed.

from dsse.

trishankatdatadog avatar trishankatdatadog commented on July 19, 2024

This shouldn't be part of the signature, no. It should be part of the signed message. Otherwise you run into the same high-severity security issue CS-DRNT15-1 identified here.

from dsse.

iamwillbar avatar iamwillbar commented on July 19, 2024

@trishankatdatadog thanks for sharing that, wasn't aware of that particular vulnerability. It can't be part of the payload because the envelope is agnostic of the payload but it could be in the envelope.

The specification does allow different signatures to use different algorithms (or at least doesn't appear to not allow that) so it could be in the signature block as long as it was incorporated into the PAE when generating the signature.

from dsse.

trishankatdatadog avatar trishankatdatadog commented on July 19, 2024

The specification does allow different signatures to use different algorithms (or at least doesn't appear to not allow that) so it could be in the signature block as long as it was incorporated into the PAE when generating the signature.

The envelope alone cannot safely solve this issue. I think it is a lower-level issue.

from dsse.

mnm678 avatar mnm678 commented on July 19, 2024

As @trishankatdatadog mentioned, the signing algorithm needs to be included in a trusted location. Another solution to the issue of determining the algorithm could be to define the algorithm when the key is delegated to or initially distributed

from dsse.

dlorenc avatar dlorenc commented on July 19, 2024

Yeah, including it on the key is the typical solution.

from dsse.

trishankatdatadog avatar trishankatdatadog commented on July 19, 2024

For example, like so

from dsse.

laurentsimon avatar laurentsimon commented on July 19, 2024

As others pointed out, the key type or other key metadata should never be taken from a parameter that is attacker-controlled or something that may be tampered with by an attacker. Having such a field is a source of vulnerabilities known as 'in-band key negotiations'.

It's a common problem in JWS (alg:none or mis-interpreting an RSA key as an HMAC key, see this example). This is still a source of vulnerabilities today, see here for a recent example. AWS cloud crypto library was also found vulnerable to this sort of attack last year - an attacker could change a ciphertext type from AES-GCM to AES-CBC and use the decrypter as a decryption oracle - see here and here.

We should think as keys not just as raw bytes, but as raw bytes + metadata. The metadata should contain all the parameters that are necessary to instantiate a signing or verification routine (signature type, hash type, etc). The TUF's format works, so long as the key is retrieved from a trusted location, for example signed by a trusted server/CA or communicated out-of-band - the latter does not scale well, though.

Theoretically, one can use x509 certificates as source of truth. There is a caveat Mark pointed out: algorithms defined using the Subject Public Key Info structure can describe all the necessary parameters for RSA signing keys, but not the hash algorithm for ECDSA. In the RSA case, the specification needs to be clear what the recipient should do if a cert does not define the hash: fail or default to, say, SHA512. In the ECDSA case, the specifications should define a mapping between ECDSA key sizes and hash algorithms. For example, P-256 => SHA-256, P-384 => SHA-384. An even simpler solution is to take the view that verification and signing operations will be performed on server machines (64bit arch) where SHA512 is faster. Ed25519 takes this approach and uses SHA512 even though it's a 265bit curve.

from dsse.

iamwillbar avatar iamwillbar commented on July 19, 2024

Thanks for the education all! I'll concede this is a bad idea 😄.

from dsse.

trishankatdatadog avatar trishankatdatadog commented on July 19, 2024

Thanks, Will, takes a lot to admit when incorrect.

from dsse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.