Nytro Posted July 21, 2013 Report Posted July 21, 2013 Breaking the links: Exploiting the linkerAbstractThe recent discussion relating to insecure library loading on the Microsoft Windows platformprovoked a signicant amount of debate as to whether GNU/Linux and UNIX variants couldbe vulnerable to similar attacks. Whilst the general consensus of the Slashdot herd appearedto be that this was just another example of Microsoft doing things wrong, I felt this was unfairand responded with a blog post[1] that sought to highlight an example of where POSIX stylelinkers get things wrong. Based on the feedback I received to that post, I decided to investigatethe issue a little further. This paper is an amalgamation of what I learnt. As such it containsmy own research, the discoveries of others and POSIX lore.Contents1 Technical Details 21.1 What is the linker? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.1 The link editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.2 The runtime linker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2 The linker attack surface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2.1 The process of linking and executing . . . . . . . . . . . . . . . . . . . . . . . 21.2.2 Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.2.3 Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.2.4 issetugid() and friends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.3 Real world exploitation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.3.1 The runtime linker as an interpreter . . . . . . . . . . . . . . . . . . . . . . . 61.3.2 The empty library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.3.3 SIGSEGV'ing for 12 years . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.3.4 What's in your RPATH? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.3.5 Debian makes me sad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111.3.6 If an environment variables is set but you don't trust it, is it still there? . . . 111.3.7 Reections on Trusting Trust revisited . . . . . . . . . . . . . . . . . . . . . . 121.3.8 Mapping NULL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.4 Auditing scripts, binaries and source . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.4.1 Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.4.2 Binaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.4.3 Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.5 Further research . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141.5.1 Other linkers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 Changes 14 BTL.pdf (2547 downloads) © Tim Brown License: n/a Paper on exploiting linkers Download BTL.pdf Sursa: Nth Dimension/downloads:: Negatively discriminating against idiots since 1995! Quote