TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Task_t considered harmful

280 pointsby rivertover 8 years ago

8 comments

0x0over 8 years ago
Copying my comment from the earlier submission that didn&#x27;t gain much traction here:<p>What an absolutely amazing tour-de-force of a devastating design flaw in all versions of macOS and iOS and tvOS and watchOS!<p>The negotiations detailed in the bug report timeline about meetings between &quot;senior apple and google leadership&quot; for keeping this secret past the general deadline really underlines that.
评论 #12795883 未加载
a-no-nover 8 years ago
Ever since installing 10.12.1, I&#x27;ve been having a bunch of processes randomly entering a quasi-paused SIGSTOP-ish state (neither closable, apps not &quot;bouncing&quot; (loading) and just not responding. Running Instruments, correlating logs and such doesn&#x27;t identify any clear cause. I&#x27;m having to `sudo kill -CONT -1` in order to get things moving again. I&#x27;m wondering if it&#x27;s related to XNU mitigations or just some spurious &quot;system configuration entropy&quot; on my box.
评论 #12796828 未加载
评论 #12795613 未加载
评论 #12803684 未加载
softawreover 8 years ago
Interesting timeline stuff here:<p><a href="https:&#x2F;&#x2F;bugs.chromium.org&#x2F;p&#x2F;project-zero&#x2F;issues&#x2F;detail?id=837" rel="nofollow">https:&#x2F;&#x2F;bugs.chromium.org&#x2F;p&#x2F;project-zero&#x2F;issues&#x2F;detail?id=83...</a>
评论 #12798157 未加载
drinchevover 8 years ago
I&#x27;m still with 10.11. I don&#x27;t plan to update soon, since the benefit of Siri, Photos and the other major features is quite small, compared to the risk that I might loose working days if something goes wrong ( I&#x27;m a freelancer ).<p>As far as I read in the article there will be 10.12.1 ( the final fix ) which will have that part of the kernel refactored. I hope Apple will also support 10.11 and issue an update with the same fix.
评论 #12797006 未加载
评论 #12796421 未加载
评论 #12796425 未加载
amlutoover 8 years ago
I would argue that the original underlying problem here is the idea that having execve() increase privilege is acceptable. It&#x27;s necessary for legacy reasons (sudo, anyone?), but even then, it&#x27;s barely necessary. &quot;sudo foo&quot; could be implemented by asking a privileged daemon to run foo and handing off access to the console to the daemon.<p>On Linux, you can do PR_SET_NO_NEW_PRIVS to turn off this type of privilege gain, and it&#x27;s even required for certain purposes. I would <i>love</i> to see someone develop a distribution that enables no_new_privs for all processes.
评论 #12813781 未加载
empath75over 8 years ago
Can someone explain what this means for the end user?
评论 #12797692 未加载
评论 #12797234 未加载
tptacekover 8 years ago
Bug 1: Many XNU drivers save task_t&#x27;s on the heap without bumping their refcount.<p><pre><code> 1. Attacker creates process A and B 2. B-&gt;A send task port Bt 3. A-&gt;XNU request IOKit framebuffer client for Bt 4. A ditches Bt, retains client 5. Kill B; Bt in client now dangling 6. Trigger creation of privileged C, unrelated to A &amp; B 7. C inherits memory once used by Bt 8. A use retained framebuffer client to write C&#x27;s memory </code></pre> What&#x27;s important to understand is that this is not just a single UAF, but a pattern of UAFs scattered throughout XNU.<p>Fix: at step 3, check to make sure the task being given to IOKit is owned by the task making the IOKit request.<p>Bug 2: IOKit drivers cache task details on their stack; the lifetime of that cached task is the lifetime of the IOKit kernel object, not of the program that made the request. In particular: if you execve() an SUID, the task_t is repurposed.<p><pre><code> 1. Attacker creates process A and B 2. B-&gt;XNU request IOKit framebuffer for Bt, Bc 3. B-&gt;A send client Bc 4. B execve &#x2F;bin&#x2F;su. B is now running as root. 5. A use retained framebuffer client to write B&#x27;s memory </code></pre> The tricky thing here is that this isn&#x27;t just one bug, but a pattern of bugs: every place where a driver stashes a task_t on the heap and exposes functionality through a passable object is a place where colluding processes can potentially take advantage of SUIDs to raise privileges.<p>Fix: Lifetime of IOKit clients now tied to lifetime of creating process.<p>Bug 3: Even if a driver doesn&#x27;t save a task_t on the heap, they&#x27;re saved on the stack during the servicing of system calls and kernel mach message handlers, so there are race conditions.<p><pre><code> 1. Attacker creates process A and B 2. B-&gt;A send task port Bt 3a. A-&gt;XNU task_threads(Bt), retrieving thread ports for Bt 3b. (simultaneously) execve &#x2F;bin&#x2F;su. B is now running as root. 4a. task_threads converts Bt to a task_t 4b. execve modifies the same task_t to replace thread ports 4c. task_threads retrieves the (now privileged) thread ports. 5. A uses thread ports to overwrite registers and take control of B. </code></pre> Fix: Kernel objects now check to see if a task_t has been touched by execve before returning them to userland. Even if you win the race, that failsafe prevents the kernel from giving you privileged objects.<p>Bug 4: You don&#x27;t need the kernel to give you a privileged object directly; all you need is to be able to influence a privileged object.<p><pre><code> 1. Attacker creates process A and B 2. B-&gt;A send task port Bt 3a. A-&gt;XNU task_set_exception_port(Bt), wiring A to B&#x27;s exceptions 3b. (simultaneously) execve &#x2F;bin&#x2F;su with rlimited stack. B is now running as root, briefly. 4a. task_set_exception_port converts Bt to a task_t 4b. execve modifies the same task_t to replace thread ports 4c. task_set_exception_port rewrites the exception port. 5. stack access in B, running &#x2F;bin&#x2F;su as root, causes a SEGV 6. XNU generates an exception message, passing with it the thread ports, to A 7. A uses thread ports to overwrite registers and take control of B. </code></pre> Fix: table flip. Rewrite execve so it generates entirely new task_ts when loading binaries, rather than repurposing old task_t.<p>This is all pretty magnificent. What&#x27;s best about it is that it totally justifies the title of the post: pretty much every place in XNU where they save a task_t creates a TOCTTOU bug.
评论 #12798773 未加载
saynseditover 8 years ago
The sad reality is that black hats have been exploiting this class of bugs for <i>years</i>.
评论 #12796175 未加载
评论 #12796009 未加载