{"id":27249,"date":"2016-12-14T08:03:11","date_gmt":"2016-12-14T01:03:11","guid":{"rendered":"http:\/\/deepquest.code511.com\/blog\/2016\/12\/samsung-devices-knox-extensions-otp-trustzone-trustlet-stack-buffer-overflow\/"},"modified":"2016-12-14T08:03:11","modified_gmt":"2016-12-14T01:03:11","slug":"samsung-devices-knox-extensions-otp-trustzone-trustlet-stack-buffer-overflow","status":"publish","type":"post","link":"https:\/\/deepquest.code511.com\/blog\/2016\/12\/samsung-devices-knox-extensions-otp-trustzone-trustlet-stack-buffer-overflow\/","title":{"rendered":"Samsung Devices KNOX Extensions OTP TrustZone Trustlet Stack Buffer Overflow"},"content":{"rendered":"<p>As a part of the KNOX extensions available on Samsung devices, Samsung provides a TrustZone trustlet which allows the generation of OTP tokens. The tokens themselves are generated in a TrustZone application within the TEE (UID: fffffffff0000000000000000000001e), which can be communicated with using the &#8220;OTP&#8221; service, published by &#8220;otp_server&#8221;. Many of the internal commands supported by the trustlet must either unwrap or wrap a token. They do so by calling the functions &#8220;otp_unwrap&#8221; and &#8220;otp_wrap&#8221;, correspondingly. Both functions copy the internal token data to a local stack based buffer before attempting to wrap or unwrap it. However, this copy operation is performed using a length field supplied in the user&#8217;s buffer (the length field&#8217;s offset changes according to the calling code-path), which is not validated at all. This means an attacker can supply a length field larger than the stack based buffer, causing the user-controlled token data to overflow the stack buffer. There is no stack cookie mitigation in MobiCore trustlets. On the device I&#8217;m working on (SM-G925V), the &#8220;OTP&#8221; service can be accessed from any user, including from the SELinux context &#8220;untrusted_app&#8221;. Successfully exploiting this vulnerability should allow a user to elevate privileges to the TrustZone TEE.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As a part of the KNOX extensions available on Samsung devices, Samsung provides a TrustZone trustlet which allows the generation of OTP tokens. The tokens themselves are generated in a&#8230;<\/p>\n","protected":false},"author":439,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[43],"tags":[],"class_list":["post-27249","post","type-post","status-publish","format-standard","hentry","category-exploit"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4bBYZ-75v","_links":{"self":[{"href":"https:\/\/deepquest.code511.com\/blog\/wp-json\/wp\/v2\/posts\/27249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/deepquest.code511.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/deepquest.code511.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/deepquest.code511.com\/blog\/wp-json\/wp\/v2\/users\/439"}],"replies":[{"embeddable":true,"href":"https:\/\/deepquest.code511.com\/blog\/wp-json\/wp\/v2\/comments?post=27249"}],"version-history":[{"count":0,"href":"https:\/\/deepquest.code511.com\/blog\/wp-json\/wp\/v2\/posts\/27249\/revisions"}],"wp:attachment":[{"href":"https:\/\/deepquest.code511.com\/blog\/wp-json\/wp\/v2\/media?parent=27249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/deepquest.code511.com\/blog\/wp-json\/wp\/v2\/categories?post=27249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/deepquest.code511.com\/blog\/wp-json\/wp\/v2\/tags?post=27249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}