closure-qmark.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. // Try variants of a pattern known to cause exploitable trashing of the Null
  6. // object's vtable: access a local var/function only within the non-evaluated
  7. // branch of a ?: operator, then do instanceof null to force virtual call using
  8. // the Null object's vtable.
  9. function write(x) { WScript.Echo(x + ''); }
  10. (function () {
  11. (function () {
  12. return true ? true : x;
  13. })();
  14. function x() { };
  15. })();
  16. try {
  17. var z = Object instanceof null;
  18. }
  19. catch (e) {
  20. write(e.message);
  21. }
  22. (function () {
  23. (function () {
  24. return true ? true : x;
  25. })();
  26. var x;
  27. })();
  28. try {
  29. var z = Object instanceof null;
  30. }
  31. catch (e) {
  32. write(e.message);
  33. }
  34. (function () {
  35. (function () {
  36. return false ? x : false;
  37. })();
  38. function x() { };
  39. })();
  40. try {
  41. var z = Object instanceof null;
  42. }
  43. catch (e) {
  44. write(e.message);
  45. }
  46. (function () {
  47. (function () {
  48. return false ? x : false;
  49. })();
  50. var x;
  51. })();
  52. try {
  53. var z = Object instanceof null;
  54. }
  55. catch (e) {
  56. write(e.message);
  57. }