{"id":12093,"date":"2010-12-08T07:00:00","date_gmt":"2010-12-08T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2010\/12\/08\/it-rather-involved-being-on-the-other-side-of-this-airtight-hatchway-invalid-parameters-from-one-security-level-crashing-code-at-the-same-security-level\/"},"modified":"2010-12-08T07:00:00","modified_gmt":"2010-12-08T07:00:00","slug":"it-rather-involved-being-on-the-other-side-of-this-airtight-hatchway-invalid-parameters-from-one-security-level-crashing-code-at-the-same-security-level","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20101208-00\/?p=12093","title":{"rendered":"It rather involved being on the other side of this airtight hatchway: Invalid parameters from one security level crashing code at the same security level"},"content":{"rendered":"<p>\nIn the category of dubious security vulnerability,\nI submit the following (paraphrased) report:\n<\/p>\n<blockquote CLASS=\"q\"><p>\nI have discovered that if you call the <code>XYZ<\/code> function\n(whose first parameter is supposed to be a pointer to a\n<i>IUnknown<\/i>),\nand instead of passing a valid COM object pointer,\nyou pass a pointer to a random hunk of data,\nyou can trigger an access violation in the\n<code>XYZ<\/code> function which is exploitable\nby putting specially-crafted  data in that memory blob.\nAn attacker can exploit the <code>XYZ<\/code> function for remote\nexecution and compromise the system,\nprovided an application uses the <code>XYZ<\/code> function and passes\na pointer to untrusted data as the first parameter\ninstead of a valid <code>IUnknown<\/code> pointer.\nAlthough we have not found an application which uses the <code>XYZ<\/code>\nin this way,\nthe function neverless contains the potential for exploit,\nand the bug should be fixed as soon as possible.\n<\/p><\/blockquote>\n<p>The person included a sample program which went something\nlike this (except more complicated):<\/p>\n<pre>\n\/\/ We can control the behavior by tweaking the value\n\/\/ of the Exploit array.\nunsigned char Exploit[] = \"\\x01\\x02\\x03...\";\nvoid main()\n{\n   XYZ((IUnknown*)Exploit);\n}\n<\/pre>\n<p>\nWell, yeah, but you&#8217;re already on the other side of the\nairtight hatchway.\nInstead of building up a complicated blob of memory\nwith exactly the right format, just write your bad\n<code>IUnknown<\/code>:\n<\/p>\n<pre>\nvoid Pwnz0r()\n{\n  ... whatever you want ...\n}\nclass Exploit : public IUnknown\n{\npublic:\n  STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\n  { Pwnz0r(); return E_NOINTERFACE; }\n  STDMETHODIMP_(ULONG) AddRef() { Pwnz0r(); return 2; }\n  STDMETHODIMP_(ULONG) Release() { Pwnz0r(); return 1; }\n};\nvoid main()\n{\n   XYZ(&amp;Exploit);\n}\n<\/pre>\n<p>\nWow, this new &#8220;exploit&#8221; is even portable to other\narchitectures!\n<\/p>\n<p>\nActually, now that you&#8217;re on the other side of the airtight\nhatchway, you may as well take <code>XYZ<\/code> out of the picture\nsince it&#8217;s just slowing you down:\n<\/p>\n<pre>\nvoid main()\n{\n   Pwnz0r();\n}\n<\/pre>\n<p>\nYou&#8217;re already running code.\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2007\/08\/07\/4268706.aspx\">\nIt&#8217;s not surprising that you can run code<\/a>.\n<\/p>\n<p>\nThere&#8217;s nothing subtle going on here.\nThere is no elevation of privilege because the rogue activity happens\nin user-mode code, based on rogue code provided by an executable\nwith trusted code execution privileges,\nat the same security level as the original executable.\n<\/p>\n<p>\nThe people reporting the alleged vulnerability do say that\nthey haven&#8217;t yet found any program that calls the <code>XYZ<\/code>\nfunction with untrusted data,\nbut even if they did,\nthat would be a data handling bug in the application itself:\nData crossed a trust boundary without proper validation.\nIt&#8217;s like saying &#8220;There is a security vulnerability in the\n<code>DeleteFile<\/code> function because it is possible for\nan application to pass an untrusted file name and thereby result\nin an attacker deleting any file of his choosing.&#8221;\nEven if such a vulnerability existed, the flaw is in the\napplication for not validating its input, not in\n<code>DeleteFile<\/code> for, um, deleting the file it was told to delete.\n<\/p>\n<p>\nThe sad thing is that it took the security team five days to\nresolve this issue,\nbecause even though it looks like a slam dunk,\nthe issue resolution process must be followed, just to be sure.\nWho knows,\nmaybe there really is a bug in the <code>XYZ<\/code> function&#8217;s\nuse of the first parameter that would result in elevation\nof privilege.\nAll supported versions of Windows need to be examined for the\nslim possibility that there&#8217;s something behind this confused\nvulnerability report.\n<\/p>\n<p>\nBut there isn&#8217;t.\nIt&#8217;s just another dubious security vulnerability report.\n<\/p>\n<p>\n<b>Exercise<\/b>:\nApply what you learned to this security vulnerability report.\nThis is also paraphrased from an actual security report:\n<\/p>\n<blockquote CLASS=\"q\">\n<p>\nThere is a serious denial-of-service vulnerability in the\nfunction <code>XYZ<\/code>.\nThis function takes a pointer to a buffer and a length.\nIf the function is passed malformed parameters,\nit may encounter an access violation when it tries to read\nfrom an invalid buffer.\nAny application which calls this function with bad parameters\nwill crash.\nHere is a sample program that illustrates the vulnerability:\n<\/p>\n<pre>\nint main(int argc, char **argv)\n{\n \/\/ crash inside XYZ attempting to read past end of buffer\n XYZ(\"x\", 9999999);\n return 0;\n}\n<\/pre>\n<p>\nCredit for discovering this vulnerability\ngoes to ABC Security Research Company.\nCopyright&copy; 20xx ABC Security Research Company.\nAll Rights Reserved.\n<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>In the category of dubious security vulnerability, I submit the following (paraphrased) report: I have discovered that if you call the XYZ function (whose first parameter is supposed to be a pointer to a IUnknown), and instead of passing a valid COM object pointer, you pass a pointer to a random hunk of data, you [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-12093","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>In the category of dubious security vulnerability, I submit the following (paraphrased) report: I have discovered that if you call the XYZ function (whose first parameter is supposed to be a pointer to a IUnknown), and instead of passing a valid COM object pointer, you pass a pointer to a random hunk of data, you [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/12093","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=12093"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/12093\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=12093"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=12093"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=12093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}