-
Notifications
You must be signed in to change notification settings - Fork 49
[Spec] Move some input validation to construction time #195
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
Conversation
@rsolomakhin - PTAL, and in particular check that this matches what we check synchronously at construction time versus asynchronously for later canMakePayment()/show() calls. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HI @stephenmcgruer, the code and the spec seem to disagree a bit. Should we get the spec into a more sensible place (re-order some checks, add some more checks here and there) and then open a bug in Chrome side to match the spec better (mostly adding more checks)?
</wpt> | ||
|
||
|
||
1. If |data|["{{SecurePaymentConfirmationRequest/credentialIds}}"] is empty, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to sync up with this Chrome code? That code should be executing in the PaymentRequest()
constructor, as far as I can see. Its sequence of checks is:
- Credential ID list: non-empty.
- Timeout: under 1 hour.
- Instrument display name: non-empty.
- Instrument icon: valid URL.
- Either payee origin or name: non-empty.
- RP ID: non-empty.
This spec here appears to have:
- Credential ID list: non-empty. ✅
- Timeout: no checks. (Spec may want to add this.) ⬅️
- Instrument icon: no checks. (Spec should check this.) 🔥
- Challenge: non-empty. (Chrome should start doing this.) 🔥
- RP ID: valid domain. (Chrome should start doing this.) 🔥
- Either payee name or origin: non-empty. ✅
- Payee origin: valid https URL. (Chrome should start doing this.) 🔥
- Instrument display name: non-empty. (Spec may want to move this up to position 3.) ⬅️
There are some differences here, including ordering of checks. Am I looking at the wrong chunk of Chrome code by accident?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this excellent and detailed overview of the differences!
There are some differences here, including ordering of checks. Am I looking at the wrong chunk of Chrome code by accident?
Nope, you are just doing a great job of reviewing <3.
I've made the following changes in the latest commit:
- Check each
credentialId
to be non-empty (I think Chrome should do this here too?) - Move
displayName
check up to after checking thechallenge
(so the order of the first few arecredentialId
checks,challenge
check,instrument
checks) - Added checking that
icon
is non-empty and valid.
Credential ID list: non-empty.
I think Chrome should also check that the individual IDs here are non-empty; WDYT?
Timeout: under 1 hour.
I think we should actually drop this check from Chrome currently, as the WebAuthn layer should handle it (https://w3c.github.io/webauthn/#:~:text=.publicKey.-,If%20the%20timeout%20member%20of%20options%20is%20present,-%2C%20check%20if%20its), and currently the timeout is only used for that layer. In the future if we make the timeout apply to the SPC dialog itself, we should do better.
WDYT?
Payee origin: valid https URL. (Chrome should start doing this.) 🔥
I think we do it here (part of the Chrome code you linked), so Chrome should be good here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RP ID: valid domain. (Chrome should start doing this.) 🔥
Btw Chrome does partially do this here, but only checks for non-empty. It's also in the wrong check-order versus the spec, should be before payeeName/payeeOrigin.
authentication-rejected.https.html | ||
</wpt> | ||
|
||
1. If |data|["{{SecurePaymentConfirmationRequest/payeeOrigin}}"] is present: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparing to the Chrome code that determines whether canMakePayment()
will return true:
- Credential IDs list: non-empty. (Fails only on compromised renderer.) ✅
- Each credential ID: non-empty. (The
PaymentRequest()
constructor should be checking this, too.) 🔥 - Timeout: under 1 hour. (Fails only on compromised renderer.) ✅
- Challenge: non-empty. (The
PaymentRequest()
constructor should be checking this, too.) 🔥 - Instrument display name: non-empty. (Fails only on compromised renderer.) ✅
- Instrument icon: valid URL. (Fails only on compromised renderer.) ✅
- Download the icon.
- Check for instrument IDs on device.
This spec here has:
- Payee origin: valid https URL. (Chrome should check that either payeer origin is a valid https URL or payee name is non empty in here.) 🔥
- Download the icon. ✅
- Check for instrument IDs on device. ✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack; I think there are no spec-changes needed from this comment? (As (2) and (4) are covered in the other comment, and since the spec shouldn't worry about compromised renderers ;)).
I will open a Chrome bug later to address all the mismatches we have identified too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making this spec more awesome 😆
This spec change LGTM and feel free to assign the Chrome bug report to me, if you need a helping hand. 👋
SHA: d002a0f Reason: push, by @stephenmcgruer Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Opened https://crbug.com/1342686 for Chrome changes, and will also send a WPT change to align tests with spec. |
…alidation, a=testonly Automatic update from web-platform-tests [SPC] Update tests for input parameter validation (#34739) See w3c/secure-payment-confirmation#195 -- wpt-commits: 4d5244f69cd4b0a5edf2dc68371d597ed5873632 wpt-pr: 34739
w3c/secure-payment-confirmation#195 clarified some of the input parameter validation in the SPC spec, and revealed some places where Chrome needed to change. This CL implements most of those changes on the renderer side. The exception is domain-checking for rpId, which will require more work. Bug: 1342686 Change-Id: I87b4f67f0bbfaf397e8937573330e65ae53751bb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3749480 Reviewed-by: Mike West <mkwst@chromium.org> Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org> Auto-Submit: Stephen McGruer <smcgruer@chromium.org> Commit-Queue: Stephen McGruer <smcgruer@chromium.org> Cr-Commit-Position: refs/heads/main@{#1024194}
…alidation, a=testonly Automatic update from web-platform-tests [SPC] Update tests for input parameter validation (#34739) See w3c/secure-payment-confirmation#195 -- wpt-commits: 4d5244f69cd4b0a5edf2dc68371d597ed5873632 wpt-pr: 34739
…alidation, a=testonly Automatic update from web-platform-tests [SPC] Update tests for input parameter validation (#34739) See w3c/secure-payment-confirmation#195 -- wpt-commits: 4d5244f69cd4b0a5edf2dc68371d597ed5873632 wpt-pr: 34739
Fixes #194
Depends on w3c/payment-request#977
Preview | Diff