GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add support for SCRAM-SHA-256-PLUS i.e. channel binding by jawj · Pull Request #3356 · brianc/node-postgres Conversation
Contributor
Hi all. I hope you'll consider this patch, which adds support for SCRAM-SHA-256-PLUS. SCRAM-SHA-256-PLUS on Postgres enables So far I've tested it working against Neon (who support SCRAM-SHA-256-PLUS) and Supabase (who don't), and with the new Feel free to make any changes you think appropriate.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
brianc
reviewed
Uh oh!
There was an error while loading. Please reload this page.
brianc
reviewed
Uh oh!
There was an error while loading. Please reload this page.
brianc
reviewed
Uh oh!
There was an error while loading. Please reload this page.
brianc
requested changes
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for the PR! Put a few comments on here. My main concern is changing the default behavior - as much as its a pain on users to enable the feature, I'd rather it be an opt-in thing vs a default...otherwise it's a slight breaking change, which requires a new semver major. Would be nice to add a callout in the docs about this as well...though I can handle that if you don't want to
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
charmander
requested changes
Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of a separate package, could
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Never mind – that wouldn’t be spec-compliant and I missed that the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do appreciate that bringing in a whole X509 parsing library (and then parsing the whole certificate, when all we actually need is the signature algorithm) feels like overkill. I did actually have a go at doing the minimum necessary parsing manually: see https://gist.github.com/jawj/04a90e51196ac054d6741c8d079d9cff The reason I didn't go with that in the PR is that I haven't been able to find a list of either (a) what signature algorithms could theoretically be used or even (b) what signature algorithms would cover 99% of cases. But I strongly suspect that the cases covered by this code would be almost all of them, and any missing ones might be plugged if people filed issues about them. So this could be another option?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I am absolutely totally down w/ the "make it mostly work and patch if different algorithms show up later" mode if it removes the requirement to pull in an entire dependency! I wouldn't say it's a mandatory change but certainly would be welcome. 😄 I have tried very hard over the years to keep as many 3rd party dependencies out of the code as possible just because....well...left-pad and all that stuff, ya know?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @brianc Good to hear: I'm all for that approach. I've done a bit more work on this code (including putting a base64 hash of the public cert in the error message, to make it easy to report failures in a way we can investigate) and removed the dependency.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests would work just as well if there were no implementation of channel binding at all, so this PR probably needs a targeted test from someone.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
hmm good question - would need to make it something that's thread through the pool to its create method as well. The pool passes its own constructor options to the client which probably if i were designing the API today from scratch I wouldn't do but..that ship sailed like 10 years ago 🙃 - so it should just be able to be set on the pool as well? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@jawj ruh roh! looks like a test is failing (should be an easy fix). There are a lot of tests - some are duplicates, etc. If you just wanna run a subset locally for faster turn around you can run |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I think the tests should be passing again now. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
BTW, you may find this interesting: https://bytebybyte.dev/?postgres (Writing this was how I figured out how channel binding works). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I just noticed that legacy crypto expects But a potential annoyance is that SubtleCrypto supports a very limited range of hash functions compared to Node's legacy crypto. If people run into this as a problem with real certificates, it could be worth considering using legacy crypto, when available, more widely. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
OK, this seems to have stalled a little in relation to testing. To summarise the previous position:
I've just added some more unit tests:
As part of the testing, I realised I have not provided a way to enforce (rather than just enable) channel binding. But since the client's response is different when it does and doesn't think the server supports channel binding, I don't think this makes a big difference to the risk of MITM attacks. @brianc and @charmander, how do you think we can move this forward? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sorry for the delay - just not sure what's missing here at this point. Code looks good to me, unfortunately some of the tests aren't passing is the only thing I can see now. 😱 Thanks for doing all the hard work here! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks @brianc. Tests are now passing! I just modified the SCRAM-SHA-256-PLUS test to only expect SCRAM-SHA-256-PLUS if we're on an SSL connection (because otherwise there's no certificate to check). So maybe this is ready to merge? As I said before, in an ideal world this would probably have CI tests (1) over an SSL connection and, even better, (2) with a variety of certificate signature algorithms. But I'm probably not the right person to make those larger changes to the testing setup, and since this is an opt-in feature I think it's probably OK to go ahead without those for now. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@brianc I think this is ready to merge (see above). Any remaining blockers? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Wow this is really fabulous. Thanks so much for going out of your way to take the time to add this. Just got back from a relatively long trip to south america. Merging this now! Will do a release tomorrow AM (I like to release in morning my time just in case something blows up I have more of the day to react to problems) 😄 ❤️ |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@jawj published! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Hi @brianc. I see some changes are proposed for connection security in v9 As noted there, I'm not sure I like these specific changes very much! But while we're trying to be more like libpq, perhaps this would this be a good time to recognise libpq's |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.