Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Employ user verification mechanisms from OpenPGP v5 #4946

Merged
merged 9 commits into from
Feb 13, 2023

Conversation

rrrooommmaaa
Copy link
Contributor

@rrrooommmaaa rrrooommmaaa commented Feb 9, 2023

This PR employs user verification mechanisms from OpenPGP v5

On diagnostics page an unverified user id looks like this
image

As for Key parsing, all unverified user ids are omitted from the Key.identities property.

close #4588


Tests (delete all except exactly one):

  • Tests added or updated

To be filled by reviewers

I have reviewed that this PR... (tick whichever items you personally focused on during this review):

  • addresses the issue it closes (if any)
  • code is readable and understandable
  • is accompanied with tests, or tests are not needed
  • is free of vulnerabilities
  • is documented clearly and usefully, or doesn't need documentation

// todo: `email-addresses` parser used by OpenPGP.js consider top-level domains to be valid for emails e.g. address@domain
// should we allow it too (or use `email-addresses` package when manipulating user ids in keys?
// For now, I'm explicitly `localhost` domain, which is perfectly legal for testing
return /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|localhost|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i.test(
Copy link
Contributor Author

@rrrooommmaaa rrrooommmaaa Feb 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm re-using Str.parseEmail method to re-extract email from userids verified by OpenPGP.js, as those verification methods only return userid string (and all valid userids are supposed to have email address embedded).
OpenPGP.js is using email-addresses NPM package to extract email address from the userid.
So several questions/issues arise:

  • Should we use email-addresses package or our own version for the re-extraction?
  • If using own version, should we validate the email address? email-addresses validation is more lenient, as it allows a top level domain only, e.g. address@domain. As I understand, this type of validation isn't convenient for compose boxes, should we have a separate validation option when extracting emails from userids, like `VALIDATE-LENIENT"?

I had to explicitly add localhost as a valid domain into the regex

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's good as you've done it. It would indeed be odd to allow hello@yup as a valid email when composing. Similarly, having two ways to verify based on context is unnecessary complication. I think it doesn't necessarily need 100% alignment with OpenPGP.js. If there is an edge case when one check passes and the other doesn't, the result is still a failed action. Actually there's currently three places that validate email: this, OpenPGP.js, Gmail API. So it will never be unified. As long as nobody reports a problem, I'd leave it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per above comment I'd remove the todo since I think it's ok as is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@rrrooommmaaa rrrooommmaaa marked this pull request as ready for review February 11, 2023 09:51
Comment on lines 310 to 311
result.set(`User id ${i}`, key.users[i].userID!.userID);
result.set(`User id ${i}`, users[i].valid ? users[i].userID : '* REVOKED, INVALID OR MISSING SIGNATURE *');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could say * REVOKED, INVALID OR MISSING SIGNATURE * ${users[i].userID} for easier debugging

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// todo: `email-addresses` parser used by OpenPGP.js consider top-level domains to be valid for emails e.g. address@domain
// should we allow it too (or use `email-addresses` package when manipulating user ids in keys?
// For now, I'm explicitly `localhost` domain, which is perfectly legal for testing
return /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|localhost|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i.test(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per above comment I'd remove the todo since I think it's ok as is

Copy link
Collaborator

@tomholub tomholub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@rrrooommmaaa rrrooommmaaa merged commit da4363a into master Feb 13, 2023
@rrrooommmaaa rrrooommmaaa deleted the issue-4588-verify-uids branch February 13, 2023 15:25
FlowCryptRobot pushed a commit that referenced this pull request Feb 22, 2023
…#4943)

* build(deps-dev): bump @openpgp/web-stream-tools from 0.0.11 to 0.0.13

Bumps [@openpgp/web-stream-tools](https://github.com/openpgpjs/web-stream-tools) from 0.0.11 to 0.0.13.
- [Release notes](https://github.com/openpgpjs/web-stream-tools/releases)
- [Commits](openpgpjs/web-stream-tools@v0.0.11...v0.0.13)

---
updated-dependencies:
- dependency-name: "@openpgp/web-stream-tools"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* #4282 fix: duplicated contact search result (#4944)

* fix: dupliated contact search result

* feat: added ui test

* fix: pr review

* #4940 Update build script to not produce .bak files (#4945)

* update build script

* rename STREAMS_OUTDIR to STREAMS_FILES

* #4844 feat: renew id token when expires (#4949)

* feat: renew id token when expires

* fix: pr reviews

* Employ user verification mechanisms from OpenPGP v5 (#4946)

* reuse getPrimeryUser method

* verifying key users

* allow localhost domain for email address

* fix

* fix and test

* use verified users in key-import-ui

* PR review fixes

---------

Co-authored-by: Roman Shevchenko <[email protected]>

* prevent pasting large input on secure compose (#4914)

* prevent pasting large input on secure compose

* Added type definition for SquireEditor.getRoot()

* apply requested change

* update

* cleanup

* update

* consider selection

* add warning modal

* update

* update

* update

---------

Co-authored-by: Roman Shevchenko <[email protected]>
Co-authored-by: Roman Shevchenko <[email protected]>

* fix

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Ioan Moldovan <[email protected]>
Co-authored-by: Roma Sosnovsky <[email protected]>
Co-authored-by: Roman <[email protected]>
Co-authored-by: Roman Shevchenko <[email protected]>
Co-authored-by: Mart G <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revoked Uids are considered as valid
2 participants