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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cater for platform-specific limitations #540

Merged
merged 5 commits into from Jun 2, 2017
Merged

Cater for platform-specific limitations #540

merged 5 commits into from Jun 2, 2017

Conversation

marcoscaceres
Copy link
Member

@marcoscaceres marcoscaceres commented May 29, 2017

Through newly added web platform tests, we discovered that it was possible to crash various browsers through unreasonably large inputs (e.g., unrealistically large currency values of sizes of 10102). Or absurdly sized payment request ids values.

This differs across platforms, because of various platform specific limits. E.g., string size limits are different on Android vs on desktop platforms etc.

As such, naturally, user agents will need to guard against unreasonably-large inputs (hence this PR).

Accompanying this change, we will change the web platform tests to limit inputs to a size of 1024 characters. That's large enough to accommodate must ridiculous values (again, e.g., a currency being 1024 characters long), but not risk hitting platform specific limits.

What we might do, is include these stress tests nonetheless, but just have them in try/catch blocks, to ensure the browser doesn't crash - but make no assumption that browsers will be able to handle these large values.

@foolip, @jgraham, @zcorpan, would appreciate your input. Does the change to the web platform tests sound reasonable? Is there precedence we should follow?

N.B.: Firefox and Chrome have been patched or are being patched to fix the crashes. But more evil tests to come! 馃槇


Preview | Diff

@foolip
Copy link
Member

foolip commented May 29, 2017

I think that crash tests as part of web-platform-tests would make good sense, especially when multiple browsers have had the same bug. We already have a few tests with "crash" in the filename:

  • html/editing/dnd/crashers/dialog-001.html
  • webgl/conformance-1.0.3/conformance/...crash

Presumably, some crashes would not reproduce if testharness.js is included, so maybe a new test type will be needed eventually. However, maybe it's fine to write crash tests using testharness.js where it's possible. I'd suggest naming them *-crash.html for now, so that it's possible to find them if we later want to impose some kind of structure on this.

@domenic
Copy link
Collaborator

domenic commented May 29, 2017

Strongly agree we should keep the crashing tests. If we're not going to standardize the limits (which I think might be a good idea?), then I guess those tests would pass whether or not an exception is thrown/the promise is rejected. We should perhaps standardize the exception?

@foolip
Copy link
Member

foolip commented May 29, 2017

Yeah, if an exception is thrown, then I'd expect a spec to say what kind.

@marcoscaceres
Copy link
Member Author

Looks like it's going to be a TypeError for all cases:

https://chromium-review.googlesource.com/c/516882/7/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp#168

That's fine with me.

@marcoscaceres
Copy link
Member Author

@molly26dalton, could you kindly please check if this works with the Edge team?

index.html Outdated
@@ -2904,6 +2904,16 @@
result that would be obtained by the specification's algorithms.
</p>
<p>
User agents impose implementation-specific limits on otherwise
Copy link
Member

Choose a reason for hiding this comment

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

Missing "may".

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we need MAY here. It's a statement of fact that implementations do this.

Copy link
Member

Choose a reason for hiding this comment

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

Well they are non-conforming unless you allow it with a "may". :-)

index.html Outdated
platform-specific limitations. When an input exceeds
implementation-specific limit, the user agent MUST throw, or, in the
context of a promise, reject with, a <a>TypeError</a> optionally
informing the developer of how a particular input exceeded a
Copy link
Member

Choose a reason for hiding this comment

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

s/a/an/

@marcoscaceres
Copy link
Member Author

marcoscaceres commented May 31, 2017

I've created the first set of crash tests:
web-platform-tests/wpt#6108

Still missing PaymentDetailsModifier tests. Probably made a couple of copy/pasta errors - but would appreciate some feedback.

@rsolomakhin, I've reduced the length of inputs on the constructor tests to 1024 or less:
web-platform-tests/wpt#6063

Can you pease take a look. Chrome seems happy tho 馃憤

@rsolomakhin
Copy link
Collaborator

LGTM, thx @marcoscaceres

@marcoscaceres
Copy link
Member Author

I'm going to move forward on merging this, but would appreciate finding additional tests owners to help with web platform tests (again, huge thanks to @rsolomakhin for getting the testing started and the tests Google provided thus far - they have been extremely helpful!).

On the Mozilla side, the more tests I add, the more issues we keep finding - so would really appreciate more help from other browser vendors and other interested parties. I'm not feeling comfortable anymore moving this to CR until we have a complete test suite. It's revealing contentious problems (e.g., #541 and #536).

@marcoscaceres marcoscaceres merged commit 23cd48a into gh-pages Jun 2, 2017
@marcoscaceres marcoscaceres deleted the limits branch June 2, 2017 04:09
MXEBot pushed a commit to mirror/chromium that referenced this pull request Jun 6, 2017
Before this patch, invoking PaymentRequest with a 10mln character value
for the "id" parameter would crash the browser on Android. The browser
was running out of memory while trying to allocate a Java String.

This patch adds protective limits of 1024 characters to all strings in
PaymentRequest that will be sent to the browser side. Lists also have
protective limits of 1024 items. The stringified "data" object cannot
exceed 1024*1024 characters in length upon serialization.

After this patch, invoking PaymentRequest with a >1024 character value
for the "id" parameter will throw a TypeError exception in JavaScript.

Spec pull request:
w3c/payment-request#540

Bug: 725744
Change-Id: I25551e7145d9d8b59d111a89a7aa6c343c45600a
Reviewed-on: https://chromium-review.googlesource.com/516882
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: Ganggui Tang <gogerald@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#476996}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants