backport_1091404.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Cheng Zhao <[email protected]>
  3. Date: Wed, 23 Oct 2019 12:54:32 -0700
  4. Subject: fix: make PDFium JS host object have immutable prototypes
  5. [1091404] [High] [CVE-2020-6513]: Google Chrome PDFium Javascript Active Document Memory Corruption Vulnerability - TALOS-2020-1092
  6. Backport https://pdfium.googlesource.com/pdfium.git/+/bee2261eab794536f236013fa8c9d01728ed326b.
  7. diff --git a/fxjs/cfxjs_engine.cpp b/fxjs/cfxjs_engine.cpp
  8. index 9624feb2dc91b03f9eb32bab772f235b682cf9a1..4a15ebe11ed7a82ded11ca0de031b8818811143b 100644
  9. --- a/fxjs/cfxjs_engine.cpp
  10. +++ b/fxjs/cfxjs_engine.cpp
  11. @@ -145,6 +145,7 @@ class CFXJS_ObjDefinition {
  12. v8::HandleScope handle_scope(isolate);
  13. v8::Local<v8::FunctionTemplate> fn = v8::FunctionTemplate::New(isolate);
  14. fn->InstanceTemplate()->SetInternalFieldCount(2);
  15. + fn->InstanceTemplate()->SetImmutableProto();
  16. fn->SetCallHandler(CallHandler, v8::Number::New(isolate, eObjType));
  17. if (eObjType == FXJSOBJTYPE_GLOBAL) {
  18. fn->InstanceTemplate()->Set(v8::Symbol::GetToStringTag(isolate),
  19. diff --git a/testing/resources/javascript/immutable_proto.in b/testing/resources/javascript/immutable_proto.in
  20. new file mode 100644
  21. index 0000000000000000000000000000000000000000..61885c53758167cae5af47f8736014dcb0933aaf
  22. --- /dev/null
  23. +++ b/testing/resources/javascript/immutable_proto.in
  24. @@ -0,0 +1,43 @@
  25. +{{header}}
  26. +{{object 1 0}} <<
  27. + /Type /Catalog
  28. + /Pages 2 0 R
  29. + /OpenAction 10 0 R
  30. +>>
  31. +endobj
  32. +{{object 2 0}} <<
  33. + /Type /Pages
  34. + /Count 1
  35. + /Kids [
  36. + 3 0 R
  37. + ]
  38. +>>
  39. +endobj
  40. +{{object 3 0}} <<
  41. + /Type /Page
  42. + /Parent 2 0 R
  43. + /MediaBox [0 0 612 792]
  44. +>>
  45. +endobj
  46. +% OpenAction action
  47. +{{object 10 0}} <<
  48. + /Type /Action
  49. + /S /JavaScript
  50. + /JS 11 0 R
  51. +>>
  52. +endobj
  53. +{{object 11 0}} <<
  54. + {{streamlen}}
  55. +>>
  56. +stream
  57. +{{include expect.js}}
  58. +expect("this.__proto__", "[object Object]");
  59. +expect("app.__proto__", "[object Object]");
  60. +expectError("this.__proto__ = {}");
  61. +expectError("app.__proto__ = this");
  62. +endstream
  63. +endobj
  64. +{{xref}}
  65. +{{trailer}}
  66. +{{startxref}}
  67. +%%EOF
  68. diff --git a/testing/resources/javascript/immutable_proto_expected.txt b/testing/resources/javascript/immutable_proto_expected.txt
  69. new file mode 100644
  70. index 0000000000000000000000000000000000000000..7e7c6701e39592ec130ae52fc98f8af903b3152b
  71. --- /dev/null
  72. +++ b/testing/resources/javascript/immutable_proto_expected.txt
  73. @@ -0,0 +1,4 @@
  74. +Alert: PASS: this.__proto__ = [object Object]
  75. +Alert: PASS: app.__proto__ = [object Object]
  76. +Alert: PASS: this.__proto__ = {} threw TypeError: Immutable prototype object '[object global]' cannot have their prototype set
  77. +Alert: PASS: app.__proto__ = this threw TypeError: Immutable prototype object '[object Object]' cannot have their prototype set