People often ask me "How did you learn how to hack?" The answer: by reading. This page is a collection of the blog posts and other articles that I have accumulated over the years of my journey. Enjoy!
NSFunctionExpression; there is no complicated ROP chain or anything else. This call does two things: cover its tracks and trigger a logic bug within NSPredicate. Covering the tracks is interesting but it is all about cleaning the things up, which I'll skip. NSPredicates. This is used for iterating over collections, such as arrays, to perform functionality. While using predicates, expressions can be used as well. This expression in a small query language, which is similar to SQL in some ways. In OS X 10.5 in 2007, the ability to use the FUNCTION keyword to invoke arbitrary methods was added. protocol for the NSXPC to designate what happens when it is invoked or used. An attack surface analysis from 2019 shows that "subclasses of classes with any level of inheritance are also allowed, as is always the case with NSKeyedUnarchiver deserialization." This means that any object which declares a particular type for a field will accept any subclass of that type, opening up the attack surface. NSObject*, which would include NSPredicate. Although this looks like a game over (code execution from the expressions), there is a specific mitigation in place for this. When an NSPredicate is deserialized, a flag is set to disable the evalulation of the predicate. Good job Apple!Sections, the code sets the allowEvaulation flag to true. This means that the predicate is trusted and will be ran, but they never evaluate the predicate. As a result, the predicate gives us code execution within the context of CommCenter. IMTranscoderAgent sandbox, they run several expressions. The final expression is to make a request to a URL to download an AES encrypted expression to evaluate this as well. This secondary payload was whatever the attackers wanted at this point, all without any memory corruption. NSExpression to prevent easy code execution with a similar bug. Secondly, they added restrictions onto the PTSection and PTRow objects for parsing NSPredicates. So, good job Apple for hardening this area against future attacks. initWithCoder implementations could be attacked, with more code execution gadgets being found. NSXPC seems like a powerful attack surface across boundaries, even though it was designed with this exactly in mind.