Better HN
topnewbestaskshowjobs
Log inSign up

CiPHPerCoder

6,663 karma · joined Feb 25, 2016 (10y ago) · 1,775 submissions

My name is Scott. I do a lot of open source security research, and cryptography.

Previously AWS Cryptography (2019 - 2023).

Unless otherwise stated, my opinions are my own and do not reflect my employer.

https://scottarc.blog/about/

Submissions

comment 4y ago · link · parent

> But what I believe someguydave was referring to was stuff like smartcard/Yubikey support, not different uses of encryption and signing.

https://twitter.com/FiloSottile/status/1474941666545086465 ¯\_(ツ)_/¯

comment 4y ago · link · parent

> GnuPG has stood up pretty well for three decades

Make sure you also look for libgcrypt, which had a lot of cryptographic weaknesses in the 2010s.

https://www.cvedetails.com/vulnerability-list/vendor_id-4711...

comment 4y ago · link · parent

I don't read your wiki, so no, you were not the cause of it.

This list item was prompted by a private discussion with friends.

comment 4y ago · link · parent

It still uses better encryption than Telegram, Threema, and several other products that market themselves as "private messaging" apps.

comment 4y ago · link · parent

More specifically, Trillian is analogous to Chronicle, which is what Gossamer uses as its underlying ledger. But yeah, there's a lot of similarities. You're on the right track. :)

comment 4y ago · link · parent

Gossamer is a 2017 design of an idea that was first published in 2015. However, it was exclusively focused on the PHP community from its inception, so it's unsurprising that nobody's heard of it.

comment 4y ago · link · parent

Solving the problem you care about requires doing what I just said. :)

And, yes, there is a lot of work necessary to get WordPress to use Gossamer. I can't guarantee a deadline right now, but 2022 looks hopeful.

comment 4y ago · link · parent

It isn't brand new, no.

comment 4y ago · link · parent

Yes: https://github.com/paragonie/libgossamer/blob/master/docs/tu...

The intention was to allow security vendors to offer code reviews of open source dependencies, and you can choose which you trust. This mechanizes Linus's Law and ensures there's an audit trail with "many eyeballs".

comment 4y ago · link · parent

It's been around since 2019, and has been discussed heavily on Hacker News.

comment 4y ago · link · parent

A "complete replacement" for GPG would be a dumb idea to begin with.

You want a specific tool for each of these use-cases. Choose one from the list for each use case.

1. Private messaging: Signal, WhatsApp, Cwtch

2. File encryption: age

3. Encrypted backups: age + a Reed-Solomon encoder for catching flipped bits

4. Digital signatures: minisign, signify, OpenSSH signatures

The problem with GPG (and with PGP in general) is it tried to do too many things. Complexity is the enemy of security.

comment 4y ago · link · parent

Consider, for the age and minisign/signify use-case: https://gossamer.tools

comment 4y ago · link · parent

Calling age an unknown upstart is a weird take.

comment 4y ago · link · parent

This is one of the most fun papers I've read in a while. I won't spoil anything; sit down with it when you have time and be prepared to laugh a bit.

comment 5y ago · link · parent

OCB isn't committing, so it doesn't solve the stated problem.

comment 5y ago · link · parent

Worth noting that the 10 and 7 are double ChaCha rounds, which means that the strength of BLAKE3's bit diffusion is closer to ChaCha14 than ChaCha7.

Given that the best attack against ChaCha fails to break ChaCha8, it's reasonable to conclude that BLAKE3 is secure.

comment 5y ago · link · parent

I maintain an account only so nobody can impersonate me to others.

comment 5y ago · link · parent

This tracks with their other choices and behaviors, unfortunately.

comment 5y ago · link · parent

How do we pay for this?

comment 5y ago · link · parent

If I give you a map of kid -> key material that looks like this:

  {
      "my-super-cool-key-id": "some hs256 secret key string goes here",
      "another-key-id": "-----BEGIN RSA PUBLIC KEY-----\n ... snip ...",
      "yet-another-key-id": "----BEGIN EC PUBLIC KEY-----\n... snip ..."
  }
And let's say you've got three different API endpoints, which each hard-code a specific algorithm (one HS256, one PS256, one ES256). But, because of the framework you're developing in, you're expected to provide a single configuration object containing a map of key IDs used by the entire application. (This is a common framework quirk.)

What stops you from swapping out the kid in a JWT's header and getting the underlying library to use the wrong key type for the endpoint that accepts HS256?

    {
      "alg": "HS256",
  -   "kid": "my-super-cool-key-id",
  +   "kid": "yet-another-key-id",
      "typ": "JWT"
    }
The answer varies per implementation. The JWT standards do not call this misuse potential out at all.

Strictly listing the keys does not, at all, hard-code the algorithm those keys are used with in every possible programming language and runtime.

Some languages (Java) accidentally prevent this through type safety in the low-level crypto APIs. Others accidentally prevent this by not supporting the kid header.

I have yet to see a JWT library that deliberately prevents this misuse potential. Is that the library's fault? Or their defaults' fault?

EDIT:

The fix, by the way, requires doing this:

  {
      "my-super-cool-key-id": {
          "alg": "HS256",
          "key": "some hs256 secret key string goes here"
      },
      "another-key-id": {
          "alg": "PS256",
          "key": "-----BEGIN RSA PUBLIC KEY-----\n ... snip ..."
      },
      "yet-another-key-id": {
          "alg": "ES256",
          "key": "----BEGIN EC PUBLIC KEY-----\n... snip ..."
      }
  }
And then verifying that the alg for the key matches the alg for the token before attempting to verify the signature/MAC.

comment 5y ago · link · parent

> Blame the library, or its defaults.

Every JWT proponent says that, but it's a misuse that shows up in multiple libraries, in multiple languages, and isn't explicitly called out in the JWT Best Practices RFC at all.

I'm going to blame the standard for being error-prone.

There's nothing in any JWT RFC, to date, that calls out the need for cryptographic keys to be the raw key material in addition to its parameter choices, rather than just the raw key material. That's a fault of the standard.

That's not a single library's fault. That's the standard's fault.

PASETO has this to say: https://github.com/paseto-standard/paseto-spec/blob/master/d...

> As for the key ID attack, this sounds like it's just a trick to know where the private key is located? It shouldn't be publicly accessible.

This doesn't involve private keys at all. Look at the proof of concept code. https://github.com/firebase/php-jwt/files/6966712/php-jwt-po...

comment 5y ago · link · parent

> Why all the hate for JWTs?

> Just pick a crypto scheme and the JWT is just an encoding that makes it easier to use.

That's not what JWT is, but I can understand why someone would be misled into believing that.

JWT isn't just an encoding format, it also includes a crypto algorithm negotiation protocol that lets the attacker choose the algorithm. Even if you strictly allow-list which algorithm you want to support, you can accidentally bypass this control in many libraries if you support the `kid` (key ID) header. [1]

It also allows attackers to completely strip the security. [2] [3]

Put shortly, JWT is a gun aimed directly at your foot. That's why there's so much hate for JWTs.

[1] https://github.com/firebase/php-jwt/issues/351

[2] https://paragonie.com/blog/2017/03/jwt-json-web-tokens-is-ba...

[3] https://www.howmanydayssinceajwtalgnonevuln.com/

comment 5y ago · link · parent

For PASETO, the quick guide to library support is https://paseto.io

comment 5y ago · link · parent

> However, it also recommends RSA & classic Diffie-Hellman over multiplicative groups of integers, while Suite B exclusively recommended elliptic curve-based public-key crypto.

I think their reasoning is probably along the lines of "large RSA keys will buy you a little bit more time to migrate than small ECC keys if a quantum computer emerged today, due to memory constraints with what we think quantum computer will look like".

comment 5y ago · link · parent

> * JWT can be secure if you are careful

https://www.howmanydayssinceajwtalgnonevuln.com/

https://www.zofrex.com/blog/2020/10/20/alg-none-jwt-nhs-cont...

https://twitter.com/SchmiegSophie/status/1413248896227155968

https://twitter.com/tqbf/status/1414087907938377735

etc.

> * there is wide support for JWT. (See for example this IETF draft https://datatracker.ietf.org/doc/html/draft-ietf-oauth-acces... as well as the numerous libraries)

Yes, and my intention is to make sure there is wide support for PASETO in the near future too.

> Maybe paseto can eventually displace JWT, but I have a hard time seeing how that happens.

It won't ever 100% displace JWT in the same way that we won't ever 100% displace PHP 4 from the Internet, or the legions of badly written tutorials full of SQL Injection vulnerabilities that new programmers learn from.

The goal isn't to displace JWT, though. The goal is to provide a secure-by-default, easy-to-use, hard-to-misuse alternative.

After all, just because it's possible to implement a set of building blocks "securely" doesn't mean the kit is secure. I wrote more about this here: https://paragonie.com/blog/2019/10/against-agility-in-crypto...

But even if you don't care about all of that, the upcoming PASETO versions (v3/v4) offer cryptographic properties that JWT does not, such as exclusive ownership. https://github.com/paragonie/paseto/blob/master/docs/Rationa...

------

Also, in case it wasn't obvious: PASERK is still a work-in-progress; things might change. Wait until you see a `1.0` tag before trying to implement it.

There is a reference implementation in PHP, but that's also experimental and no stable release has occurred there yet.

comment 5y ago · link · parent

> Great article. How should the community fix this problem with bad and dangerous tutorials?

By updating all of the old, insecure tutorials to redirect towards secure answers instead.

Details here: https://paragonie.com/blog/2018/01/our-ambitious-plan-make-i...

comment 5y ago · link · parent

Suggested title: Publicly Available Standards by ISO

ISO is somewhat unique in requiring you to pay money to even know what the standard says before you can ever think about being in compliance.

Most other standards organizations (i.e. NIST, IETF, W3C) do not have this weird financial burden, so merely "Publicly Available Standards" doesn't sell the significance of this.

Making their standards publicly available is a good move by ISO. I hope we see more of this.

comment 5y ago · link · parent

https://paseto.io

149.

Gossamer: Supply-Chain Security for the PHP Ecosystem(gossamer.tools ↗)

2 points · by CiPHPerCoder · 5y ago · discuss

comment 6y ago · link · parent

> Is there anything that PHP is developing or adopting that can not be had at other established languages?

Modern cryptography is baked in since 7.2.

https://libsodium.gitbook.io/doc/bindings_for_other_language...

Most of the people who shit on PHP have a lot of love for other languages. A survey of the cryptography features the "favored" languages offer will almost certainly fall into two camps:

1. "We wrap OpenSSL"

2. "Go compile it yourself" (i.e. there is nothing baked in)

There's a lot of badness with OpenSSL's API design, especially with asymmetric cryptography. For a fun exercise in these languages, try encrypting with RSA with OAEP padding, but without using SHA1 as your hash function.

For completeness, PHP is one of the languages that wraps OpenSSL too! But it also wraps libsodium, and the community has been moving towards libsodium (unless they need something from OpenSSL for the sake of backwards compatibility) since early in the 7.x series.

If you're going to provide cryptography features in your language, but you aren't shipping modern cryptography in your standard library, you're underperforming what PHP has offered for years at this point. The easiest way to meet the standard that PHP 7.2+ establishes is to add libsodium to your language's standard library.

(There are salient arguments for "why even provide a cryptography feature as part of the language at all?" but most of the languages that see real world deployment are already doing that.)

1
456
60